@kedem/okdb 1.5.3 → 1.6.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kedem/okdb",
3
- "version": "1.5.3",
3
+ "version": "1.6.0",
4
4
  "description": "A fast, type-oriented database — strong consistency and rich indexing at the core, with sync, vector embeddings, full-text search, and AI tooling built in. Designed for the AI era.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "engines": {
@@ -1,25 +1,96 @@
1
- export interface OKDBFtsIndex {
2
- name: string;
3
- type: string;
1
+ export interface OKDBFtsTokenizerOptions {
2
+ minTokenLength?: number;
3
+ maxTokenLength?: number;
4
+ keepNumbers?: boolean;
5
+ toLower?: boolean;
6
+ stopwords?: string[];
7
+ }
8
+
9
+ export interface OKDBFtsConfig {
4
10
  fields: string[];
5
- [key: string]: unknown;
11
+ tokenizer?: OKDBFtsTokenizerOptions;
6
12
  }
7
13
 
8
- export interface OKDBFtsQueryResult {
9
- key: string | number;
10
- score: number;
11
- value?: unknown;
14
+ export interface OKDBFtsListEntry {
15
+ name: string;
16
+ status: 'creating' | 'resetting' | 'ready' | 'waiting' | null;
17
+ config: OKDBFtsConfig | null;
18
+ created: number | null;
19
+ updated: number | null;
20
+ error: { message: string; timestamp: number } | null;
21
+ /**
22
+ * Per-TYPE async processor state. Repeated identically on every entry of the same type.
23
+ * Reflects the single processor that drives all FTS indexes on this type.
24
+ */
25
+ processorState: 'building' | 'online' | 'error' | 'waiting' | null;
26
+ /**
27
+ * Per-TYPE number of changes the async processor has not yet indexed. Repeated identically
28
+ * on every entry of the same type. 0 = caught up.
29
+ */
30
+ lag: number | null;
12
31
  }
13
32
 
14
- export interface OKDBFtsRegisterOptions {
15
- fields?: string[];
16
- [key: string]: unknown;
33
+ export interface OKDBFtsSearchOptions {
34
+ limit?: number;
35
+ mode?: 'and' | 'or';
36
+ prefix?: boolean;
37
+ }
38
+
39
+ export interface OKDBFtsSearchResult {
40
+ key: string;
41
+ value: unknown;
42
+ version: number | null;
43
+ score: number | null;
44
+ numTerms: number;
45
+ maxScore: number;
17
46
  }
18
47
 
19
48
  export declare class OKDBFts {
20
- registerIndex(type: string, name: string, options?: OKDBFtsRegisterOptions): Promise<void>;
21
- dropIndex(type: string, name: string): Promise<void>;
22
- hasIndex(type: string, name: string): boolean;
23
- query(type: string, name: string, text: string, filter?: Record<string, unknown>, options?: { limit?: number; offset?: number }): Iterable<OKDBFtsQueryResult>;
49
+ /** Register a new FTS index on a type. Builds in background; await ready(type) to confirm. */
50
+ register(type: string, name: string, config: OKDBFtsConfig, timestamp?: number, env?: unknown): Promise<void>;
51
+
52
+ /** Idempotent register no-op if index already exists. */
53
+ ensure(type: string, name: string, config: OKDBFtsConfig, env?: unknown): Promise<void>;
54
+
55
+ /** Drop a FTS index. */
56
+ drop(type: string, name: string, env?: unknown): Promise<void>;
57
+
58
+ /** Force-rebuild a FTS index from scratch. */
59
+ reset(type: string, name: string, clear?: boolean, env?: unknown): Promise<void>;
60
+
61
+ /** Returns true if the FTS index exists. */
62
+ has(type: string, name: string, env?: unknown): boolean;
63
+
64
+ /** Returns the index status, or null if not registered. */
65
+ status(type: string, name: string, env?: unknown): 'creating' | 'resetting' | 'ready' | 'waiting' | null;
66
+
67
+ /** List all FTS indexes for a type. */
68
+ list(type: string, env?: unknown): OKDBFtsListEntry[];
69
+
70
+ /**
71
+ * Resolves when all FTS indexes for the type finish their initial build.
72
+ * The `name` parameter is accepted for backward compatibility but ignored.
73
+ */
74
+ ready(type: string, name?: string, env?: unknown): Promise<boolean>;
75
+
76
+ /**
77
+ * Waits for the FTS processor to catch up to the current write position.
78
+ * Use after writes when immediate search consistency is required.
79
+ */
80
+ flush(type: string, env?: unknown): Promise<void>;
81
+
82
+ /** Search the FTS index. Returns an array of matching document keys. */
83
+ search(type: string, name: string, query: string, options?: OKDBFtsSearchOptions, env?: unknown): string[];
84
+
85
+ /** Search and return hydrated documents with scores. */
86
+ searchDocs(
87
+ type: string,
88
+ name: string,
89
+ query: string,
90
+ options?: OKDBFtsSearchOptions & { keysOnly?: boolean },
91
+ env?: unknown,
92
+ ): OKDBFtsSearchResult[] | string[];
93
+
94
+ /** Wait for all pending FTS operations to complete (used during shutdown). */
24
95
  drain(): Promise<void>;
25
96
  }