taladb 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/dist/index.d.ts +0 -139
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taladb",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Local-first document and vector database for React, React Native, and Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -48,11 +48,11 @@
48
48
  "vitest": "^3.2.0"
49
49
  },
50
50
  "optionalDependencies": {
51
- "@taladb/node": "0.2.2",
52
- "@taladb/web": "0.2.2"
51
+ "@taladb/web": "0.2.3",
52
+ "@taladb/node": "0.2.3"
53
53
  },
54
54
  "scripts": {
55
- "build": "tsup src/index.ts --format cjs,esm --dts --out-dir dist --external @taladb/web --external @taladb/node --external @taladb/react-native",
55
+ "build": "tsup",
56
56
  "typecheck": "tsc --noEmit",
57
57
  "test": "vitest run",
58
58
  "test:watch": "vitest"
package/dist/index.d.ts DELETED
@@ -1,139 +0,0 @@
1
- /** Similarity metric used for vector search. */
2
- type VectorMetric = 'cosine' | 'dot' | 'euclidean';
3
- interface VectorIndexOptions {
4
- /** Number of dimensions in each stored vector. Enforced on insert and search. */
5
- dimensions: number;
6
- /** Similarity metric. Defaults to `"cosine"`. */
7
- metric?: VectorMetric;
8
- }
9
- /** A single result returned by `Collection.findNearest`. */
10
- interface VectorSearchResult<T extends Document = Document> {
11
- /** The matched document. */
12
- document: T;
13
- /**
14
- * Similarity score — higher means more similar.
15
- * Range depends on metric: cosine ∈ [-1,1], dot ∈ ℝ, euclidean ∈ (0,1].
16
- */
17
- score: number;
18
- }
19
- type Value = null | boolean | number | string | Uint8Array | Value[] | {
20
- [key: string]: Value;
21
- };
22
- type Document = {
23
- _id?: string;
24
- [key: string]: Value | undefined;
25
- };
26
- type FieldOps<T> = T extends null | undefined ? {
27
- $exists?: boolean;
28
- } : {
29
- $eq?: T;
30
- $ne?: T;
31
- $gt?: T;
32
- $gte?: T;
33
- $lt?: T;
34
- $lte?: T;
35
- $in?: T[];
36
- $nin?: T[];
37
- $exists?: boolean;
38
- /** Full-text search: matches documents where this string field contains the given token. */
39
- $contains?: string;
40
- };
41
- type Filter<T extends Document = Document> = {
42
- [K in keyof T]?: T[K] | FieldOps<T[K]>;
43
- } & {
44
- $and?: Filter<T>[];
45
- $or?: Filter<T>[];
46
- $not?: Filter<T>;
47
- };
48
- type Update<T extends Document = Document> = {
49
- $set?: Partial<T>;
50
- $unset?: {
51
- [K in keyof T]?: true;
52
- };
53
- $inc?: {
54
- [K in keyof T]?: number;
55
- };
56
- $push?: {
57
- [K in keyof T]?: Value;
58
- };
59
- $pull?: {
60
- [K in keyof T]?: Value;
61
- };
62
- };
63
- interface Collection<T extends Document = Document> {
64
- insert(doc: Omit<T, '_id'>): Promise<string>;
65
- insertMany(docs: Omit<T, '_id'>[]): Promise<string[]>;
66
- find(filter?: Filter<T>): Promise<T[]>;
67
- findOne(filter: Filter<T>): Promise<T | null>;
68
- updateOne(filter: Filter<T>, update: Update<T>): Promise<boolean>;
69
- updateMany(filter: Filter<T>, update: Update<T>): Promise<number>;
70
- deleteOne(filter: Filter<T>): Promise<boolean>;
71
- deleteMany(filter: Filter<T>): Promise<number>;
72
- count(filter?: Filter<T>): Promise<number>;
73
- createIndex(field: keyof Omit<T, '_id'> & string): Promise<void>;
74
- dropIndex(field: keyof Omit<T, '_id'> & string): Promise<void>;
75
- /**
76
- * Create a vector index on a numeric-array field.
77
- *
78
- * After creation, `findNearest` can search this field and new inserts/updates
79
- * automatically maintain the index. Existing documents are backfilled.
80
- *
81
- * @example
82
- * await articles.createVectorIndex('embedding', { dimensions: 384 });
83
- */
84
- createVectorIndex(field: keyof Omit<T, '_id'> & string, options: VectorIndexOptions): Promise<void>;
85
- /** Drop a vector index. */
86
- dropVectorIndex(field: keyof Omit<T, '_id'> & string): Promise<void>;
87
- /**
88
- * Find the `topK` most similar documents to `vector` using a vector index.
89
- *
90
- * Optionally combine with a metadata `filter` to restrict the search space
91
- * before ranking — e.g. find the 5 most similar english-language articles.
92
- *
93
- * Results are ordered by descending similarity score (highest first).
94
- *
95
- * @example
96
- * const results = await articles.findNearest('embedding', queryVec, 5);
97
- * // results: Array<{ document: Article, score: number }>
98
- *
99
- * @example with pre-filter
100
- * const results = await articles.findNearest('embedding', queryVec, 5, {
101
- * locale: 'en',
102
- * });
103
- */
104
- findNearest(field: keyof Omit<T, '_id'> & string, vector: number[], topK: number, filter?: Filter<T>): Promise<VectorSearchResult<T>[]>;
105
- /**
106
- * Subscribe to live query results. The callback receives a full snapshot of
107
- * matching documents immediately and again after every write that could
108
- * affect the result set.
109
- *
110
- * @returns An unsubscribe function. Call it to stop receiving updates.
111
- *
112
- * @example
113
- * const unsub = users.subscribe({ active: true }, (docs) => {
114
- * console.log('active users:', docs);
115
- * });
116
- * // later…
117
- * unsub();
118
- */
119
- subscribe(filter: Filter<T>, callback: (docs: T[]) => void): () => void;
120
- }
121
- interface TalaDB {
122
- collection<T extends Document = Document>(name: string): Collection<T>;
123
- close(): Promise<void>;
124
- }
125
-
126
- /**
127
- * Open a TalaDB database.
128
- *
129
- * @param dbName Name of the database file (used for OPFS and native file paths).
130
- * Ignored for in-memory databases.
131
- *
132
- * @example
133
- * const db = await openDB('myapp.db');
134
- * const users = db.collection<User>('users');
135
- * const id = await users.insert({ name: 'Alice', age: 30 });
136
- */
137
- declare function openDB(dbName?: string): Promise<TalaDB>;
138
-
139
- export { type Collection, type Document, type Filter, type TalaDB, type Update, type Value, type VectorIndexOptions, type VectorMetric, type VectorSearchResult, openDB };