@verdaccio/search 7.0.0-next.2 → 8.0.0-next-8.1
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/CHANGELOG.md +96 -702
- package/LICENSE +1 -1
- package/build/index.d.ts +2 -1
- package/build/index.js +26 -0
- package/build/index.js.map +1 -0
- package/build/search-utils.d.ts +2 -0
- package/build/search-utils.js +20 -0
- package/build/search-utils.js.map +1 -0
- package/build/search.d.ts +21 -0
- package/build/search.js +104 -0
- package/build/search.js.map +1 -0
- package/package.json +18 -9
- package/src/index.ts +2 -1
- package/src/search-utils.ts +15 -0
- package/src/search.ts +104 -0
- package/test/partials/search.json +273 -0
- package/test/search.test.ts +103 -0
- package/tsconfig.json +0 -6
- package/README.md +0 -29
- package/build/dist.js +0 -3965
- package/build/indexer.d.ts +0 -39
- package/jest.config.js +0 -12
- package/src/indexer.ts +0 -128
- package/test/index.spec.ts +0 -47
- package/types/patch.d.ts +0 -10
package/build/dist.js
DELETED
|
@@ -1,3965 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
22
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
23
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
24
|
-
};
|
|
25
|
-
var __export = (target, all) => {
|
|
26
|
-
for (var name in all)
|
|
27
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
-
};
|
|
29
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
30
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
31
|
-
for (let key of __getOwnPropNames(module2))
|
|
32
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
33
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
|
-
var __toESM = (module2, isNodeMode) => {
|
|
38
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
39
|
-
};
|
|
40
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
41
|
-
return (module2, temp) => {
|
|
42
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
43
|
-
};
|
|
44
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
45
|
-
|
|
46
|
-
// ../../node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
|
|
47
|
-
var require_ms = __commonJS({
|
|
48
|
-
"../../node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module2) {
|
|
49
|
-
var s = 1e3;
|
|
50
|
-
var m = s * 60;
|
|
51
|
-
var h = m * 60;
|
|
52
|
-
var d = h * 24;
|
|
53
|
-
var w = d * 7;
|
|
54
|
-
var y = d * 365.25;
|
|
55
|
-
module2.exports = function(val, options) {
|
|
56
|
-
options = options || {};
|
|
57
|
-
var type = typeof val;
|
|
58
|
-
if (type === "string" && val.length > 0) {
|
|
59
|
-
return parse(val);
|
|
60
|
-
} else if (type === "number" && isFinite(val)) {
|
|
61
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
62
|
-
}
|
|
63
|
-
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
64
|
-
};
|
|
65
|
-
function parse(str) {
|
|
66
|
-
str = String(str);
|
|
67
|
-
if (str.length > 100) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
71
|
-
if (!match) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
var n = parseFloat(match[1]);
|
|
75
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
76
|
-
switch (type) {
|
|
77
|
-
case "years":
|
|
78
|
-
case "year":
|
|
79
|
-
case "yrs":
|
|
80
|
-
case "yr":
|
|
81
|
-
case "y":
|
|
82
|
-
return n * y;
|
|
83
|
-
case "weeks":
|
|
84
|
-
case "week":
|
|
85
|
-
case "w":
|
|
86
|
-
return n * w;
|
|
87
|
-
case "days":
|
|
88
|
-
case "day":
|
|
89
|
-
case "d":
|
|
90
|
-
return n * d;
|
|
91
|
-
case "hours":
|
|
92
|
-
case "hour":
|
|
93
|
-
case "hrs":
|
|
94
|
-
case "hr":
|
|
95
|
-
case "h":
|
|
96
|
-
return n * h;
|
|
97
|
-
case "minutes":
|
|
98
|
-
case "minute":
|
|
99
|
-
case "mins":
|
|
100
|
-
case "min":
|
|
101
|
-
case "m":
|
|
102
|
-
return n * m;
|
|
103
|
-
case "seconds":
|
|
104
|
-
case "second":
|
|
105
|
-
case "secs":
|
|
106
|
-
case "sec":
|
|
107
|
-
case "s":
|
|
108
|
-
return n * s;
|
|
109
|
-
case "milliseconds":
|
|
110
|
-
case "millisecond":
|
|
111
|
-
case "msecs":
|
|
112
|
-
case "msec":
|
|
113
|
-
case "ms":
|
|
114
|
-
return n;
|
|
115
|
-
default:
|
|
116
|
-
return void 0;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function fmtShort(ms) {
|
|
120
|
-
var msAbs = Math.abs(ms);
|
|
121
|
-
if (msAbs >= d) {
|
|
122
|
-
return Math.round(ms / d) + "d";
|
|
123
|
-
}
|
|
124
|
-
if (msAbs >= h) {
|
|
125
|
-
return Math.round(ms / h) + "h";
|
|
126
|
-
}
|
|
127
|
-
if (msAbs >= m) {
|
|
128
|
-
return Math.round(ms / m) + "m";
|
|
129
|
-
}
|
|
130
|
-
if (msAbs >= s) {
|
|
131
|
-
return Math.round(ms / s) + "s";
|
|
132
|
-
}
|
|
133
|
-
return ms + "ms";
|
|
134
|
-
}
|
|
135
|
-
function fmtLong(ms) {
|
|
136
|
-
var msAbs = Math.abs(ms);
|
|
137
|
-
if (msAbs >= d) {
|
|
138
|
-
return plural(ms, msAbs, d, "day");
|
|
139
|
-
}
|
|
140
|
-
if (msAbs >= h) {
|
|
141
|
-
return plural(ms, msAbs, h, "hour");
|
|
142
|
-
}
|
|
143
|
-
if (msAbs >= m) {
|
|
144
|
-
return plural(ms, msAbs, m, "minute");
|
|
145
|
-
}
|
|
146
|
-
if (msAbs >= s) {
|
|
147
|
-
return plural(ms, msAbs, s, "second");
|
|
148
|
-
}
|
|
149
|
-
return ms + " ms";
|
|
150
|
-
}
|
|
151
|
-
function plural(ms, msAbs, n, name) {
|
|
152
|
-
var isPlural = msAbs >= n * 1.5;
|
|
153
|
-
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
// ../../node_modules/.pnpm/debug@4.3.4_supports-color@6.1.0/node_modules/debug/src/common.js
|
|
159
|
-
var require_common = __commonJS({
|
|
160
|
-
"../../node_modules/.pnpm/debug@4.3.4_supports-color@6.1.0/node_modules/debug/src/common.js"(exports, module2) {
|
|
161
|
-
function setup(env) {
|
|
162
|
-
createDebug.debug = createDebug;
|
|
163
|
-
createDebug.default = createDebug;
|
|
164
|
-
createDebug.coerce = coerce;
|
|
165
|
-
createDebug.disable = disable;
|
|
166
|
-
createDebug.enable = enable;
|
|
167
|
-
createDebug.enabled = enabled;
|
|
168
|
-
createDebug.humanize = require_ms();
|
|
169
|
-
createDebug.destroy = destroy;
|
|
170
|
-
Object.keys(env).forEach((key) => {
|
|
171
|
-
createDebug[key] = env[key];
|
|
172
|
-
});
|
|
173
|
-
createDebug.names = [];
|
|
174
|
-
createDebug.skips = [];
|
|
175
|
-
createDebug.formatters = {};
|
|
176
|
-
function selectColor(namespace) {
|
|
177
|
-
let hash = 0;
|
|
178
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
179
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
180
|
-
hash |= 0;
|
|
181
|
-
}
|
|
182
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
183
|
-
}
|
|
184
|
-
createDebug.selectColor = selectColor;
|
|
185
|
-
function createDebug(namespace) {
|
|
186
|
-
let prevTime;
|
|
187
|
-
let enableOverride = null;
|
|
188
|
-
let namespacesCache;
|
|
189
|
-
let enabledCache;
|
|
190
|
-
function debug2(...args) {
|
|
191
|
-
if (!debug2.enabled) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const self = debug2;
|
|
195
|
-
const curr = Number(new Date());
|
|
196
|
-
const ms = curr - (prevTime || curr);
|
|
197
|
-
self.diff = ms;
|
|
198
|
-
self.prev = prevTime;
|
|
199
|
-
self.curr = curr;
|
|
200
|
-
prevTime = curr;
|
|
201
|
-
args[0] = createDebug.coerce(args[0]);
|
|
202
|
-
if (typeof args[0] !== "string") {
|
|
203
|
-
args.unshift("%O");
|
|
204
|
-
}
|
|
205
|
-
let index = 0;
|
|
206
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
207
|
-
if (match === "%%") {
|
|
208
|
-
return "%";
|
|
209
|
-
}
|
|
210
|
-
index++;
|
|
211
|
-
const formatter = createDebug.formatters[format];
|
|
212
|
-
if (typeof formatter === "function") {
|
|
213
|
-
const val = args[index];
|
|
214
|
-
match = formatter.call(self, val);
|
|
215
|
-
args.splice(index, 1);
|
|
216
|
-
index--;
|
|
217
|
-
}
|
|
218
|
-
return match;
|
|
219
|
-
});
|
|
220
|
-
createDebug.formatArgs.call(self, args);
|
|
221
|
-
const logFn = self.log || createDebug.log;
|
|
222
|
-
logFn.apply(self, args);
|
|
223
|
-
}
|
|
224
|
-
debug2.namespace = namespace;
|
|
225
|
-
debug2.useColors = createDebug.useColors();
|
|
226
|
-
debug2.color = createDebug.selectColor(namespace);
|
|
227
|
-
debug2.extend = extend;
|
|
228
|
-
debug2.destroy = createDebug.destroy;
|
|
229
|
-
Object.defineProperty(debug2, "enabled", {
|
|
230
|
-
enumerable: true,
|
|
231
|
-
configurable: false,
|
|
232
|
-
get: () => {
|
|
233
|
-
if (enableOverride !== null) {
|
|
234
|
-
return enableOverride;
|
|
235
|
-
}
|
|
236
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
237
|
-
namespacesCache = createDebug.namespaces;
|
|
238
|
-
enabledCache = createDebug.enabled(namespace);
|
|
239
|
-
}
|
|
240
|
-
return enabledCache;
|
|
241
|
-
},
|
|
242
|
-
set: (v2) => {
|
|
243
|
-
enableOverride = v2;
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
if (typeof createDebug.init === "function") {
|
|
247
|
-
createDebug.init(debug2);
|
|
248
|
-
}
|
|
249
|
-
return debug2;
|
|
250
|
-
}
|
|
251
|
-
function extend(namespace, delimiter) {
|
|
252
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
253
|
-
newDebug.log = this.log;
|
|
254
|
-
return newDebug;
|
|
255
|
-
}
|
|
256
|
-
function enable(namespaces) {
|
|
257
|
-
createDebug.save(namespaces);
|
|
258
|
-
createDebug.namespaces = namespaces;
|
|
259
|
-
createDebug.names = [];
|
|
260
|
-
createDebug.skips = [];
|
|
261
|
-
let i;
|
|
262
|
-
const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
|
|
263
|
-
const len = split.length;
|
|
264
|
-
for (i = 0; i < len; i++) {
|
|
265
|
-
if (!split[i]) {
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
|
-
namespaces = split[i].replace(/\*/g, ".*?");
|
|
269
|
-
if (namespaces[0] === "-") {
|
|
270
|
-
createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
|
|
271
|
-
} else {
|
|
272
|
-
createDebug.names.push(new RegExp("^" + namespaces + "$"));
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
function disable() {
|
|
277
|
-
const namespaces = [
|
|
278
|
-
...createDebug.names.map(toNamespace),
|
|
279
|
-
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
|
|
280
|
-
].join(",");
|
|
281
|
-
createDebug.enable("");
|
|
282
|
-
return namespaces;
|
|
283
|
-
}
|
|
284
|
-
function enabled(name) {
|
|
285
|
-
if (name[name.length - 1] === "*") {
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
let i;
|
|
289
|
-
let len;
|
|
290
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
291
|
-
if (createDebug.skips[i].test(name)) {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
|
296
|
-
if (createDebug.names[i].test(name)) {
|
|
297
|
-
return true;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return false;
|
|
301
|
-
}
|
|
302
|
-
function toNamespace(regexp) {
|
|
303
|
-
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
304
|
-
}
|
|
305
|
-
function coerce(val) {
|
|
306
|
-
if (val instanceof Error) {
|
|
307
|
-
return val.stack || val.message;
|
|
308
|
-
}
|
|
309
|
-
return val;
|
|
310
|
-
}
|
|
311
|
-
function destroy() {
|
|
312
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
313
|
-
}
|
|
314
|
-
createDebug.enable(createDebug.load());
|
|
315
|
-
return createDebug;
|
|
316
|
-
}
|
|
317
|
-
module2.exports = setup;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// ../../node_modules/.pnpm/debug@4.3.4_supports-color@6.1.0/node_modules/debug/src/browser.js
|
|
322
|
-
var require_browser = __commonJS({
|
|
323
|
-
"../../node_modules/.pnpm/debug@4.3.4_supports-color@6.1.0/node_modules/debug/src/browser.js"(exports, module2) {
|
|
324
|
-
exports.formatArgs = formatArgs;
|
|
325
|
-
exports.save = save5;
|
|
326
|
-
exports.load = load5;
|
|
327
|
-
exports.useColors = useColors;
|
|
328
|
-
exports.storage = localstorage();
|
|
329
|
-
exports.destroy = (() => {
|
|
330
|
-
let warned = false;
|
|
331
|
-
return () => {
|
|
332
|
-
if (!warned) {
|
|
333
|
-
warned = true;
|
|
334
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
})();
|
|
338
|
-
exports.colors = [
|
|
339
|
-
"#0000CC",
|
|
340
|
-
"#0000FF",
|
|
341
|
-
"#0033CC",
|
|
342
|
-
"#0033FF",
|
|
343
|
-
"#0066CC",
|
|
344
|
-
"#0066FF",
|
|
345
|
-
"#0099CC",
|
|
346
|
-
"#0099FF",
|
|
347
|
-
"#00CC00",
|
|
348
|
-
"#00CC33",
|
|
349
|
-
"#00CC66",
|
|
350
|
-
"#00CC99",
|
|
351
|
-
"#00CCCC",
|
|
352
|
-
"#00CCFF",
|
|
353
|
-
"#3300CC",
|
|
354
|
-
"#3300FF",
|
|
355
|
-
"#3333CC",
|
|
356
|
-
"#3333FF",
|
|
357
|
-
"#3366CC",
|
|
358
|
-
"#3366FF",
|
|
359
|
-
"#3399CC",
|
|
360
|
-
"#3399FF",
|
|
361
|
-
"#33CC00",
|
|
362
|
-
"#33CC33",
|
|
363
|
-
"#33CC66",
|
|
364
|
-
"#33CC99",
|
|
365
|
-
"#33CCCC",
|
|
366
|
-
"#33CCFF",
|
|
367
|
-
"#6600CC",
|
|
368
|
-
"#6600FF",
|
|
369
|
-
"#6633CC",
|
|
370
|
-
"#6633FF",
|
|
371
|
-
"#66CC00",
|
|
372
|
-
"#66CC33",
|
|
373
|
-
"#9900CC",
|
|
374
|
-
"#9900FF",
|
|
375
|
-
"#9933CC",
|
|
376
|
-
"#9933FF",
|
|
377
|
-
"#99CC00",
|
|
378
|
-
"#99CC33",
|
|
379
|
-
"#CC0000",
|
|
380
|
-
"#CC0033",
|
|
381
|
-
"#CC0066",
|
|
382
|
-
"#CC0099",
|
|
383
|
-
"#CC00CC",
|
|
384
|
-
"#CC00FF",
|
|
385
|
-
"#CC3300",
|
|
386
|
-
"#CC3333",
|
|
387
|
-
"#CC3366",
|
|
388
|
-
"#CC3399",
|
|
389
|
-
"#CC33CC",
|
|
390
|
-
"#CC33FF",
|
|
391
|
-
"#CC6600",
|
|
392
|
-
"#CC6633",
|
|
393
|
-
"#CC9900",
|
|
394
|
-
"#CC9933",
|
|
395
|
-
"#CCCC00",
|
|
396
|
-
"#CCCC33",
|
|
397
|
-
"#FF0000",
|
|
398
|
-
"#FF0033",
|
|
399
|
-
"#FF0066",
|
|
400
|
-
"#FF0099",
|
|
401
|
-
"#FF00CC",
|
|
402
|
-
"#FF00FF",
|
|
403
|
-
"#FF3300",
|
|
404
|
-
"#FF3333",
|
|
405
|
-
"#FF3366",
|
|
406
|
-
"#FF3399",
|
|
407
|
-
"#FF33CC",
|
|
408
|
-
"#FF33FF",
|
|
409
|
-
"#FF6600",
|
|
410
|
-
"#FF6633",
|
|
411
|
-
"#FF9900",
|
|
412
|
-
"#FF9933",
|
|
413
|
-
"#FFCC00",
|
|
414
|
-
"#FFCC33"
|
|
415
|
-
];
|
|
416
|
-
function useColors() {
|
|
417
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
418
|
-
return true;
|
|
419
|
-
}
|
|
420
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
424
|
-
}
|
|
425
|
-
function formatArgs(args) {
|
|
426
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
|
|
427
|
-
if (!this.useColors) {
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
const c2 = "color: " + this.color;
|
|
431
|
-
args.splice(1, 0, c2, "color: inherit");
|
|
432
|
-
let index = 0;
|
|
433
|
-
let lastC = 0;
|
|
434
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
435
|
-
if (match === "%%") {
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
index++;
|
|
439
|
-
if (match === "%c") {
|
|
440
|
-
lastC = index;
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
args.splice(lastC, 0, c2);
|
|
444
|
-
}
|
|
445
|
-
exports.log = console.debug || console.log || (() => {
|
|
446
|
-
});
|
|
447
|
-
function save5(namespaces) {
|
|
448
|
-
try {
|
|
449
|
-
if (namespaces) {
|
|
450
|
-
exports.storage.setItem("debug", namespaces);
|
|
451
|
-
} else {
|
|
452
|
-
exports.storage.removeItem("debug");
|
|
453
|
-
}
|
|
454
|
-
} catch (error) {
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
function load5() {
|
|
458
|
-
let r;
|
|
459
|
-
try {
|
|
460
|
-
r = exports.storage.getItem("debug");
|
|
461
|
-
} catch (error) {
|
|
462
|
-
}
|
|
463
|
-
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
464
|
-
r = process.env.DEBUG;
|
|
465
|
-
}
|
|
466
|
-
return r;
|
|
467
|
-
}
|
|
468
|
-
function localstorage() {
|
|
469
|
-
try {
|
|
470
|
-
return localStorage;
|
|
471
|
-
} catch (error) {
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
module2.exports = require_common()(exports);
|
|
475
|
-
var { formatters } = module2.exports;
|
|
476
|
-
formatters.j = function(v2) {
|
|
477
|
-
try {
|
|
478
|
-
return JSON.stringify(v2);
|
|
479
|
-
} catch (error) {
|
|
480
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
// ../../node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js
|
|
487
|
-
var require_has_flag = __commonJS({
|
|
488
|
-
"../../node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js"(exports, module2) {
|
|
489
|
-
"use strict";
|
|
490
|
-
module2.exports = (flag, argv) => {
|
|
491
|
-
argv = argv || process.argv;
|
|
492
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
493
|
-
const pos = argv.indexOf(prefix + flag);
|
|
494
|
-
const terminatorPos = argv.indexOf("--");
|
|
495
|
-
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
// ../../node_modules/.pnpm/supports-color@6.1.0/node_modules/supports-color/index.js
|
|
501
|
-
var require_supports_color = __commonJS({
|
|
502
|
-
"../../node_modules/.pnpm/supports-color@6.1.0/node_modules/supports-color/index.js"(exports, module2) {
|
|
503
|
-
"use strict";
|
|
504
|
-
var os = require("os");
|
|
505
|
-
var hasFlag = require_has_flag();
|
|
506
|
-
var { env } = process;
|
|
507
|
-
var forceColor;
|
|
508
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
509
|
-
forceColor = 0;
|
|
510
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
511
|
-
forceColor = 1;
|
|
512
|
-
}
|
|
513
|
-
if ("FORCE_COLOR" in env) {
|
|
514
|
-
if (env.FORCE_COLOR === true || env.FORCE_COLOR === "true") {
|
|
515
|
-
forceColor = 1;
|
|
516
|
-
} else if (env.FORCE_COLOR === false || env.FORCE_COLOR === "false") {
|
|
517
|
-
forceColor = 0;
|
|
518
|
-
} else {
|
|
519
|
-
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
function translateLevel(level) {
|
|
523
|
-
if (level === 0) {
|
|
524
|
-
return false;
|
|
525
|
-
}
|
|
526
|
-
return {
|
|
527
|
-
level,
|
|
528
|
-
hasBasic: true,
|
|
529
|
-
has256: level >= 2,
|
|
530
|
-
has16m: level >= 3
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
function supportsColor(stream) {
|
|
534
|
-
if (forceColor === 0) {
|
|
535
|
-
return 0;
|
|
536
|
-
}
|
|
537
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
538
|
-
return 3;
|
|
539
|
-
}
|
|
540
|
-
if (hasFlag("color=256")) {
|
|
541
|
-
return 2;
|
|
542
|
-
}
|
|
543
|
-
if (stream && !stream.isTTY && forceColor === void 0) {
|
|
544
|
-
return 0;
|
|
545
|
-
}
|
|
546
|
-
const min = forceColor || 0;
|
|
547
|
-
if (env.TERM === "dumb") {
|
|
548
|
-
return min;
|
|
549
|
-
}
|
|
550
|
-
if (process.platform === "win32") {
|
|
551
|
-
const osRelease = os.release().split(".");
|
|
552
|
-
if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
553
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
554
|
-
}
|
|
555
|
-
return 1;
|
|
556
|
-
}
|
|
557
|
-
if ("CI" in env) {
|
|
558
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
559
|
-
return 1;
|
|
560
|
-
}
|
|
561
|
-
return min;
|
|
562
|
-
}
|
|
563
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
564
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
565
|
-
}
|
|
566
|
-
if (env.COLORTERM === "truecolor") {
|
|
567
|
-
return 3;
|
|
568
|
-
}
|
|
569
|
-
if ("TERM_PROGRAM" in env) {
|
|
570
|
-
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
571
|
-
switch (env.TERM_PROGRAM) {
|
|
572
|
-
case "iTerm.app":
|
|
573
|
-
return version >= 3 ? 3 : 2;
|
|
574
|
-
case "Apple_Terminal":
|
|
575
|
-
return 2;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
579
|
-
return 2;
|
|
580
|
-
}
|
|
581
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
582
|
-
return 1;
|
|
583
|
-
}
|
|
584
|
-
if ("COLORTERM" in env) {
|
|
585
|
-
return 1;
|
|
586
|
-
}
|
|
587
|
-
return min;
|
|
588
|
-
}
|
|
589
|
-
function getSupportLevel(stream) {
|
|
590
|
-
const level = supportsColor(stream);
|
|
591
|
-
return translateLevel(level);
|
|
592
|
-
}
|
|
593
|
-
module2.exports = {
|
|
594
|
-
supportsColor: getSupportLevel,
|
|
595
|
-
stdout: getSupportLevel(process.stdout),
|
|
596
|
-
stderr: getSupportLevel(process.stderr)
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
|
|
601
|
-
// ../../node_modules/.pnpm/debug@4.3.4_supports-color@6.1.0/node_modules/debug/src/node.js
|
|
602
|
-
var require_node = __commonJS({
|
|
603
|
-
"../../node_modules/.pnpm/debug@4.3.4_supports-color@6.1.0/node_modules/debug/src/node.js"(exports, module2) {
|
|
604
|
-
var tty = require("tty");
|
|
605
|
-
var util = require("util");
|
|
606
|
-
exports.init = init;
|
|
607
|
-
exports.log = log;
|
|
608
|
-
exports.formatArgs = formatArgs;
|
|
609
|
-
exports.save = save5;
|
|
610
|
-
exports.load = load5;
|
|
611
|
-
exports.useColors = useColors;
|
|
612
|
-
exports.destroy = util.deprecate(() => {
|
|
613
|
-
}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
614
|
-
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
615
|
-
try {
|
|
616
|
-
const supportsColor = require_supports_color();
|
|
617
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
618
|
-
exports.colors = [
|
|
619
|
-
20,
|
|
620
|
-
21,
|
|
621
|
-
26,
|
|
622
|
-
27,
|
|
623
|
-
32,
|
|
624
|
-
33,
|
|
625
|
-
38,
|
|
626
|
-
39,
|
|
627
|
-
40,
|
|
628
|
-
41,
|
|
629
|
-
42,
|
|
630
|
-
43,
|
|
631
|
-
44,
|
|
632
|
-
45,
|
|
633
|
-
56,
|
|
634
|
-
57,
|
|
635
|
-
62,
|
|
636
|
-
63,
|
|
637
|
-
68,
|
|
638
|
-
69,
|
|
639
|
-
74,
|
|
640
|
-
75,
|
|
641
|
-
76,
|
|
642
|
-
77,
|
|
643
|
-
78,
|
|
644
|
-
79,
|
|
645
|
-
80,
|
|
646
|
-
81,
|
|
647
|
-
92,
|
|
648
|
-
93,
|
|
649
|
-
98,
|
|
650
|
-
99,
|
|
651
|
-
112,
|
|
652
|
-
113,
|
|
653
|
-
128,
|
|
654
|
-
129,
|
|
655
|
-
134,
|
|
656
|
-
135,
|
|
657
|
-
148,
|
|
658
|
-
149,
|
|
659
|
-
160,
|
|
660
|
-
161,
|
|
661
|
-
162,
|
|
662
|
-
163,
|
|
663
|
-
164,
|
|
664
|
-
165,
|
|
665
|
-
166,
|
|
666
|
-
167,
|
|
667
|
-
168,
|
|
668
|
-
169,
|
|
669
|
-
170,
|
|
670
|
-
171,
|
|
671
|
-
172,
|
|
672
|
-
173,
|
|
673
|
-
178,
|
|
674
|
-
179,
|
|
675
|
-
184,
|
|
676
|
-
185,
|
|
677
|
-
196,
|
|
678
|
-
197,
|
|
679
|
-
198,
|
|
680
|
-
199,
|
|
681
|
-
200,
|
|
682
|
-
201,
|
|
683
|
-
202,
|
|
684
|
-
203,
|
|
685
|
-
204,
|
|
686
|
-
205,
|
|
687
|
-
206,
|
|
688
|
-
207,
|
|
689
|
-
208,
|
|
690
|
-
209,
|
|
691
|
-
214,
|
|
692
|
-
215,
|
|
693
|
-
220,
|
|
694
|
-
221
|
|
695
|
-
];
|
|
696
|
-
}
|
|
697
|
-
} catch (error) {
|
|
698
|
-
}
|
|
699
|
-
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
700
|
-
return /^debug_/i.test(key);
|
|
701
|
-
}).reduce((obj, key) => {
|
|
702
|
-
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
703
|
-
return k.toUpperCase();
|
|
704
|
-
});
|
|
705
|
-
let val = process.env[key];
|
|
706
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
707
|
-
val = true;
|
|
708
|
-
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
709
|
-
val = false;
|
|
710
|
-
} else if (val === "null") {
|
|
711
|
-
val = null;
|
|
712
|
-
} else {
|
|
713
|
-
val = Number(val);
|
|
714
|
-
}
|
|
715
|
-
obj[prop] = val;
|
|
716
|
-
return obj;
|
|
717
|
-
}, {});
|
|
718
|
-
function useColors() {
|
|
719
|
-
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
720
|
-
}
|
|
721
|
-
function formatArgs(args) {
|
|
722
|
-
const { namespace: name, useColors: useColors2 } = this;
|
|
723
|
-
if (useColors2) {
|
|
724
|
-
const c2 = this.color;
|
|
725
|
-
const colorCode = "[3" + (c2 < 8 ? c2 : "8;5;" + c2);
|
|
726
|
-
const prefix = ` ${colorCode};1m${name} [0m`;
|
|
727
|
-
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
728
|
-
args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "[0m");
|
|
729
|
-
} else {
|
|
730
|
-
args[0] = getDate() + name + " " + args[0];
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
function getDate() {
|
|
734
|
-
if (exports.inspectOpts.hideDate) {
|
|
735
|
-
return "";
|
|
736
|
-
}
|
|
737
|
-
return new Date().toISOString() + " ";
|
|
738
|
-
}
|
|
739
|
-
function log(...args) {
|
|
740
|
-
return process.stderr.write(util.format(...args) + "\n");
|
|
741
|
-
}
|
|
742
|
-
function save5(namespaces) {
|
|
743
|
-
if (namespaces) {
|
|
744
|
-
process.env.DEBUG = namespaces;
|
|
745
|
-
} else {
|
|
746
|
-
delete process.env.DEBUG;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
function load5() {
|
|
750
|
-
return process.env.DEBUG;
|
|
751
|
-
}
|
|
752
|
-
function init(debug2) {
|
|
753
|
-
debug2.inspectOpts = {};
|
|
754
|
-
const keys = Object.keys(exports.inspectOpts);
|
|
755
|
-
for (let i = 0; i < keys.length; i++) {
|
|
756
|
-
debug2.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
module2.exports = require_common()(exports);
|
|
760
|
-
var { formatters } = module2.exports;
|
|
761
|
-
formatters.o = function(v2) {
|
|
762
|
-
this.inspectOpts.colors = this.useColors;
|
|
763
|
-
return util.inspect(v2, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
764
|
-
};
|
|
765
|
-
formatters.O = function(v2) {
|
|
766
|
-
this.inspectOpts.colors = this.useColors;
|
|
767
|
-
return util.inspect(v2, this.inspectOpts);
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
|
-
|
|
772
|
-
// ../../node_modules/.pnpm/debug@4.3.4_supports-color@6.1.0/node_modules/debug/src/index.js
|
|
773
|
-
var require_src = __commonJS({
|
|
774
|
-
"../../node_modules/.pnpm/debug@4.3.4_supports-color@6.1.0/node_modules/debug/src/index.js"(exports, module2) {
|
|
775
|
-
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
776
|
-
module2.exports = require_browser();
|
|
777
|
-
} else {
|
|
778
|
-
module2.exports = require_node();
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
// src/index.ts
|
|
784
|
-
var src_exports = {};
|
|
785
|
-
__export(src_exports, {
|
|
786
|
-
SearchMemoryIndexer: () => indexer_default
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/tokenizer/languages.js
|
|
790
|
-
var STEMMERS = {
|
|
791
|
-
arabic: "ar",
|
|
792
|
-
armenian: "am",
|
|
793
|
-
bulgarian: "bg",
|
|
794
|
-
danish: "dk",
|
|
795
|
-
dutch: "nl",
|
|
796
|
-
english: "en",
|
|
797
|
-
finnish: "fi",
|
|
798
|
-
french: "fr",
|
|
799
|
-
german: "de",
|
|
800
|
-
greek: "gr",
|
|
801
|
-
hungarian: "hu",
|
|
802
|
-
indian: "in",
|
|
803
|
-
indonesian: "id",
|
|
804
|
-
irish: "ie",
|
|
805
|
-
italian: "it",
|
|
806
|
-
lithuanian: "lt",
|
|
807
|
-
nepali: "np",
|
|
808
|
-
norwegian: "no",
|
|
809
|
-
portuguese: "pt",
|
|
810
|
-
romanian: "ro",
|
|
811
|
-
russian: "ru",
|
|
812
|
-
serbian: "rs",
|
|
813
|
-
slovenian: "ru",
|
|
814
|
-
spanish: "es",
|
|
815
|
-
swedish: "se",
|
|
816
|
-
tamil: "ta",
|
|
817
|
-
turkish: "tr",
|
|
818
|
-
ukrainian: "uk"
|
|
819
|
-
};
|
|
820
|
-
var SPLITTERS = {
|
|
821
|
-
dutch: /[^A-Za-zàèéìòóù0-9_'-]+/gim,
|
|
822
|
-
english: /[^A-Za-zàèéìòóù0-9_'-]+/gim,
|
|
823
|
-
french: /[^a-z0-9äâàéèëêïîöôùüûœç-]+/gim,
|
|
824
|
-
italian: /[^A-Za-zàèéìòóù0-9_'-]+/gim,
|
|
825
|
-
norwegian: /[^a-z0-9_æøåÆØÅäÄöÖüÜ]+/gim,
|
|
826
|
-
portuguese: /[^a-z0-9à-úÀ-Ú]/gim,
|
|
827
|
-
russian: /[^a-z0-9а-яА-ЯёЁ]+/gim,
|
|
828
|
-
spanish: /[^a-z0-9A-Zá-úÁ-ÚñÑüÜ]+/gim,
|
|
829
|
-
swedish: /[^a-z0-9_åÅäÄöÖüÜ-]+/gim,
|
|
830
|
-
german: /[^a-z0-9A-ZäöüÄÖÜß]+/gim,
|
|
831
|
-
finnish: /[^a-z0-9äöÄÖ]+/gim,
|
|
832
|
-
danish: /[^a-z0-9æøåÆØÅ]+/gim,
|
|
833
|
-
hungarian: /[^a-z0-9áéíóöőúüűÁÉÍÓÖŐÚÜŰ]+/gim,
|
|
834
|
-
romanian: /[^a-z0-9ăâîșțĂÂÎȘȚ]+/gim,
|
|
835
|
-
serbian: /[^a-z0-9čćžšđČĆŽŠĐ]+/gim,
|
|
836
|
-
turkish: /[^a-z0-9çÇğĞıİöÖşŞüÜ]+/gim,
|
|
837
|
-
lithuanian: /[^a-z0-9ąčęėįšųūžĄČĘĖĮŠŲŪŽ]+/gim,
|
|
838
|
-
arabic: /[^a-z0-9أ-ي]+/gim,
|
|
839
|
-
nepali: /[^a-z0-9अ-ह]+/gim,
|
|
840
|
-
irish: /[^a-z0-9áéíóúÁÉÍÓÚ]+/gim,
|
|
841
|
-
indian: /[^a-z0-9अ-ह]+/gim,
|
|
842
|
-
armenian: /[^a-z0-9ա-ֆ]+/gim,
|
|
843
|
-
greek: /[^a-z0-9α-ωά-ώ]+/gim,
|
|
844
|
-
indonesian: /[^a-z0-9]+/gim,
|
|
845
|
-
ukrainian: /[^a-z0-9а-яА-ЯіїєІЇЄ]+/gim,
|
|
846
|
-
slovenian: /[^a-z0-9螚ȎŠ]+/gim,
|
|
847
|
-
bulgarian: /[^a-z0-9а-яА-Я]+/gim,
|
|
848
|
-
tamil: /[^a-z0-9அ-ஹ]+/gim
|
|
849
|
-
};
|
|
850
|
-
var SUPPORTED_LANGUAGES = Object.keys(STEMMERS);
|
|
851
|
-
|
|
852
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/utils.js
|
|
853
|
-
var baseId = Date.now().toString().slice(5);
|
|
854
|
-
var lastId = 0;
|
|
855
|
-
var nano = BigInt(1e3);
|
|
856
|
-
var milli = BigInt(1e6);
|
|
857
|
-
var second = BigInt(1e9);
|
|
858
|
-
var MAX_ARGUMENT_FOR_STACK = 65535;
|
|
859
|
-
function safeArrayPush(arr, newArr) {
|
|
860
|
-
if (newArr.length < MAX_ARGUMENT_FOR_STACK) {
|
|
861
|
-
Array.prototype.push.apply(arr, newArr);
|
|
862
|
-
} else {
|
|
863
|
-
for (let i = 0; i < newArr.length; i += MAX_ARGUMENT_FOR_STACK) {
|
|
864
|
-
Array.prototype.push.apply(arr, newArr.slice(i, i + MAX_ARGUMENT_FOR_STACK));
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
function sprintf(template, ...args) {
|
|
869
|
-
return template.replace(/%(?:(?<position>\d+)\$)?(?<width>-?\d*\.?\d*)(?<type>[dfs])/g, function(...replaceArgs) {
|
|
870
|
-
const groups = replaceArgs[replaceArgs.length - 1];
|
|
871
|
-
const { width: rawWidth, type, position } = groups;
|
|
872
|
-
const replacement = position ? args[Number.parseInt(position) - 1] : args.shift();
|
|
873
|
-
const width = rawWidth === "" ? 0 : Number.parseInt(rawWidth);
|
|
874
|
-
switch (type) {
|
|
875
|
-
case "d":
|
|
876
|
-
return replacement.toString().padStart(width, "0");
|
|
877
|
-
case "f": {
|
|
878
|
-
let value = replacement;
|
|
879
|
-
const [padding, precision] = rawWidth.split(".").map((w) => Number.parseFloat(w));
|
|
880
|
-
if (typeof precision === "number" && precision >= 0) {
|
|
881
|
-
value = value.toFixed(precision);
|
|
882
|
-
}
|
|
883
|
-
return typeof padding === "number" && padding >= 0 ? value.toString().padStart(width, "0") : value.toString();
|
|
884
|
-
}
|
|
885
|
-
case "s":
|
|
886
|
-
return width < 0 ? replacement.toString().padEnd(-width, " ") : replacement.toString().padStart(width, " ");
|
|
887
|
-
default:
|
|
888
|
-
return replacement;
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
async function formatNanoseconds(value) {
|
|
893
|
-
if (typeof value === "number") {
|
|
894
|
-
value = BigInt(value);
|
|
895
|
-
}
|
|
896
|
-
if (value < nano) {
|
|
897
|
-
return `${value}ns`;
|
|
898
|
-
} else if (value < milli) {
|
|
899
|
-
return `${value / nano}\u03BCs`;
|
|
900
|
-
} else if (value < second) {
|
|
901
|
-
return `${value / milli}ms`;
|
|
902
|
-
}
|
|
903
|
-
return `${value / second}s`;
|
|
904
|
-
}
|
|
905
|
-
async function getNanosecondsTime() {
|
|
906
|
-
if (typeof process !== "undefined" && process.hrtime !== void 0) {
|
|
907
|
-
return process.hrtime.bigint();
|
|
908
|
-
}
|
|
909
|
-
if (typeof performance !== "undefined") {
|
|
910
|
-
return BigInt(Math.floor(performance.now() * 1e6));
|
|
911
|
-
}
|
|
912
|
-
return BigInt(0);
|
|
913
|
-
}
|
|
914
|
-
async function uniqueId() {
|
|
915
|
-
return `${baseId}-${lastId++}`;
|
|
916
|
-
}
|
|
917
|
-
function getOwnProperty(object, property) {
|
|
918
|
-
if (Object.hasOwn === void 0) {
|
|
919
|
-
return Object.prototype.hasOwnProperty.call(object, property) ? object[property] : void 0;
|
|
920
|
-
}
|
|
921
|
-
return Object.hasOwn(object, property) ? object[property] : void 0;
|
|
922
|
-
}
|
|
923
|
-
function sortTokenScorePredicate(a, b) {
|
|
924
|
-
if (b[1] === a[1]) {
|
|
925
|
-
return a[0] - b[0];
|
|
926
|
-
}
|
|
927
|
-
return b[1] - a[1];
|
|
928
|
-
}
|
|
929
|
-
function intersect(arrays) {
|
|
930
|
-
if (arrays.length === 0) {
|
|
931
|
-
return [];
|
|
932
|
-
} else if (arrays.length === 1) {
|
|
933
|
-
return arrays[0];
|
|
934
|
-
}
|
|
935
|
-
for (let i = 1; i < arrays.length; i++) {
|
|
936
|
-
if (arrays[i].length < arrays[0].length) {
|
|
937
|
-
const tmp = arrays[0];
|
|
938
|
-
arrays[0] = arrays[i];
|
|
939
|
-
arrays[i] = tmp;
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
const set = /* @__PURE__ */ new Map();
|
|
943
|
-
for (const elem of arrays[0]) {
|
|
944
|
-
set.set(elem, 1);
|
|
945
|
-
}
|
|
946
|
-
for (let i = 1; i < arrays.length; i++) {
|
|
947
|
-
let found = 0;
|
|
948
|
-
for (const elem of arrays[i]) {
|
|
949
|
-
const count2 = set.get(elem);
|
|
950
|
-
if (count2 === i) {
|
|
951
|
-
set.set(elem, count2 + 1);
|
|
952
|
-
found++;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
if (found === 0)
|
|
956
|
-
return [];
|
|
957
|
-
}
|
|
958
|
-
return arrays[0].filter((e) => {
|
|
959
|
-
const count2 = set.get(e);
|
|
960
|
-
if (count2 !== void 0)
|
|
961
|
-
set.set(e, 0);
|
|
962
|
-
return count2 === arrays.length;
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
async function getDocumentProperties(doc, paths) {
|
|
966
|
-
const properties = {};
|
|
967
|
-
const pathsLength = paths.length;
|
|
968
|
-
for (let i = 0; i < pathsLength; i++) {
|
|
969
|
-
const path = paths[i];
|
|
970
|
-
const pathTokens = path.split(".");
|
|
971
|
-
let current = doc;
|
|
972
|
-
const pathTokensLength = pathTokens.length;
|
|
973
|
-
for (let j = 0; j < pathTokensLength; j++) {
|
|
974
|
-
current = current[pathTokens[j]];
|
|
975
|
-
if (typeof current === "object" && !Array.isArray(current) && current !== null && j === pathTokensLength - 1) {
|
|
976
|
-
current = void 0;
|
|
977
|
-
break;
|
|
978
|
-
} else if ((current === null || typeof current !== "object") && j < pathTokensLength - 1) {
|
|
979
|
-
current = void 0;
|
|
980
|
-
break;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
if (typeof current !== "undefined") {
|
|
984
|
-
properties[path] = current;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
return properties;
|
|
988
|
-
}
|
|
989
|
-
async function getNested(obj, path) {
|
|
990
|
-
const props = await getDocumentProperties(obj, [
|
|
991
|
-
path
|
|
992
|
-
]);
|
|
993
|
-
return props[path];
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/errors.js
|
|
997
|
-
var allLanguages = SUPPORTED_LANGUAGES.join("\n - ");
|
|
998
|
-
var errors = {
|
|
999
|
-
NO_LANGUAGE_WITH_CUSTOM_TOKENIZER: "Do not pass the language option to create when using a custom tokenizer.",
|
|
1000
|
-
LANGUAGE_NOT_SUPPORTED: `Language "%s" is not supported.
|
|
1001
|
-
Supported languages are:
|
|
1002
|
-
- ${allLanguages}`,
|
|
1003
|
-
INVALID_STEMMER_FUNCTION_TYPE: `config.stemmer property must be a function.`,
|
|
1004
|
-
MISSING_STEMMER: `As of version 1.0.0 @orama/orama does not ship non English stemmers by default. To solve this, please explicitly import and specify the "%s" stemmer from the package @orama/stemmers. See https://docs.oramasearch.com/text-analysis/stemming for more information.`,
|
|
1005
|
-
CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY: "Custom stop words array must only contain strings.",
|
|
1006
|
-
UNSUPPORTED_COMPONENT: `Unsupported component "%s".`,
|
|
1007
|
-
COMPONENT_MUST_BE_FUNCTION: `The component "%s" must be a function.`,
|
|
1008
|
-
COMPONENT_MUST_BE_FUNCTION_OR_ARRAY_FUNCTIONS: `The component "%s" must be a function or an array of functions.`,
|
|
1009
|
-
INVALID_SCHEMA_TYPE: `Unsupported schema type "%s" at "%s". Expected "string", "boolean" or "number" or array of them.`,
|
|
1010
|
-
DOCUMENT_ID_MUST_BE_STRING: `Document id must be of type "string". Got "%s" instead.`,
|
|
1011
|
-
DOCUMENT_ALREADY_EXISTS: `A document with id "%s" already exists.`,
|
|
1012
|
-
DOCUMENT_DOES_NOT_EXIST: `A document with id "%s" does not exists.`,
|
|
1013
|
-
MISSING_DOCUMENT_PROPERTY: `Missing searchable property "%s".`,
|
|
1014
|
-
INVALID_DOCUMENT_PROPERTY: `Invalid document property "%s": expected "%s", got "%s"`,
|
|
1015
|
-
UNKNOWN_INDEX: `Invalid property name "%s". Expected a wildcard string ("*") or array containing one of the following properties: %s`,
|
|
1016
|
-
INVALID_BOOST_VALUE: `Boost value must be a number greater than, or less than 0.`,
|
|
1017
|
-
INVALID_FILTER_OPERATION: `You can only use one operation per filter, you requested %d.`,
|
|
1018
|
-
SCHEMA_VALIDATION_FAILURE: `Cannot insert document due schema validation failure on "%s" property.`,
|
|
1019
|
-
INVALID_SORT_SCHEMA_TYPE: `Unsupported sort schema type "%s" at "%s". Expected "string" or "number".`,
|
|
1020
|
-
CANNOT_SORT_BY_ARRAY: `Cannot configure sort for "%s" because it is an array (%s).`,
|
|
1021
|
-
UNABLE_TO_SORT_ON_UNKNOWN_FIELD: `Unable to sort on unknown field "%s". Allowed fields: %s`,
|
|
1022
|
-
SORT_DISABLED: `Sort is disabled. Please read the documentation at https://docs.oramasearch for more information.`,
|
|
1023
|
-
UNKNOWN_GROUP_BY_PROPERTY: `Unknown groupBy property "%s".`,
|
|
1024
|
-
INVALID_GROUP_BY_PROPERTY: `Invalid groupBy property "%s". Allowed types: "%s", but given "%s".`,
|
|
1025
|
-
UNKNOWN_FILTER_PROPERTY: `Unknown filter property "%s".`,
|
|
1026
|
-
INVALID_VECTOR_SIZE: `Vector size must be a number greater than 0. Got "%s" instead.`,
|
|
1027
|
-
INVALID_VECTOR_VALUE: `Vector value must be a number greater than 0. Got "%s" instead.`,
|
|
1028
|
-
INVALID_INPUT_VECTOR: `Property "%s" was declared as a %s-dimentional vector, but got a %s-dimentional vector instead.
|
|
1029
|
-
Input vectors must be of the size declared in the schema, as calculating similarity between vectors of different sizes can lead to unexpected results.`,
|
|
1030
|
-
WRONG_SEARCH_PROPERTY_TYPE: `Property "%s" is not searchable. Only "string" properties are searchable.`
|
|
1031
|
-
};
|
|
1032
|
-
function createError(code, ...args) {
|
|
1033
|
-
var _a2;
|
|
1034
|
-
const error = new Error(sprintf((_a2 = errors[code]) != null ? _a2 : `Unsupported Orama Error code: ${code}`, ...args));
|
|
1035
|
-
error.code = code;
|
|
1036
|
-
if ("captureStackTrace" in Error.prototype) {
|
|
1037
|
-
Error.captureStackTrace(error);
|
|
1038
|
-
}
|
|
1039
|
-
return error;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/defaults.js
|
|
1043
|
-
async function formatElapsedTime(n) {
|
|
1044
|
-
return {
|
|
1045
|
-
raw: Number(n),
|
|
1046
|
-
formatted: await formatNanoseconds(n)
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
async function getDocumentIndexId(doc) {
|
|
1050
|
-
if (doc.id) {
|
|
1051
|
-
if (typeof doc.id !== "string") {
|
|
1052
|
-
throw createError("DOCUMENT_ID_MUST_BE_STRING", typeof doc.id);
|
|
1053
|
-
}
|
|
1054
|
-
return doc.id;
|
|
1055
|
-
}
|
|
1056
|
-
return await uniqueId();
|
|
1057
|
-
}
|
|
1058
|
-
async function validateSchema(doc, schema) {
|
|
1059
|
-
for (const [prop, type] of Object.entries(schema)) {
|
|
1060
|
-
const value = doc[prop];
|
|
1061
|
-
const typeOfValue = typeof value;
|
|
1062
|
-
if (typeOfValue === "undefined") {
|
|
1063
|
-
continue;
|
|
1064
|
-
}
|
|
1065
|
-
if (type === "enum" && (typeOfValue === "string" || typeOfValue === "number")) {
|
|
1066
|
-
continue;
|
|
1067
|
-
}
|
|
1068
|
-
const typeOfType = typeof type;
|
|
1069
|
-
if (isVectorType(type)) {
|
|
1070
|
-
const vectorSize = getVectorSize(type);
|
|
1071
|
-
if (!Array.isArray(value) || value.length !== vectorSize) {
|
|
1072
|
-
throw createError("INVALID_INPUT_VECTOR", prop, vectorSize, value.length);
|
|
1073
|
-
}
|
|
1074
|
-
continue;
|
|
1075
|
-
}
|
|
1076
|
-
if (typeOfType === "string" && isArrayType(type)) {
|
|
1077
|
-
if (!Array.isArray(value)) {
|
|
1078
|
-
return prop;
|
|
1079
|
-
}
|
|
1080
|
-
const expectedType = getInnerType(type);
|
|
1081
|
-
const valueLength = value.length;
|
|
1082
|
-
for (let i = 0; i < valueLength; i++) {
|
|
1083
|
-
if (typeof value[i] !== expectedType) {
|
|
1084
|
-
return prop + "." + i;
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
continue;
|
|
1088
|
-
}
|
|
1089
|
-
if (typeOfType === "object") {
|
|
1090
|
-
if (!value || typeOfValue !== "object") {
|
|
1091
|
-
return prop;
|
|
1092
|
-
}
|
|
1093
|
-
const subProp = await validateSchema(value, type);
|
|
1094
|
-
if (subProp) {
|
|
1095
|
-
return prop + "." + subProp;
|
|
1096
|
-
}
|
|
1097
|
-
continue;
|
|
1098
|
-
}
|
|
1099
|
-
if (typeOfValue !== type) {
|
|
1100
|
-
return prop;
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
return void 0;
|
|
1104
|
-
}
|
|
1105
|
-
var IS_ARRAY_TYPE = {
|
|
1106
|
-
string: false,
|
|
1107
|
-
number: false,
|
|
1108
|
-
boolean: false,
|
|
1109
|
-
enum: false,
|
|
1110
|
-
"string[]": true,
|
|
1111
|
-
"number[]": true,
|
|
1112
|
-
"boolean[]": true
|
|
1113
|
-
};
|
|
1114
|
-
var INNER_TYPE = {
|
|
1115
|
-
"string[]": "string",
|
|
1116
|
-
"number[]": "number",
|
|
1117
|
-
"boolean[]": "boolean"
|
|
1118
|
-
};
|
|
1119
|
-
function isVectorType(type) {
|
|
1120
|
-
return /^vector\[\d+\]$/.test(type);
|
|
1121
|
-
}
|
|
1122
|
-
function isArrayType(type) {
|
|
1123
|
-
return IS_ARRAY_TYPE[type];
|
|
1124
|
-
}
|
|
1125
|
-
function getInnerType(type) {
|
|
1126
|
-
return INNER_TYPE[type];
|
|
1127
|
-
}
|
|
1128
|
-
function getVectorSize(type) {
|
|
1129
|
-
const size = Number(type.slice(7, -1));
|
|
1130
|
-
switch (true) {
|
|
1131
|
-
case isNaN(size):
|
|
1132
|
-
throw createError("INVALID_VECTOR_VALUE", type);
|
|
1133
|
-
case size <= 0:
|
|
1134
|
-
throw createError("INVALID_VECTOR_SIZE", type);
|
|
1135
|
-
default:
|
|
1136
|
-
return size;
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/internal-document-id-store.js
|
|
1141
|
-
function createInternalDocumentIDStore() {
|
|
1142
|
-
return {
|
|
1143
|
-
idToInternalId: /* @__PURE__ */ new Map(),
|
|
1144
|
-
internalIdToId: [],
|
|
1145
|
-
save,
|
|
1146
|
-
load
|
|
1147
|
-
};
|
|
1148
|
-
}
|
|
1149
|
-
function save(store2) {
|
|
1150
|
-
return {
|
|
1151
|
-
internalIdToId: store2.internalIdToId
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
function load(orama, raw) {
|
|
1155
|
-
const { internalIdToId } = raw;
|
|
1156
|
-
orama.internalDocumentIDStore.idToInternalId.clear();
|
|
1157
|
-
orama.internalDocumentIDStore.internalIdToId = [];
|
|
1158
|
-
for (let i = 0; i < internalIdToId.length; i++) {
|
|
1159
|
-
orama.internalDocumentIDStore.idToInternalId.set(internalIdToId[i], i + 1);
|
|
1160
|
-
orama.internalDocumentIDStore.internalIdToId.push(internalIdToId[i]);
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
function getInternalDocumentId(store2, id) {
|
|
1164
|
-
if (typeof id === "string") {
|
|
1165
|
-
const internalId = store2.idToInternalId.get(id);
|
|
1166
|
-
if (internalId) {
|
|
1167
|
-
return internalId;
|
|
1168
|
-
}
|
|
1169
|
-
const currentId = store2.idToInternalId.size + 1;
|
|
1170
|
-
store2.idToInternalId.set(id, currentId);
|
|
1171
|
-
store2.internalIdToId.push(id);
|
|
1172
|
-
return currentId;
|
|
1173
|
-
}
|
|
1174
|
-
if (id > store2.internalIdToId.length) {
|
|
1175
|
-
return getInternalDocumentId(store2, id.toString());
|
|
1176
|
-
}
|
|
1177
|
-
return id;
|
|
1178
|
-
}
|
|
1179
|
-
function getDocumentIdFromInternalId(store2, internalId) {
|
|
1180
|
-
if (store2.internalIdToId.length < internalId) {
|
|
1181
|
-
throw new Error(`Invalid internalId ${internalId}`);
|
|
1182
|
-
}
|
|
1183
|
-
return store2.internalIdToId[internalId - 1];
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/documents-store.js
|
|
1187
|
-
async function create(_, sharedInternalDocumentStore) {
|
|
1188
|
-
return {
|
|
1189
|
-
sharedInternalDocumentStore,
|
|
1190
|
-
docs: {},
|
|
1191
|
-
count: 0
|
|
1192
|
-
};
|
|
1193
|
-
}
|
|
1194
|
-
async function get(store2, id) {
|
|
1195
|
-
const internalId = getInternalDocumentId(store2.sharedInternalDocumentStore, id);
|
|
1196
|
-
return store2.docs[internalId];
|
|
1197
|
-
}
|
|
1198
|
-
async function getMultiple(store2, ids) {
|
|
1199
|
-
const found = Array.from({
|
|
1200
|
-
length: ids.length
|
|
1201
|
-
});
|
|
1202
|
-
for (let i = 0; i < ids.length; i++) {
|
|
1203
|
-
const internalId = getInternalDocumentId(store2.sharedInternalDocumentStore, ids[i]);
|
|
1204
|
-
found[i] = store2.docs[internalId];
|
|
1205
|
-
}
|
|
1206
|
-
return found;
|
|
1207
|
-
}
|
|
1208
|
-
async function getAll(store2) {
|
|
1209
|
-
return store2.docs;
|
|
1210
|
-
}
|
|
1211
|
-
async function store(store2, id, doc) {
|
|
1212
|
-
const internalId = getInternalDocumentId(store2.sharedInternalDocumentStore, id);
|
|
1213
|
-
if (typeof store2.docs[internalId] !== "undefined") {
|
|
1214
|
-
return false;
|
|
1215
|
-
}
|
|
1216
|
-
store2.docs[internalId] = doc;
|
|
1217
|
-
store2.count++;
|
|
1218
|
-
return true;
|
|
1219
|
-
}
|
|
1220
|
-
async function remove(store2, id) {
|
|
1221
|
-
const internalId = getInternalDocumentId(store2.sharedInternalDocumentStore, id);
|
|
1222
|
-
if (typeof store2.docs[internalId] === "undefined") {
|
|
1223
|
-
return false;
|
|
1224
|
-
}
|
|
1225
|
-
delete store2.docs[internalId];
|
|
1226
|
-
store2.count--;
|
|
1227
|
-
return true;
|
|
1228
|
-
}
|
|
1229
|
-
async function count(store2) {
|
|
1230
|
-
return store2.count;
|
|
1231
|
-
}
|
|
1232
|
-
async function load2(sharedInternalDocumentStore, raw) {
|
|
1233
|
-
const rawDocument = raw;
|
|
1234
|
-
return {
|
|
1235
|
-
docs: rawDocument.docs,
|
|
1236
|
-
count: rawDocument.count,
|
|
1237
|
-
sharedInternalDocumentStore
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
async function save2(store2) {
|
|
1241
|
-
return {
|
|
1242
|
-
docs: store2.docs,
|
|
1243
|
-
count: store2.count
|
|
1244
|
-
};
|
|
1245
|
-
}
|
|
1246
|
-
async function createDocumentsStore() {
|
|
1247
|
-
return {
|
|
1248
|
-
create,
|
|
1249
|
-
get,
|
|
1250
|
-
getMultiple,
|
|
1251
|
-
getAll,
|
|
1252
|
-
store,
|
|
1253
|
-
remove,
|
|
1254
|
-
count,
|
|
1255
|
-
load: load2,
|
|
1256
|
-
save: save2
|
|
1257
|
-
};
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/hooks.js
|
|
1261
|
-
var OBJECT_COMPONENTS = [
|
|
1262
|
-
"tokenizer",
|
|
1263
|
-
"index",
|
|
1264
|
-
"documentsStore",
|
|
1265
|
-
"sorter"
|
|
1266
|
-
];
|
|
1267
|
-
var FUNCTION_COMPONENTS = [
|
|
1268
|
-
"validateSchema",
|
|
1269
|
-
"getDocumentIndexId",
|
|
1270
|
-
"getDocumentProperties",
|
|
1271
|
-
"formatElapsedTime"
|
|
1272
|
-
];
|
|
1273
|
-
var SINGLE_OR_ARRAY_COMPONENTS = [
|
|
1274
|
-
"beforeInsert",
|
|
1275
|
-
"afterInsert",
|
|
1276
|
-
"beforeRemove",
|
|
1277
|
-
"afterRemove",
|
|
1278
|
-
"beforeUpdate",
|
|
1279
|
-
"afterUpdate",
|
|
1280
|
-
"afterSearch",
|
|
1281
|
-
"beforeMultipleInsert",
|
|
1282
|
-
"afterMultipleInsert",
|
|
1283
|
-
"beforeMultipleRemove",
|
|
1284
|
-
"afterMultipleRemove",
|
|
1285
|
-
"beforeMultipleUpdate",
|
|
1286
|
-
"afterMultipleUpdate"
|
|
1287
|
-
];
|
|
1288
|
-
async function runSingleHook(hooks, orama, id, doc) {
|
|
1289
|
-
const hooksLength = hooks.length;
|
|
1290
|
-
for (let i = 0; i < hooksLength; i++) {
|
|
1291
|
-
await hooks[i](orama, id, doc);
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
async function runAfterSearch(hooks, db, params, language, results) {
|
|
1295
|
-
const hooksLength = hooks.length;
|
|
1296
|
-
for (let i = 0; i < hooksLength; i++) {
|
|
1297
|
-
await hooks[i](db, params, language, results);
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/trees/avl.js
|
|
1302
|
-
var BALANCE_STATE = {
|
|
1303
|
-
UNBALANCED_RIGHT: -2,
|
|
1304
|
-
SLIGHTLY_UNBALANCED_RIGHT: -1,
|
|
1305
|
-
BALANCED: 0,
|
|
1306
|
-
SLIGHTLY_UNBALANCED_LEFT: 1,
|
|
1307
|
-
UNBALANCED_LEFT: 2
|
|
1308
|
-
};
|
|
1309
|
-
function getHeight(node) {
|
|
1310
|
-
return node ? node.height : -1;
|
|
1311
|
-
}
|
|
1312
|
-
function rotateLeft(node) {
|
|
1313
|
-
const right = node.right;
|
|
1314
|
-
node.right = right.left;
|
|
1315
|
-
right.left = node;
|
|
1316
|
-
node.height = Math.max(getHeight(node.left), getHeight(node.right)) + 1;
|
|
1317
|
-
right.height = Math.max(getHeight(right.left), getHeight(right.right)) + 1;
|
|
1318
|
-
return right;
|
|
1319
|
-
}
|
|
1320
|
-
function rotateRight(node) {
|
|
1321
|
-
const left = node.left;
|
|
1322
|
-
node.left = left.right;
|
|
1323
|
-
left.right = node;
|
|
1324
|
-
node.height = Math.max(getHeight(node.left), getHeight(node.right)) + 1;
|
|
1325
|
-
left.height = Math.max(getHeight(left.left), getHeight(left.right)) + 1;
|
|
1326
|
-
return left;
|
|
1327
|
-
}
|
|
1328
|
-
function rangeSearch(node, min, max) {
|
|
1329
|
-
if (!node) {
|
|
1330
|
-
return [];
|
|
1331
|
-
}
|
|
1332
|
-
const result = [];
|
|
1333
|
-
function traverse(node2) {
|
|
1334
|
-
if (!node2) {
|
|
1335
|
-
return;
|
|
1336
|
-
}
|
|
1337
|
-
if (node2.key > min) {
|
|
1338
|
-
traverse(node2.left);
|
|
1339
|
-
}
|
|
1340
|
-
if (node2.key >= min && node2.key <= max) {
|
|
1341
|
-
safeArrayPush(result, node2.value);
|
|
1342
|
-
}
|
|
1343
|
-
if (node2.key < max) {
|
|
1344
|
-
traverse(node2.right);
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
traverse(node);
|
|
1348
|
-
return result;
|
|
1349
|
-
}
|
|
1350
|
-
function greaterThan(node, key, inclusive = false) {
|
|
1351
|
-
if (!node) {
|
|
1352
|
-
return [];
|
|
1353
|
-
}
|
|
1354
|
-
const result = [];
|
|
1355
|
-
function traverse(node2) {
|
|
1356
|
-
if (!node2) {
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
if (inclusive && node2.key >= key) {
|
|
1360
|
-
safeArrayPush(result, node2.value);
|
|
1361
|
-
}
|
|
1362
|
-
if (!inclusive && node2.key > key) {
|
|
1363
|
-
safeArrayPush(result, node2.value);
|
|
1364
|
-
}
|
|
1365
|
-
traverse(node2.left);
|
|
1366
|
-
traverse(node2.right);
|
|
1367
|
-
}
|
|
1368
|
-
traverse(node);
|
|
1369
|
-
return result;
|
|
1370
|
-
}
|
|
1371
|
-
function lessThan(node, key, inclusive = false) {
|
|
1372
|
-
if (!node) {
|
|
1373
|
-
return [];
|
|
1374
|
-
}
|
|
1375
|
-
const result = [];
|
|
1376
|
-
function traverse(node2) {
|
|
1377
|
-
if (!node2) {
|
|
1378
|
-
return;
|
|
1379
|
-
}
|
|
1380
|
-
if (inclusive && node2.key <= key) {
|
|
1381
|
-
safeArrayPush(result, node2.value);
|
|
1382
|
-
}
|
|
1383
|
-
if (!inclusive && node2.key < key) {
|
|
1384
|
-
safeArrayPush(result, node2.value);
|
|
1385
|
-
}
|
|
1386
|
-
traverse(node2.left);
|
|
1387
|
-
traverse(node2.right);
|
|
1388
|
-
}
|
|
1389
|
-
traverse(node);
|
|
1390
|
-
return result;
|
|
1391
|
-
}
|
|
1392
|
-
function getNodeByKey(node, key) {
|
|
1393
|
-
while (node !== null) {
|
|
1394
|
-
if (key < node.key) {
|
|
1395
|
-
node = node.left;
|
|
1396
|
-
} else if (key > node.key) {
|
|
1397
|
-
node = node.right;
|
|
1398
|
-
} else {
|
|
1399
|
-
return node;
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
return null;
|
|
1403
|
-
}
|
|
1404
|
-
function create2(key, value) {
|
|
1405
|
-
return {
|
|
1406
|
-
key,
|
|
1407
|
-
value,
|
|
1408
|
-
left: null,
|
|
1409
|
-
right: null,
|
|
1410
|
-
height: 0
|
|
1411
|
-
};
|
|
1412
|
-
}
|
|
1413
|
-
function insert(root, key, value) {
|
|
1414
|
-
let parent = null;
|
|
1415
|
-
let current = root;
|
|
1416
|
-
while (current !== null) {
|
|
1417
|
-
parent = current;
|
|
1418
|
-
if (key < current.key) {
|
|
1419
|
-
current = current.left;
|
|
1420
|
-
} else if (key > current.key) {
|
|
1421
|
-
current = current.right;
|
|
1422
|
-
} else {
|
|
1423
|
-
current.value = current.value.concat(value);
|
|
1424
|
-
return root;
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
const newNode = create2(key, value);
|
|
1428
|
-
if (!parent) {
|
|
1429
|
-
root = newNode;
|
|
1430
|
-
} else if (key < parent.key) {
|
|
1431
|
-
parent.left = newNode;
|
|
1432
|
-
} else {
|
|
1433
|
-
parent.right = newNode;
|
|
1434
|
-
}
|
|
1435
|
-
current = newNode;
|
|
1436
|
-
while (parent) {
|
|
1437
|
-
const balanceFactor = getHeight(parent.left) - getHeight(parent.right);
|
|
1438
|
-
if (balanceFactor === BALANCE_STATE.UNBALANCED_LEFT) {
|
|
1439
|
-
if (key > parent.left.key) {
|
|
1440
|
-
parent.left = rotateLeft(parent.left);
|
|
1441
|
-
}
|
|
1442
|
-
parent = rotateRight(parent);
|
|
1443
|
-
}
|
|
1444
|
-
if (balanceFactor === BALANCE_STATE.UNBALANCED_RIGHT) {
|
|
1445
|
-
if (key < parent.right.key) {
|
|
1446
|
-
parent.right = rotateRight(parent.right);
|
|
1447
|
-
}
|
|
1448
|
-
parent = rotateLeft(parent);
|
|
1449
|
-
}
|
|
1450
|
-
if (parent === root) {
|
|
1451
|
-
break;
|
|
1452
|
-
}
|
|
1453
|
-
current = parent;
|
|
1454
|
-
parent = getNodeParent(root, current.key);
|
|
1455
|
-
}
|
|
1456
|
-
return root;
|
|
1457
|
-
}
|
|
1458
|
-
function getNodeParent(root, key) {
|
|
1459
|
-
let current = root;
|
|
1460
|
-
let parent = null;
|
|
1461
|
-
while (current !== null) {
|
|
1462
|
-
if (key < current.key) {
|
|
1463
|
-
parent = current;
|
|
1464
|
-
current = current.left;
|
|
1465
|
-
} else if (key > current.key) {
|
|
1466
|
-
parent = current;
|
|
1467
|
-
current = current.right;
|
|
1468
|
-
} else {
|
|
1469
|
-
break;
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
return parent;
|
|
1473
|
-
}
|
|
1474
|
-
function find(root, key) {
|
|
1475
|
-
const node = getNodeByKey(root, key);
|
|
1476
|
-
if (!node) {
|
|
1477
|
-
return null;
|
|
1478
|
-
}
|
|
1479
|
-
return node.value;
|
|
1480
|
-
}
|
|
1481
|
-
function remove2(root, key) {
|
|
1482
|
-
let node = root;
|
|
1483
|
-
let parentNode = null;
|
|
1484
|
-
while (node && node.key !== key) {
|
|
1485
|
-
parentNode = node;
|
|
1486
|
-
if (key < node.key) {
|
|
1487
|
-
node = node.left;
|
|
1488
|
-
} else {
|
|
1489
|
-
node = node.right;
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
if (!node) {
|
|
1493
|
-
return null;
|
|
1494
|
-
}
|
|
1495
|
-
if (!node.left && !node.right) {
|
|
1496
|
-
if (!parentNode) {
|
|
1497
|
-
root = null;
|
|
1498
|
-
} else {
|
|
1499
|
-
if (parentNode.left === node) {
|
|
1500
|
-
parentNode.left = null;
|
|
1501
|
-
} else {
|
|
1502
|
-
parentNode.right = null;
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
} else if (node.left && node.right) {
|
|
1506
|
-
let minValueNode = node.right;
|
|
1507
|
-
let minValueParent = node;
|
|
1508
|
-
while (minValueNode.left) {
|
|
1509
|
-
minValueParent = minValueNode;
|
|
1510
|
-
minValueNode = minValueNode.left;
|
|
1511
|
-
}
|
|
1512
|
-
node.key = minValueNode.key;
|
|
1513
|
-
if (minValueParent === node) {
|
|
1514
|
-
minValueParent.right = minValueNode.right;
|
|
1515
|
-
} else {
|
|
1516
|
-
minValueParent.left = minValueNode.right;
|
|
1517
|
-
}
|
|
1518
|
-
} else {
|
|
1519
|
-
const childNode = node.left ? node.left : node.right;
|
|
1520
|
-
if (!parentNode) {
|
|
1521
|
-
root = childNode;
|
|
1522
|
-
} else {
|
|
1523
|
-
if (parentNode.left === node) {
|
|
1524
|
-
parentNode.left = childNode;
|
|
1525
|
-
} else {
|
|
1526
|
-
parentNode.right = childNode;
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
return root;
|
|
1531
|
-
}
|
|
1532
|
-
function removeDocument(root, id, key) {
|
|
1533
|
-
const node = getNodeByKey(root, key);
|
|
1534
|
-
if (!node) {
|
|
1535
|
-
return;
|
|
1536
|
-
}
|
|
1537
|
-
if (node.value.length === 1) {
|
|
1538
|
-
remove2(root, key);
|
|
1539
|
-
return;
|
|
1540
|
-
}
|
|
1541
|
-
node.value.splice(node.value.indexOf(id), 1);
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/levenshtein.js
|
|
1545
|
-
function _boundedLevenshtein(a, b, tolerance) {
|
|
1546
|
-
if (a === b) {
|
|
1547
|
-
return 0;
|
|
1548
|
-
}
|
|
1549
|
-
const swap = a;
|
|
1550
|
-
if (a.length > b.length) {
|
|
1551
|
-
a = b;
|
|
1552
|
-
b = swap;
|
|
1553
|
-
}
|
|
1554
|
-
let lenA = a.length;
|
|
1555
|
-
let lenB = b.length;
|
|
1556
|
-
while (lenA > 0 && a.charCodeAt(~-lenA) === b.charCodeAt(~-lenB)) {
|
|
1557
|
-
lenA--;
|
|
1558
|
-
lenB--;
|
|
1559
|
-
}
|
|
1560
|
-
if (!lenA) {
|
|
1561
|
-
return lenB > tolerance ? -1 : lenB;
|
|
1562
|
-
}
|
|
1563
|
-
let startIdx = 0;
|
|
1564
|
-
while (startIdx < lenA && a.charCodeAt(startIdx) === b.charCodeAt(startIdx)) {
|
|
1565
|
-
startIdx++;
|
|
1566
|
-
}
|
|
1567
|
-
lenA -= startIdx;
|
|
1568
|
-
lenB -= startIdx;
|
|
1569
|
-
if (lenA === 0) {
|
|
1570
|
-
return lenB > tolerance ? -1 : lenB;
|
|
1571
|
-
}
|
|
1572
|
-
const delta = lenB - lenA;
|
|
1573
|
-
if (tolerance > lenB) {
|
|
1574
|
-
tolerance = lenB;
|
|
1575
|
-
} else if (delta > tolerance) {
|
|
1576
|
-
return -1;
|
|
1577
|
-
}
|
|
1578
|
-
let i = 0;
|
|
1579
|
-
const row = [];
|
|
1580
|
-
const characterCodeCache = [];
|
|
1581
|
-
while (i < tolerance) {
|
|
1582
|
-
characterCodeCache[i] = b.charCodeAt(startIdx + i);
|
|
1583
|
-
row[i] = ++i;
|
|
1584
|
-
}
|
|
1585
|
-
while (i < lenB) {
|
|
1586
|
-
characterCodeCache[i] = b.charCodeAt(startIdx + i);
|
|
1587
|
-
row[i++] = tolerance + 1;
|
|
1588
|
-
}
|
|
1589
|
-
const offset = tolerance - delta;
|
|
1590
|
-
const haveMax = tolerance < lenB;
|
|
1591
|
-
let jStart = 0;
|
|
1592
|
-
let jEnd = tolerance;
|
|
1593
|
-
let current = 0;
|
|
1594
|
-
let left = 0;
|
|
1595
|
-
let above = 0;
|
|
1596
|
-
let charA = 0;
|
|
1597
|
-
let j = 0;
|
|
1598
|
-
for (i = 0; i < lenA; i++) {
|
|
1599
|
-
left = i;
|
|
1600
|
-
current = i + 1;
|
|
1601
|
-
charA = a.charCodeAt(startIdx + i);
|
|
1602
|
-
jStart += i > offset ? 1 : 0;
|
|
1603
|
-
jEnd += jEnd < lenB ? 1 : 0;
|
|
1604
|
-
for (j = jStart; j < jEnd; j++) {
|
|
1605
|
-
above = current;
|
|
1606
|
-
current = left;
|
|
1607
|
-
left = row[j];
|
|
1608
|
-
if (charA !== characterCodeCache[j]) {
|
|
1609
|
-
if (left < current) {
|
|
1610
|
-
current = left;
|
|
1611
|
-
}
|
|
1612
|
-
if (above < current) {
|
|
1613
|
-
current = above;
|
|
1614
|
-
}
|
|
1615
|
-
current++;
|
|
1616
|
-
}
|
|
1617
|
-
row[j] = current;
|
|
1618
|
-
}
|
|
1619
|
-
if (haveMax && row[i + delta] > tolerance) {
|
|
1620
|
-
return -1;
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
return current <= tolerance ? current : -1;
|
|
1624
|
-
}
|
|
1625
|
-
function syncBoundedLevenshtein(a, b, tolerance) {
|
|
1626
|
-
const distance = _boundedLevenshtein(a, b, tolerance);
|
|
1627
|
-
return {
|
|
1628
|
-
distance,
|
|
1629
|
-
isBounded: distance >= 0
|
|
1630
|
-
};
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1633
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/trees/radix.js
|
|
1634
|
-
var Node = class {
|
|
1635
|
-
constructor(key, subWord, end) {
|
|
1636
|
-
this.key = key;
|
|
1637
|
-
this.subWord = subWord;
|
|
1638
|
-
this.end = end;
|
|
1639
|
-
}
|
|
1640
|
-
children = {};
|
|
1641
|
-
docs = [];
|
|
1642
|
-
word = "";
|
|
1643
|
-
toJSON() {
|
|
1644
|
-
return {
|
|
1645
|
-
word: this.word,
|
|
1646
|
-
subWord: this.subWord,
|
|
1647
|
-
children: this.children,
|
|
1648
|
-
docs: this.docs,
|
|
1649
|
-
end: this.end
|
|
1650
|
-
};
|
|
1651
|
-
}
|
|
1652
|
-
};
|
|
1653
|
-
function updateParent(node, parent) {
|
|
1654
|
-
node.word = parent.word + node.subWord;
|
|
1655
|
-
}
|
|
1656
|
-
function addDocument(node, docID) {
|
|
1657
|
-
node.docs.push(docID);
|
|
1658
|
-
}
|
|
1659
|
-
function removeDocument2(node, docID) {
|
|
1660
|
-
const index = node.docs.indexOf(docID);
|
|
1661
|
-
if (index === -1) {
|
|
1662
|
-
return false;
|
|
1663
|
-
}
|
|
1664
|
-
node.docs.splice(index, 1);
|
|
1665
|
-
return true;
|
|
1666
|
-
}
|
|
1667
|
-
function findAllWords(node, output, term, exact, tolerance) {
|
|
1668
|
-
if (node.end) {
|
|
1669
|
-
const { word, docs: docIDs } = node;
|
|
1670
|
-
if (exact && word !== term) {
|
|
1671
|
-
return {};
|
|
1672
|
-
}
|
|
1673
|
-
if (!getOwnProperty(output, word)) {
|
|
1674
|
-
if (tolerance) {
|
|
1675
|
-
const difference = Math.abs(term.length - word.length);
|
|
1676
|
-
if (difference <= tolerance && syncBoundedLevenshtein(term, word, tolerance).isBounded) {
|
|
1677
|
-
output[word] = [];
|
|
1678
|
-
}
|
|
1679
|
-
} else {
|
|
1680
|
-
output[word] = [];
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
if (getOwnProperty(output, word) && docIDs.length) {
|
|
1684
|
-
const docs = new Set(output[word]);
|
|
1685
|
-
const docIDsLength = docIDs.length;
|
|
1686
|
-
for (let i = 0; i < docIDsLength; i++) {
|
|
1687
|
-
docs.add(docIDs[i]);
|
|
1688
|
-
}
|
|
1689
|
-
output[word] = Array.from(docs);
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
for (const character of Object.keys(node.children)) {
|
|
1693
|
-
findAllWords(node.children[character], output, term, exact, tolerance);
|
|
1694
|
-
}
|
|
1695
|
-
return output;
|
|
1696
|
-
}
|
|
1697
|
-
function getCommonPrefix(a, b) {
|
|
1698
|
-
let commonPrefix = "";
|
|
1699
|
-
const len = Math.min(a.length, b.length);
|
|
1700
|
-
for (let i = 0; i < len; i++) {
|
|
1701
|
-
if (a[i] !== b[i]) {
|
|
1702
|
-
return commonPrefix;
|
|
1703
|
-
}
|
|
1704
|
-
commonPrefix += a[i];
|
|
1705
|
-
}
|
|
1706
|
-
return commonPrefix;
|
|
1707
|
-
}
|
|
1708
|
-
function create3(end = false, subWord = "", key = "") {
|
|
1709
|
-
return new Node(key, subWord, end);
|
|
1710
|
-
}
|
|
1711
|
-
function insert2(root, word, docId) {
|
|
1712
|
-
for (let i = 0; i < word.length; i++) {
|
|
1713
|
-
const currentCharacter = word[i];
|
|
1714
|
-
const wordAtIndex = word.substring(i);
|
|
1715
|
-
const rootChildCurrentChar = root.children[currentCharacter];
|
|
1716
|
-
if (rootChildCurrentChar) {
|
|
1717
|
-
const edgeLabel = rootChildCurrentChar.subWord;
|
|
1718
|
-
const edgeLabelLength = edgeLabel.length;
|
|
1719
|
-
const commonPrefix = getCommonPrefix(edgeLabel, wordAtIndex);
|
|
1720
|
-
const commonPrefixLength = commonPrefix.length;
|
|
1721
|
-
if (edgeLabel === wordAtIndex) {
|
|
1722
|
-
addDocument(rootChildCurrentChar, docId);
|
|
1723
|
-
rootChildCurrentChar.end = true;
|
|
1724
|
-
return;
|
|
1725
|
-
}
|
|
1726
|
-
const edgeLabelAtCommonPrefix = edgeLabel[commonPrefixLength];
|
|
1727
|
-
if (commonPrefixLength < edgeLabelLength && commonPrefixLength === wordAtIndex.length) {
|
|
1728
|
-
const newNode = create3(true, wordAtIndex, currentCharacter);
|
|
1729
|
-
newNode.children[edgeLabelAtCommonPrefix] = rootChildCurrentChar;
|
|
1730
|
-
const newNodeChild = newNode.children[edgeLabelAtCommonPrefix];
|
|
1731
|
-
newNodeChild.subWord = edgeLabel.substring(commonPrefixLength);
|
|
1732
|
-
newNodeChild.key = edgeLabelAtCommonPrefix;
|
|
1733
|
-
root.children[currentCharacter] = newNode;
|
|
1734
|
-
updateParent(newNode, root);
|
|
1735
|
-
updateParent(newNodeChild, newNode);
|
|
1736
|
-
addDocument(newNode, docId);
|
|
1737
|
-
return;
|
|
1738
|
-
}
|
|
1739
|
-
if (commonPrefixLength < edgeLabelLength && commonPrefixLength < wordAtIndex.length) {
|
|
1740
|
-
const inbetweenNode = create3(false, commonPrefix, currentCharacter);
|
|
1741
|
-
inbetweenNode.children[edgeLabelAtCommonPrefix] = rootChildCurrentChar;
|
|
1742
|
-
root.children[currentCharacter] = inbetweenNode;
|
|
1743
|
-
const inbetweenNodeChild = inbetweenNode.children[edgeLabelAtCommonPrefix];
|
|
1744
|
-
inbetweenNodeChild.subWord = edgeLabel.substring(commonPrefixLength);
|
|
1745
|
-
inbetweenNodeChild.key = edgeLabelAtCommonPrefix;
|
|
1746
|
-
const wordAtCommonPrefix = wordAtIndex[commonPrefixLength];
|
|
1747
|
-
const newNode = create3(true, word.substring(i + commonPrefixLength), wordAtCommonPrefix);
|
|
1748
|
-
addDocument(newNode, docId);
|
|
1749
|
-
inbetweenNode.children[wordAtCommonPrefix] = newNode;
|
|
1750
|
-
updateParent(inbetweenNode, root);
|
|
1751
|
-
updateParent(newNode, inbetweenNode);
|
|
1752
|
-
updateParent(inbetweenNodeChild, inbetweenNode);
|
|
1753
|
-
return;
|
|
1754
|
-
}
|
|
1755
|
-
i += edgeLabelLength - 1;
|
|
1756
|
-
root = rootChildCurrentChar;
|
|
1757
|
-
} else {
|
|
1758
|
-
const newNode = create3(true, wordAtIndex, currentCharacter);
|
|
1759
|
-
addDocument(newNode, docId);
|
|
1760
|
-
root.children[currentCharacter] = newNode;
|
|
1761
|
-
updateParent(newNode, root);
|
|
1762
|
-
return;
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
function find2(root, { term, exact, tolerance }) {
|
|
1767
|
-
for (let i = 0; i < term.length; i++) {
|
|
1768
|
-
const character = term[i];
|
|
1769
|
-
if (character in root.children) {
|
|
1770
|
-
const rootChildCurrentChar = root.children[character];
|
|
1771
|
-
const edgeLabel = rootChildCurrentChar.subWord;
|
|
1772
|
-
const termSubstring = term.substring(i);
|
|
1773
|
-
const commonPrefix = getCommonPrefix(edgeLabel, termSubstring);
|
|
1774
|
-
const commonPrefixLength = commonPrefix.length;
|
|
1775
|
-
if (commonPrefixLength !== edgeLabel.length && commonPrefixLength !== termSubstring.length) {
|
|
1776
|
-
if (tolerance)
|
|
1777
|
-
break;
|
|
1778
|
-
return {};
|
|
1779
|
-
}
|
|
1780
|
-
i += rootChildCurrentChar.subWord.length - 1;
|
|
1781
|
-
root = rootChildCurrentChar;
|
|
1782
|
-
} else {
|
|
1783
|
-
return {};
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
const output = {};
|
|
1787
|
-
findAllWords(root, output, term, exact, tolerance);
|
|
1788
|
-
return output;
|
|
1789
|
-
}
|
|
1790
|
-
function removeDocumentByWord(root, term, docID, exact = true) {
|
|
1791
|
-
if (!term) {
|
|
1792
|
-
return true;
|
|
1793
|
-
}
|
|
1794
|
-
for (let i = 0; i < term.length; i++) {
|
|
1795
|
-
const character = term[i];
|
|
1796
|
-
if (character in root.children) {
|
|
1797
|
-
const rootChildCurrentChar = root.children[character];
|
|
1798
|
-
i += rootChildCurrentChar.subWord.length - 1;
|
|
1799
|
-
root = rootChildCurrentChar;
|
|
1800
|
-
if (exact && root.word !== term) {
|
|
1801
|
-
} else {
|
|
1802
|
-
removeDocument2(root, docID);
|
|
1803
|
-
}
|
|
1804
|
-
} else {
|
|
1805
|
-
return false;
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
return true;
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/trees/flat.js
|
|
1812
|
-
function create4() {
|
|
1813
|
-
return {
|
|
1814
|
-
numberToDocumentId: /* @__PURE__ */ new Map()
|
|
1815
|
-
};
|
|
1816
|
-
}
|
|
1817
|
-
function insert3(root, key, value) {
|
|
1818
|
-
if (root.numberToDocumentId.has(key)) {
|
|
1819
|
-
root.numberToDocumentId.get(key).push(value);
|
|
1820
|
-
return root;
|
|
1821
|
-
}
|
|
1822
|
-
root.numberToDocumentId.set(key, [
|
|
1823
|
-
value
|
|
1824
|
-
]);
|
|
1825
|
-
return root;
|
|
1826
|
-
}
|
|
1827
|
-
function removeDocument3(root, id, key) {
|
|
1828
|
-
var _a2;
|
|
1829
|
-
var _root_numberToDocumentId_get, _root_numberToDocumentId_get1;
|
|
1830
|
-
root === null || root === void 0 ? void 0 : root.numberToDocumentId.set(key, (_a2 = (_root_numberToDocumentId_get = root === null || root === void 0 ? void 0 : root.numberToDocumentId.get(key)) === null || _root_numberToDocumentId_get === void 0 ? void 0 : _root_numberToDocumentId_get.filter((v2) => v2 !== id)) != null ? _a2 : []);
|
|
1831
|
-
if (((_root_numberToDocumentId_get1 = root === null || root === void 0 ? void 0 : root.numberToDocumentId.get(key)) === null || _root_numberToDocumentId_get1 === void 0 ? void 0 : _root_numberToDocumentId_get1.length) === 0) {
|
|
1832
|
-
root === null || root === void 0 ? void 0 : root.numberToDocumentId.delete(key);
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
function filter(root, operation) {
|
|
1836
|
-
var _a2;
|
|
1837
|
-
const operationKeys = Object.keys(operation);
|
|
1838
|
-
if (operationKeys.length !== 1) {
|
|
1839
|
-
throw new Error("Invalid operation");
|
|
1840
|
-
}
|
|
1841
|
-
const operationType = operationKeys[0];
|
|
1842
|
-
switch (operationType) {
|
|
1843
|
-
case "eq": {
|
|
1844
|
-
const value = operation[operationType];
|
|
1845
|
-
return (_a2 = root.numberToDocumentId.get(value)) != null ? _a2 : [];
|
|
1846
|
-
}
|
|
1847
|
-
case "in": {
|
|
1848
|
-
const value = operation[operationType];
|
|
1849
|
-
const result = [];
|
|
1850
|
-
for (const v2 of value) {
|
|
1851
|
-
const ids = root.numberToDocumentId.get(v2);
|
|
1852
|
-
if (ids) {
|
|
1853
|
-
result.push(...ids);
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
return result;
|
|
1857
|
-
}
|
|
1858
|
-
case "nin": {
|
|
1859
|
-
const value = operation[operationType];
|
|
1860
|
-
const result = [];
|
|
1861
|
-
const keys = root.numberToDocumentId.keys();
|
|
1862
|
-
for (const key of keys) {
|
|
1863
|
-
if (value.includes(key)) {
|
|
1864
|
-
continue;
|
|
1865
|
-
}
|
|
1866
|
-
const ids = root.numberToDocumentId.get(key);
|
|
1867
|
-
if (ids) {
|
|
1868
|
-
result.push(...ids);
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
return result;
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
throw new Error("Invalid operation");
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/algorithms.js
|
|
1878
|
-
function prioritizeTokenScores(arrays, boost, threshold = 1, keywordsCount) {
|
|
1879
|
-
if (boost === 0) {
|
|
1880
|
-
throw createError("INVALID_BOOST_VALUE");
|
|
1881
|
-
}
|
|
1882
|
-
const tokenScoresMap = /* @__PURE__ */ new Map();
|
|
1883
|
-
const tokenKeywordsCountMap = /* @__PURE__ */ new Map();
|
|
1884
|
-
const mapsLength = arrays.length;
|
|
1885
|
-
for (let i = 0; i < mapsLength; i++) {
|
|
1886
|
-
const arr = arrays[i];
|
|
1887
|
-
const entriesLength = arr.length;
|
|
1888
|
-
for (let j = 0; j < entriesLength; j++) {
|
|
1889
|
-
const [token, score] = arr[j];
|
|
1890
|
-
const boostScore = score * boost;
|
|
1891
|
-
const oldScore = tokenScoresMap.get(token);
|
|
1892
|
-
if (oldScore !== void 0) {
|
|
1893
|
-
tokenScoresMap.set(token, oldScore * 1.5 + boostScore);
|
|
1894
|
-
tokenKeywordsCountMap.set(token, tokenKeywordsCountMap.get(token) + 1);
|
|
1895
|
-
} else {
|
|
1896
|
-
tokenScoresMap.set(token, boostScore);
|
|
1897
|
-
tokenKeywordsCountMap.set(token, 1);
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
const tokenScores = [];
|
|
1902
|
-
for (const tokenScoreEntry of tokenScoresMap.entries()) {
|
|
1903
|
-
tokenScores.push(tokenScoreEntry);
|
|
1904
|
-
}
|
|
1905
|
-
const results = tokenScores.sort((a, b) => b[1] - a[1]);
|
|
1906
|
-
if (threshold === 1) {
|
|
1907
|
-
return results;
|
|
1908
|
-
}
|
|
1909
|
-
const allResults = results.length;
|
|
1910
|
-
const tokenKeywordsCount = [];
|
|
1911
|
-
for (const tokenKeywordsCountEntry of tokenKeywordsCountMap.entries()) {
|
|
1912
|
-
tokenKeywordsCount.push(tokenKeywordsCountEntry);
|
|
1913
|
-
}
|
|
1914
|
-
const keywordsPerToken = tokenKeywordsCount.sort((a, b) => b[1] - a[1]);
|
|
1915
|
-
let lastTokenWithAllKeywords = void 0;
|
|
1916
|
-
for (let i = 0; i < allResults; i++) {
|
|
1917
|
-
if (keywordsPerToken[i][1] === keywordsCount) {
|
|
1918
|
-
lastTokenWithAllKeywords = i;
|
|
1919
|
-
} else {
|
|
1920
|
-
break;
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
if (typeof lastTokenWithAllKeywords === "undefined") {
|
|
1924
|
-
if (threshold === 0) {
|
|
1925
|
-
return [];
|
|
1926
|
-
}
|
|
1927
|
-
lastTokenWithAllKeywords = 0;
|
|
1928
|
-
}
|
|
1929
|
-
if (threshold === 0) {
|
|
1930
|
-
return results.slice(0, lastTokenWithAllKeywords + 1);
|
|
1931
|
-
}
|
|
1932
|
-
const thresholdLength = lastTokenWithAllKeywords + Math.ceil(threshold * 100 * (results.length - lastTokenWithAllKeywords) / 100);
|
|
1933
|
-
return results.slice(0, results.length + thresholdLength);
|
|
1934
|
-
}
|
|
1935
|
-
function BM25(tf, matchingCount, docsCount, fieldLength, averageFieldLength, BM25Params) {
|
|
1936
|
-
const { k, b, d } = BM25Params;
|
|
1937
|
-
const idf = Math.log(1 + (docsCount - matchingCount + 0.5) / (matchingCount + 0.5));
|
|
1938
|
-
return idf * (d + tf * (k + 1)) / (tf + k * (1 - b + b * fieldLength / averageFieldLength));
|
|
1939
|
-
}
|
|
1940
|
-
|
|
1941
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/cosine-similarity.js
|
|
1942
|
-
function getMagnitude(vector, vectorLength) {
|
|
1943
|
-
let magnitude = 0;
|
|
1944
|
-
for (let i = 0; i < vectorLength; i++) {
|
|
1945
|
-
magnitude += vector[i] * vector[i];
|
|
1946
|
-
}
|
|
1947
|
-
return Math.sqrt(magnitude);
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/index.js
|
|
1951
|
-
async function insertDocumentScoreParameters(index, prop, id, tokens, docsCount) {
|
|
1952
|
-
var _a2;
|
|
1953
|
-
const internalId = getInternalDocumentId(index.sharedInternalDocumentStore, id);
|
|
1954
|
-
index.avgFieldLength[prop] = (((_a2 = index.avgFieldLength[prop]) != null ? _a2 : 0) * (docsCount - 1) + tokens.length) / docsCount;
|
|
1955
|
-
index.fieldLengths[prop][internalId] = tokens.length;
|
|
1956
|
-
index.frequencies[prop][internalId] = {};
|
|
1957
|
-
}
|
|
1958
|
-
async function insertTokenScoreParameters(index, prop, id, tokens, token) {
|
|
1959
|
-
var _a2;
|
|
1960
|
-
let tokenFrequency = 0;
|
|
1961
|
-
for (const t of tokens) {
|
|
1962
|
-
if (t === token) {
|
|
1963
|
-
tokenFrequency++;
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
const internalId = getInternalDocumentId(index.sharedInternalDocumentStore, id);
|
|
1967
|
-
const tf = tokenFrequency / tokens.length;
|
|
1968
|
-
index.frequencies[prop][internalId][token] = tf;
|
|
1969
|
-
if (!(token in index.tokenOccurrences[prop])) {
|
|
1970
|
-
index.tokenOccurrences[prop][token] = 0;
|
|
1971
|
-
}
|
|
1972
|
-
index.tokenOccurrences[prop][token] = ((_a2 = index.tokenOccurrences[prop][token]) != null ? _a2 : 0) + 1;
|
|
1973
|
-
}
|
|
1974
|
-
async function removeDocumentScoreParameters(index, prop, id, docsCount) {
|
|
1975
|
-
const internalId = getInternalDocumentId(index.sharedInternalDocumentStore, id);
|
|
1976
|
-
index.avgFieldLength[prop] = (index.avgFieldLength[prop] * docsCount - index.fieldLengths[prop][internalId]) / (docsCount - 1);
|
|
1977
|
-
index.fieldLengths[prop][internalId] = void 0;
|
|
1978
|
-
index.frequencies[prop][internalId] = void 0;
|
|
1979
|
-
}
|
|
1980
|
-
async function removeTokenScoreParameters(index, prop, token) {
|
|
1981
|
-
index.tokenOccurrences[prop][token]--;
|
|
1982
|
-
}
|
|
1983
|
-
async function calculateResultScores(context, index, prop, term, ids) {
|
|
1984
|
-
var _a2, _b;
|
|
1985
|
-
const documentIDs = Array.from(ids);
|
|
1986
|
-
const avgFieldLength = index.avgFieldLength[prop];
|
|
1987
|
-
const fieldLengths = index.fieldLengths[prop];
|
|
1988
|
-
const oramaOccurrences = index.tokenOccurrences[prop];
|
|
1989
|
-
const oramaFrequencies = index.frequencies[prop];
|
|
1990
|
-
const termOccurrences = typeof oramaOccurrences[term] === "number" ? (_a2 = oramaOccurrences[term]) != null ? _a2 : 0 : 0;
|
|
1991
|
-
const scoreList = [];
|
|
1992
|
-
const documentIDsLength = documentIDs.length;
|
|
1993
|
-
for (let k = 0; k < documentIDsLength; k++) {
|
|
1994
|
-
var _oramaFrequencies_internalId;
|
|
1995
|
-
const internalId = getInternalDocumentId(index.sharedInternalDocumentStore, documentIDs[k]);
|
|
1996
|
-
const tf = (_b = oramaFrequencies === null || oramaFrequencies === void 0 ? void 0 : (_oramaFrequencies_internalId = oramaFrequencies[internalId]) === null || _oramaFrequencies_internalId === void 0 ? void 0 : _oramaFrequencies_internalId[term]) != null ? _b : 0;
|
|
1997
|
-
const bm25 = BM25(tf, termOccurrences, context.docsCount, fieldLengths[internalId], avgFieldLength, context.params.relevance);
|
|
1998
|
-
scoreList.push([
|
|
1999
|
-
internalId,
|
|
2000
|
-
bm25
|
|
2001
|
-
]);
|
|
2002
|
-
}
|
|
2003
|
-
return scoreList;
|
|
2004
|
-
}
|
|
2005
|
-
async function create5(orama, sharedInternalDocumentStore, schema, index, prefix = "") {
|
|
2006
|
-
if (!index) {
|
|
2007
|
-
index = {
|
|
2008
|
-
sharedInternalDocumentStore,
|
|
2009
|
-
indexes: {},
|
|
2010
|
-
vectorIndexes: {},
|
|
2011
|
-
searchableProperties: [],
|
|
2012
|
-
searchablePropertiesWithTypes: {},
|
|
2013
|
-
frequencies: {},
|
|
2014
|
-
tokenOccurrences: {},
|
|
2015
|
-
avgFieldLength: {},
|
|
2016
|
-
fieldLengths: {}
|
|
2017
|
-
};
|
|
2018
|
-
}
|
|
2019
|
-
for (const [prop, type] of Object.entries(schema)) {
|
|
2020
|
-
const typeActualType = typeof type;
|
|
2021
|
-
const path = `${prefix}${prefix ? "." : ""}${prop}`;
|
|
2022
|
-
if (typeActualType === "object" && !Array.isArray(type)) {
|
|
2023
|
-
create5(orama, sharedInternalDocumentStore, type, index, path);
|
|
2024
|
-
continue;
|
|
2025
|
-
}
|
|
2026
|
-
if (isVectorType(type)) {
|
|
2027
|
-
index.searchableProperties.push(path);
|
|
2028
|
-
index.searchablePropertiesWithTypes[path] = type;
|
|
2029
|
-
index.vectorIndexes[path] = {
|
|
2030
|
-
size: getVectorSize(type),
|
|
2031
|
-
vectors: {}
|
|
2032
|
-
};
|
|
2033
|
-
} else {
|
|
2034
|
-
switch (type) {
|
|
2035
|
-
case "boolean":
|
|
2036
|
-
case "boolean[]":
|
|
2037
|
-
index.indexes[path] = {
|
|
2038
|
-
type: "Bool",
|
|
2039
|
-
node: {
|
|
2040
|
-
true: [],
|
|
2041
|
-
false: []
|
|
2042
|
-
}
|
|
2043
|
-
};
|
|
2044
|
-
break;
|
|
2045
|
-
case "number":
|
|
2046
|
-
case "number[]":
|
|
2047
|
-
index.indexes[path] = {
|
|
2048
|
-
type: "AVL",
|
|
2049
|
-
node: create2(0, [])
|
|
2050
|
-
};
|
|
2051
|
-
break;
|
|
2052
|
-
case "string":
|
|
2053
|
-
case "string[]":
|
|
2054
|
-
index.indexes[path] = {
|
|
2055
|
-
type: "Radix",
|
|
2056
|
-
node: create3()
|
|
2057
|
-
};
|
|
2058
|
-
index.avgFieldLength[path] = 0;
|
|
2059
|
-
index.frequencies[path] = {};
|
|
2060
|
-
index.tokenOccurrences[path] = {};
|
|
2061
|
-
index.fieldLengths[path] = {};
|
|
2062
|
-
break;
|
|
2063
|
-
case "enum":
|
|
2064
|
-
index.indexes[path] = {
|
|
2065
|
-
type: "Flat",
|
|
2066
|
-
node: create4()
|
|
2067
|
-
};
|
|
2068
|
-
break;
|
|
2069
|
-
default:
|
|
2070
|
-
throw createError("INVALID_SCHEMA_TYPE", Array.isArray(type) ? "array" : type, path);
|
|
2071
|
-
}
|
|
2072
|
-
index.searchableProperties.push(path);
|
|
2073
|
-
index.searchablePropertiesWithTypes[path] = type;
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
return index;
|
|
2077
|
-
}
|
|
2078
|
-
async function insertScalar(implementation, index, prop, id, value, schemaType, language, tokenizer, docsCount) {
|
|
2079
|
-
const internalId = getInternalDocumentId(index.sharedInternalDocumentStore, id);
|
|
2080
|
-
const { type, node } = index.indexes[prop];
|
|
2081
|
-
switch (type) {
|
|
2082
|
-
case "Bool": {
|
|
2083
|
-
node[value ? "true" : "false"].push(internalId);
|
|
2084
|
-
break;
|
|
2085
|
-
}
|
|
2086
|
-
case "AVL":
|
|
2087
|
-
insert(node, value, [
|
|
2088
|
-
internalId
|
|
2089
|
-
]);
|
|
2090
|
-
break;
|
|
2091
|
-
case "Radix": {
|
|
2092
|
-
const tokens = await tokenizer.tokenize(value, language, prop);
|
|
2093
|
-
await implementation.insertDocumentScoreParameters(index, prop, internalId, tokens, docsCount);
|
|
2094
|
-
for (const token of tokens) {
|
|
2095
|
-
await implementation.insertTokenScoreParameters(index, prop, internalId, tokens, token);
|
|
2096
|
-
insert2(node, token, internalId);
|
|
2097
|
-
}
|
|
2098
|
-
break;
|
|
2099
|
-
}
|
|
2100
|
-
case "Flat": {
|
|
2101
|
-
insert3(node, value, internalId);
|
|
2102
|
-
break;
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
async function insert4(implementation, index, prop, id, value, schemaType, language, tokenizer, docsCount) {
|
|
2107
|
-
if (isVectorType(schemaType)) {
|
|
2108
|
-
return insertVector(index, prop, value, id);
|
|
2109
|
-
}
|
|
2110
|
-
if (!isArrayType(schemaType)) {
|
|
2111
|
-
return insertScalar(implementation, index, prop, id, value, schemaType, language, tokenizer, docsCount);
|
|
2112
|
-
}
|
|
2113
|
-
const innerSchemaType = getInnerType(schemaType);
|
|
2114
|
-
const elements = value;
|
|
2115
|
-
const elementsLength = elements.length;
|
|
2116
|
-
for (let i = 0; i < elementsLength; i++) {
|
|
2117
|
-
await insertScalar(implementation, index, prop, id, elements[i], innerSchemaType, language, tokenizer, docsCount);
|
|
2118
|
-
}
|
|
2119
|
-
}
|
|
2120
|
-
function insertVector(index, prop, value, id) {
|
|
2121
|
-
if (!(value instanceof Float32Array)) {
|
|
2122
|
-
value = new Float32Array(value);
|
|
2123
|
-
}
|
|
2124
|
-
const size = index.vectorIndexes[prop].size;
|
|
2125
|
-
const magnitude = getMagnitude(value, size);
|
|
2126
|
-
index.vectorIndexes[prop].vectors[id] = [
|
|
2127
|
-
magnitude,
|
|
2128
|
-
value
|
|
2129
|
-
];
|
|
2130
|
-
}
|
|
2131
|
-
async function removeScalar(implementation, index, prop, id, value, schemaType, language, tokenizer, docsCount) {
|
|
2132
|
-
const internalId = getInternalDocumentId(index.sharedInternalDocumentStore, id);
|
|
2133
|
-
const { type, node } = index.indexes[prop];
|
|
2134
|
-
switch (type) {
|
|
2135
|
-
case "AVL": {
|
|
2136
|
-
removeDocument(node, internalId, value);
|
|
2137
|
-
return true;
|
|
2138
|
-
}
|
|
2139
|
-
case "Bool": {
|
|
2140
|
-
const booleanKey = value ? "true" : "false";
|
|
2141
|
-
const position = node[booleanKey].indexOf(internalId);
|
|
2142
|
-
node[value ? "true" : "false"].splice(position, 1);
|
|
2143
|
-
return true;
|
|
2144
|
-
}
|
|
2145
|
-
case "Radix": {
|
|
2146
|
-
const tokens = await tokenizer.tokenize(value, language, prop);
|
|
2147
|
-
await implementation.removeDocumentScoreParameters(index, prop, id, docsCount);
|
|
2148
|
-
for (const token of tokens) {
|
|
2149
|
-
await implementation.removeTokenScoreParameters(index, prop, token);
|
|
2150
|
-
removeDocumentByWord(node, token, internalId);
|
|
2151
|
-
}
|
|
2152
|
-
return true;
|
|
2153
|
-
}
|
|
2154
|
-
case "Flat": {
|
|
2155
|
-
removeDocument3(node, internalId, value);
|
|
2156
|
-
return true;
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
async function remove3(implementation, index, prop, id, value, schemaType, language, tokenizer, docsCount) {
|
|
2161
|
-
if (!isArrayType(schemaType)) {
|
|
2162
|
-
return removeScalar(implementation, index, prop, id, value, schemaType, language, tokenizer, docsCount);
|
|
2163
|
-
}
|
|
2164
|
-
const innerSchemaType = getInnerType(schemaType);
|
|
2165
|
-
const elements = value;
|
|
2166
|
-
const elementsLength = elements.length;
|
|
2167
|
-
for (let i = 0; i < elementsLength; i++) {
|
|
2168
|
-
await removeScalar(implementation, index, prop, id, elements[i], innerSchemaType, language, tokenizer, docsCount);
|
|
2169
|
-
}
|
|
2170
|
-
return true;
|
|
2171
|
-
}
|
|
2172
|
-
async function search(context, index, prop, term) {
|
|
2173
|
-
if (!(prop in index.tokenOccurrences)) {
|
|
2174
|
-
return [];
|
|
2175
|
-
}
|
|
2176
|
-
const { node, type } = index.indexes[prop];
|
|
2177
|
-
if (type !== "Radix") {
|
|
2178
|
-
throw createError("WRONG_SEARCH_PROPERTY_TYPE", prop);
|
|
2179
|
-
}
|
|
2180
|
-
const { exact, tolerance } = context.params;
|
|
2181
|
-
const searchResult = find2(node, {
|
|
2182
|
-
term,
|
|
2183
|
-
exact,
|
|
2184
|
-
tolerance
|
|
2185
|
-
});
|
|
2186
|
-
const ids = /* @__PURE__ */ new Set();
|
|
2187
|
-
for (const key in searchResult) {
|
|
2188
|
-
for (const id of searchResult[key]) {
|
|
2189
|
-
ids.add(id);
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2192
|
-
return context.index.calculateResultScores(context, index, prop, term, Array.from(ids));
|
|
2193
|
-
}
|
|
2194
|
-
async function searchByWhereClause(context, index, filters) {
|
|
2195
|
-
var _a2;
|
|
2196
|
-
const filterKeys = Object.keys(filters);
|
|
2197
|
-
const filtersMap = filterKeys.reduce((acc, key) => __spreadValues({
|
|
2198
|
-
[key]: []
|
|
2199
|
-
}, acc), {});
|
|
2200
|
-
for (const param of filterKeys) {
|
|
2201
|
-
const operation = filters[param];
|
|
2202
|
-
if (typeof index.indexes[param] === "undefined") {
|
|
2203
|
-
throw createError("UNKNOWN_FILTER_PROPERTY", param);
|
|
2204
|
-
}
|
|
2205
|
-
const { node, type } = index.indexes[param];
|
|
2206
|
-
if (type === "Bool") {
|
|
2207
|
-
const idx = node;
|
|
2208
|
-
const filteredIDs = idx[operation.toString()];
|
|
2209
|
-
safeArrayPush(filtersMap[param], filteredIDs);
|
|
2210
|
-
continue;
|
|
2211
|
-
}
|
|
2212
|
-
if (type === "Radix" && (typeof operation === "string" || Array.isArray(operation))) {
|
|
2213
|
-
for (const raw of [
|
|
2214
|
-
operation
|
|
2215
|
-
].flat()) {
|
|
2216
|
-
const term = await context.tokenizer.tokenize(raw, context.language, param);
|
|
2217
|
-
for (const t of term) {
|
|
2218
|
-
const filteredIDsResults = find2(node, {
|
|
2219
|
-
term: t,
|
|
2220
|
-
exact: true
|
|
2221
|
-
});
|
|
2222
|
-
safeArrayPush(filtersMap[param], Object.values(filteredIDsResults).flat());
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
continue;
|
|
2226
|
-
}
|
|
2227
|
-
const operationKeys = Object.keys(operation);
|
|
2228
|
-
if (operationKeys.length > 1) {
|
|
2229
|
-
throw createError("INVALID_FILTER_OPERATION", operationKeys.length);
|
|
2230
|
-
}
|
|
2231
|
-
if (type === "Flat") {
|
|
2232
|
-
filtersMap[param].push(...filter(node, operation));
|
|
2233
|
-
continue;
|
|
2234
|
-
}
|
|
2235
|
-
if (type === "AVL") {
|
|
2236
|
-
const operationOpt = operationKeys[0];
|
|
2237
|
-
const operationValue = operation[operationOpt];
|
|
2238
|
-
let filteredIDs = [];
|
|
2239
|
-
switch (operationOpt) {
|
|
2240
|
-
case "gt": {
|
|
2241
|
-
filteredIDs = greaterThan(node, operationValue, false);
|
|
2242
|
-
break;
|
|
2243
|
-
}
|
|
2244
|
-
case "gte": {
|
|
2245
|
-
filteredIDs = greaterThan(node, operationValue, true);
|
|
2246
|
-
break;
|
|
2247
|
-
}
|
|
2248
|
-
case "lt": {
|
|
2249
|
-
filteredIDs = lessThan(node, operationValue, false);
|
|
2250
|
-
break;
|
|
2251
|
-
}
|
|
2252
|
-
case "lte": {
|
|
2253
|
-
filteredIDs = lessThan(node, operationValue, true);
|
|
2254
|
-
break;
|
|
2255
|
-
}
|
|
2256
|
-
case "eq": {
|
|
2257
|
-
filteredIDs = (_a2 = find(node, operationValue)) != null ? _a2 : [];
|
|
2258
|
-
break;
|
|
2259
|
-
}
|
|
2260
|
-
case "between": {
|
|
2261
|
-
const [min, max] = operationValue;
|
|
2262
|
-
filteredIDs = rangeSearch(node, min, max);
|
|
2263
|
-
break;
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
safeArrayPush(filtersMap[param], filteredIDs);
|
|
2267
|
-
}
|
|
2268
|
-
}
|
|
2269
|
-
const result = intersect(Object.values(filtersMap));
|
|
2270
|
-
return result;
|
|
2271
|
-
}
|
|
2272
|
-
async function getSearchableProperties(index) {
|
|
2273
|
-
return index.searchableProperties;
|
|
2274
|
-
}
|
|
2275
|
-
async function getSearchablePropertiesWithTypes(index) {
|
|
2276
|
-
return index.searchablePropertiesWithTypes;
|
|
2277
|
-
}
|
|
2278
|
-
function loadRadixNode(node) {
|
|
2279
|
-
const convertedNode = create3(node.end, node.subWord, node.key);
|
|
2280
|
-
convertedNode.docs = node.docs;
|
|
2281
|
-
convertedNode.word = node.word;
|
|
2282
|
-
for (const childrenKey of Object.keys(node.children)) {
|
|
2283
|
-
convertedNode.children[childrenKey] = loadRadixNode(node.children[childrenKey]);
|
|
2284
|
-
}
|
|
2285
|
-
return convertedNode;
|
|
2286
|
-
}
|
|
2287
|
-
function loadFlatNode(node) {
|
|
2288
|
-
return {
|
|
2289
|
-
numberToDocumentId: new Map(node)
|
|
2290
|
-
};
|
|
2291
|
-
}
|
|
2292
|
-
function saveFlatNode(node) {
|
|
2293
|
-
return Array.from(node.numberToDocumentId.entries());
|
|
2294
|
-
}
|
|
2295
|
-
async function load3(sharedInternalDocumentStore, raw) {
|
|
2296
|
-
const { indexes: rawIndexes, vectorIndexes: rawVectorIndexes, searchableProperties, searchablePropertiesWithTypes, frequencies, tokenOccurrences, avgFieldLength, fieldLengths } = raw;
|
|
2297
|
-
const indexes = {};
|
|
2298
|
-
const vectorIndexes = {};
|
|
2299
|
-
for (const prop of Object.keys(rawIndexes)) {
|
|
2300
|
-
const { node, type } = rawIndexes[prop];
|
|
2301
|
-
switch (type) {
|
|
2302
|
-
case "Radix":
|
|
2303
|
-
indexes[prop] = {
|
|
2304
|
-
type: "Radix",
|
|
2305
|
-
node: loadRadixNode(node)
|
|
2306
|
-
};
|
|
2307
|
-
break;
|
|
2308
|
-
case "Flat":
|
|
2309
|
-
indexes[prop] = {
|
|
2310
|
-
type: "Flat",
|
|
2311
|
-
node: loadFlatNode(node)
|
|
2312
|
-
};
|
|
2313
|
-
break;
|
|
2314
|
-
default:
|
|
2315
|
-
indexes[prop] = rawIndexes[prop];
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
for (const idx of Object.keys(rawVectorIndexes)) {
|
|
2319
|
-
const vectors = rawVectorIndexes[idx].vectors;
|
|
2320
|
-
for (const vec in vectors) {
|
|
2321
|
-
vectors[vec] = [
|
|
2322
|
-
vectors[vec][0],
|
|
2323
|
-
new Float32Array(vectors[vec][1])
|
|
2324
|
-
];
|
|
2325
|
-
}
|
|
2326
|
-
vectorIndexes[idx] = {
|
|
2327
|
-
size: rawVectorIndexes[idx].size,
|
|
2328
|
-
vectors
|
|
2329
|
-
};
|
|
2330
|
-
}
|
|
2331
|
-
return {
|
|
2332
|
-
sharedInternalDocumentStore,
|
|
2333
|
-
indexes,
|
|
2334
|
-
vectorIndexes,
|
|
2335
|
-
searchableProperties,
|
|
2336
|
-
searchablePropertiesWithTypes,
|
|
2337
|
-
frequencies,
|
|
2338
|
-
tokenOccurrences,
|
|
2339
|
-
avgFieldLength,
|
|
2340
|
-
fieldLengths
|
|
2341
|
-
};
|
|
2342
|
-
}
|
|
2343
|
-
async function save3(index) {
|
|
2344
|
-
const { indexes, vectorIndexes, searchableProperties, searchablePropertiesWithTypes, frequencies, tokenOccurrences, avgFieldLength, fieldLengths } = index;
|
|
2345
|
-
const vectorIndexesAsArrays = {};
|
|
2346
|
-
for (const idx of Object.keys(vectorIndexes)) {
|
|
2347
|
-
const vectors = vectorIndexes[idx].vectors;
|
|
2348
|
-
for (const vec in vectors) {
|
|
2349
|
-
vectors[vec] = [
|
|
2350
|
-
vectors[vec][0],
|
|
2351
|
-
Array.from(vectors[vec][1])
|
|
2352
|
-
];
|
|
2353
|
-
}
|
|
2354
|
-
vectorIndexesAsArrays[idx] = {
|
|
2355
|
-
size: vectorIndexes[idx].size,
|
|
2356
|
-
vectors
|
|
2357
|
-
};
|
|
2358
|
-
}
|
|
2359
|
-
const savedIndexes = {};
|
|
2360
|
-
for (const name of Object.keys(indexes)) {
|
|
2361
|
-
const { type, node } = indexes[name];
|
|
2362
|
-
if (type !== "Flat") {
|
|
2363
|
-
savedIndexes[name] = indexes[name];
|
|
2364
|
-
continue;
|
|
2365
|
-
}
|
|
2366
|
-
savedIndexes[name] = {
|
|
2367
|
-
type: "Flat",
|
|
2368
|
-
node: saveFlatNode(node)
|
|
2369
|
-
};
|
|
2370
|
-
}
|
|
2371
|
-
return {
|
|
2372
|
-
indexes: savedIndexes,
|
|
2373
|
-
vectorIndexes: vectorIndexesAsArrays,
|
|
2374
|
-
searchableProperties,
|
|
2375
|
-
searchablePropertiesWithTypes,
|
|
2376
|
-
frequencies,
|
|
2377
|
-
tokenOccurrences,
|
|
2378
|
-
avgFieldLength,
|
|
2379
|
-
fieldLengths
|
|
2380
|
-
};
|
|
2381
|
-
}
|
|
2382
|
-
async function createIndex() {
|
|
2383
|
-
return {
|
|
2384
|
-
create: create5,
|
|
2385
|
-
insert: insert4,
|
|
2386
|
-
remove: remove3,
|
|
2387
|
-
insertDocumentScoreParameters,
|
|
2388
|
-
insertTokenScoreParameters,
|
|
2389
|
-
removeDocumentScoreParameters,
|
|
2390
|
-
removeTokenScoreParameters,
|
|
2391
|
-
calculateResultScores,
|
|
2392
|
-
search,
|
|
2393
|
-
searchByWhereClause,
|
|
2394
|
-
getSearchableProperties,
|
|
2395
|
-
getSearchablePropertiesWithTypes,
|
|
2396
|
-
load: load3,
|
|
2397
|
-
save: save3
|
|
2398
|
-
};
|
|
2399
|
-
}
|
|
2400
|
-
|
|
2401
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/tokenizer/diacritics.js
|
|
2402
|
-
var DIACRITICS_CHARCODE_START = 192;
|
|
2403
|
-
var DIACRITICS_CHARCODE_END = 383;
|
|
2404
|
-
var CHARCODE_REPLACE_MAPPING = [
|
|
2405
|
-
65,
|
|
2406
|
-
65,
|
|
2407
|
-
65,
|
|
2408
|
-
65,
|
|
2409
|
-
65,
|
|
2410
|
-
65,
|
|
2411
|
-
65,
|
|
2412
|
-
67,
|
|
2413
|
-
69,
|
|
2414
|
-
69,
|
|
2415
|
-
69,
|
|
2416
|
-
69,
|
|
2417
|
-
73,
|
|
2418
|
-
73,
|
|
2419
|
-
73,
|
|
2420
|
-
73,
|
|
2421
|
-
69,
|
|
2422
|
-
78,
|
|
2423
|
-
79,
|
|
2424
|
-
79,
|
|
2425
|
-
79,
|
|
2426
|
-
79,
|
|
2427
|
-
79,
|
|
2428
|
-
null,
|
|
2429
|
-
79,
|
|
2430
|
-
85,
|
|
2431
|
-
85,
|
|
2432
|
-
85,
|
|
2433
|
-
85,
|
|
2434
|
-
89,
|
|
2435
|
-
80,
|
|
2436
|
-
115,
|
|
2437
|
-
97,
|
|
2438
|
-
97,
|
|
2439
|
-
97,
|
|
2440
|
-
97,
|
|
2441
|
-
97,
|
|
2442
|
-
97,
|
|
2443
|
-
97,
|
|
2444
|
-
99,
|
|
2445
|
-
101,
|
|
2446
|
-
101,
|
|
2447
|
-
101,
|
|
2448
|
-
101,
|
|
2449
|
-
105,
|
|
2450
|
-
105,
|
|
2451
|
-
105,
|
|
2452
|
-
105,
|
|
2453
|
-
101,
|
|
2454
|
-
110,
|
|
2455
|
-
111,
|
|
2456
|
-
111,
|
|
2457
|
-
111,
|
|
2458
|
-
111,
|
|
2459
|
-
111,
|
|
2460
|
-
null,
|
|
2461
|
-
111,
|
|
2462
|
-
117,
|
|
2463
|
-
117,
|
|
2464
|
-
117,
|
|
2465
|
-
117,
|
|
2466
|
-
121,
|
|
2467
|
-
112,
|
|
2468
|
-
121,
|
|
2469
|
-
65,
|
|
2470
|
-
97,
|
|
2471
|
-
65,
|
|
2472
|
-
97,
|
|
2473
|
-
65,
|
|
2474
|
-
97,
|
|
2475
|
-
67,
|
|
2476
|
-
99,
|
|
2477
|
-
67,
|
|
2478
|
-
99,
|
|
2479
|
-
67,
|
|
2480
|
-
99,
|
|
2481
|
-
67,
|
|
2482
|
-
99,
|
|
2483
|
-
68,
|
|
2484
|
-
100,
|
|
2485
|
-
68,
|
|
2486
|
-
100,
|
|
2487
|
-
69,
|
|
2488
|
-
101,
|
|
2489
|
-
69,
|
|
2490
|
-
101,
|
|
2491
|
-
69,
|
|
2492
|
-
101,
|
|
2493
|
-
69,
|
|
2494
|
-
101,
|
|
2495
|
-
69,
|
|
2496
|
-
101,
|
|
2497
|
-
71,
|
|
2498
|
-
103,
|
|
2499
|
-
71,
|
|
2500
|
-
103,
|
|
2501
|
-
71,
|
|
2502
|
-
103,
|
|
2503
|
-
71,
|
|
2504
|
-
103,
|
|
2505
|
-
72,
|
|
2506
|
-
104,
|
|
2507
|
-
72,
|
|
2508
|
-
104,
|
|
2509
|
-
73,
|
|
2510
|
-
105,
|
|
2511
|
-
73,
|
|
2512
|
-
105,
|
|
2513
|
-
73,
|
|
2514
|
-
105,
|
|
2515
|
-
73,
|
|
2516
|
-
105,
|
|
2517
|
-
73,
|
|
2518
|
-
105,
|
|
2519
|
-
73,
|
|
2520
|
-
105,
|
|
2521
|
-
74,
|
|
2522
|
-
106,
|
|
2523
|
-
75,
|
|
2524
|
-
107,
|
|
2525
|
-
107,
|
|
2526
|
-
76,
|
|
2527
|
-
108,
|
|
2528
|
-
76,
|
|
2529
|
-
108,
|
|
2530
|
-
76,
|
|
2531
|
-
108,
|
|
2532
|
-
76,
|
|
2533
|
-
108,
|
|
2534
|
-
76,
|
|
2535
|
-
108,
|
|
2536
|
-
78,
|
|
2537
|
-
110,
|
|
2538
|
-
78,
|
|
2539
|
-
110,
|
|
2540
|
-
78,
|
|
2541
|
-
110,
|
|
2542
|
-
110,
|
|
2543
|
-
78,
|
|
2544
|
-
110,
|
|
2545
|
-
79,
|
|
2546
|
-
111,
|
|
2547
|
-
79,
|
|
2548
|
-
111,
|
|
2549
|
-
79,
|
|
2550
|
-
111,
|
|
2551
|
-
79,
|
|
2552
|
-
111,
|
|
2553
|
-
82,
|
|
2554
|
-
114,
|
|
2555
|
-
82,
|
|
2556
|
-
114,
|
|
2557
|
-
82,
|
|
2558
|
-
114,
|
|
2559
|
-
83,
|
|
2560
|
-
115,
|
|
2561
|
-
83,
|
|
2562
|
-
115,
|
|
2563
|
-
83,
|
|
2564
|
-
115,
|
|
2565
|
-
83,
|
|
2566
|
-
115,
|
|
2567
|
-
84,
|
|
2568
|
-
116,
|
|
2569
|
-
84,
|
|
2570
|
-
116,
|
|
2571
|
-
84,
|
|
2572
|
-
116,
|
|
2573
|
-
85,
|
|
2574
|
-
117,
|
|
2575
|
-
85,
|
|
2576
|
-
117,
|
|
2577
|
-
85,
|
|
2578
|
-
117,
|
|
2579
|
-
85,
|
|
2580
|
-
117,
|
|
2581
|
-
85,
|
|
2582
|
-
117,
|
|
2583
|
-
85,
|
|
2584
|
-
117,
|
|
2585
|
-
87,
|
|
2586
|
-
119,
|
|
2587
|
-
89,
|
|
2588
|
-
121,
|
|
2589
|
-
89,
|
|
2590
|
-
90,
|
|
2591
|
-
122,
|
|
2592
|
-
90,
|
|
2593
|
-
122,
|
|
2594
|
-
90,
|
|
2595
|
-
122,
|
|
2596
|
-
115
|
|
2597
|
-
];
|
|
2598
|
-
function replaceChar(charCode) {
|
|
2599
|
-
if (charCode < DIACRITICS_CHARCODE_START || charCode > DIACRITICS_CHARCODE_END)
|
|
2600
|
-
return charCode;
|
|
2601
|
-
return CHARCODE_REPLACE_MAPPING[charCode - DIACRITICS_CHARCODE_START] || charCode;
|
|
2602
|
-
}
|
|
2603
|
-
function replaceDiacritics(str) {
|
|
2604
|
-
const stringCharCode = [];
|
|
2605
|
-
for (let idx = 0; idx < str.length; idx++) {
|
|
2606
|
-
stringCharCode[idx] = replaceChar(str.charCodeAt(idx));
|
|
2607
|
-
}
|
|
2608
|
-
return String.fromCharCode(...stringCharCode);
|
|
2609
|
-
}
|
|
2610
|
-
|
|
2611
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/tokenizer/english-stemmer.js
|
|
2612
|
-
var step2List = {
|
|
2613
|
-
ational: "ate",
|
|
2614
|
-
tional: "tion",
|
|
2615
|
-
enci: "ence",
|
|
2616
|
-
anci: "ance",
|
|
2617
|
-
izer: "ize",
|
|
2618
|
-
bli: "ble",
|
|
2619
|
-
alli: "al",
|
|
2620
|
-
entli: "ent",
|
|
2621
|
-
eli: "e",
|
|
2622
|
-
ousli: "ous",
|
|
2623
|
-
ization: "ize",
|
|
2624
|
-
ation: "ate",
|
|
2625
|
-
ator: "ate",
|
|
2626
|
-
alism: "al",
|
|
2627
|
-
iveness: "ive",
|
|
2628
|
-
fulness: "ful",
|
|
2629
|
-
ousness: "ous",
|
|
2630
|
-
aliti: "al",
|
|
2631
|
-
iviti: "ive",
|
|
2632
|
-
biliti: "ble",
|
|
2633
|
-
logi: "log"
|
|
2634
|
-
};
|
|
2635
|
-
var step3List = {
|
|
2636
|
-
icate: "ic",
|
|
2637
|
-
ative: "",
|
|
2638
|
-
alize: "al",
|
|
2639
|
-
iciti: "ic",
|
|
2640
|
-
ical: "ic",
|
|
2641
|
-
ful: "",
|
|
2642
|
-
ness: ""
|
|
2643
|
-
};
|
|
2644
|
-
var c = "[^aeiou]";
|
|
2645
|
-
var v = "[aeiouy]";
|
|
2646
|
-
var C = c + "[^aeiouy]*";
|
|
2647
|
-
var V = v + "[aeiou]*";
|
|
2648
|
-
var mgr0 = "^(" + C + ")?" + V + C;
|
|
2649
|
-
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$";
|
|
2650
|
-
var mgr1 = "^(" + C + ")?" + V + C + V + C;
|
|
2651
|
-
var s_v = "^(" + C + ")?" + v;
|
|
2652
|
-
function stemmer(w) {
|
|
2653
|
-
var _a2, _b;
|
|
2654
|
-
let stem;
|
|
2655
|
-
let suffix;
|
|
2656
|
-
let re;
|
|
2657
|
-
let re2;
|
|
2658
|
-
let re3;
|
|
2659
|
-
let re4;
|
|
2660
|
-
if (w.length < 3) {
|
|
2661
|
-
return w;
|
|
2662
|
-
}
|
|
2663
|
-
const firstch = w.substring(0, 1);
|
|
2664
|
-
if (firstch == "y") {
|
|
2665
|
-
w = firstch.toUpperCase() + w.substring(1);
|
|
2666
|
-
}
|
|
2667
|
-
re = /^(.+?)(ss|i)es$/;
|
|
2668
|
-
re2 = /^(.+?)([^s])s$/;
|
|
2669
|
-
if (re.test(w)) {
|
|
2670
|
-
w = w.replace(re, "$1$2");
|
|
2671
|
-
} else if (re2.test(w)) {
|
|
2672
|
-
w = w.replace(re2, "$1$2");
|
|
2673
|
-
}
|
|
2674
|
-
re = /^(.+?)eed$/;
|
|
2675
|
-
re2 = /^(.+?)(ed|ing)$/;
|
|
2676
|
-
if (re.test(w)) {
|
|
2677
|
-
const fp = re.exec(w);
|
|
2678
|
-
re = new RegExp(mgr0);
|
|
2679
|
-
if (re.test(fp[1])) {
|
|
2680
|
-
re = /.$/;
|
|
2681
|
-
w = w.replace(re, "");
|
|
2682
|
-
}
|
|
2683
|
-
} else if (re2.test(w)) {
|
|
2684
|
-
const fp = re2.exec(w);
|
|
2685
|
-
stem = fp[1];
|
|
2686
|
-
re2 = new RegExp(s_v);
|
|
2687
|
-
if (re2.test(stem)) {
|
|
2688
|
-
w = stem;
|
|
2689
|
-
re2 = /(at|bl|iz)$/;
|
|
2690
|
-
re3 = new RegExp("([^aeiouylsz])\\1$");
|
|
2691
|
-
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
|
2692
|
-
if (re2.test(w)) {
|
|
2693
|
-
w = w + "e";
|
|
2694
|
-
} else if (re3.test(w)) {
|
|
2695
|
-
re = /.$/;
|
|
2696
|
-
w = w.replace(re, "");
|
|
2697
|
-
} else if (re4.test(w)) {
|
|
2698
|
-
w = w + "e";
|
|
2699
|
-
}
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
re = /^(.+?)y$/;
|
|
2703
|
-
if (re.test(w)) {
|
|
2704
|
-
const fp = re.exec(w);
|
|
2705
|
-
stem = fp === null || fp === void 0 ? void 0 : fp[1];
|
|
2706
|
-
re = new RegExp(s_v);
|
|
2707
|
-
if (stem && re.test(stem)) {
|
|
2708
|
-
w = stem + "i";
|
|
2709
|
-
}
|
|
2710
|
-
}
|
|
2711
|
-
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
|
|
2712
|
-
if (re.test(w)) {
|
|
2713
|
-
const fp = re.exec(w);
|
|
2714
|
-
stem = fp === null || fp === void 0 ? void 0 : fp[1];
|
|
2715
|
-
suffix = fp === null || fp === void 0 ? void 0 : fp[2];
|
|
2716
|
-
re = new RegExp(mgr0);
|
|
2717
|
-
if (stem && re.test(stem)) {
|
|
2718
|
-
w = stem + step2List[suffix];
|
|
2719
|
-
}
|
|
2720
|
-
}
|
|
2721
|
-
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
|
|
2722
|
-
if (re.test(w)) {
|
|
2723
|
-
const fp = re.exec(w);
|
|
2724
|
-
stem = fp === null || fp === void 0 ? void 0 : fp[1];
|
|
2725
|
-
suffix = fp === null || fp === void 0 ? void 0 : fp[2];
|
|
2726
|
-
re = new RegExp(mgr0);
|
|
2727
|
-
if (stem && re.test(stem)) {
|
|
2728
|
-
w = stem + step3List[suffix];
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
|
|
2732
|
-
re2 = /^(.+?)(s|t)(ion)$/;
|
|
2733
|
-
if (re.test(w)) {
|
|
2734
|
-
const fp = re.exec(w);
|
|
2735
|
-
stem = fp === null || fp === void 0 ? void 0 : fp[1];
|
|
2736
|
-
re = new RegExp(mgr1);
|
|
2737
|
-
if (stem && re.test(stem)) {
|
|
2738
|
-
w = stem;
|
|
2739
|
-
}
|
|
2740
|
-
} else if (re2.test(w)) {
|
|
2741
|
-
const fp = re2.exec(w);
|
|
2742
|
-
stem = (_b = (_a2 = fp === null || fp === void 0 ? void 0 : fp[1]) != null ? _a2 : "" + (fp === null || fp === void 0 ? void 0 : fp[2])) != null ? _b : "";
|
|
2743
|
-
re2 = new RegExp(mgr1);
|
|
2744
|
-
if (re2.test(stem)) {
|
|
2745
|
-
w = stem;
|
|
2746
|
-
}
|
|
2747
|
-
}
|
|
2748
|
-
re = /^(.+?)e$/;
|
|
2749
|
-
if (re.test(w)) {
|
|
2750
|
-
const fp = re.exec(w);
|
|
2751
|
-
stem = fp === null || fp === void 0 ? void 0 : fp[1];
|
|
2752
|
-
re = new RegExp(mgr1);
|
|
2753
|
-
re2 = new RegExp(meq1);
|
|
2754
|
-
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
|
2755
|
-
if (stem && (re.test(stem) || re2.test(stem) && !re3.test(stem))) {
|
|
2756
|
-
w = stem;
|
|
2757
|
-
}
|
|
2758
|
-
}
|
|
2759
|
-
re = /ll$/;
|
|
2760
|
-
re2 = new RegExp(mgr1);
|
|
2761
|
-
if (re.test(w) && re2.test(w)) {
|
|
2762
|
-
re = /.$/;
|
|
2763
|
-
w = w.replace(re, "");
|
|
2764
|
-
}
|
|
2765
|
-
if (firstch == "y") {
|
|
2766
|
-
w = firstch.toLowerCase() + w.substring(1);
|
|
2767
|
-
}
|
|
2768
|
-
return w;
|
|
2769
|
-
}
|
|
2770
|
-
|
|
2771
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/tokenizer/index.js
|
|
2772
|
-
function normalizeToken(prop, token) {
|
|
2773
|
-
var _this_stopWords;
|
|
2774
|
-
const key = `${this.language}:${prop}:${token}`;
|
|
2775
|
-
if (this.normalizationCache.has(key)) {
|
|
2776
|
-
return this.normalizationCache.get(key);
|
|
2777
|
-
}
|
|
2778
|
-
if ((_this_stopWords = this.stopWords) === null || _this_stopWords === void 0 ? void 0 : _this_stopWords.includes(token)) {
|
|
2779
|
-
this.normalizationCache.set(key, "");
|
|
2780
|
-
return "";
|
|
2781
|
-
}
|
|
2782
|
-
if (this.stemmer && !this.stemmerSkipProperties.has(prop)) {
|
|
2783
|
-
token = this.stemmer(token);
|
|
2784
|
-
}
|
|
2785
|
-
token = replaceDiacritics(token);
|
|
2786
|
-
this.normalizationCache.set(key, token);
|
|
2787
|
-
return token;
|
|
2788
|
-
}
|
|
2789
|
-
function trim(text) {
|
|
2790
|
-
while (text[text.length - 1] === "") {
|
|
2791
|
-
text.pop();
|
|
2792
|
-
}
|
|
2793
|
-
while (text[0] === "") {
|
|
2794
|
-
text.shift();
|
|
2795
|
-
}
|
|
2796
|
-
return text;
|
|
2797
|
-
}
|
|
2798
|
-
function tokenize(input, language, prop) {
|
|
2799
|
-
if (language && language !== this.language) {
|
|
2800
|
-
throw createError("LANGUAGE_NOT_SUPPORTED", language);
|
|
2801
|
-
}
|
|
2802
|
-
if (typeof input !== "string") {
|
|
2803
|
-
return [
|
|
2804
|
-
input
|
|
2805
|
-
];
|
|
2806
|
-
}
|
|
2807
|
-
let tokens;
|
|
2808
|
-
if (prop && this.tokenizeSkipProperties.has(prop)) {
|
|
2809
|
-
tokens = [
|
|
2810
|
-
this.normalizeToken.bind(this, prop != null ? prop : "")(input)
|
|
2811
|
-
];
|
|
2812
|
-
} else {
|
|
2813
|
-
const splitRule = SPLITTERS[this.language];
|
|
2814
|
-
tokens = input.toLowerCase().split(splitRule).map(this.normalizeToken.bind(this, prop != null ? prop : "")).filter(Boolean);
|
|
2815
|
-
}
|
|
2816
|
-
const trimTokens = trim(tokens);
|
|
2817
|
-
if (!this.allowDuplicates) {
|
|
2818
|
-
return Array.from(new Set(trimTokens));
|
|
2819
|
-
}
|
|
2820
|
-
return trimTokens;
|
|
2821
|
-
}
|
|
2822
|
-
async function createTokenizer(config = {}) {
|
|
2823
|
-
if (!config.language) {
|
|
2824
|
-
config.language = "english";
|
|
2825
|
-
} else if (!SUPPORTED_LANGUAGES.includes(config.language)) {
|
|
2826
|
-
throw createError("LANGUAGE_NOT_SUPPORTED", config.language);
|
|
2827
|
-
}
|
|
2828
|
-
let stemmer2;
|
|
2829
|
-
if (config.stemming || config.stemmer && !("stemming" in config)) {
|
|
2830
|
-
if (config.stemmer) {
|
|
2831
|
-
if (typeof config.stemmer !== "function") {
|
|
2832
|
-
throw createError("INVALID_STEMMER_FUNCTION_TYPE");
|
|
2833
|
-
}
|
|
2834
|
-
stemmer2 = config.stemmer;
|
|
2835
|
-
} else {
|
|
2836
|
-
if (config.language === "english") {
|
|
2837
|
-
stemmer2 = stemmer;
|
|
2838
|
-
} else {
|
|
2839
|
-
throw createError("MISSING_STEMMER", config.language);
|
|
2840
|
-
}
|
|
2841
|
-
}
|
|
2842
|
-
}
|
|
2843
|
-
let stopWords;
|
|
2844
|
-
if (config.stopWords !== false) {
|
|
2845
|
-
stopWords = [];
|
|
2846
|
-
if (Array.isArray(config.stopWords)) {
|
|
2847
|
-
stopWords = config.stopWords;
|
|
2848
|
-
} else if (typeof config.stopWords === "function") {
|
|
2849
|
-
stopWords = await config.stopWords(stopWords);
|
|
2850
|
-
} else if (config.stopWords) {
|
|
2851
|
-
throw createError("CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY");
|
|
2852
|
-
}
|
|
2853
|
-
if (!Array.isArray(stopWords)) {
|
|
2854
|
-
throw createError("CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY");
|
|
2855
|
-
}
|
|
2856
|
-
for (const s of stopWords) {
|
|
2857
|
-
if (typeof s !== "string") {
|
|
2858
|
-
throw createError("CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY");
|
|
2859
|
-
}
|
|
2860
|
-
}
|
|
2861
|
-
}
|
|
2862
|
-
const tokenizer = {
|
|
2863
|
-
tokenize,
|
|
2864
|
-
language: config.language,
|
|
2865
|
-
stemmer: stemmer2,
|
|
2866
|
-
stemmerSkipProperties: new Set(config.stemmerSkipProperties ? [
|
|
2867
|
-
config.stemmerSkipProperties
|
|
2868
|
-
].flat() : []),
|
|
2869
|
-
tokenizeSkipProperties: new Set(config.tokenizeSkipProperties ? [
|
|
2870
|
-
config.tokenizeSkipProperties
|
|
2871
|
-
].flat() : []),
|
|
2872
|
-
stopWords,
|
|
2873
|
-
allowDuplicates: Boolean(config.allowDuplicates),
|
|
2874
|
-
normalizeToken,
|
|
2875
|
-
normalizationCache: /* @__PURE__ */ new Map()
|
|
2876
|
-
};
|
|
2877
|
-
tokenizer.tokenize = tokenize.bind(tokenizer);
|
|
2878
|
-
tokenizer.normalizeToken = normalizeToken;
|
|
2879
|
-
return tokenizer;
|
|
2880
|
-
}
|
|
2881
|
-
|
|
2882
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/sorter.js
|
|
2883
|
-
function innerCreate(orama, sharedInternalDocumentStore, schema, sortableDeniedProperties, prefix) {
|
|
2884
|
-
const sorter = {
|
|
2885
|
-
language: orama.tokenizer.language,
|
|
2886
|
-
sharedInternalDocumentStore,
|
|
2887
|
-
enabled: true,
|
|
2888
|
-
isSorted: true,
|
|
2889
|
-
sortableProperties: [],
|
|
2890
|
-
sortablePropertiesWithTypes: {},
|
|
2891
|
-
sorts: {}
|
|
2892
|
-
};
|
|
2893
|
-
for (const [prop, type] of Object.entries(schema)) {
|
|
2894
|
-
const typeActualType = typeof type;
|
|
2895
|
-
const path = `${prefix}${prefix ? "." : ""}${prop}`;
|
|
2896
|
-
if (sortableDeniedProperties.includes(path)) {
|
|
2897
|
-
continue;
|
|
2898
|
-
}
|
|
2899
|
-
if (typeActualType === "object" && !Array.isArray(type)) {
|
|
2900
|
-
const ret = innerCreate(orama, sharedInternalDocumentStore, type, sortableDeniedProperties, path);
|
|
2901
|
-
sorter.sortableProperties.push(...ret.sortableProperties);
|
|
2902
|
-
sorter.sorts = __spreadValues(__spreadValues({}, sorter.sorts), ret.sorts);
|
|
2903
|
-
sorter.sortablePropertiesWithTypes = __spreadValues(__spreadValues({}, sorter.sortablePropertiesWithTypes), ret.sortablePropertiesWithTypes);
|
|
2904
|
-
continue;
|
|
2905
|
-
}
|
|
2906
|
-
if (!isVectorType(type)) {
|
|
2907
|
-
switch (type) {
|
|
2908
|
-
case "boolean":
|
|
2909
|
-
case "number":
|
|
2910
|
-
case "string":
|
|
2911
|
-
sorter.sortableProperties.push(path);
|
|
2912
|
-
sorter.sortablePropertiesWithTypes[path] = type;
|
|
2913
|
-
sorter.sorts[path] = {
|
|
2914
|
-
docs: /* @__PURE__ */ new Map(),
|
|
2915
|
-
orderedDocsToRemove: /* @__PURE__ */ new Map(),
|
|
2916
|
-
orderedDocs: [],
|
|
2917
|
-
type
|
|
2918
|
-
};
|
|
2919
|
-
break;
|
|
2920
|
-
case "enum":
|
|
2921
|
-
case "boolean[]":
|
|
2922
|
-
case "number[]":
|
|
2923
|
-
case "string[]":
|
|
2924
|
-
continue;
|
|
2925
|
-
default:
|
|
2926
|
-
throw createError("INVALID_SORT_SCHEMA_TYPE", Array.isArray(type) ? "array" : type, path);
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
}
|
|
2930
|
-
return sorter;
|
|
2931
|
-
}
|
|
2932
|
-
async function create6(orama, sharedInternalDocumentStore, schema, config) {
|
|
2933
|
-
const isSortEnabled = (config === null || config === void 0 ? void 0 : config.enabled) !== false;
|
|
2934
|
-
if (!isSortEnabled) {
|
|
2935
|
-
return {
|
|
2936
|
-
disabled: true
|
|
2937
|
-
};
|
|
2938
|
-
}
|
|
2939
|
-
return innerCreate(orama, sharedInternalDocumentStore, schema, (config || {}).unsortableProperties || [], "");
|
|
2940
|
-
}
|
|
2941
|
-
async function insert5(sorter, prop, id, value) {
|
|
2942
|
-
if (!sorter.enabled) {
|
|
2943
|
-
return;
|
|
2944
|
-
}
|
|
2945
|
-
sorter.isSorted = false;
|
|
2946
|
-
const internalId = getInternalDocumentId(sorter.sharedInternalDocumentStore, id);
|
|
2947
|
-
const s = sorter.sorts[prop];
|
|
2948
|
-
s.docs.set(internalId, s.orderedDocs.length);
|
|
2949
|
-
s.orderedDocs.push([
|
|
2950
|
-
internalId,
|
|
2951
|
-
value
|
|
2952
|
-
]);
|
|
2953
|
-
}
|
|
2954
|
-
function ensureIsSorted(sorter) {
|
|
2955
|
-
if (sorter.isSorted) {
|
|
2956
|
-
return;
|
|
2957
|
-
}
|
|
2958
|
-
if (!sorter.enabled) {
|
|
2959
|
-
return;
|
|
2960
|
-
}
|
|
2961
|
-
const properties = Object.keys(sorter.sorts);
|
|
2962
|
-
for (const prop of properties) {
|
|
2963
|
-
ensurePropertyIsSorted(sorter, prop);
|
|
2964
|
-
}
|
|
2965
|
-
sorter.isSorted = true;
|
|
2966
|
-
}
|
|
2967
|
-
function stringSort(language, value, d) {
|
|
2968
|
-
return value[1].localeCompare(d[1], language);
|
|
2969
|
-
}
|
|
2970
|
-
function numberSort(value, d) {
|
|
2971
|
-
return value[1] - d[1];
|
|
2972
|
-
}
|
|
2973
|
-
function booleanSort(value, d) {
|
|
2974
|
-
return d[1] ? -1 : 1;
|
|
2975
|
-
}
|
|
2976
|
-
function ensurePropertyIsSorted(sorter, prop) {
|
|
2977
|
-
const s = sorter.sorts[prop];
|
|
2978
|
-
let predicate;
|
|
2979
|
-
switch (s.type) {
|
|
2980
|
-
case "string":
|
|
2981
|
-
predicate = stringSort.bind(null, sorter.language);
|
|
2982
|
-
break;
|
|
2983
|
-
case "number":
|
|
2984
|
-
predicate = numberSort.bind(null);
|
|
2985
|
-
break;
|
|
2986
|
-
case "boolean":
|
|
2987
|
-
predicate = booleanSort.bind(null);
|
|
2988
|
-
break;
|
|
2989
|
-
}
|
|
2990
|
-
s.orderedDocs.sort(predicate);
|
|
2991
|
-
const orderedDocsLength = s.orderedDocs.length;
|
|
2992
|
-
for (let i = 0; i < orderedDocsLength; i++) {
|
|
2993
|
-
const docId = s.orderedDocs[i][0];
|
|
2994
|
-
s.docs.set(docId, i);
|
|
2995
|
-
}
|
|
2996
|
-
}
|
|
2997
|
-
function ensureOrderedDocsAreDeleted(sorter) {
|
|
2998
|
-
const properties = Object.keys(sorter.sorts);
|
|
2999
|
-
for (const prop of properties) {
|
|
3000
|
-
ensureOrderedDocsAreDeletedByProperty(sorter, prop);
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
function ensureOrderedDocsAreDeletedByProperty(sorter, prop) {
|
|
3004
|
-
const s = sorter.sorts[prop];
|
|
3005
|
-
if (!s.orderedDocsToRemove.size)
|
|
3006
|
-
return;
|
|
3007
|
-
s.orderedDocs = s.orderedDocs.filter((doc) => !s.orderedDocsToRemove.has(doc[0]));
|
|
3008
|
-
s.orderedDocsToRemove.clear();
|
|
3009
|
-
}
|
|
3010
|
-
async function remove4(sorter, prop, id) {
|
|
3011
|
-
if (!sorter.enabled) {
|
|
3012
|
-
return;
|
|
3013
|
-
}
|
|
3014
|
-
const s = sorter.sorts[prop];
|
|
3015
|
-
const internalId = getInternalDocumentId(sorter.sharedInternalDocumentStore, id);
|
|
3016
|
-
const index = s.docs.get(internalId);
|
|
3017
|
-
if (!index)
|
|
3018
|
-
return;
|
|
3019
|
-
s.docs.delete(internalId);
|
|
3020
|
-
s.orderedDocsToRemove.set(internalId, true);
|
|
3021
|
-
}
|
|
3022
|
-
async function sortBy(sorter, docIds, by) {
|
|
3023
|
-
if (!sorter.enabled) {
|
|
3024
|
-
throw createError("SORT_DISABLED");
|
|
3025
|
-
}
|
|
3026
|
-
const property = by.property;
|
|
3027
|
-
const isDesc = by.order === "DESC";
|
|
3028
|
-
const s = sorter.sorts[property];
|
|
3029
|
-
if (!s) {
|
|
3030
|
-
throw createError("UNABLE_TO_SORT_ON_UNKNOWN_FIELD", property, sorter.sortableProperties.join(", "));
|
|
3031
|
-
}
|
|
3032
|
-
ensureOrderedDocsAreDeletedByProperty(sorter, property);
|
|
3033
|
-
ensureIsSorted(sorter);
|
|
3034
|
-
docIds.sort((a, b) => {
|
|
3035
|
-
const indexOfA = s.docs.get(getInternalDocumentId(sorter.sharedInternalDocumentStore, a[0]));
|
|
3036
|
-
const indexOfB = s.docs.get(getInternalDocumentId(sorter.sharedInternalDocumentStore, b[0]));
|
|
3037
|
-
const isAIndexed = typeof indexOfA !== "undefined";
|
|
3038
|
-
const isBIndexed = typeof indexOfB !== "undefined";
|
|
3039
|
-
if (!isAIndexed && !isBIndexed) {
|
|
3040
|
-
return 0;
|
|
3041
|
-
}
|
|
3042
|
-
if (!isAIndexed) {
|
|
3043
|
-
return 1;
|
|
3044
|
-
}
|
|
3045
|
-
if (!isBIndexed) {
|
|
3046
|
-
return -1;
|
|
3047
|
-
}
|
|
3048
|
-
return isDesc ? indexOfB - indexOfA : indexOfA - indexOfB;
|
|
3049
|
-
});
|
|
3050
|
-
return docIds;
|
|
3051
|
-
}
|
|
3052
|
-
async function getSortableProperties(sorter) {
|
|
3053
|
-
if (!sorter.enabled) {
|
|
3054
|
-
return [];
|
|
3055
|
-
}
|
|
3056
|
-
return sorter.sortableProperties;
|
|
3057
|
-
}
|
|
3058
|
-
async function getSortablePropertiesWithTypes(sorter) {
|
|
3059
|
-
if (!sorter.enabled) {
|
|
3060
|
-
return {};
|
|
3061
|
-
}
|
|
3062
|
-
return sorter.sortablePropertiesWithTypes;
|
|
3063
|
-
}
|
|
3064
|
-
async function load4(sharedInternalDocumentStore, raw) {
|
|
3065
|
-
const rawDocument = raw;
|
|
3066
|
-
if (!rawDocument.enabled) {
|
|
3067
|
-
return {
|
|
3068
|
-
enabled: false
|
|
3069
|
-
};
|
|
3070
|
-
}
|
|
3071
|
-
const sorts = Object.keys(rawDocument.sorts).reduce((acc, prop) => {
|
|
3072
|
-
const { docs, orderedDocs, type } = rawDocument.sorts[prop];
|
|
3073
|
-
acc[prop] = {
|
|
3074
|
-
docs: new Map(Object.entries(docs).map(([k, v2]) => [
|
|
3075
|
-
+k,
|
|
3076
|
-
v2
|
|
3077
|
-
])),
|
|
3078
|
-
orderedDocsToRemove: /* @__PURE__ */ new Map(),
|
|
3079
|
-
orderedDocs,
|
|
3080
|
-
type
|
|
3081
|
-
};
|
|
3082
|
-
return acc;
|
|
3083
|
-
}, {});
|
|
3084
|
-
return {
|
|
3085
|
-
sharedInternalDocumentStore,
|
|
3086
|
-
language: rawDocument.language,
|
|
3087
|
-
sortableProperties: rawDocument.sortableProperties,
|
|
3088
|
-
sortablePropertiesWithTypes: rawDocument.sortablePropertiesWithTypes,
|
|
3089
|
-
sorts,
|
|
3090
|
-
enabled: true,
|
|
3091
|
-
isSorted: rawDocument.isSorted
|
|
3092
|
-
};
|
|
3093
|
-
}
|
|
3094
|
-
async function save4(sorter) {
|
|
3095
|
-
if (!sorter.enabled) {
|
|
3096
|
-
return {
|
|
3097
|
-
enabled: false
|
|
3098
|
-
};
|
|
3099
|
-
}
|
|
3100
|
-
ensureOrderedDocsAreDeleted(sorter);
|
|
3101
|
-
ensureIsSorted(sorter);
|
|
3102
|
-
const sorts = Object.keys(sorter.sorts).reduce((acc, prop) => {
|
|
3103
|
-
const { docs, orderedDocs, type } = sorter.sorts[prop];
|
|
3104
|
-
acc[prop] = {
|
|
3105
|
-
docs: Object.fromEntries(docs.entries()),
|
|
3106
|
-
orderedDocs,
|
|
3107
|
-
type
|
|
3108
|
-
};
|
|
3109
|
-
return acc;
|
|
3110
|
-
}, {});
|
|
3111
|
-
return {
|
|
3112
|
-
language: sorter.language,
|
|
3113
|
-
sortableProperties: sorter.sortableProperties,
|
|
3114
|
-
sortablePropertiesWithTypes: sorter.sortablePropertiesWithTypes,
|
|
3115
|
-
sorts,
|
|
3116
|
-
enabled: sorter.enabled,
|
|
3117
|
-
isSorted: sorter.isSorted
|
|
3118
|
-
};
|
|
3119
|
-
}
|
|
3120
|
-
async function createSorter() {
|
|
3121
|
-
return {
|
|
3122
|
-
create: create6,
|
|
3123
|
-
insert: insert5,
|
|
3124
|
-
remove: remove4,
|
|
3125
|
-
save: save4,
|
|
3126
|
-
load: load4,
|
|
3127
|
-
sortBy,
|
|
3128
|
-
getSortableProperties,
|
|
3129
|
-
getSortablePropertiesWithTypes
|
|
3130
|
-
};
|
|
3131
|
-
}
|
|
3132
|
-
|
|
3133
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/methods/create.js
|
|
3134
|
-
function validateComponents(components) {
|
|
3135
|
-
const defaultComponents = {
|
|
3136
|
-
formatElapsedTime,
|
|
3137
|
-
getDocumentIndexId,
|
|
3138
|
-
getDocumentProperties,
|
|
3139
|
-
validateSchema
|
|
3140
|
-
};
|
|
3141
|
-
for (const rawKey of FUNCTION_COMPONENTS) {
|
|
3142
|
-
const key = rawKey;
|
|
3143
|
-
if (components[key]) {
|
|
3144
|
-
if (typeof components[key] !== "function") {
|
|
3145
|
-
throw createError("COMPONENT_MUST_BE_FUNCTION", key);
|
|
3146
|
-
}
|
|
3147
|
-
} else {
|
|
3148
|
-
components[key] = defaultComponents[key];
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3151
|
-
for (const rawKey of SINGLE_OR_ARRAY_COMPONENTS) {
|
|
3152
|
-
const key = rawKey;
|
|
3153
|
-
const component = components[key];
|
|
3154
|
-
if (!component) {
|
|
3155
|
-
components[key] = [];
|
|
3156
|
-
} else if (!Array.isArray(components[key])) {
|
|
3157
|
-
components[key] = [
|
|
3158
|
-
components[key]
|
|
3159
|
-
];
|
|
3160
|
-
}
|
|
3161
|
-
for (const fn of components[key]) {
|
|
3162
|
-
if (typeof fn !== "function") {
|
|
3163
|
-
throw createError("COMPONENT_MUST_BE_FUNCTION_OR_ARRAY_FUNCTIONS", key);
|
|
3164
|
-
}
|
|
3165
|
-
}
|
|
3166
|
-
}
|
|
3167
|
-
for (const rawKey of Object.keys(components)) {
|
|
3168
|
-
if (!OBJECT_COMPONENTS.includes(rawKey) && !FUNCTION_COMPONENTS.includes(rawKey) && !SINGLE_OR_ARRAY_COMPONENTS.includes(rawKey)) {
|
|
3169
|
-
throw createError("UNSUPPORTED_COMPONENT", rawKey);
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
}
|
|
3173
|
-
async function create7({ schema, sort, language, components, id }) {
|
|
3174
|
-
if (!components) {
|
|
3175
|
-
components = {};
|
|
3176
|
-
}
|
|
3177
|
-
if (!id) {
|
|
3178
|
-
id = await uniqueId();
|
|
3179
|
-
}
|
|
3180
|
-
let tokenizer = components.tokenizer;
|
|
3181
|
-
let index = components.index;
|
|
3182
|
-
let documentsStore = components.documentsStore;
|
|
3183
|
-
let sorter = components.sorter;
|
|
3184
|
-
if (!tokenizer) {
|
|
3185
|
-
tokenizer = await createTokenizer({
|
|
3186
|
-
language: language != null ? language : "english"
|
|
3187
|
-
});
|
|
3188
|
-
} else if (!tokenizer.tokenize) {
|
|
3189
|
-
tokenizer = await createTokenizer(tokenizer);
|
|
3190
|
-
}
|
|
3191
|
-
if (components.tokenizer && language) {
|
|
3192
|
-
throw createError("NO_LANGUAGE_WITH_CUSTOM_TOKENIZER");
|
|
3193
|
-
}
|
|
3194
|
-
const internalDocumentStore = createInternalDocumentIDStore();
|
|
3195
|
-
index || (index = await createIndex());
|
|
3196
|
-
sorter || (sorter = await createSorter());
|
|
3197
|
-
documentsStore || (documentsStore = await createDocumentsStore());
|
|
3198
|
-
validateComponents(components);
|
|
3199
|
-
const { getDocumentProperties: getDocumentProperties2, getDocumentIndexId: getDocumentIndexId2, validateSchema: validateSchema2, beforeInsert, afterInsert, beforeRemove, afterRemove, beforeUpdate, afterUpdate, afterSearch, beforeMultipleInsert, afterMultipleInsert, beforeMultipleRemove, afterMultipleRemove, beforeMultipleUpdate, afterMultipleUpdate, formatElapsedTime: formatElapsedTime2 } = components;
|
|
3200
|
-
const orama = {
|
|
3201
|
-
data: {},
|
|
3202
|
-
caches: {},
|
|
3203
|
-
schema,
|
|
3204
|
-
tokenizer,
|
|
3205
|
-
index,
|
|
3206
|
-
sorter,
|
|
3207
|
-
documentsStore,
|
|
3208
|
-
internalDocumentIDStore: internalDocumentStore,
|
|
3209
|
-
getDocumentProperties: getDocumentProperties2,
|
|
3210
|
-
getDocumentIndexId: getDocumentIndexId2,
|
|
3211
|
-
validateSchema: validateSchema2,
|
|
3212
|
-
beforeInsert,
|
|
3213
|
-
afterInsert,
|
|
3214
|
-
beforeRemove,
|
|
3215
|
-
afterRemove,
|
|
3216
|
-
beforeUpdate,
|
|
3217
|
-
afterUpdate,
|
|
3218
|
-
afterSearch,
|
|
3219
|
-
beforeMultipleInsert,
|
|
3220
|
-
afterMultipleInsert,
|
|
3221
|
-
beforeMultipleRemove,
|
|
3222
|
-
afterMultipleRemove,
|
|
3223
|
-
beforeMultipleUpdate,
|
|
3224
|
-
afterMultipleUpdate,
|
|
3225
|
-
formatElapsedTime: formatElapsedTime2,
|
|
3226
|
-
id
|
|
3227
|
-
};
|
|
3228
|
-
orama.data = {
|
|
3229
|
-
index: await orama.index.create(orama, internalDocumentStore, schema),
|
|
3230
|
-
docs: await orama.documentsStore.create(orama, internalDocumentStore),
|
|
3231
|
-
sorting: await orama.sorter.create(orama, internalDocumentStore, schema, sort)
|
|
3232
|
-
};
|
|
3233
|
-
return orama;
|
|
3234
|
-
}
|
|
3235
|
-
|
|
3236
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/types.js
|
|
3237
|
-
var kInsertions = Symbol("orama.insertions");
|
|
3238
|
-
var kRemovals = Symbol("orama.removals");
|
|
3239
|
-
|
|
3240
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/sync-blocking-checker.js
|
|
3241
|
-
var _globalThis_process;
|
|
3242
|
-
var _a;
|
|
3243
|
-
var warn = (_a = (_globalThis_process = globalThis.process) === null || _globalThis_process === void 0 ? void 0 : _globalThis_process.emitWarning) != null ? _a : function emitWarning(message, options) {
|
|
3244
|
-
console.warn(`[WARNING] [${options.code}] ${message}`);
|
|
3245
|
-
};
|
|
3246
|
-
function trackInsertion(orama) {
|
|
3247
|
-
if (typeof orama[kInsertions] !== "number") {
|
|
3248
|
-
queueMicrotask(() => {
|
|
3249
|
-
orama[kInsertions] = void 0;
|
|
3250
|
-
});
|
|
3251
|
-
orama[kInsertions] = 0;
|
|
3252
|
-
}
|
|
3253
|
-
if (orama[kInsertions] > 1e3) {
|
|
3254
|
-
warn("Orama's insert operation is synchronous. Please avoid inserting a large number of document in a single operation in order not to block the main thread or, in alternative, please use insertMultiple.", {
|
|
3255
|
-
code: "ORAMA0001"
|
|
3256
|
-
});
|
|
3257
|
-
orama[kInsertions] = -1;
|
|
3258
|
-
} else if (orama[kInsertions] >= 0) {
|
|
3259
|
-
orama[kInsertions]++;
|
|
3260
|
-
}
|
|
3261
|
-
}
|
|
3262
|
-
function trackRemoval(orama) {
|
|
3263
|
-
if (typeof orama[kRemovals] !== "number") {
|
|
3264
|
-
queueMicrotask(() => {
|
|
3265
|
-
orama[kRemovals] = void 0;
|
|
3266
|
-
});
|
|
3267
|
-
orama[kRemovals] = 0;
|
|
3268
|
-
}
|
|
3269
|
-
if (orama[kRemovals] > 1e3) {
|
|
3270
|
-
warn("Orama's remove operation is synchronous. Please avoid removing a large number of document in a single operation in order not to block the main thread, in alternative, please use updateMultiple.", {
|
|
3271
|
-
code: "ORAMA0002"
|
|
3272
|
-
});
|
|
3273
|
-
orama[kRemovals] = -1;
|
|
3274
|
-
} else if (orama[kRemovals] >= 0) {
|
|
3275
|
-
orama[kRemovals]++;
|
|
3276
|
-
}
|
|
3277
|
-
}
|
|
3278
|
-
|
|
3279
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/methods/insert.js
|
|
3280
|
-
async function insert6(orama, doc, language, skipHooks) {
|
|
3281
|
-
const errorProperty = await orama.validateSchema(doc, orama.schema);
|
|
3282
|
-
if (errorProperty) {
|
|
3283
|
-
throw createError("SCHEMA_VALIDATION_FAILURE", errorProperty);
|
|
3284
|
-
}
|
|
3285
|
-
return innerInsert(orama, doc, language, skipHooks);
|
|
3286
|
-
}
|
|
3287
|
-
async function innerInsert(orama, doc, language, skipHooks) {
|
|
3288
|
-
const { index, docs } = orama.data;
|
|
3289
|
-
const id = await orama.getDocumentIndexId(doc);
|
|
3290
|
-
if (typeof id !== "string") {
|
|
3291
|
-
throw createError("DOCUMENT_ID_MUST_BE_STRING", typeof id);
|
|
3292
|
-
}
|
|
3293
|
-
if (!await orama.documentsStore.store(docs, id, doc)) {
|
|
3294
|
-
throw createError("DOCUMENT_ALREADY_EXISTS", id);
|
|
3295
|
-
}
|
|
3296
|
-
const docsCount = await orama.documentsStore.count(docs);
|
|
3297
|
-
if (!skipHooks) {
|
|
3298
|
-
await runSingleHook(orama.beforeInsert, orama, id, doc);
|
|
3299
|
-
}
|
|
3300
|
-
const indexableProperties = await orama.index.getSearchableProperties(index);
|
|
3301
|
-
const indexablePropertiesWithTypes = await orama.index.getSearchablePropertiesWithTypes(index);
|
|
3302
|
-
const indexableValues = await orama.getDocumentProperties(doc, indexableProperties);
|
|
3303
|
-
for (const [key, value] of Object.entries(indexableValues)) {
|
|
3304
|
-
if (typeof value === "undefined") {
|
|
3305
|
-
continue;
|
|
3306
|
-
}
|
|
3307
|
-
const actualType = typeof value;
|
|
3308
|
-
const expectedType = indexablePropertiesWithTypes[key];
|
|
3309
|
-
if (isVectorType(expectedType) && Array.isArray(value)) {
|
|
3310
|
-
continue;
|
|
3311
|
-
}
|
|
3312
|
-
if (isArrayType(expectedType) && Array.isArray(value)) {
|
|
3313
|
-
continue;
|
|
3314
|
-
}
|
|
3315
|
-
if (expectedType === "enum" && (actualType === "string" || actualType === "number")) {
|
|
3316
|
-
continue;
|
|
3317
|
-
}
|
|
3318
|
-
if (actualType !== expectedType) {
|
|
3319
|
-
throw createError("INVALID_DOCUMENT_PROPERTY", key, expectedType, actualType);
|
|
3320
|
-
}
|
|
3321
|
-
}
|
|
3322
|
-
for (const prop of indexableProperties) {
|
|
3323
|
-
var _orama_index, _orama_index_beforeInsert, _orama_index1, _orama_index_afterInsert;
|
|
3324
|
-
const value = indexableValues[prop];
|
|
3325
|
-
if (typeof value === "undefined") {
|
|
3326
|
-
continue;
|
|
3327
|
-
}
|
|
3328
|
-
const expectedType = indexablePropertiesWithTypes[prop];
|
|
3329
|
-
await ((_orama_index_beforeInsert = (_orama_index = orama.index).beforeInsert) === null || _orama_index_beforeInsert === void 0 ? void 0 : _orama_index_beforeInsert.call(_orama_index, orama.data.index, prop, id, value, expectedType, language, orama.tokenizer, docsCount));
|
|
3330
|
-
await orama.index.insert(orama.index, orama.data.index, prop, id, value, expectedType, language, orama.tokenizer, docsCount);
|
|
3331
|
-
await ((_orama_index_afterInsert = (_orama_index1 = orama.index).afterInsert) === null || _orama_index_afterInsert === void 0 ? void 0 : _orama_index_afterInsert.call(_orama_index1, orama.data.index, prop, id, value, expectedType, language, orama.tokenizer, docsCount));
|
|
3332
|
-
}
|
|
3333
|
-
const sortableProperties = await orama.sorter.getSortableProperties(orama.data.sorting);
|
|
3334
|
-
const sortablePropertiesWithTypes = await orama.sorter.getSortablePropertiesWithTypes(orama.data.sorting);
|
|
3335
|
-
const sortableValues = await orama.getDocumentProperties(doc, sortableProperties);
|
|
3336
|
-
for (const prop of sortableProperties) {
|
|
3337
|
-
const value = sortableValues[prop];
|
|
3338
|
-
if (typeof value === "undefined") {
|
|
3339
|
-
continue;
|
|
3340
|
-
}
|
|
3341
|
-
const expectedType = sortablePropertiesWithTypes[prop];
|
|
3342
|
-
await orama.sorter.insert(orama.data.sorting, prop, id, value, expectedType, language);
|
|
3343
|
-
}
|
|
3344
|
-
if (!skipHooks) {
|
|
3345
|
-
await runSingleHook(orama.afterInsert, orama, id, doc);
|
|
3346
|
-
}
|
|
3347
|
-
trackInsertion(orama);
|
|
3348
|
-
return id;
|
|
3349
|
-
}
|
|
3350
|
-
|
|
3351
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/methods/remove.js
|
|
3352
|
-
async function remove5(orama, id, language, skipHooks) {
|
|
3353
|
-
let result = true;
|
|
3354
|
-
const { index, docs } = orama.data;
|
|
3355
|
-
const doc = await orama.documentsStore.get(docs, id);
|
|
3356
|
-
if (!doc) {
|
|
3357
|
-
return false;
|
|
3358
|
-
}
|
|
3359
|
-
const docId = getDocumentIdFromInternalId(orama.internalDocumentIDStore, getInternalDocumentId(orama.internalDocumentIDStore, id));
|
|
3360
|
-
const docsCount = await orama.documentsStore.count(docs);
|
|
3361
|
-
if (!skipHooks) {
|
|
3362
|
-
await runSingleHook(orama.beforeRemove, orama, docId);
|
|
3363
|
-
}
|
|
3364
|
-
const indexableProperties = await orama.index.getSearchableProperties(index);
|
|
3365
|
-
const indexablePropertiesWithTypes = await orama.index.getSearchablePropertiesWithTypes(index);
|
|
3366
|
-
const values = await orama.getDocumentProperties(doc, indexableProperties);
|
|
3367
|
-
for (const prop of indexableProperties) {
|
|
3368
|
-
var _orama_index, _orama_index_beforeRemove, _orama_index1, _orama_index_afterRemove;
|
|
3369
|
-
const value = values[prop];
|
|
3370
|
-
if (typeof value === "undefined") {
|
|
3371
|
-
continue;
|
|
3372
|
-
}
|
|
3373
|
-
const schemaType = indexablePropertiesWithTypes[prop];
|
|
3374
|
-
await ((_orama_index_beforeRemove = (_orama_index = orama.index).beforeRemove) === null || _orama_index_beforeRemove === void 0 ? void 0 : _orama_index_beforeRemove.call(_orama_index, orama.data.index, prop, docId, value, schemaType, language, orama.tokenizer, docsCount));
|
|
3375
|
-
if (!await orama.index.remove(orama.index, orama.data.index, prop, id, value, schemaType, language, orama.tokenizer, docsCount)) {
|
|
3376
|
-
result = false;
|
|
3377
|
-
}
|
|
3378
|
-
await ((_orama_index_afterRemove = (_orama_index1 = orama.index).afterRemove) === null || _orama_index_afterRemove === void 0 ? void 0 : _orama_index_afterRemove.call(_orama_index1, orama.data.index, prop, docId, value, schemaType, language, orama.tokenizer, docsCount));
|
|
3379
|
-
}
|
|
3380
|
-
const sortableProperties = await orama.sorter.getSortableProperties(orama.data.sorting);
|
|
3381
|
-
const sortableValues = await orama.getDocumentProperties(doc, sortableProperties);
|
|
3382
|
-
for (const prop of sortableProperties) {
|
|
3383
|
-
if (typeof sortableValues[prop] === "undefined") {
|
|
3384
|
-
continue;
|
|
3385
|
-
}
|
|
3386
|
-
await orama.sorter.remove(orama.data.sorting, prop, id);
|
|
3387
|
-
}
|
|
3388
|
-
if (!skipHooks) {
|
|
3389
|
-
await runSingleHook(orama.afterRemove, orama, docId);
|
|
3390
|
-
}
|
|
3391
|
-
await orama.documentsStore.remove(orama.data.docs, id);
|
|
3392
|
-
trackRemoval(orama);
|
|
3393
|
-
return result;
|
|
3394
|
-
}
|
|
3395
|
-
|
|
3396
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/facets.js
|
|
3397
|
-
function sortingPredicate(order = "desc", a, b) {
|
|
3398
|
-
if (order.toLowerCase() === "asc") {
|
|
3399
|
-
return a[1] - b[1];
|
|
3400
|
-
} else {
|
|
3401
|
-
return b[1] - a[1];
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
async function getFacets(orama, results, facetsConfig) {
|
|
3405
|
-
var _a2, _b;
|
|
3406
|
-
const facets = {};
|
|
3407
|
-
const allIDs = results.map(([id]) => id);
|
|
3408
|
-
const allDocs = await orama.documentsStore.getMultiple(orama.data.docs, allIDs);
|
|
3409
|
-
const facetKeys = Object.keys(facetsConfig);
|
|
3410
|
-
const properties = await orama.index.getSearchablePropertiesWithTypes(orama.data.index);
|
|
3411
|
-
for (const facet of facetKeys) {
|
|
3412
|
-
let values = {};
|
|
3413
|
-
if (properties[facet] === "number") {
|
|
3414
|
-
const { ranges } = facetsConfig[facet];
|
|
3415
|
-
const tmp = [];
|
|
3416
|
-
for (const range of ranges) {
|
|
3417
|
-
tmp.push([
|
|
3418
|
-
`${range.from}-${range.to}`,
|
|
3419
|
-
0
|
|
3420
|
-
]);
|
|
3421
|
-
}
|
|
3422
|
-
values = Object.fromEntries(tmp);
|
|
3423
|
-
}
|
|
3424
|
-
facets[facet] = {
|
|
3425
|
-
count: 0,
|
|
3426
|
-
values
|
|
3427
|
-
};
|
|
3428
|
-
}
|
|
3429
|
-
const allDocsLength = allDocs.length;
|
|
3430
|
-
for (let i = 0; i < allDocsLength; i++) {
|
|
3431
|
-
const doc = allDocs[i];
|
|
3432
|
-
for (const facet of facetKeys) {
|
|
3433
|
-
const facetValue = facet.includes(".") ? await getNested(doc, facet) : doc[facet];
|
|
3434
|
-
const propertyType = properties[facet];
|
|
3435
|
-
switch (propertyType) {
|
|
3436
|
-
case "number": {
|
|
3437
|
-
const ranges = facetsConfig[facet].ranges;
|
|
3438
|
-
calculateNumberFacet(ranges, facets[facet].values, facetValue);
|
|
3439
|
-
break;
|
|
3440
|
-
}
|
|
3441
|
-
case "number[]": {
|
|
3442
|
-
const alreadyInsertedValues = /* @__PURE__ */ new Set();
|
|
3443
|
-
const ranges = facetsConfig[facet].ranges;
|
|
3444
|
-
for (const v2 of facetValue) {
|
|
3445
|
-
calculateNumberFacet(ranges, facets[facet].values, v2, alreadyInsertedValues);
|
|
3446
|
-
}
|
|
3447
|
-
break;
|
|
3448
|
-
}
|
|
3449
|
-
case "boolean":
|
|
3450
|
-
case "string": {
|
|
3451
|
-
calculateBooleanOrStringFacet(facets[facet].values, facetValue, propertyType);
|
|
3452
|
-
break;
|
|
3453
|
-
}
|
|
3454
|
-
case "boolean[]":
|
|
3455
|
-
case "string[]": {
|
|
3456
|
-
const alreadyInsertedValues = /* @__PURE__ */ new Set();
|
|
3457
|
-
const innerType = propertyType === "boolean[]" ? "boolean" : "string";
|
|
3458
|
-
for (const v2 of facetValue) {
|
|
3459
|
-
calculateBooleanOrStringFacet(facets[facet].values, v2, innerType, alreadyInsertedValues);
|
|
3460
|
-
}
|
|
3461
|
-
break;
|
|
3462
|
-
}
|
|
3463
|
-
}
|
|
3464
|
-
}
|
|
3465
|
-
}
|
|
3466
|
-
for (const facet of facetKeys) {
|
|
3467
|
-
facets[facet].count = Object.keys(facets[facet].values).length;
|
|
3468
|
-
if (properties[facet] === "string") {
|
|
3469
|
-
const stringFacetDefinition = facetsConfig;
|
|
3470
|
-
facets[facet].values = Object.fromEntries(Object.entries(facets[facet].values).sort((a, b) => sortingPredicate(stringFacetDefinition.sort, a, b)).slice((_a2 = stringFacetDefinition.offset) != null ? _a2 : 0, (_b = stringFacetDefinition.limit) != null ? _b : 10));
|
|
3471
|
-
}
|
|
3472
|
-
}
|
|
3473
|
-
return facets;
|
|
3474
|
-
}
|
|
3475
|
-
function calculateNumberFacet(ranges, values, facetValue, alreadyInsertedValues) {
|
|
3476
|
-
for (const range of ranges) {
|
|
3477
|
-
const value = `${range.from}-${range.to}`;
|
|
3478
|
-
if (alreadyInsertedValues && alreadyInsertedValues.has(value)) {
|
|
3479
|
-
continue;
|
|
3480
|
-
}
|
|
3481
|
-
if (facetValue >= range.from && facetValue <= range.to) {
|
|
3482
|
-
if (values[value] === void 0) {
|
|
3483
|
-
values[value] = 1;
|
|
3484
|
-
} else {
|
|
3485
|
-
values[value]++;
|
|
3486
|
-
if (alreadyInsertedValues) {
|
|
3487
|
-
alreadyInsertedValues.add(value);
|
|
3488
|
-
}
|
|
3489
|
-
}
|
|
3490
|
-
}
|
|
3491
|
-
}
|
|
3492
|
-
}
|
|
3493
|
-
function calculateBooleanOrStringFacet(values, facetValue, propertyType, alreadyInsertedValues) {
|
|
3494
|
-
var _a2, _b;
|
|
3495
|
-
const value = (_a2 = facetValue === null || facetValue === void 0 ? void 0 : facetValue.toString()) != null ? _a2 : propertyType === "boolean" ? "false" : "";
|
|
3496
|
-
if (alreadyInsertedValues && alreadyInsertedValues.has(value)) {
|
|
3497
|
-
return;
|
|
3498
|
-
}
|
|
3499
|
-
values[value] = ((_b = values[value]) != null ? _b : 0) + 1;
|
|
3500
|
-
if (alreadyInsertedValues) {
|
|
3501
|
-
alreadyInsertedValues.add(value);
|
|
3502
|
-
}
|
|
3503
|
-
}
|
|
3504
|
-
|
|
3505
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/filters.js
|
|
3506
|
-
function intersectFilteredIDs(filtered, lookedUp) {
|
|
3507
|
-
const map = /* @__PURE__ */ new Map();
|
|
3508
|
-
const result = [];
|
|
3509
|
-
for (const id of filtered) {
|
|
3510
|
-
map.set(id, true);
|
|
3511
|
-
}
|
|
3512
|
-
for (const [id, score] of lookedUp) {
|
|
3513
|
-
if (map.has(id)) {
|
|
3514
|
-
result.push([
|
|
3515
|
-
id,
|
|
3516
|
-
score
|
|
3517
|
-
]);
|
|
3518
|
-
map.delete(id);
|
|
3519
|
-
}
|
|
3520
|
-
}
|
|
3521
|
-
return result;
|
|
3522
|
-
}
|
|
3523
|
-
|
|
3524
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/components/groups.js
|
|
3525
|
-
var DEFAULT_REDUCE = {
|
|
3526
|
-
reducer: (_, acc, res, index) => {
|
|
3527
|
-
acc[index] = res;
|
|
3528
|
-
return acc;
|
|
3529
|
-
},
|
|
3530
|
-
getInitialValue: (length) => Array.from({
|
|
3531
|
-
length
|
|
3532
|
-
})
|
|
3533
|
-
};
|
|
3534
|
-
var ALLOWED_TYPES = [
|
|
3535
|
-
"string",
|
|
3536
|
-
"number",
|
|
3537
|
-
"boolean"
|
|
3538
|
-
];
|
|
3539
|
-
async function getGroups(orama, results, groupBy) {
|
|
3540
|
-
const properties = groupBy.properties;
|
|
3541
|
-
const propertiesLength = properties.length;
|
|
3542
|
-
const schemaProperties = await orama.index.getSearchablePropertiesWithTypes(orama.data.index);
|
|
3543
|
-
for (let i = 0; i < propertiesLength; i++) {
|
|
3544
|
-
const property = properties[i];
|
|
3545
|
-
if (typeof schemaProperties[property] === "undefined") {
|
|
3546
|
-
throw createError("UNKNOWN_GROUP_BY_PROPERTY", property);
|
|
3547
|
-
}
|
|
3548
|
-
if (!ALLOWED_TYPES.includes(schemaProperties[property])) {
|
|
3549
|
-
throw createError("INVALID_GROUP_BY_PROPERTY", property, ALLOWED_TYPES.join(", "), schemaProperties[property]);
|
|
3550
|
-
}
|
|
3551
|
-
}
|
|
3552
|
-
const allIDs = results.map(([id]) => getDocumentIdFromInternalId(orama.internalDocumentIDStore, id));
|
|
3553
|
-
const allDocs = await orama.documentsStore.getMultiple(orama.data.docs, allIDs);
|
|
3554
|
-
const allDocsLength = allDocs.length;
|
|
3555
|
-
const returnedCount = groupBy.maxResult || Number.MAX_SAFE_INTEGER;
|
|
3556
|
-
const listOfValues = [];
|
|
3557
|
-
const g = {};
|
|
3558
|
-
for (let i = 0; i < propertiesLength; i++) {
|
|
3559
|
-
const groupByKey = properties[i];
|
|
3560
|
-
const group = {
|
|
3561
|
-
property: groupByKey,
|
|
3562
|
-
perValue: {}
|
|
3563
|
-
};
|
|
3564
|
-
const values = /* @__PURE__ */ new Set();
|
|
3565
|
-
for (let j = 0; j < allDocsLength; j++) {
|
|
3566
|
-
const doc = allDocs[j];
|
|
3567
|
-
const value = await getNested(doc, groupByKey);
|
|
3568
|
-
if (typeof value === "undefined") {
|
|
3569
|
-
continue;
|
|
3570
|
-
}
|
|
3571
|
-
const keyValue = typeof value !== "boolean" ? value : "" + value;
|
|
3572
|
-
if (typeof group.perValue[keyValue] === "undefined") {
|
|
3573
|
-
group.perValue[keyValue] = {
|
|
3574
|
-
indexes: [],
|
|
3575
|
-
count: 0
|
|
3576
|
-
};
|
|
3577
|
-
}
|
|
3578
|
-
if (group.perValue[keyValue].count >= returnedCount) {
|
|
3579
|
-
continue;
|
|
3580
|
-
}
|
|
3581
|
-
group.perValue[keyValue].indexes.push(j);
|
|
3582
|
-
group.perValue[keyValue].count++;
|
|
3583
|
-
values.add(value);
|
|
3584
|
-
}
|
|
3585
|
-
listOfValues.push(Array.from(values));
|
|
3586
|
-
g[groupByKey] = group;
|
|
3587
|
-
}
|
|
3588
|
-
const combinations = calculateCombination(listOfValues);
|
|
3589
|
-
const combinationsLength = combinations.length;
|
|
3590
|
-
const groups = [];
|
|
3591
|
-
for (let i = 0; i < combinationsLength; i++) {
|
|
3592
|
-
const combination = combinations[i];
|
|
3593
|
-
const combinationLength = combination.length;
|
|
3594
|
-
const group = {
|
|
3595
|
-
values: [],
|
|
3596
|
-
indexes: []
|
|
3597
|
-
};
|
|
3598
|
-
const indexes = [];
|
|
3599
|
-
for (let j = 0; j < combinationLength; j++) {
|
|
3600
|
-
const value = combination[j];
|
|
3601
|
-
const property = properties[j];
|
|
3602
|
-
indexes.push(g[property].perValue[typeof value !== "boolean" ? value : "" + value].indexes);
|
|
3603
|
-
group.values.push(value);
|
|
3604
|
-
}
|
|
3605
|
-
group.indexes = intersect(indexes).sort((a, b) => a - b);
|
|
3606
|
-
if (group.indexes.length === 0) {
|
|
3607
|
-
continue;
|
|
3608
|
-
}
|
|
3609
|
-
groups.push(group);
|
|
3610
|
-
}
|
|
3611
|
-
const groupsLength = groups.length;
|
|
3612
|
-
const res = Array.from({
|
|
3613
|
-
length: groupsLength
|
|
3614
|
-
});
|
|
3615
|
-
for (let i = 0; i < groupsLength; i++) {
|
|
3616
|
-
const group = groups[i];
|
|
3617
|
-
const reduce = groupBy.reduce || DEFAULT_REDUCE;
|
|
3618
|
-
const docs = group.indexes.map((index) => {
|
|
3619
|
-
return {
|
|
3620
|
-
id: allIDs[index],
|
|
3621
|
-
score: results[index][1],
|
|
3622
|
-
document: allDocs[index]
|
|
3623
|
-
};
|
|
3624
|
-
});
|
|
3625
|
-
const func = reduce.reducer.bind(null, group.values);
|
|
3626
|
-
const initialValue = reduce.getInitialValue(group.indexes.length);
|
|
3627
|
-
const aggregationValue = docs.reduce(func, initialValue);
|
|
3628
|
-
res[i] = {
|
|
3629
|
-
values: group.values,
|
|
3630
|
-
result: aggregationValue
|
|
3631
|
-
};
|
|
3632
|
-
}
|
|
3633
|
-
return res;
|
|
3634
|
-
}
|
|
3635
|
-
function calculateCombination(arrs, index = 0) {
|
|
3636
|
-
if (index + 1 === arrs.length)
|
|
3637
|
-
return arrs[index].map((item) => [
|
|
3638
|
-
item
|
|
3639
|
-
]);
|
|
3640
|
-
const head = arrs[index];
|
|
3641
|
-
const c2 = calculateCombination(arrs, index + 1);
|
|
3642
|
-
const combinations = [];
|
|
3643
|
-
for (const value of head) {
|
|
3644
|
-
for (const combination of c2) {
|
|
3645
|
-
const result = [
|
|
3646
|
-
value
|
|
3647
|
-
];
|
|
3648
|
-
safeArrayPush(result, combination);
|
|
3649
|
-
combinations.push(result);
|
|
3650
|
-
}
|
|
3651
|
-
}
|
|
3652
|
-
return combinations;
|
|
3653
|
-
}
|
|
3654
|
-
|
|
3655
|
-
// ../../node_modules/.pnpm/@orama+orama@1.2.4/node_modules/@orama/orama/dist/methods/search.js
|
|
3656
|
-
var defaultBM25Params = {
|
|
3657
|
-
k: 1.2,
|
|
3658
|
-
b: 0.75,
|
|
3659
|
-
d: 0.5
|
|
3660
|
-
};
|
|
3661
|
-
async function createSearchContext(tokenizer, index, documentsStore, language, params, properties, tokens, docsCount, timeStart) {
|
|
3662
|
-
const indexMap = {};
|
|
3663
|
-
const docsIntersection = {};
|
|
3664
|
-
for (const prop of properties) {
|
|
3665
|
-
const tokensMap = {};
|
|
3666
|
-
for (const token of tokens) {
|
|
3667
|
-
tokensMap[token] = [];
|
|
3668
|
-
}
|
|
3669
|
-
indexMap[prop] = tokensMap;
|
|
3670
|
-
docsIntersection[prop] = [];
|
|
3671
|
-
}
|
|
3672
|
-
return {
|
|
3673
|
-
timeStart,
|
|
3674
|
-
tokenizer,
|
|
3675
|
-
index,
|
|
3676
|
-
documentsStore,
|
|
3677
|
-
language,
|
|
3678
|
-
params,
|
|
3679
|
-
docsCount,
|
|
3680
|
-
uniqueDocsIDs: {},
|
|
3681
|
-
indexMap,
|
|
3682
|
-
docsIntersection
|
|
3683
|
-
};
|
|
3684
|
-
}
|
|
3685
|
-
async function search2(orama, params, language) {
|
|
3686
|
-
var _a2, _b, _c;
|
|
3687
|
-
const timeStart = await getNanosecondsTime();
|
|
3688
|
-
params.relevance = Object.assign((_a2 = params.relevance) != null ? _a2 : {}, defaultBM25Params);
|
|
3689
|
-
const shouldCalculateFacets = params.facets && Object.keys(params.facets).length > 0;
|
|
3690
|
-
const { limit = 10, offset = 0, term, properties, threshold = 1, distinctOn } = params;
|
|
3691
|
-
const isPreflight = params.preflight === true;
|
|
3692
|
-
const { index, docs } = orama.data;
|
|
3693
|
-
const tokens = await orama.tokenizer.tokenize(term != null ? term : "", language);
|
|
3694
|
-
let propertiesToSearch = orama.caches["propertiesToSearch"];
|
|
3695
|
-
if (!propertiesToSearch) {
|
|
3696
|
-
const propertiesToSearchWithTypes = await orama.index.getSearchablePropertiesWithTypes(index);
|
|
3697
|
-
propertiesToSearch = await orama.index.getSearchableProperties(index);
|
|
3698
|
-
propertiesToSearch = propertiesToSearch.filter((prop) => propertiesToSearchWithTypes[prop].startsWith("string"));
|
|
3699
|
-
orama.caches["propertiesToSearch"] = propertiesToSearch;
|
|
3700
|
-
}
|
|
3701
|
-
if (properties && properties !== "*") {
|
|
3702
|
-
for (const prop of properties) {
|
|
3703
|
-
if (!propertiesToSearch.includes(prop)) {
|
|
3704
|
-
throw createError("UNKNOWN_INDEX", prop, propertiesToSearch.join(", "));
|
|
3705
|
-
}
|
|
3706
|
-
}
|
|
3707
|
-
propertiesToSearch = propertiesToSearch.filter((prop) => properties.includes(prop));
|
|
3708
|
-
}
|
|
3709
|
-
const context = await createSearchContext(orama.tokenizer, orama.index, orama.documentsStore, language, params, propertiesToSearch, tokens, await orama.documentsStore.count(docs), timeStart);
|
|
3710
|
-
const hasFilters = Object.keys((_b = params.where) != null ? _b : {}).length > 0;
|
|
3711
|
-
let whereFiltersIDs = [];
|
|
3712
|
-
if (hasFilters) {
|
|
3713
|
-
whereFiltersIDs = await orama.index.searchByWhereClause(context, index, params.where);
|
|
3714
|
-
}
|
|
3715
|
-
const tokensLength = tokens.length;
|
|
3716
|
-
if (tokensLength) {
|
|
3717
|
-
const indexesLength = propertiesToSearch.length;
|
|
3718
|
-
for (let i = 0; i < indexesLength; i++) {
|
|
3719
|
-
var _params_boost;
|
|
3720
|
-
const prop = propertiesToSearch[i];
|
|
3721
|
-
const tokensLength2 = tokens.length;
|
|
3722
|
-
for (let j = 0; j < tokensLength2; j++) {
|
|
3723
|
-
const term2 = tokens[j];
|
|
3724
|
-
const scoreList = await orama.index.search(context, index, prop, term2);
|
|
3725
|
-
safeArrayPush(context.indexMap[prop][term2], scoreList);
|
|
3726
|
-
}
|
|
3727
|
-
const docIds = context.indexMap[prop];
|
|
3728
|
-
const vals = Object.values(docIds);
|
|
3729
|
-
context.docsIntersection[prop] = prioritizeTokenScores(vals, (_c = params === null || params === void 0 ? void 0 : (_params_boost = params.boost) === null || _params_boost === void 0 ? void 0 : _params_boost[prop]) != null ? _c : 1, threshold, tokensLength2);
|
|
3730
|
-
const uniqueDocs = context.docsIntersection[prop];
|
|
3731
|
-
const uniqueDocsLength = uniqueDocs.length;
|
|
3732
|
-
for (let i2 = 0; i2 < uniqueDocsLength; i2++) {
|
|
3733
|
-
const [id, score] = uniqueDocs[i2];
|
|
3734
|
-
const prevScore = context.uniqueDocsIDs[id];
|
|
3735
|
-
if (prevScore) {
|
|
3736
|
-
context.uniqueDocsIDs[id] = prevScore + score + 0.5;
|
|
3737
|
-
} else {
|
|
3738
|
-
context.uniqueDocsIDs[id] = score;
|
|
3739
|
-
}
|
|
3740
|
-
}
|
|
3741
|
-
}
|
|
3742
|
-
} else if (tokens.length === 0 && term) {
|
|
3743
|
-
context.uniqueDocsIDs = {};
|
|
3744
|
-
} else {
|
|
3745
|
-
context.uniqueDocsIDs = Object.fromEntries(Object.keys(await orama.documentsStore.getAll(orama.data.docs)).map((k) => [
|
|
3746
|
-
k,
|
|
3747
|
-
0
|
|
3748
|
-
]));
|
|
3749
|
-
}
|
|
3750
|
-
let uniqueDocsArray = Object.entries(context.uniqueDocsIDs).map(([id, score]) => [
|
|
3751
|
-
+id,
|
|
3752
|
-
score
|
|
3753
|
-
]);
|
|
3754
|
-
if (hasFilters) {
|
|
3755
|
-
uniqueDocsArray = intersectFilteredIDs(whereFiltersIDs, uniqueDocsArray);
|
|
3756
|
-
}
|
|
3757
|
-
if (params.sortBy) {
|
|
3758
|
-
if (typeof params.sortBy === "function") {
|
|
3759
|
-
const ids = uniqueDocsArray.map(([id]) => id);
|
|
3760
|
-
const docs2 = await orama.documentsStore.getMultiple(orama.data.docs, ids);
|
|
3761
|
-
const docsWithIdAndScore = docs2.map((d, i) => [
|
|
3762
|
-
uniqueDocsArray[i][0],
|
|
3763
|
-
uniqueDocsArray[i][1],
|
|
3764
|
-
d
|
|
3765
|
-
]);
|
|
3766
|
-
docsWithIdAndScore.sort(params.sortBy);
|
|
3767
|
-
uniqueDocsArray = docsWithIdAndScore.map(([id, score]) => [
|
|
3768
|
-
id,
|
|
3769
|
-
score
|
|
3770
|
-
]);
|
|
3771
|
-
} else {
|
|
3772
|
-
uniqueDocsArray = await orama.sorter.sortBy(orama.data.sorting, uniqueDocsArray, params.sortBy).then((results2) => results2.map(([id, score]) => [
|
|
3773
|
-
getInternalDocumentId(orama.internalDocumentIDStore, id),
|
|
3774
|
-
score
|
|
3775
|
-
]));
|
|
3776
|
-
}
|
|
3777
|
-
} else {
|
|
3778
|
-
uniqueDocsArray = uniqueDocsArray.sort(sortTokenScorePredicate);
|
|
3779
|
-
}
|
|
3780
|
-
let results;
|
|
3781
|
-
if (!isPreflight && distinctOn) {
|
|
3782
|
-
results = await fetchDocumentsWithDistinct(orama, uniqueDocsArray, offset, limit, distinctOn);
|
|
3783
|
-
} else if (!isPreflight) {
|
|
3784
|
-
results = await fetchDocuments(orama, uniqueDocsArray, offset, limit);
|
|
3785
|
-
}
|
|
3786
|
-
const searchResult = {
|
|
3787
|
-
elapsed: {
|
|
3788
|
-
formatted: "",
|
|
3789
|
-
raw: 0
|
|
3790
|
-
},
|
|
3791
|
-
hits: [],
|
|
3792
|
-
count: uniqueDocsArray.length
|
|
3793
|
-
};
|
|
3794
|
-
if (typeof results !== "undefined") {
|
|
3795
|
-
searchResult.hits = results.filter(Boolean);
|
|
3796
|
-
}
|
|
3797
|
-
if (shouldCalculateFacets) {
|
|
3798
|
-
const facets = await getFacets(orama, uniqueDocsArray, params.facets);
|
|
3799
|
-
searchResult.facets = facets;
|
|
3800
|
-
}
|
|
3801
|
-
if (params.groupBy) {
|
|
3802
|
-
searchResult.groups = await getGroups(orama, uniqueDocsArray, params.groupBy);
|
|
3803
|
-
}
|
|
3804
|
-
if (orama.afterSearch) {
|
|
3805
|
-
await runAfterSearch(orama.afterSearch, orama, params, language, searchResult);
|
|
3806
|
-
}
|
|
3807
|
-
searchResult.elapsed = await orama.formatElapsedTime(await getNanosecondsTime() - context.timeStart);
|
|
3808
|
-
return searchResult;
|
|
3809
|
-
}
|
|
3810
|
-
async function fetchDocumentsWithDistinct(orama, uniqueDocsArray, offset, limit, distinctOn) {
|
|
3811
|
-
const docs = orama.data.docs;
|
|
3812
|
-
const values = /* @__PURE__ */ new Map();
|
|
3813
|
-
const results = [];
|
|
3814
|
-
const resultIDs = /* @__PURE__ */ new Set();
|
|
3815
|
-
const uniqueDocsArrayLength = uniqueDocsArray.length;
|
|
3816
|
-
let count2 = 0;
|
|
3817
|
-
for (let i = 0; i < uniqueDocsArrayLength; i++) {
|
|
3818
|
-
const idAndScore = uniqueDocsArray[i];
|
|
3819
|
-
if (typeof idAndScore === "undefined") {
|
|
3820
|
-
continue;
|
|
3821
|
-
}
|
|
3822
|
-
const [id, score] = idAndScore;
|
|
3823
|
-
if (resultIDs.has(id)) {
|
|
3824
|
-
continue;
|
|
3825
|
-
}
|
|
3826
|
-
const doc = await orama.documentsStore.get(docs, id);
|
|
3827
|
-
const value = await getNested(doc, distinctOn);
|
|
3828
|
-
if (typeof value === "undefined" || values.has(value)) {
|
|
3829
|
-
continue;
|
|
3830
|
-
}
|
|
3831
|
-
values.set(value, true);
|
|
3832
|
-
count2++;
|
|
3833
|
-
if (count2 <= offset) {
|
|
3834
|
-
continue;
|
|
3835
|
-
}
|
|
3836
|
-
results.push({
|
|
3837
|
-
id: getDocumentIdFromInternalId(orama.internalDocumentIDStore, id),
|
|
3838
|
-
score,
|
|
3839
|
-
document: doc
|
|
3840
|
-
});
|
|
3841
|
-
resultIDs.add(id);
|
|
3842
|
-
if (count2 >= offset + limit) {
|
|
3843
|
-
break;
|
|
3844
|
-
}
|
|
3845
|
-
}
|
|
3846
|
-
return results;
|
|
3847
|
-
}
|
|
3848
|
-
async function fetchDocuments(orama, uniqueDocsArray, offset, limit) {
|
|
3849
|
-
const docs = orama.data.docs;
|
|
3850
|
-
const results = Array.from({
|
|
3851
|
-
length: limit
|
|
3852
|
-
});
|
|
3853
|
-
const resultIDs = /* @__PURE__ */ new Set();
|
|
3854
|
-
for (let i = offset; i < limit + offset; i++) {
|
|
3855
|
-
const idAndScore = uniqueDocsArray[i];
|
|
3856
|
-
if (typeof idAndScore === "undefined") {
|
|
3857
|
-
break;
|
|
3858
|
-
}
|
|
3859
|
-
const [id, score] = idAndScore;
|
|
3860
|
-
if (!resultIDs.has(id)) {
|
|
3861
|
-
const fullDoc = await orama.documentsStore.get(docs, id);
|
|
3862
|
-
results[i] = {
|
|
3863
|
-
id: getDocumentIdFromInternalId(orama.internalDocumentIDStore, id),
|
|
3864
|
-
score,
|
|
3865
|
-
document: fullDoc
|
|
3866
|
-
};
|
|
3867
|
-
resultIDs.add(id);
|
|
3868
|
-
}
|
|
3869
|
-
}
|
|
3870
|
-
return results;
|
|
3871
|
-
}
|
|
3872
|
-
|
|
3873
|
-
// src/indexer.ts
|
|
3874
|
-
var import_debug = __toESM(require_src());
|
|
3875
|
-
var debug = (0, import_debug.default)("verdaccio:search:indexer");
|
|
3876
|
-
var SearchMemoryIndexer = class {
|
|
3877
|
-
database;
|
|
3878
|
-
storage;
|
|
3879
|
-
logger;
|
|
3880
|
-
configureStorage(storage) {
|
|
3881
|
-
this.storage = storage;
|
|
3882
|
-
}
|
|
3883
|
-
async query(term) {
|
|
3884
|
-
if (this.database) {
|
|
3885
|
-
debug("searching %s at indexer", term);
|
|
3886
|
-
const searchResult = await search2(this.database, {
|
|
3887
|
-
term
|
|
3888
|
-
});
|
|
3889
|
-
return searchResult;
|
|
3890
|
-
}
|
|
3891
|
-
}
|
|
3892
|
-
prepareKeywords(keywords) {
|
|
3893
|
-
if (typeof keywords === "undefined") {
|
|
3894
|
-
return "";
|
|
3895
|
-
} else if (typeof keywords === "string") {
|
|
3896
|
-
return keywords;
|
|
3897
|
-
}
|
|
3898
|
-
return keywords.join(",");
|
|
3899
|
-
}
|
|
3900
|
-
async add(pkg) {
|
|
3901
|
-
if (this.database) {
|
|
3902
|
-
const name = pkg.name;
|
|
3903
|
-
debug("adding item %s to the indexer", name);
|
|
3904
|
-
const item = {
|
|
3905
|
-
id: name,
|
|
3906
|
-
name,
|
|
3907
|
-
description: pkg.description,
|
|
3908
|
-
version: pkg.version,
|
|
3909
|
-
keywords: this.prepareKeywords(pkg.keywords),
|
|
3910
|
-
author: pkg._npmUser ? pkg._npmUser.name : ""
|
|
3911
|
-
};
|
|
3912
|
-
await insert6(this.database, item);
|
|
3913
|
-
}
|
|
3914
|
-
}
|
|
3915
|
-
async remove(name) {
|
|
3916
|
-
if (this.database) {
|
|
3917
|
-
debug("removing item %s to the indexer", name);
|
|
3918
|
-
await remove5(this.database, name);
|
|
3919
|
-
}
|
|
3920
|
-
}
|
|
3921
|
-
async reindex() {
|
|
3922
|
-
var _a2;
|
|
3923
|
-
debug("reindexing search indexer");
|
|
3924
|
-
(_a2 = this.storage) == null ? void 0 : _a2.getLocalDatabase(async (error, packages) => {
|
|
3925
|
-
var _a3;
|
|
3926
|
-
if (error) {
|
|
3927
|
-
throw error;
|
|
3928
|
-
}
|
|
3929
|
-
let i = packages.length;
|
|
3930
|
-
if (i === 0) {
|
|
3931
|
-
debug("no packages to index");
|
|
3932
|
-
}
|
|
3933
|
-
while (i--) {
|
|
3934
|
-
const pkg = packages[i];
|
|
3935
|
-
debug("indexing package %s", pkg == null ? void 0 : pkg.name);
|
|
3936
|
-
try {
|
|
3937
|
-
await this.add(pkg);
|
|
3938
|
-
} catch (err) {
|
|
3939
|
-
(_a3 = this.logger) == null ? void 0 : _a3.error({ err: err.message }, "error @{err} indexing package");
|
|
3940
|
-
}
|
|
3941
|
-
}
|
|
3942
|
-
debug("reindexed search indexer");
|
|
3943
|
-
});
|
|
3944
|
-
}
|
|
3945
|
-
async init(logger) {
|
|
3946
|
-
this.logger = logger;
|
|
3947
|
-
this.database = await create7({
|
|
3948
|
-
schema: {
|
|
3949
|
-
id: "string",
|
|
3950
|
-
name: "string",
|
|
3951
|
-
description: "string",
|
|
3952
|
-
keywords: "string",
|
|
3953
|
-
version: "string",
|
|
3954
|
-
readme: "string"
|
|
3955
|
-
}
|
|
3956
|
-
});
|
|
3957
|
-
this.reindex();
|
|
3958
|
-
}
|
|
3959
|
-
};
|
|
3960
|
-
var indexer_default = new SearchMemoryIndexer();
|
|
3961
|
-
module.exports = __toCommonJS(src_exports);
|
|
3962
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
3963
|
-
0 && (module.exports = {
|
|
3964
|
-
SearchMemoryIndexer
|
|
3965
|
-
});
|