taladb 0.11.0 → 0.11.2

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.
@@ -310,6 +310,10 @@ function encodeUlid(value) {
310
310
  }
311
311
  return out;
312
312
  }
313
+ var DOC_ID_PATTERN = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
314
+ function isDocId(value) {
315
+ return typeof value === "string" && DOC_ID_PATTERN.test(value);
316
+ }
313
317
  function deriveDocId(collection, key) {
314
318
  const bytes = [...UTF8.encode(collection), 0, ...UTF8.encode(key)];
315
319
  let hash = FNV1A128_OFFSET_BASIS;
@@ -923,7 +927,11 @@ async function createBrowserDB(dbName, webhook, config, passphrase, migrations)
923
927
  return handle;
924
928
  }
925
929
  async function createNodeDB(dbName, webhook, config, passphrase, migrations) {
926
- const native = await import("./node-A4LKRSW5.mjs");
930
+ const native = await import(
931
+ /* webpackIgnore: true */
932
+ /* turbopackIgnore: true */
933
+ "./node-A4LKRSW5.mjs"
934
+ );
927
935
  const TalaDBNode = native.TalaDbNode ?? native.TalaDBNode;
928
936
  if (!TalaDBNode) throw new Error("@taladb/node loaded but exports no TalaDbNode class \u2014 rebuild the native module");
929
937
  const configJson = config !== void 0 ? JSON.stringify(config) : null;
@@ -1151,6 +1159,7 @@ export {
1151
1159
  createWebhookDispatcher,
1152
1160
  decorateCollection,
1153
1161
  deriveDocId,
1162
+ isDocId,
1154
1163
  openDB,
1155
1164
  runMigrations,
1156
1165
  validateWebhookConfig
package/dist/index.d.mts CHANGED
@@ -781,22 +781,18 @@ interface TalaDbConfig {
781
781
  * trusts, not adversarial input.
782
782
  */
783
783
  /**
784
- * Derive a stable `_id` for a row replicated from a remote origin.
784
+ * Whether `value` is usable as a document `_id`.
785
785
  *
786
- * `collection` is part of the preimage, so the same remote id in two different
787
- * collections cannot collide.
786
+ * Ids are 16 raw bytes on disk, so only a ULID qualifies a natural key like
787
+ * `'sku-1'`, `'265'` or a UUID is rejected on insert. Use this to check a value
788
+ * before writing it, and {@link deriveDocId} to turn a natural key into one.
788
789
  *
789
790
  * @example
790
- * deriveDocId('products', 'sku-123') // → '56GC678DQYWW1Z98HPYJ90WVKH', always
791
- *
792
- * ## Ordering caveat
793
- *
794
- * The result is a hash, so its ULID timestamp prefix is **not** chronological.
795
- * Documents written with a derived id do not come back in insertion order from an
796
- * unsorted `find()`; reads over replicated collections must carry an explicit
797
- * sort. Documents written via `insert`/`insertMany` are unaffected — they still
798
- * get monotonic ULIDs.
791
+ * isDocId(deriveDocId('products', 'sku-123')) // true
792
+ * isDocId('sku-123') // false
793
+ * isDocId(crypto.randomUUID()) // false — a UUID is not a ULID
799
794
  */
795
+ declare function isDocId(value: unknown): value is string;
800
796
  declare function deriveDocId(collection: string, key: string): string;
801
797
 
802
798
  /**
@@ -949,4 +945,4 @@ interface OpenDBOptions {
949
945
  */
950
946
  declare function openDB(dbName?: string, options?: OpenDBOptions): Promise<TalaDB>;
951
947
 
952
- export { type AggregatePipeline, type AggregateStage, type Collection, type CollectionIndexInfo, type CollectionOptions, type Document, type DurabilityConfig, type Filter, type HybridSearchOptions, type HybridSearchResult, type InsertDoc, type Migration, type OpenDBOptions, type Schema, type TalaDB, type TalaDbConfig, TalaDbValidationError, type TextSearchOptions, type TextSearchResult, type Update, type Value, type VectorIndexOptions, type VectorMetric, type VectorSearchResult, type WebhookConfig, type WebhookDispatcher, type WebhookEvent, type WebhookOp, type WebhookStats, applySchema, createWebhookDispatcher, decorateCollection, deriveDocId, openDB, runMigrations, validateWebhookConfig };
948
+ export { type AggregatePipeline, type AggregateStage, type Collection, type CollectionIndexInfo, type CollectionOptions, type Document, type DurabilityConfig, type Filter, type HybridSearchOptions, type HybridSearchResult, type InsertDoc, type Migration, type OpenDBOptions, type Schema, type TalaDB, type TalaDbConfig, TalaDbValidationError, type TextSearchOptions, type TextSearchResult, type Update, type Value, type VectorIndexOptions, type VectorMetric, type VectorSearchResult, type WebhookConfig, type WebhookDispatcher, type WebhookEvent, type WebhookOp, type WebhookStats, applySchema, createWebhookDispatcher, decorateCollection, deriveDocId, isDocId, openDB, runMigrations, validateWebhookConfig };
package/dist/index.d.ts CHANGED
@@ -781,22 +781,18 @@ interface TalaDbConfig {
781
781
  * trusts, not adversarial input.
782
782
  */
783
783
  /**
784
- * Derive a stable `_id` for a row replicated from a remote origin.
784
+ * Whether `value` is usable as a document `_id`.
785
785
  *
786
- * `collection` is part of the preimage, so the same remote id in two different
787
- * collections cannot collide.
786
+ * Ids are 16 raw bytes on disk, so only a ULID qualifies a natural key like
787
+ * `'sku-1'`, `'265'` or a UUID is rejected on insert. Use this to check a value
788
+ * before writing it, and {@link deriveDocId} to turn a natural key into one.
788
789
  *
789
790
  * @example
790
- * deriveDocId('products', 'sku-123') // → '56GC678DQYWW1Z98HPYJ90WVKH', always
791
- *
792
- * ## Ordering caveat
793
- *
794
- * The result is a hash, so its ULID timestamp prefix is **not** chronological.
795
- * Documents written with a derived id do not come back in insertion order from an
796
- * unsorted `find()`; reads over replicated collections must carry an explicit
797
- * sort. Documents written via `insert`/`insertMany` are unaffected — they still
798
- * get monotonic ULIDs.
791
+ * isDocId(deriveDocId('products', 'sku-123')) // true
792
+ * isDocId('sku-123') // false
793
+ * isDocId(crypto.randomUUID()) // false — a UUID is not a ULID
799
794
  */
795
+ declare function isDocId(value: unknown): value is string;
800
796
  declare function deriveDocId(collection: string, key: string): string;
801
797
 
802
798
  /**
@@ -949,4 +945,4 @@ interface OpenDBOptions {
949
945
  */
950
946
  declare function openDB(dbName?: string, options?: OpenDBOptions): Promise<TalaDB>;
951
947
 
952
- export { type AggregatePipeline, type AggregateStage, type Collection, type CollectionIndexInfo, type CollectionOptions, type Document, type DurabilityConfig, type Filter, type HybridSearchOptions, type HybridSearchResult, type InsertDoc, type Migration, type OpenDBOptions, type Schema, type TalaDB, type TalaDbConfig, TalaDbValidationError, type TextSearchOptions, type TextSearchResult, type Update, type Value, type VectorIndexOptions, type VectorMetric, type VectorSearchResult, type WebhookConfig, type WebhookDispatcher, type WebhookEvent, type WebhookOp, type WebhookStats, applySchema, createWebhookDispatcher, decorateCollection, deriveDocId, openDB, runMigrations, validateWebhookConfig };
948
+ export { type AggregatePipeline, type AggregateStage, type Collection, type CollectionIndexInfo, type CollectionOptions, type Document, type DurabilityConfig, type Filter, type HybridSearchOptions, type HybridSearchResult, type InsertDoc, type Migration, type OpenDBOptions, type Schema, type TalaDB, type TalaDbConfig, TalaDbValidationError, type TextSearchOptions, type TextSearchResult, type Update, type Value, type VectorIndexOptions, type VectorMetric, type VectorSearchResult, type WebhookConfig, type WebhookDispatcher, type WebhookEvent, type WebhookOp, type WebhookStats, applySchema, createWebhookDispatcher, decorateCollection, deriveDocId, isDocId, openDB, runMigrations, validateWebhookConfig };
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  createWebhookDispatcher: () => createWebhookDispatcher,
36
36
  decorateCollection: () => decorateCollection,
37
37
  deriveDocId: () => deriveDocId,
38
+ isDocId: () => isDocId,
38
39
  openDB: () => openDB,
39
40
  runMigrations: () => runMigrations,
40
41
  validateWebhookConfig: () => validateWebhookConfig
@@ -382,6 +383,10 @@ function encodeUlid(value) {
382
383
  }
383
384
  return out;
384
385
  }
386
+ var DOC_ID_PATTERN = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
387
+ function isDocId(value) {
388
+ return typeof value === "string" && DOC_ID_PATTERN.test(value);
389
+ }
385
390
  function deriveDocId(collection, key) {
386
391
  const bytes = [...UTF8.encode(collection), 0, ...UTF8.encode(key)];
387
392
  let hash = FNV1A128_OFFSET_BASIS;
@@ -996,7 +1001,11 @@ async function createBrowserDB(dbName, webhook, config, passphrase, migrations)
996
1001
  return handle;
997
1002
  }
998
1003
  async function createNodeDB(dbName, webhook, config, passphrase, migrations) {
999
- const native = await import("@taladb/node");
1004
+ const native = await import(
1005
+ /* webpackIgnore: true */
1006
+ /* turbopackIgnore: true */
1007
+ "@taladb/node"
1008
+ );
1000
1009
  const TalaDBNode = native.TalaDbNode ?? native.TalaDBNode;
1001
1010
  if (!TalaDBNode) throw new Error("@taladb/node loaded but exports no TalaDbNode class \u2014 rebuild the native module");
1002
1011
  const configJson = config !== void 0 ? JSON.stringify(config) : null;
@@ -1225,6 +1234,7 @@ function attachWebhook(db, webhook) {
1225
1234
  createWebhookDispatcher,
1226
1235
  decorateCollection,
1227
1236
  deriveDocId,
1237
+ isDocId,
1228
1238
  openDB,
1229
1239
  runMigrations,
1230
1240
  validateWebhookConfig
package/dist/index.mjs CHANGED
@@ -339,6 +339,10 @@ function encodeUlid(value) {
339
339
  }
340
340
  return out;
341
341
  }
342
+ var DOC_ID_PATTERN = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
343
+ function isDocId(value) {
344
+ return typeof value === "string" && DOC_ID_PATTERN.test(value);
345
+ }
342
346
  function deriveDocId(collection, key) {
343
347
  const bytes = [...UTF8.encode(collection), 0, ...UTF8.encode(key)];
344
348
  let hash = FNV1A128_OFFSET_BASIS;
@@ -952,7 +956,11 @@ async function createBrowserDB(dbName, webhook, config, passphrase, migrations)
952
956
  return handle;
953
957
  }
954
958
  async function createNodeDB(dbName, webhook, config, passphrase, migrations) {
955
- const native = await import("@taladb/node");
959
+ const native = await import(
960
+ /* webpackIgnore: true */
961
+ /* turbopackIgnore: true */
962
+ "@taladb/node"
963
+ );
956
964
  const TalaDBNode = native.TalaDbNode ?? native.TalaDBNode;
957
965
  if (!TalaDBNode) throw new Error("@taladb/node loaded but exports no TalaDbNode class \u2014 rebuild the native module");
958
966
  const configJson = config !== void 0 ? JSON.stringify(config) : null;
@@ -1180,6 +1188,7 @@ export {
1180
1188
  createWebhookDispatcher,
1181
1189
  decorateCollection,
1182
1190
  deriveDocId,
1191
+ isDocId,
1183
1192
  openDB,
1184
1193
  runMigrations,
1185
1194
  validateWebhookConfig
@@ -310,6 +310,10 @@ function encodeUlid(value) {
310
310
  }
311
311
  return out;
312
312
  }
313
+ var DOC_ID_PATTERN = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
314
+ function isDocId(value) {
315
+ return typeof value === "string" && DOC_ID_PATTERN.test(value);
316
+ }
313
317
  function deriveDocId(collection, key) {
314
318
  const bytes = [...UTF8.encode(collection), 0, ...UTF8.encode(key)];
315
319
  let hash = FNV1A128_OFFSET_BASIS;
@@ -923,7 +927,11 @@ async function createBrowserDB(dbName, webhook, config, passphrase, migrations)
923
927
  return handle;
924
928
  }
925
929
  async function createNodeDB(dbName, webhook, config, passphrase, migrations) {
926
- const native = await import("./node-A4LKRSW5.mjs");
930
+ const native = await import(
931
+ /* webpackIgnore: true */
932
+ /* turbopackIgnore: true */
933
+ "./node-A4LKRSW5.mjs"
934
+ );
927
935
  const TalaDBNode = native.TalaDbNode ?? native.TalaDBNode;
928
936
  if (!TalaDBNode) throw new Error("@taladb/node loaded but exports no TalaDbNode class \u2014 rebuild the native module");
929
937
  const configJson = config !== void 0 ? JSON.stringify(config) : null;
@@ -1151,6 +1159,7 @@ export {
1151
1159
  createWebhookDispatcher,
1152
1160
  decorateCollection,
1153
1161
  deriveDocId,
1162
+ isDocId,
1154
1163
  openDB,
1155
1164
  runMigrations,
1156
1165
  validateWebhookConfig
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taladb",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "The embedded vector database for on-device AI — documents, similarity search, and offline sync for browser, React Native, and Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -62,8 +62,8 @@
62
62
  "vitest": "^3.2.0"
63
63
  },
64
64
  "peerDependencies": {
65
- "@taladb/web": "0.11.0",
66
- "@taladb/node": "0.11.0"
65
+ "@taladb/web": "0.11.2",
66
+ "@taladb/node": "0.11.2"
67
67
  },
68
68
  "peerDependenciesMeta": {
69
69
  "@taladb/web": {