taladb 0.7.8 → 0.7.10

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.
@@ -69,6 +69,9 @@ function applySchema(col, options) {
69
69
  };
70
70
  }
71
71
  function detectPlatform() {
72
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
73
+ return "react-native";
74
+ }
72
75
  if (globalThis.nativeCallSyncHook !== void 0) {
73
76
  return "react-native";
74
77
  }
@@ -309,30 +312,36 @@ async function createNativeDB(_dbName) {
309
312
  }
310
313
  const native = maybeNative;
311
314
  function wrapCollection(name, opts) {
312
- const col = native.collection(name);
313
315
  const wrapped = {
314
- insert: async (doc) => col.insert(doc),
315
- insertMany: async (docs) => col.insertMany(docs),
316
- find: async (filter) => col.find(filter ?? {}),
317
- findOne: async (filter) => col.findOne(filter ?? {}),
318
- updateOne: async (filter, update) => col.updateOne(filter, update),
319
- updateMany: async (filter, update) => col.updateMany(filter, update),
320
- deleteOne: async (filter) => col.deleteOne(filter),
321
- deleteMany: async (filter) => col.deleteMany(filter),
322
- count: async (filter) => col.count(filter ?? {}),
323
- createIndex: async (field) => col.createIndex(field),
324
- dropIndex: async (field) => col.dropIndex(field),
325
- createFtsIndex: async (field) => col.createFtsIndex(field),
326
- dropFtsIndex: async (field) => col.dropFtsIndex(field),
327
- createVectorIndex: async (field, options) => col.createVectorIndex(field, options.dimensions, options.metric ?? null, options.indexType ?? null, options.hnswM ?? null, options.hnswEfConstruction ?? null),
328
- dropVectorIndex: async (field) => col.dropVectorIndex(field),
329
- upgradeVectorIndex: async (field) => col.upgradeVectorIndex(field),
330
- listIndexes: async () => JSON.parse(col.listIndexes()),
316
+ insert: async (doc) => native.insert(name, doc),
317
+ insertMany: async (docs) => native.insertMany(name, docs),
318
+ find: async (filter) => native.find(name, filter ?? {}),
319
+ findOne: async (filter) => native.findOne(name, filter ?? {}),
320
+ updateOne: async (filter, update) => native.updateOne(name, filter, update),
321
+ updateMany: async (filter, update) => native.updateMany(name, filter, update),
322
+ deleteOne: async (filter) => native.deleteOne(name, filter),
323
+ deleteMany: async (filter) => native.deleteMany(name, filter),
324
+ count: async (filter) => native.count(name, filter ?? {}),
325
+ createIndex: async (field) => native.createIndex(name, field),
326
+ dropIndex: async (field) => native.dropIndex(name, field),
327
+ createFtsIndex: async (field) => native.createFtsIndex(name, field),
328
+ dropFtsIndex: async (field) => native.dropFtsIndex(name, field),
329
+ createVectorIndex: async (field, options) => {
330
+ const opts2 = {};
331
+ if (options.metric) opts2.metric = options.metric;
332
+ if (options.hnswM || options.hnswEfConstruction) {
333
+ opts2.hnsw = { m: options.hnswM, efConstruction: options.hnswEfConstruction };
334
+ }
335
+ return native.createVectorIndex(name, field, options.dimensions, opts2);
336
+ },
337
+ dropVectorIndex: async (field) => native.dropVectorIndex(name, field),
338
+ upgradeVectorIndex: async (field) => native.upgradeVectorIndex(name, field),
339
+ listIndexes: async () => ({}),
331
340
  findNearest: async (field, vector, topK, filter) => {
332
- const raw = col.findNearest(field, vector, topK, filter ?? null);
341
+ const raw = native.findNearest(name, field, vector, topK, filter ?? null);
333
342
  return raw;
334
343
  },
335
- subscribe: (filter, callback) => makePoller(async () => col.find(filter ?? {}), callback)
344
+ subscribe: (filter, callback) => makePoller(async () => native.find(name, filter ?? {}), callback)
336
345
  };
337
346
  return opts ? applySchema(wrapped, opts) : wrapped;
338
347
  }
package/dist/index.js CHANGED
@@ -151,6 +151,9 @@ function applySchema(col, options) {
151
151
  };
152
152
  }
153
153
  function detectPlatform() {
154
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
155
+ return "react-native";
156
+ }
154
157
  if (globalThis.nativeCallSyncHook !== void 0) {
155
158
  return "react-native";
156
159
  }
@@ -391,30 +394,36 @@ async function createNativeDB(_dbName) {
391
394
  }
392
395
  const native = maybeNative;
393
396
  function wrapCollection(name, opts) {
394
- const col = native.collection(name);
395
397
  const wrapped = {
396
- insert: async (doc) => col.insert(doc),
397
- insertMany: async (docs) => col.insertMany(docs),
398
- find: async (filter) => col.find(filter ?? {}),
399
- findOne: async (filter) => col.findOne(filter ?? {}),
400
- updateOne: async (filter, update) => col.updateOne(filter, update),
401
- updateMany: async (filter, update) => col.updateMany(filter, update),
402
- deleteOne: async (filter) => col.deleteOne(filter),
403
- deleteMany: async (filter) => col.deleteMany(filter),
404
- count: async (filter) => col.count(filter ?? {}),
405
- createIndex: async (field) => col.createIndex(field),
406
- dropIndex: async (field) => col.dropIndex(field),
407
- createFtsIndex: async (field) => col.createFtsIndex(field),
408
- dropFtsIndex: async (field) => col.dropFtsIndex(field),
409
- createVectorIndex: async (field, options) => col.createVectorIndex(field, options.dimensions, options.metric ?? null, options.indexType ?? null, options.hnswM ?? null, options.hnswEfConstruction ?? null),
410
- dropVectorIndex: async (field) => col.dropVectorIndex(field),
411
- upgradeVectorIndex: async (field) => col.upgradeVectorIndex(field),
412
- listIndexes: async () => JSON.parse(col.listIndexes()),
398
+ insert: async (doc) => native.insert(name, doc),
399
+ insertMany: async (docs) => native.insertMany(name, docs),
400
+ find: async (filter) => native.find(name, filter ?? {}),
401
+ findOne: async (filter) => native.findOne(name, filter ?? {}),
402
+ updateOne: async (filter, update) => native.updateOne(name, filter, update),
403
+ updateMany: async (filter, update) => native.updateMany(name, filter, update),
404
+ deleteOne: async (filter) => native.deleteOne(name, filter),
405
+ deleteMany: async (filter) => native.deleteMany(name, filter),
406
+ count: async (filter) => native.count(name, filter ?? {}),
407
+ createIndex: async (field) => native.createIndex(name, field),
408
+ dropIndex: async (field) => native.dropIndex(name, field),
409
+ createFtsIndex: async (field) => native.createFtsIndex(name, field),
410
+ dropFtsIndex: async (field) => native.dropFtsIndex(name, field),
411
+ createVectorIndex: async (field, options) => {
412
+ const opts2 = {};
413
+ if (options.metric) opts2.metric = options.metric;
414
+ if (options.hnswM || options.hnswEfConstruction) {
415
+ opts2.hnsw = { m: options.hnswM, efConstruction: options.hnswEfConstruction };
416
+ }
417
+ return native.createVectorIndex(name, field, options.dimensions, opts2);
418
+ },
419
+ dropVectorIndex: async (field) => native.dropVectorIndex(name, field),
420
+ upgradeVectorIndex: async (field) => native.upgradeVectorIndex(name, field),
421
+ listIndexes: async () => ({}),
413
422
  findNearest: async (field, vector, topK, filter) => {
414
- const raw = col.findNearest(field, vector, topK, filter ?? null);
423
+ const raw = native.findNearest(name, field, vector, topK, filter ?? null);
415
424
  return raw;
416
425
  },
417
- subscribe: (filter, callback) => makePoller(async () => col.find(filter ?? {}), callback)
426
+ subscribe: (filter, callback) => makePoller(async () => native.find(name, filter ?? {}), callback)
418
427
  };
419
428
  return opts ? applySchema(wrapped, opts) : wrapped;
420
429
  }
package/dist/index.mjs CHANGED
@@ -113,6 +113,9 @@ function applySchema(col, options) {
113
113
  };
114
114
  }
115
115
  function detectPlatform() {
116
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
117
+ return "react-native";
118
+ }
116
119
  if (globalThis.nativeCallSyncHook !== void 0) {
117
120
  return "react-native";
118
121
  }
@@ -353,30 +356,36 @@ async function createNativeDB(_dbName) {
353
356
  }
354
357
  const native = maybeNative;
355
358
  function wrapCollection(name, opts) {
356
- const col = native.collection(name);
357
359
  const wrapped = {
358
- insert: async (doc) => col.insert(doc),
359
- insertMany: async (docs) => col.insertMany(docs),
360
- find: async (filter) => col.find(filter ?? {}),
361
- findOne: async (filter) => col.findOne(filter ?? {}),
362
- updateOne: async (filter, update) => col.updateOne(filter, update),
363
- updateMany: async (filter, update) => col.updateMany(filter, update),
364
- deleteOne: async (filter) => col.deleteOne(filter),
365
- deleteMany: async (filter) => col.deleteMany(filter),
366
- count: async (filter) => col.count(filter ?? {}),
367
- createIndex: async (field) => col.createIndex(field),
368
- dropIndex: async (field) => col.dropIndex(field),
369
- createFtsIndex: async (field) => col.createFtsIndex(field),
370
- dropFtsIndex: async (field) => col.dropFtsIndex(field),
371
- createVectorIndex: async (field, options) => col.createVectorIndex(field, options.dimensions, options.metric ?? null, options.indexType ?? null, options.hnswM ?? null, options.hnswEfConstruction ?? null),
372
- dropVectorIndex: async (field) => col.dropVectorIndex(field),
373
- upgradeVectorIndex: async (field) => col.upgradeVectorIndex(field),
374
- listIndexes: async () => JSON.parse(col.listIndexes()),
360
+ insert: async (doc) => native.insert(name, doc),
361
+ insertMany: async (docs) => native.insertMany(name, docs),
362
+ find: async (filter) => native.find(name, filter ?? {}),
363
+ findOne: async (filter) => native.findOne(name, filter ?? {}),
364
+ updateOne: async (filter, update) => native.updateOne(name, filter, update),
365
+ updateMany: async (filter, update) => native.updateMany(name, filter, update),
366
+ deleteOne: async (filter) => native.deleteOne(name, filter),
367
+ deleteMany: async (filter) => native.deleteMany(name, filter),
368
+ count: async (filter) => native.count(name, filter ?? {}),
369
+ createIndex: async (field) => native.createIndex(name, field),
370
+ dropIndex: async (field) => native.dropIndex(name, field),
371
+ createFtsIndex: async (field) => native.createFtsIndex(name, field),
372
+ dropFtsIndex: async (field) => native.dropFtsIndex(name, field),
373
+ createVectorIndex: async (field, options) => {
374
+ const opts2 = {};
375
+ if (options.metric) opts2.metric = options.metric;
376
+ if (options.hnswM || options.hnswEfConstruction) {
377
+ opts2.hnsw = { m: options.hnswM, efConstruction: options.hnswEfConstruction };
378
+ }
379
+ return native.createVectorIndex(name, field, options.dimensions, opts2);
380
+ },
381
+ dropVectorIndex: async (field) => native.dropVectorIndex(name, field),
382
+ upgradeVectorIndex: async (field) => native.upgradeVectorIndex(name, field),
383
+ listIndexes: async () => ({}),
375
384
  findNearest: async (field, vector, topK, filter) => {
376
- const raw = col.findNearest(field, vector, topK, filter ?? null);
385
+ const raw = native.findNearest(name, field, vector, topK, filter ?? null);
377
386
  return raw;
378
387
  },
379
- subscribe: (filter, callback) => makePoller(async () => col.find(filter ?? {}), callback)
388
+ subscribe: (filter, callback) => makePoller(async () => native.find(name, filter ?? {}), callback)
380
389
  };
381
390
  return opts ? applySchema(wrapped, opts) : wrapped;
382
391
  }
@@ -69,6 +69,9 @@ function applySchema(col, options) {
69
69
  };
70
70
  }
71
71
  function detectPlatform() {
72
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
73
+ return "react-native";
74
+ }
72
75
  if (globalThis.nativeCallSyncHook !== void 0) {
73
76
  return "react-native";
74
77
  }
@@ -123,7 +126,7 @@ function makePoller(findFn, callback) {
123
126
  };
124
127
  }
125
128
  async function createBrowserDB(dbName, config) {
126
- const workerUrl = new URL("@taladb/web/worker/taladb.worker.js", import.meta.url);
129
+ const workerUrl = new URL("@taladb/web/worker/taladb.worker.js", "react-native://unreachable");
127
130
  const worker = new Worker(workerUrl, { type: "module", name: "taladb" });
128
131
  const proxy = new WorkerProxy(worker);
129
132
  const configJson = config !== void 0 ? JSON.stringify(config) : void 0;
@@ -259,7 +262,7 @@ async function createBrowserDB(dbName, config) {
259
262
  };
260
263
  }
261
264
  async function createNodeDB(dbName, config) {
262
- const { TalaDBNode } = await import("@taladb/node");
265
+ const { TalaDBNode } = await import("./node-A4LKRSW5.mjs");
263
266
  const configJson = config !== void 0 ? JSON.stringify(config) : null;
264
267
  const db = TalaDBNode.open(dbName, configJson);
265
268
  function wrapCollection(name, opts) {
@@ -309,30 +312,36 @@ async function createNativeDB(_dbName) {
309
312
  }
310
313
  const native = maybeNative;
311
314
  function wrapCollection(name, opts) {
312
- const col = native.collection(name);
313
315
  const wrapped = {
314
- insert: async (doc) => col.insert(doc),
315
- insertMany: async (docs) => col.insertMany(docs),
316
- find: async (filter) => col.find(filter ?? {}),
317
- findOne: async (filter) => col.findOne(filter ?? {}),
318
- updateOne: async (filter, update) => col.updateOne(filter, update),
319
- updateMany: async (filter, update) => col.updateMany(filter, update),
320
- deleteOne: async (filter) => col.deleteOne(filter),
321
- deleteMany: async (filter) => col.deleteMany(filter),
322
- count: async (filter) => col.count(filter ?? {}),
323
- createIndex: async (field) => col.createIndex(field),
324
- dropIndex: async (field) => col.dropIndex(field),
325
- createFtsIndex: async (field) => col.createFtsIndex(field),
326
- dropFtsIndex: async (field) => col.dropFtsIndex(field),
327
- createVectorIndex: async (field, options) => col.createVectorIndex(field, options.dimensions, options.metric ?? null, options.indexType ?? null, options.hnswM ?? null, options.hnswEfConstruction ?? null),
328
- dropVectorIndex: async (field) => col.dropVectorIndex(field),
329
- upgradeVectorIndex: async (field) => col.upgradeVectorIndex(field),
330
- listIndexes: async () => JSON.parse(col.listIndexes()),
316
+ insert: async (doc) => native.insert(name, doc),
317
+ insertMany: async (docs) => native.insertMany(name, docs),
318
+ find: async (filter) => native.find(name, filter ?? {}),
319
+ findOne: async (filter) => native.findOne(name, filter ?? {}),
320
+ updateOne: async (filter, update) => native.updateOne(name, filter, update),
321
+ updateMany: async (filter, update) => native.updateMany(name, filter, update),
322
+ deleteOne: async (filter) => native.deleteOne(name, filter),
323
+ deleteMany: async (filter) => native.deleteMany(name, filter),
324
+ count: async (filter) => native.count(name, filter ?? {}),
325
+ createIndex: async (field) => native.createIndex(name, field),
326
+ dropIndex: async (field) => native.dropIndex(name, field),
327
+ createFtsIndex: async (field) => native.createFtsIndex(name, field),
328
+ dropFtsIndex: async (field) => native.dropFtsIndex(name, field),
329
+ createVectorIndex: async (field, options) => {
330
+ const opts2 = {};
331
+ if (options.metric) opts2.metric = options.metric;
332
+ if (options.hnswM || options.hnswEfConstruction) {
333
+ opts2.hnsw = { m: options.hnswM, efConstruction: options.hnswEfConstruction };
334
+ }
335
+ return native.createVectorIndex(name, field, options.dimensions, opts2);
336
+ },
337
+ dropVectorIndex: async (field) => native.dropVectorIndex(name, field),
338
+ upgradeVectorIndex: async (field) => native.upgradeVectorIndex(name, field),
339
+ listIndexes: async () => ({}),
331
340
  findNearest: async (field, vector, topK, filter) => {
332
- const raw = col.findNearest(field, vector, topK, filter ?? null);
341
+ const raw = native.findNearest(name, field, vector, topK, filter ?? null);
333
342
  return raw;
334
343
  },
335
- subscribe: (filter, callback) => makePoller(async () => col.find(filter ?? {}), callback)
344
+ subscribe: (filter, callback) => makePoller(async () => native.find(name, filter ?? {}), callback)
336
345
  };
337
346
  return opts ? applySchema(wrapped, opts) : wrapped;
338
347
  }
@@ -0,0 +1,5 @@
1
+ // src/stubs/node.ts
2
+ var TalaDBNode = null;
3
+ export {
4
+ TalaDBNode
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taladb",
3
- "version": "0.7.8",
3
+ "version": "0.7.10",
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",