@delali/narsil 0.3.1-next.69 → 0.3.1-next.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{capabilities-B1wz2Zl0.d.ts → capabilities-Dt-7B4Wz.d.ts} +2 -2
- package/dist/{chunk-DD5X23E6.mjs → chunk-2STVUTNA.mjs} +1 -1
- package/dist/chunk-3JGWULDF.mjs +256 -0
- package/dist/{chunk-6TGZG2TV.mjs → chunk-653BNMAF.mjs} +190 -58
- package/dist/{chunk-YA52AC2V.mjs → chunk-FVLQ63B7.mjs} +203 -9
- package/dist/{chunk-5JLSTECC.mjs → chunk-GIVAGD3Q.mjs} +1 -1
- package/dist/{chunk-AV4IJKD2.mjs → chunk-HWQLTLNG.mjs} +18 -1
- package/dist/{chunk-4VU5TWCR.mjs → chunk-LMO5TJUS.mjs} +40 -35
- package/dist/{chunk-BEWOA4VV.mjs → chunk-M76V3OGJ.mjs} +508 -401
- package/dist/{chunk-YMZCMH5M.mjs → chunk-OI42GWLR.mjs} +17 -1
- package/dist/{chunk-2BDG2IWP.mjs → chunk-P4DSQ6M4.mjs} +16 -6
- package/dist/{chunk-6IT3MH5M.mjs → chunk-VNMTB3KC.mjs} +130 -216
- package/dist/{chunk-THYRHHO2.mjs → chunk-YJDQ7NLA.mjs} +1 -1
- package/dist/{client-xVrOCYTW.d.ts → client-COek5GXK.d.ts} +3 -3
- package/dist/client.d.ts +8 -8
- package/dist/{config-CEeSV_Xo.d.ts → config-Dfanyqqt.d.ts} +2 -2
- package/dist/{config-CSvCVtB7.d.ts → config-rBpbgTw8.d.ts} +2 -2
- package/dist/direct-executor-GYJEKNV5.mjs +12 -0
- package/dist/distribution/coordinator/etcd.d.ts +2 -2
- package/dist/distribution/coordinator/etcd.mjs +1 -1
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution/coordinator/in-memory.mjs +1 -1
- package/dist/distribution.d.ts +8 -8
- package/dist/distribution.mjs +109 -69
- package/dist/{engine-77ErLy8P.d.ts → engine-CXKfmK7I.d.ts} +12 -5
- package/dist/index.browser.mjs +1132 -740
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +10 -10
- package/dist/invalidation/filesystem.mjs +1 -1
- package/dist/{memory-CKF-9WLP.d.ts → memory-C7UMCMH3.d.ts} +35 -17
- package/dist/persistence/durability/checkpoint-worker.d.ts +2 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +10 -10
- package/dist/react.d.ts +6 -6
- package/dist/{schema-d5Afu03A.d.ts → schema-Bgzr4g7b.d.ts} +62 -10
- package/dist/server.d.ts +10 -10
- package/dist/server.mjs +11 -7
- package/dist/{tasks-BEiNxDRs.d.ts → tasks-BZt_zes6.d.ts} +3 -1
- package/dist/{thread-FLP45EUD.mjs → thread-JEVAYETR.mjs} +6 -6
- package/dist/{types-DAK7mnUZ.d.ts → types-gOUqhs2F.d.ts} +1 -1
- package/dist/vector/search-worker.d.ts +1 -1
- package/dist/vector/search-worker.mjs +2 -2
- package/dist/workers/entry.mjs +3 -3
- package/package.json +7 -7
- package/dist/chunk-VTPLKNWI.mjs +0 -135
- package/dist/direct-executor-3ZYXSGFX.mjs +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { b as StopWordOverride, C as CustomTokenizer } from './schema-
|
|
2
|
-
export { A as AnyDocument, B as BM25Params, E as EmbeddingFieldConfig, F as FieldType, I as IndexConfig, a as InsertOptions, P as PartitionConfig, S as SchemaDefinition,
|
|
1
|
+
import { b as StopWordOverride, C as CustomTokenizer } from './schema-Bgzr4g7b.js';
|
|
2
|
+
export { A as AnyDocument, B as BM25Params, E as EmbeddingFieldConfig, F as FieldOptionChain, c as FieldType, I as IndexConfig, a as InsertOptions, P as PartitionConfig, S as SchemaDefinition, d as ScoringMode, T as TextFieldOption, V as VectorIndexConfig, e as VectorQuantizationMode, f as VectorStorageMode, W as WriteOptions } from './schema-Bgzr4g7b.js';
|
|
3
3
|
import { L as LanguageModule } from './language-DB8KG1z5.js';
|
|
4
4
|
export { T as TokenizerConfig } from './language-DB8KG1z5.js';
|
|
5
|
-
export { A as ArrayFilter, B as BatchResult, C as ClientErrorCode, a as ClientErrorCodes, l as ComparisonFilter, D as DocumentProjection, E as ErrorCode, b as ErrorCodes, F as FacetConfig, m as FacetResult, n as FieldFilter, o as FilterExpression, G as GeoFilter, p as GeoPolygonFilter, q as GeoRadiusFilter, r as GroupConfig, s as GroupReducer, t as GroupResult, H as HighlightConfig, u as HighlightMatch, v as Hit, w as HybridConfig, I as IndexInfo, f as IndexStats, L as ListParams, g as ListResult, x as ListedDocument, M as MemoryStats, N as NarsilError, c as NarsilErrorCode, P as PartitionStatsResult, h as PreflightResult, y as PresenceFilter, z as ProcessMemoryReport, J as QueryCoverage, Q as QueryParams, e as QueryResult, K as ScoreComponents, O as SearchMode, S as ServerErrorCode, d as ServerErrorCodes, R as SortField, T as SortSpec, U as StringFilter, j as SuggestParams, k as SuggestResult, W as TermMatchPolicy, V as VectorMaintenanceResult, X as VectorQueryConfig, Y as WorkerCopyReport, i as isNarsilError } from './memory-
|
|
6
|
-
import { N as NarsilConfig } from './config-
|
|
7
|
-
export { A as AnalysisConfig, D as DurabilityConfig, I as IndexContext, a as IndexLifecycleConfig, b as InsertContext, M as MainCopyQueries, c as NarsilPlugin, P as PartitionContext, R as RemoveContext, S as SearchContext, d as StaleAnalysis, U as UpdateContext, W as WorkerConfig, e as WorkerContext } from './config-
|
|
8
|
-
import { a as Narsil } from './engine-
|
|
9
|
-
export { D as DocumentWriteOperations, I as IndexLifecycleOperations, N as NarsilEventMap } from './engine-
|
|
5
|
+
export { A as ArrayFilter, B as BatchResult, C as ClientErrorCode, a as ClientErrorCodes, l as ComparisonFilter, D as DocumentProjection, E as ErrorCode, b as ErrorCodes, F as FacetConfig, m as FacetResult, n as FieldFilter, o as FilterExpression, G as GeoFilter, p as GeoPolygonFilter, q as GeoRadiusFilter, r as GroupConfig, s as GroupReducer, t as GroupResult, H as HighlightConfig, u as HighlightMatch, v as Hit, w as HybridConfig, I as IndexInfo, f as IndexStats, L as ListParams, g as ListResult, x as ListedDocument, M as MemoryStats, N as NarsilError, c as NarsilErrorCode, P as PartitionStatsResult, h as PreflightResult, y as PresenceFilter, z as ProcessMemoryReport, J as QueryCoverage, Q as QueryParams, e as QueryResult, K as ScoreComponents, O as SearchMode, S as ServerErrorCode, d as ServerErrorCodes, R as SortField, T as SortSpec, U as StringFilter, j as SuggestParams, k as SuggestResult, W as TermMatchPolicy, V as VectorMaintenanceResult, X as VectorQueryConfig, Y as WorkerCopyReport, i as isNarsilError } from './memory-C7UMCMH3.js';
|
|
6
|
+
import { N as NarsilConfig } from './config-Dfanyqqt.js';
|
|
7
|
+
export { A as AnalysisConfig, D as DurabilityConfig, I as IndexContext, a as IndexLifecycleConfig, b as InsertContext, M as MainCopyQueries, c as NarsilPlugin, P as PartitionContext, R as RemoveContext, S as SearchContext, d as StaleAnalysis, U as UpdateContext, W as WorkerConfig, e as WorkerContext } from './config-Dfanyqqt.js';
|
|
8
|
+
import { a as Narsil } from './engine-CXKfmK7I.js';
|
|
9
|
+
export { D as DocumentWriteOperations, I as IndexLifecycleOperations, N as NarsilEventMap } from './engine-CXKfmK7I.js';
|
|
10
10
|
export { E as EmbeddingAdapter, I as InvalidationAdapter, a as InvalidationEvent, b as PartitionStatistics, P as PersistenceAdapter } from './adapters-79OIa4xm.js';
|
|
11
11
|
export { i as isSimdAvailable } from './simd-DW5AtJ6B.js';
|
|
12
12
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { VERSION, createNarsil } from './chunk-
|
|
1
|
+
export { VERSION, createNarsil } from './chunk-VNMTB3KC.mjs';
|
|
2
2
|
import './chunk-GCM3JFVA.mjs';
|
|
3
|
-
import './chunk-
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
import './chunk-
|
|
7
|
-
import './chunk-
|
|
8
|
-
export { clearNormalizationCache, configureNormalizationCache, getNormalizationCacheSize, resetNormalizationCache } from './chunk-
|
|
9
|
-
import './chunk-
|
|
3
|
+
import './chunk-FVLQ63B7.mjs';
|
|
4
|
+
export { getStopWords, getTokenizer, hasStopWords, hasTokenizer, registerStopWords, registerTokenizer } from './chunk-M76V3OGJ.mjs';
|
|
5
|
+
export { getLanguage, registerLanguage } from './chunk-HWQLTLNG.mjs';
|
|
6
|
+
import './chunk-P4DSQ6M4.mjs';
|
|
7
|
+
import './chunk-GIVAGD3Q.mjs';
|
|
8
|
+
export { clearNormalizationCache, configureNormalizationCache, getNormalizationCacheSize, resetNormalizationCache } from './chunk-LMO5TJUS.mjs';
|
|
9
|
+
import './chunk-653BNMAF.mjs';
|
|
10
10
|
import './chunk-TGP5M5R7.mjs';
|
|
11
|
-
export { isSimdAvailable } from './chunk-
|
|
11
|
+
export { isSimdAvailable } from './chunk-YJDQ7NLA.mjs';
|
|
12
12
|
import './chunk-ZJ4CSAB2.mjs';
|
|
13
13
|
import './chunk-YNVIUGF5.mjs';
|
|
14
14
|
import './chunk-3L4U6EJQ.mjs';
|
|
15
15
|
import './chunk-IFBKLBGB.mjs';
|
|
16
16
|
import './chunk-U2BKYEC7.mjs';
|
|
17
|
-
import './chunk-
|
|
17
|
+
import './chunk-OI42GWLR.mjs';
|
|
18
18
|
import './chunk-POWOTUKJ.mjs';
|
|
19
19
|
export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, isNarsilError } from './chunk-USKFU7J5.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AnyDocument, S as SchemaDefinition,
|
|
1
|
+
import { A as AnyDocument, S as SchemaDefinition, d as ScoringMode } from './schema-Bgzr4g7b.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Every code a {@link NarsilError} carries, grouped by the part of the engine
|
|
@@ -593,19 +593,36 @@ type ComparisonFilter = {
|
|
|
593
593
|
between?: [number, number];
|
|
594
594
|
};
|
|
595
595
|
/**
|
|
596
|
-
*
|
|
597
|
-
*
|
|
596
|
+
* The engine tests a text field against this filter for equality, for a text
|
|
597
|
+
* range, or with the set and prefix tests.
|
|
598
598
|
*
|
|
599
|
-
*
|
|
600
|
-
* `eq`, `in`, `startsWith`,
|
|
601
|
-
*
|
|
599
|
+
* The engine compares each element of a `string[]` or `verbatim[]` field, so
|
|
600
|
+
* it matches a document with `eq`, `in`, `startsWith`, or `endsWith` where
|
|
601
|
+
* one element passes the test, while it matches a document with `ne` or `nin`
|
|
602
|
+
* where every element differs from the values.
|
|
603
|
+
*
|
|
604
|
+
* The engine applies the range tests `gt`, `gte`, `lt`, `lte`, and `between`
|
|
605
|
+
* to a single `string` or `verbatim` field whose type includes `sortable`,
|
|
606
|
+
* while it throws `SEARCH_INVALID_FILTER` for a text range on any other field.
|
|
607
|
+
* It orders the values as a sort on the field does, comparing their case folds
|
|
608
|
+
* first and their raw code points only where the folds are equal.
|
|
602
609
|
*
|
|
603
610
|
* @public
|
|
604
611
|
*/
|
|
605
|
-
type StringFilter = ComparisonFilter & {
|
|
612
|
+
type StringFilter = Pick<ComparisonFilter, 'eq' | 'ne'> & {
|
|
613
|
+
/** This matches a value that comes after the text in sort order. */
|
|
614
|
+
gt?: string;
|
|
615
|
+
/** This matches a value that comes before the text in sort order. */
|
|
616
|
+
lt?: string;
|
|
617
|
+
/** This matches a value equal to the text or after it in sort order. */
|
|
618
|
+
gte?: string;
|
|
619
|
+
/** This matches a value equal to the text or before it in sort order. */
|
|
620
|
+
lte?: string;
|
|
621
|
+
/** This matches a value inside the inclusive range in sort order, given as `[low, high]`. */
|
|
622
|
+
between?: [string, string];
|
|
606
623
|
/** This matches a field equal to any value in the list. */
|
|
607
624
|
in?: string[];
|
|
608
|
-
/** This matches a field
|
|
625
|
+
/** This matches a field that differs from every value in the list. */
|
|
609
626
|
nin?: string[];
|
|
610
627
|
/** This matches a field starting with the text. */
|
|
611
628
|
startsWith?: string;
|
|
@@ -915,15 +932,16 @@ interface QueryParams {
|
|
|
915
932
|
/**
|
|
916
933
|
* The engine sorts the hits by the values of these fields, in place of the
|
|
917
934
|
* relevance ranking. Pass an object keyed by field, or a list of fields in
|
|
918
|
-
* the order that the engine compares them.
|
|
919
|
-
* `boolean`,
|
|
920
|
-
*
|
|
921
|
-
* `SEARCH_INVALID_FIELD` for a sort on a
|
|
922
|
-
* vector field, because
|
|
923
|
-
*
|
|
924
|
-
*
|
|
925
|
-
*
|
|
926
|
-
*
|
|
935
|
+
* the order that the engine compares them. The engine sorts by a `number`,
|
|
936
|
+
* `boolean`, or `enum` field, by a text field whose type includes
|
|
937
|
+
* `sortable`, or by a list of any of these, which it reduces to one value by
|
|
938
|
+
* the entry's `mode`. It throws `SEARCH_INVALID_FIELD` for a sort on a
|
|
939
|
+
* `geopoint` or a vector field, because neither type has an order. It throws
|
|
940
|
+
* the same code for a sort on any other text field, since the engine keeps
|
|
941
|
+
* up to the first 512 code points of every document's value in memory to
|
|
942
|
+
* sort by a text field. The engine orders hybrid results by fusion, so it
|
|
943
|
+
* throws `SEARCH_INVALID_MODE` for a sort on a hybrid query. It also throws
|
|
944
|
+
* that code for a direction other than `asc` and `desc`.
|
|
927
945
|
*/
|
|
928
946
|
sort?: SortSpec;
|
|
929
947
|
/** These settings collapse the hits into groups by field value. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PartitionConfig,
|
|
1
|
+
import { P as PartitionConfig, d as ScoringMode, V as VectorIndexConfig } from '../../schema-Bgzr4g7b.js';
|
|
2
2
|
import '../../adapters-79OIa4xm.js';
|
|
3
3
|
|
|
4
4
|
interface IndexMetadata {
|
|
@@ -36,6 +36,7 @@ interface IndexMetadata {
|
|
|
36
36
|
strict?: boolean;
|
|
37
37
|
required?: string[];
|
|
38
38
|
vectorPromotion?: VectorIndexConfig;
|
|
39
|
+
patternValueLimit?: number;
|
|
39
40
|
}
|
|
40
41
|
/** Persisted so recovery can restore field mappings and rebind the adapter by
|
|
41
42
|
* name; the name is absent when the index was configured with a bare instance. */
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { CHECKPOINT_WORKER_HEARTBEAT_MS, createDurableDirectory, writeCheckpointSegments } from '../../chunk-
|
|
1
|
+
import { CHECKPOINT_WORKER_HEARTBEAT_MS, createDurableDirectory, writeCheckpointSegments } from '../../chunk-VNMTB3KC.mjs';
|
|
2
2
|
import '../../chunk-GCM3JFVA.mjs';
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
7
|
-
import '../../chunk-
|
|
8
|
-
import '../../chunk-
|
|
9
|
-
import '../../chunk-
|
|
3
|
+
import '../../chunk-FVLQ63B7.mjs';
|
|
4
|
+
import '../../chunk-M76V3OGJ.mjs';
|
|
5
|
+
import '../../chunk-HWQLTLNG.mjs';
|
|
6
|
+
import '../../chunk-P4DSQ6M4.mjs';
|
|
7
|
+
import '../../chunk-GIVAGD3Q.mjs';
|
|
8
|
+
import '../../chunk-LMO5TJUS.mjs';
|
|
9
|
+
import '../../chunk-653BNMAF.mjs';
|
|
10
10
|
import '../../chunk-TGP5M5R7.mjs';
|
|
11
|
-
import '../../chunk-
|
|
11
|
+
import '../../chunk-YJDQ7NLA.mjs';
|
|
12
12
|
import '../../chunk-ZJ4CSAB2.mjs';
|
|
13
13
|
import '../../chunk-YNVIUGF5.mjs';
|
|
14
14
|
import '../../chunk-3L4U6EJQ.mjs';
|
|
15
15
|
import '../../chunk-IFBKLBGB.mjs';
|
|
16
16
|
import '../../chunk-U2BKYEC7.mjs';
|
|
17
|
-
import '../../chunk-
|
|
17
|
+
import '../../chunk-OI42GWLR.mjs';
|
|
18
18
|
import '../../chunk-POWOTUKJ.mjs';
|
|
19
19
|
import '../../chunk-USKFU7J5.mjs';
|
|
20
20
|
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { N as NarsilError, L as ListParams, g as ListResult, I as IndexInfo, f as IndexStats, Q as QueryParams, h as PreflightResult, e as QueryResult, j as SuggestParams, k as SuggestResult } from './memory-
|
|
2
|
-
export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes, i as isNarsilError } from './memory-
|
|
3
|
-
import { e as TaskRecord, d as TaskProgress, b as ImportResult, c as TaskListQuery, T as TaskListPage } from './tasks-
|
|
4
|
-
export { I as ImportError, f as TaskStatus, g as TaskType } from './tasks-
|
|
1
|
+
import { N as NarsilError, L as ListParams, g as ListResult, I as IndexInfo, f as IndexStats, Q as QueryParams, h as PreflightResult, e as QueryResult, j as SuggestParams, k as SuggestResult } from './memory-C7UMCMH3.js';
|
|
2
|
+
export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes, i as isNarsilError } from './memory-C7UMCMH3.js';
|
|
3
|
+
import { e as TaskRecord, d as TaskProgress, b as ImportResult, c as TaskListQuery, T as TaskListPage } from './tasks-BZt_zes6.js';
|
|
4
|
+
export { I as ImportError, f as TaskStatus, g as TaskType } from './tasks-BZt_zes6.js';
|
|
5
5
|
import { ReactNode, ReactElement } from 'react';
|
|
6
|
-
import { N as NarsilClient, I as ImportSource } from './client-
|
|
7
|
-
import { A as AnyDocument } from './schema-
|
|
6
|
+
import { N as NarsilClient, I as ImportSource } from './client-COek5GXK.js';
|
|
7
|
+
import { A as AnyDocument } from './schema-Bgzr4g7b.js';
|
|
8
8
|
import './adapters-79OIa4xm.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -13,20 +13,63 @@ type AnyDocument = Record<string, unknown> & {
|
|
|
13
13
|
id?: string;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Each of these options can follow the base type of a `string` or `string[]`
|
|
17
|
+
* field after a colon, as in `string:sortable:pattern`.
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* The engine can sort by a field whose type includes `sortable`. On a single
|
|
20
|
+
* `string` field with that option, the engine can also test a text range with
|
|
21
|
+
* `gt`, `gte`, `lt`, `lte`, or `between`. The engine raises
|
|
22
|
+
* `DOC_VALIDATION_FAILED` for a value longer than
|
|
23
|
+
* {@link IndexConfig.patternValueLimit} in a field whose type includes
|
|
24
|
+
* `pattern`. A later release will add pattern search and partial-word search,
|
|
25
|
+
* which will test the fields whose types include `pattern` and `partial`
|
|
26
|
+
* respectively.
|
|
22
27
|
*
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
type TextFieldOption = 'sortable' | 'pattern' | 'partial';
|
|
31
|
+
/**
|
|
32
|
+
* This union contains every string of options that can follow a base type,
|
|
33
|
+
* with each option after a colon. The options can come in any order, although
|
|
34
|
+
* each one can appear only once.
|
|
26
35
|
*
|
|
27
36
|
* @public
|
|
28
37
|
*/
|
|
29
|
-
type
|
|
38
|
+
type FieldOptionChain<Remaining extends string> = {
|
|
39
|
+
[Option in Remaining]: `:${Option}` | `:${Option}${FieldOptionChain<Exclude<Remaining, Option>>}`;
|
|
40
|
+
}[Remaining];
|
|
41
|
+
/**
|
|
42
|
+
* The engine indexes each field of a schema according to the field's type,
|
|
43
|
+
* which is one of these.
|
|
44
|
+
*
|
|
45
|
+
* The engine splits a `string` value into words, so it can find the document
|
|
46
|
+
* by any word in the value. It can filter and sort by a `number`, `boolean`,
|
|
47
|
+
* or `enum` field. A `geopoint` value is a latitude and longitude pair. A
|
|
48
|
+
* `vector[N]` value is an embedding with N dimensions. For each list form, the
|
|
49
|
+
* engine indexes every element of the list.
|
|
50
|
+
*
|
|
51
|
+
* The engine stores and compares a `verbatim` value exactly as written, as one
|
|
52
|
+
* piece of text. Because the engine keeps that value whole, it leaves the
|
|
53
|
+
* field out of keyword search, although it can test the whole value in a
|
|
54
|
+
* filter.
|
|
55
|
+
*
|
|
56
|
+
* Add the {@link TextFieldOption} options to a `string` or `string[]` type, or
|
|
57
|
+
* `sortable` alone to a `verbatim` or `verbatim[]` type, as in
|
|
58
|
+
* `string:sortable:pattern` or `verbatim[]:sortable`. The engine stores the
|
|
59
|
+
* options in the order `sortable`, `pattern`, `partial`, whatever their order
|
|
60
|
+
* in the type name. It raises `SCHEMA_INVALID_TYPE` for any other
|
|
61
|
+
* option, such as `number:sortable` or `verbatim:pattern`, and for an option
|
|
62
|
+
* written twice.
|
|
63
|
+
*
|
|
64
|
+
* To sort by a text field, the engine keeps up to the first 512 code points of
|
|
65
|
+
* every document's value in memory, against 8 bytes per document for a number
|
|
66
|
+
* field. For that reason, the engine sorts by a text field only where the
|
|
67
|
+
* field's type includes `sortable`, while it raises `SEARCH_INVALID_FIELD`
|
|
68
|
+
* for a sort on any other text field.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
type FieldType = 'string' | `string${FieldOptionChain<TextFieldOption>}` | 'string[]' | `string[]${FieldOptionChain<TextFieldOption>}` | 'verbatim' | 'verbatim:sortable' | 'verbatim[]' | 'verbatim[]:sortable' | 'number' | 'boolean' | 'enum' | 'geopoint' | `vector[${number}]` | 'number[]' | 'boolean[]' | 'enum[]';
|
|
30
73
|
/**
|
|
31
74
|
* The field layout of an index, written as a plain object.
|
|
32
75
|
*
|
|
@@ -173,6 +216,15 @@ interface IndexConfig {
|
|
|
173
216
|
* insert throughput and one entry per changed spelling.
|
|
174
217
|
*/
|
|
175
218
|
surfaceForms?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* The engine raises `DOC_VALIDATION_FAILED` for a document whose value in a
|
|
221
|
+
* `verbatim` field, or in a field whose type includes `pattern`, is longer
|
|
222
|
+
* than this many code points. It tests each element of a list on its own.
|
|
223
|
+
* Set a whole number from 1 to 65,536, or leave this unset for a limit of
|
|
224
|
+
* 8,192. For any other value, {@link Narsil.createIndex} throws
|
|
225
|
+
* `CONFIG_INVALID`.
|
|
226
|
+
*/
|
|
227
|
+
patternValueLimit?: number;
|
|
176
228
|
}
|
|
177
229
|
/**
|
|
178
230
|
* BM25 tuning for an index.
|
|
@@ -286,4 +338,4 @@ interface InsertOptions extends WriteOptions {
|
|
|
286
338
|
skipClone?: boolean;
|
|
287
339
|
}
|
|
288
340
|
|
|
289
|
-
export type { AnyDocument as A, BM25Params as B, CustomTokenizer as C, EmbeddingFieldConfig as E,
|
|
341
|
+
export type { AnyDocument as A, BM25Params as B, CustomTokenizer as C, EmbeddingFieldConfig as E, FieldOptionChain as F, IndexConfig as I, PartitionConfig as P, SchemaDefinition as S, TextFieldOption as T, VectorIndexConfig as V, WriteOptions as W, InsertOptions as a, StopWordOverride as b, FieldType as c, ScoringMode as d, VectorQuantizationMode as e, VectorStorageMode as f };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, N as NarsilError, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes, i as isNarsilError } from './memory-
|
|
2
|
-
import { b as ServerOptions, N as NarsilServer } from './capabilities-
|
|
3
|
-
export { A as ASYNC_IMPORT_CAPABILITY, C as CorsOptions, E as ErrorEnvelope, I as INDEX_LIFECYCLE_CAPABILITY, O as OnRequestHook, R as REBUILD_ANALYSIS_CAPABILITY, c as RequestContext, d as RequestDenial, S as SERVER_CAPABILITIES, e as ServerLimits, T as TASK_CANCEL_CAPABILITY, a as TASK_FILTER_CAPABILITY } from './capabilities-
|
|
4
|
-
import { a as Narsil } from './engine-
|
|
5
|
-
import { d as TaskProgress, b as ImportResult, h as TaskStore, e as TaskRecord } from './tasks-
|
|
6
|
-
export { C as CapabilitiesResponse, a as CreateIndexEmbedding, i as CreateIndexRequest, H as HttpIndexConfig, I as ImportError, M as MemoryStatsResponse, T as TaskListPage, c as TaskListQuery, f as TaskStatus, g as TaskType } from './tasks-
|
|
7
|
-
import './schema-
|
|
1
|
+
export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, N as NarsilError, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes, i as isNarsilError } from './memory-C7UMCMH3.js';
|
|
2
|
+
import { b as ServerOptions, N as NarsilServer } from './capabilities-Dt-7B4Wz.js';
|
|
3
|
+
export { A as ASYNC_IMPORT_CAPABILITY, C as CorsOptions, E as ErrorEnvelope, I as INDEX_LIFECYCLE_CAPABILITY, O as OnRequestHook, R as REBUILD_ANALYSIS_CAPABILITY, c as RequestContext, d as RequestDenial, S as SERVER_CAPABILITIES, e as ServerLimits, T as TASK_CANCEL_CAPABILITY, a as TASK_FILTER_CAPABILITY } from './capabilities-Dt-7B4Wz.js';
|
|
4
|
+
import { a as Narsil } from './engine-CXKfmK7I.js';
|
|
5
|
+
import { d as TaskProgress, b as ImportResult, h as TaskStore, e as TaskRecord } from './tasks-BZt_zes6.js';
|
|
6
|
+
export { C as CapabilitiesResponse, a as CreateIndexEmbedding, i as CreateIndexRequest, H as HttpIndexConfig, I as ImportError, M as MemoryStatsResponse, T as TaskListPage, c as TaskListQuery, f as TaskStatus, g as TaskType } from './tasks-BZt_zes6.js';
|
|
7
|
+
import './schema-Bgzr4g7b.js';
|
|
8
8
|
import './adapters-79OIa4xm.js';
|
|
9
|
-
import './config-
|
|
10
|
-
import './config-
|
|
11
|
-
import './types-
|
|
9
|
+
import './config-rBpbgTw8.js';
|
|
10
|
+
import './config-Dfanyqqt.js';
|
|
11
|
+
import './types-gOUqhs2F.js';
|
|
12
12
|
import './types-D5OwhtsQ.js';
|
|
13
13
|
|
|
14
14
|
/**
|
package/dist/server.mjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { DEFAULT_MAX_RETAINED_TASKS, loadUWebSockets, resolveCors, authorizerFor, createSharedGateBuffer, gateSlotOfWorker, createRouteRunner, corsHeaderReader, createSharedRequestGate, MAIN_THREAD_GATE_SLOT, registerServerRoutes, DEFAULT_MAX_CONCURRENT_TASKS, DEFAULT_MAX_TASK_PAGE_SIZE, DEFAULT_MAX_IMPORT_ERRORS, DEFAULT_MAX_FETCH_DOCUMENTS, DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_CONCURRENT_REQUESTS, DEFAULT_IMPORT_BATCH_SIZE, DEFAULT_MAX_LINE_BYTES, DEFAULT_MAX_IMPORT_BYTES, DEFAULT_MAX_BODY_BYTES, RUNNING_TASK_TTL_MS, DEFAULT_TASK_PAGE_SIZE, TERMINAL_TASK_TTL_MS, TASK_PROGRESS_WRITE_INTERVAL_MS, serializeNarsilError, createVersionHandler, acceptorOf, createDocumentReadHandlers, sendError, respondError, respondJson, MAX_INDEX_TOUCH_INTERVAL_MS, INDEX_TOUCH_INTERVALS_PER_IDLE_TIMEOUT, clearGateSlot, parseJson, validateCreateIndex, rejectInvalid, validateBatch, serializeBatchResult, validateDocumentBody, validateSuggest, validateQuery, parseTaskListQuery, parseJsonOptional, validateRebalance, sendBinary, IMPORT_FLUSHES_IN_FLIGHT, badRequest, SERVER_CAPABILITIES, toHttpError, MIN_UNBOUNDED_SERVER_LIMIT, MIN_COUNTED_SERVER_LIMIT } from './chunk-
|
|
2
|
-
export { ASYNC_IMPORT_CAPABILITY, INDEX_LIFECYCLE_CAPABILITY, REBUILD_ANALYSIS_CAPABILITY, SERVER_CAPABILITIES, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, httpStatusForNarsilError } from './chunk-
|
|
3
|
-
import { validateIndexName } from './chunk-
|
|
4
|
-
import { engineCoreOf, providedDocId, resolveVectorText } from './chunk-
|
|
5
|
-
import { detectRuntime } from './chunk-
|
|
6
|
-
import './chunk-
|
|
7
|
-
import './chunk-
|
|
1
|
+
import { DEFAULT_MAX_RETAINED_TASKS, loadUWebSockets, resolveCors, authorizerFor, createSharedGateBuffer, gateSlotOfWorker, createRouteRunner, corsHeaderReader, createSharedRequestGate, MAIN_THREAD_GATE_SLOT, registerServerRoutes, DEFAULT_MAX_CONCURRENT_TASKS, DEFAULT_MAX_TASK_PAGE_SIZE, DEFAULT_MAX_IMPORT_ERRORS, DEFAULT_MAX_FETCH_DOCUMENTS, DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_CONCURRENT_REQUESTS, DEFAULT_IMPORT_BATCH_SIZE, DEFAULT_MAX_LINE_BYTES, DEFAULT_MAX_IMPORT_BYTES, DEFAULT_MAX_BODY_BYTES, RUNNING_TASK_TTL_MS, DEFAULT_TASK_PAGE_SIZE, TERMINAL_TASK_TTL_MS, TASK_PROGRESS_WRITE_INTERVAL_MS, serializeNarsilError, createVersionHandler, acceptorOf, createDocumentReadHandlers, sendError, respondError, respondJson, MAX_INDEX_TOUCH_INTERVAL_MS, INDEX_TOUCH_INTERVALS_PER_IDLE_TIMEOUT, clearGateSlot, parseJson, validateCreateIndex, rejectInvalid, validateBatch, serializeBatchResult, validateDocumentBody, validateSuggest, validateQuery, parseTaskListQuery, parseJsonOptional, validateRebalance, sendBinary, IMPORT_FLUSHES_IN_FLIGHT, badRequest, SERVER_CAPABILITIES, toHttpError, MIN_UNBOUNDED_SERVER_LIMIT, MIN_COUNTED_SERVER_LIMIT } from './chunk-2STVUTNA.mjs';
|
|
2
|
+
export { ASYNC_IMPORT_CAPABILITY, INDEX_LIFECYCLE_CAPABILITY, REBUILD_ANALYSIS_CAPABILITY, SERVER_CAPABILITIES, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, httpStatusForNarsilError } from './chunk-2STVUTNA.mjs';
|
|
3
|
+
import { validateIndexName } from './chunk-3JGWULDF.mjs';
|
|
4
|
+
import { engineCoreOf, providedDocId, resolveVectorText } from './chunk-FVLQ63B7.mjs';
|
|
5
|
+
import { detectRuntime } from './chunk-HWQLTLNG.mjs';
|
|
6
|
+
import './chunk-GIVAGD3Q.mjs';
|
|
7
|
+
import './chunk-653BNMAF.mjs';
|
|
8
|
+
import './chunk-TGP5M5R7.mjs';
|
|
8
9
|
import './chunk-YNVIUGF5.mjs';
|
|
10
|
+
import './chunk-U2BKYEC7.mjs';
|
|
11
|
+
import './chunk-OI42GWLR.mjs';
|
|
9
12
|
import { startIdleHeapCleanup } from './chunk-Y3L5MDRV.mjs';
|
|
10
13
|
import { NarsilError, ErrorCodes, ServerErrorCodes, isNarsilError } from './chunk-USKFU7J5.mjs';
|
|
11
14
|
export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, isNarsilError } from './chunk-USKFU7J5.mjs';
|
|
@@ -594,6 +597,7 @@ function mapHttpIndexConfig(http) {
|
|
|
594
597
|
if (http.vectorPromotion !== void 0) config.vectorPromotion = http.vectorPromotion;
|
|
595
598
|
if (http.strict !== void 0) config.strict = http.strict;
|
|
596
599
|
if (http.required !== void 0) config.required = http.required;
|
|
600
|
+
if (http.patternValueLimit !== void 0) config.patternValueLimit = http.patternValueLimit;
|
|
597
601
|
if (http.stopWords !== void 0) {
|
|
598
602
|
if (!Array.isArray(http.stopWords) || http.stopWords.some((w) => typeof w !== "string")) {
|
|
599
603
|
throw new NarsilError(ErrorCodes.CONFIG_INVALID, 'Field "stopWords" must be an array of strings');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as MemoryStats } from './memory-
|
|
1
|
+
import { M as MemoryStats } from './memory-C7UMCMH3.js';
|
|
2
2
|
|
|
3
3
|
/** Declarative index configuration accepted over HTTP. Function-valued engine
|
|
4
4
|
* options (custom tokenizer, stopWords-as-function, group reducer, embedding
|
|
@@ -68,6 +68,8 @@ interface HttpIndexConfig {
|
|
|
68
68
|
embedding?: CreateIndexEmbedding;
|
|
69
69
|
/** The server rejects a document that omits any of these fields. */
|
|
70
70
|
required?: string[];
|
|
71
|
+
/** The server returns a `DOC_VALIDATION_FAILED` error for a document whose value in a `verbatim` field, or in a field whose type includes `pattern`, is longer than this many code points. Set a whole number from 1 to 65,536, or leave this unset for a limit of 8,192. */
|
|
72
|
+
patternValueLimit?: number;
|
|
71
73
|
}
|
|
72
74
|
/**
|
|
73
75
|
* One record an import refused, naming the line it came from and why the
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { loadUWebSockets, childAppOf, createRouteRunner, corsHeaderReader, createSharedRequestGate, registerServerRoutes, sendRelayed, createDocumentReadHandlers, respondJson, SERVER_CAPABILITIES, versionReport, sendError, serverRoutes, parseJson, validateSuggest, rejectInvalid, respondError, validateQuery } from './chunk-
|
|
2
|
-
import { executeListDocuments, executeSuggest, executePreflight, queryBindingOf, executeQuery } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import { resolveProjection, projectionKeepsField, setNestedValue } from './chunk-
|
|
5
|
-
import { extractVectorFieldsFromSchema } from './chunk-
|
|
1
|
+
import { loadUWebSockets, childAppOf, createRouteRunner, corsHeaderReader, createSharedRequestGate, registerServerRoutes, sendRelayed, createDocumentReadHandlers, respondJson, SERVER_CAPABILITIES, versionReport, sendError, serverRoutes, parseJson, validateSuggest, rejectInvalid, respondError, validateQuery } from './chunk-2STVUTNA.mjs';
|
|
2
|
+
import { executeListDocuments, executeSuggest, executePreflight, queryBindingOf, executeQuery } from './chunk-P4DSQ6M4.mjs';
|
|
3
|
+
import './chunk-GIVAGD3Q.mjs';
|
|
4
|
+
import { resolveProjection, projectionKeepsField, setNestedValue } from './chunk-LMO5TJUS.mjs';
|
|
5
|
+
import { extractVectorFieldsFromSchema } from './chunk-653BNMAF.mjs';
|
|
6
6
|
import './chunk-ZJ4CSAB2.mjs';
|
|
7
7
|
import './chunk-YNVIUGF5.mjs';
|
|
8
|
-
import './chunk-
|
|
8
|
+
import './chunk-OI42GWLR.mjs';
|
|
9
9
|
import { ServerErrorCodes, NarsilError, ErrorCodes } from './chunk-USKFU7J5.mjs';
|
|
10
10
|
|
|
11
11
|
// src/server/request-threads/held-vectors.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { openSharedVectorField, MAX_WORKER_COPIES, createVectorStore, osqBitsOf, createHNSWIndex, createOsqQuantizer, osqRecordBytes } from '../chunk-
|
|
1
|
+
import { openSharedVectorField, MAX_WORKER_COPIES, createVectorStore, osqBitsOf, createHNSWIndex, createOsqQuantizer, osqRecordBytes } from '../chunk-YJDQ7NLA.mjs';
|
|
2
2
|
import '../chunk-ZJ4CSAB2.mjs';
|
|
3
3
|
import '../chunk-YNVIUGF5.mjs';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-OI42GWLR.mjs';
|
|
5
5
|
import '../chunk-USKFU7J5.mjs';
|
|
6
6
|
|
|
7
7
|
// src/vector/worker-copy.ts
|
package/dist/workers/entry.mjs
CHANGED
|
@@ -18,7 +18,7 @@ async function importBootstrapModule(moduleUrl) {
|
|
|
18
18
|
await import(moduleUrl);
|
|
19
19
|
}
|
|
20
20
|
async function stopServingRequests() {
|
|
21
|
-
const { closeRequestThread } = await import('../thread-
|
|
21
|
+
const { closeRequestThread } = await import('../thread-JEVAYETR.mjs');
|
|
22
22
|
closeRequestThread();
|
|
23
23
|
}
|
|
24
24
|
function holdsCopies(executor) {
|
|
@@ -49,7 +49,7 @@ function createActionHandler(executor) {
|
|
|
49
49
|
if (!holdsCopies(executor)) {
|
|
50
50
|
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "This executor holds no copies to answer requests from");
|
|
51
51
|
}
|
|
52
|
-
const starting = import('../thread-
|
|
52
|
+
const starting = import('../thread-JEVAYETR.mjs').then(
|
|
53
53
|
({ serveRequests }) => serveRequests(executor, action.settings)
|
|
54
54
|
);
|
|
55
55
|
serving.start = starting.then(
|
|
@@ -102,7 +102,7 @@ async function setup() {
|
|
|
102
102
|
} catch {
|
|
103
103
|
parentPort = null;
|
|
104
104
|
}
|
|
105
|
-
const { createDirectExecutor } = await import('../direct-executor-
|
|
105
|
+
const { createDirectExecutor } = await import('../direct-executor-GYJEKNV5.mjs');
|
|
106
106
|
const handleAction = createActionHandler(createDirectExecutor({ threadSlot }));
|
|
107
107
|
if (parentPort) {
|
|
108
108
|
const port = parentPort;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delali/narsil",
|
|
3
|
-
"version": "0.3.1-next.
|
|
3
|
+
"version": "0.3.1-next.70",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Distributed search engine with full-text, vector, hybrid, and geosearch. One engine, embedded or on a server, with a cross-language .nrsl format.",
|
|
6
6
|
"author": "Delali (https://sondelali.com)",
|
|
@@ -223,11 +223,11 @@
|
|
|
223
223
|
}
|
|
224
224
|
},
|
|
225
225
|
"optionalDependencies": {
|
|
226
|
-
"@delali/narsil-native-darwin-arm64": "0.3.1-next.
|
|
227
|
-
"@delali/narsil-native-darwin-x64": "0.3.1-next.
|
|
228
|
-
"@delali/narsil-native-linux-arm64": "0.3.1-next.
|
|
229
|
-
"@delali/narsil-native-linux-x64": "0.3.1-next.
|
|
230
|
-
"@delali/narsil-native-win32-arm64": "0.3.1-next.
|
|
231
|
-
"@delali/narsil-native-win32-x64": "0.3.1-next.
|
|
226
|
+
"@delali/narsil-native-darwin-arm64": "0.3.1-next.70",
|
|
227
|
+
"@delali/narsil-native-darwin-x64": "0.3.1-next.70",
|
|
228
|
+
"@delali/narsil-native-linux-arm64": "0.3.1-next.70",
|
|
229
|
+
"@delali/narsil-native-linux-x64": "0.3.1-next.70",
|
|
230
|
+
"@delali/narsil-native-win32-arm64": "0.3.1-next.70",
|
|
231
|
+
"@delali/narsil-native-win32-x64": "0.3.1-next.70"
|
|
232
232
|
}
|
|
233
233
|
}
|
package/dist/chunk-VTPLKNWI.mjs
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR } from './chunk-YA52AC2V.mjs';
|
|
2
|
-
import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN } from './chunk-5JLSTECC.mjs';
|
|
3
|
-
import { NarsilError, ErrorCodes } from './chunk-USKFU7J5.mjs';
|
|
4
|
-
import { encode, decode } from '@msgpack/msgpack';
|
|
5
|
-
|
|
6
|
-
var INDEX_CONFIG_PREFIX = "_narsil/index/";
|
|
7
|
-
var INDEX_CONFIG_SUFFIX = "/config";
|
|
8
|
-
function truncateForDisplay(value) {
|
|
9
|
-
const str = String(value);
|
|
10
|
-
if (str.length > 100) {
|
|
11
|
-
return `${str.slice(0, 100)}...`;
|
|
12
|
-
}
|
|
13
|
-
return str;
|
|
14
|
-
}
|
|
15
|
-
function validateIndexName(indexName) {
|
|
16
|
-
if (indexName.length === 0 || indexName.length > MAX_INDEX_NAME_LENGTH) {
|
|
17
|
-
throw new NarsilError(
|
|
18
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
19
|
-
`Index name must be between 1 and ${MAX_INDEX_NAME_LENGTH} characters`,
|
|
20
|
-
{ indexName: truncateForDisplay(indexName) }
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
if (indexName.includes("\0") || indexName.includes("/") || indexName.includes("\\") || indexName.includes("..")) {
|
|
24
|
-
throw new NarsilError(
|
|
25
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
26
|
-
"Index name contains forbidden characters (/, \\, .., or null bytes)",
|
|
27
|
-
{ indexName: truncateForDisplay(indexName) }
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
if (!INDEX_NAME_PATTERN.test(indexName)) {
|
|
31
|
-
throw new NarsilError(
|
|
32
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
33
|
-
"Index name must start with an alphanumeric character and contain only alphanumeric characters, hyphens, underscores, or dots",
|
|
34
|
-
{ indexName: truncateForDisplay(indexName) }
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function isValidInteger(value) {
|
|
39
|
-
return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value);
|
|
40
|
-
}
|
|
41
|
-
function indexConfigKey(indexName) {
|
|
42
|
-
return `${INDEX_CONFIG_PREFIX}${indexName}${INDEX_CONFIG_SUFFIX}`;
|
|
43
|
-
}
|
|
44
|
-
function isRecord(value) {
|
|
45
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
46
|
-
}
|
|
47
|
-
function validateDecodedMetadata(decoded, indexName) {
|
|
48
|
-
if (!isRecord(decoded)) {
|
|
49
|
-
throw new NarsilError(
|
|
50
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
51
|
-
`Index metadata for '${indexName}' is not an object`,
|
|
52
|
-
{ indexName }
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
if (typeof decoded.indexUuid !== "string" || decoded.indexUuid.length === 0 || decoded.indexUuid.length > 128) {
|
|
56
|
-
throw new NarsilError(
|
|
57
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
58
|
-
`Index metadata for '${indexName}' has invalid indexUuid`,
|
|
59
|
-
{ indexName, received: truncateForDisplay(decoded.indexUuid) }
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
if (typeof decoded.indexName !== "string") {
|
|
63
|
-
throw new NarsilError(
|
|
64
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
65
|
-
`Index metadata for '${indexName}' has invalid indexName`,
|
|
66
|
-
{ indexName, received: truncateForDisplay(decoded.indexName) }
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
if (!isValidInteger(decoded.partitionCount) || decoded.partitionCount <= 0 || decoded.partitionCount > MAX_PARTITION_COUNT) {
|
|
70
|
-
throw new NarsilError(
|
|
71
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
72
|
-
`Index metadata for '${indexName}' has invalid partitionCount (must be an integer between 1 and ${MAX_PARTITION_COUNT})`,
|
|
73
|
-
{ indexName, partitionCount: truncateForDisplay(decoded.partitionCount) }
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
if (!isValidInteger(decoded.replicationFactor) || decoded.replicationFactor < 0 || decoded.replicationFactor > MAX_REPLICATION_FACTOR) {
|
|
77
|
-
throw new NarsilError(
|
|
78
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
79
|
-
`Index metadata for '${indexName}' has invalid replicationFactor (must be an integer between 0 and ${MAX_REPLICATION_FACTOR})`,
|
|
80
|
-
{ indexName, replicationFactor: truncateForDisplay(decoded.replicationFactor) }
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
if (!isRecord(decoded.constraints)) {
|
|
84
|
-
throw new NarsilError(
|
|
85
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
86
|
-
`Index metadata for '${indexName}' has invalid constraints`,
|
|
87
|
-
{ indexName }
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
const constraints = decoded.constraints;
|
|
91
|
-
if (constraints.maxShardsPerNode !== void 0 && constraints.maxShardsPerNode !== null && typeof constraints.maxShardsPerNode !== "number") {
|
|
92
|
-
throw new NarsilError(
|
|
93
|
-
ErrorCodes.CONTROLLER_METADATA_INVALID,
|
|
94
|
-
`Index metadata for '${indexName}' has invalid maxShardsPerNode (must be a number or null)`,
|
|
95
|
-
{ indexName, maxShardsPerNode: truncateForDisplay(constraints.maxShardsPerNode) }
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
indexUuid: decoded.indexUuid,
|
|
100
|
-
indexName: decoded.indexName,
|
|
101
|
-
partitionCount: decoded.partitionCount,
|
|
102
|
-
replicationFactor: decoded.replicationFactor,
|
|
103
|
-
constraints: {
|
|
104
|
-
zoneAwareness: constraints.zoneAwareness === true,
|
|
105
|
-
zoneAttribute: typeof constraints.zoneAttribute === "string" ? constraints.zoneAttribute : "zone",
|
|
106
|
-
maxShardsPerNode: typeof constraints.maxShardsPerNode === "number" ? constraints.maxShardsPerNode : null
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
async function putIndexMetadata(coordinator, metadata) {
|
|
111
|
-
validateIndexName(metadata.indexName);
|
|
112
|
-
const key = indexConfigKey(metadata.indexName);
|
|
113
|
-
const encoded = encode(metadata);
|
|
114
|
-
const bytes = new Uint8Array(encoded);
|
|
115
|
-
if (await coordinator.compareAndSet(key, null, bytes)) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
const current = await coordinator.get(key);
|
|
119
|
-
if (current === null || current.byteLength > 0) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
return coordinator.compareAndSet(key, current, bytes);
|
|
123
|
-
}
|
|
124
|
-
async function getIndexMetadata(coordinator, indexName) {
|
|
125
|
-
validateIndexName(indexName);
|
|
126
|
-
const key = indexConfigKey(indexName);
|
|
127
|
-
const raw = await coordinator.get(key);
|
|
128
|
-
if (raw === null || raw.byteLength === 0) {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
const decoded = decode(raw);
|
|
132
|
-
return validateDecodedMetadata(decoded, indexName);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export { getIndexMetadata, indexConfigKey, putIndexMetadata, validateIndexName };
|