bun-sqlite-for-rxdb 1.8.0 → 1.8.3-beta

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 (35) hide show
  1. package/README.md +76 -76
  2. package/dist/index.js +4961 -3283
  3. package/dist/src/connection-pool.d.ts +1 -1
  4. package/dist/src/instance.d.ts +3 -0
  5. package/dist/src/query/builder.d.ts +17 -6
  6. package/dist/src/query/cache.d.ts +8 -9
  7. package/dist/src/query/js-operators/array.d.ts +7 -0
  8. package/dist/src/query/js-operators/comparison.d.ts +7 -0
  9. package/dist/src/query/js-operators/evaluation.d.ts +7 -0
  10. package/dist/src/query/js-operators/index.d.ts +8 -0
  11. package/dist/src/query/js-regex-matcher.d.ts +3 -0
  12. package/dist/src/query/no-op-cache.d.ts +1 -1
  13. package/dist/src/query/operator-registry.d.ts +61 -0
  14. package/dist/src/query/regex-to-sql.d.ts +8 -0
  15. package/dist/src/query/schema-to-field-type.d.ts +9 -0
  16. package/dist/src/query/sql-operators/array.d.ts +7 -0
  17. package/dist/src/query/sql-operators/comparison.d.ts +10 -0
  18. package/dist/src/query/sql-operators/evaluation.d.ts +8 -0
  19. package/dist/src/query/sql-operators/field-utils.d.ts +2 -0
  20. package/dist/src/query/sql-operators/index.d.ts +16 -0
  21. package/dist/src/query/sql-operators/null-aware.d.ts +4 -0
  22. package/dist/src/query/sql-operators/null-semantics.d.ts +2 -0
  23. package/dist/src/query/sql-operators/primitives.d.ts +17 -0
  24. package/dist/src/query/sql-operators/query-budget.d.ts +4 -0
  25. package/dist/src/query/sql-operators/result.d.ts +34 -0
  26. package/dist/src/query/sql-operators/traversal.d.ts +13 -0
  27. package/dist/src/query/sql-typeguard.d.ts +35 -0
  28. package/dist/src/query/type-guards.d.ts +2 -0
  29. package/dist/src/query/value-from-unknowntype.d.ts +21 -0
  30. package/dist/src/statement-manager.d.ts +1 -2
  31. package/dist/src/telemetry.d.ts +7 -0
  32. package/dist/src/top-k-heap.d.ts +13 -0
  33. package/dist/src/types.d.ts +7 -0
  34. package/dist/src/utils/sieve-cache.d.ts +26 -0
  35. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  import { Database } from 'bun:sqlite';
2
2
  export declare function getDatabase(databaseName: string, filename: string): Database;
3
- export declare function releaseDatabase(databaseName: string): void;
3
+ export declare function releaseDatabase(filename: string): void;
4
4
  //# sourceMappingURL=connection-pool.d.ts.map
@@ -13,13 +13,16 @@ export declare class BunSQLiteStorageInstance<RxDocType> implements RxStorageIns
13
13
  readonly options: Readonly<BunSQLiteStorageSettings>;
14
14
  private primaryPath;
15
15
  private tableName;
16
+ private columnInfoCache;
16
17
  private useStoredColumns;
18
+ private filename;
17
19
  closed?: Promise<void>;
18
20
  constructor(params: RxStorageInstanceCreationParams<RxDocType, BunSQLiteStorageSettings>, settings?: BunSQLiteStorageSettings);
19
21
  private initTable;
20
22
  bulkWrite(documentWrites: BulkWriteRow<RxDocType>[], context: string): Promise<RxStorageBulkWriteResponse<RxDocType>>;
21
23
  findDocumentsById(ids: string[], withDeleted: boolean): Promise<RxDocumentData<RxDocType>[]>;
22
24
  query(preparedQuery: PreparedQuery<RxDocType>): Promise<RxStorageQueryResult<RxDocType>>;
25
+ private getBsonType;
23
26
  private sortDocuments;
24
27
  private getNestedValue;
25
28
  count(preparedQuery: PreparedQuery<RxDocType>): Promise<RxStorageCountResult>;
@@ -1,12 +1,23 @@
1
1
  import type { RxJsonSchema, MangoQuerySelector, RxDocumentData } from 'rxdb';
2
- import type { SqlFragment } from './operators';
3
- import type { SieveCache } from './sieve-cache';
4
- export { getCacheSize, clearCache } from './cache';
2
+ import type { SqlFragment } from './sql-operators';
3
+ import type { ColumnInfo } from './schema-to-field-type';
4
+ import type { SieveCache } from '../utils/sieve-cache';
5
+ import type { RegexCacheEntry } from './cache';
6
+ export interface QueryContext<RxDocType> {
7
+ schema: RxJsonSchema<RxDocumentData<RxDocType>>;
8
+ collectionName: string;
9
+ columnInfoCache: SieveCache<string, ColumnInfo>;
10
+ regexCache: SieveCache<string, RegexCacheEntry>;
11
+ indexCache: SieveCache<string, boolean>;
12
+ queryCache: SieveCache<string, SqlFragment | null>;
13
+ }
14
+ export declare function setStrictMode(enabled: boolean): void;
15
+ export declare function getStrictMode(): boolean;
5
16
  export interface BipartiteQuery<RxDocType> {
6
17
  sqlWhere: SqlFragment | null;
7
18
  jsSelector: MangoQuerySelector<RxDocumentData<RxDocType>> | null;
8
19
  }
9
- export declare function buildWhereClause<RxDocType>(selector: MangoQuerySelector<RxDocumentData<RxDocType>>, schema: RxJsonSchema<RxDocumentData<RxDocType>>, collectionName: string, cache?: Map<string, SqlFragment | null> | SieveCache<string, SqlFragment | null>): SqlFragment | null;
10
- export declare function buildWhereClauseWithFallback<RxDocType>(selector: MangoQuerySelector<RxDocumentData<RxDocType>>, schema: RxJsonSchema<RxDocumentData<RxDocType>>, collectionName: string, cache?: Map<string, SqlFragment | null> | SieveCache<string, SqlFragment | null>): BipartiteQuery<RxDocType>;
11
- export declare function buildLogicalOperator<RxDocType>(operator: 'or' | 'nor' | 'and', conditions: MangoQuerySelector<RxDocumentData<RxDocType>>[], schema: RxJsonSchema<RxDocumentData<RxDocType>>, logicalDepth: number): SqlFragment | null;
20
+ export declare function buildWhereClause<RxDocType>(selector: MangoQuerySelector<RxDocumentData<RxDocType>>, context: QueryContext<RxDocType>): SqlFragment | null;
21
+ export declare function buildWhereClauseWithFallback<RxDocType>(selector: MangoQuerySelector<RxDocumentData<RxDocType>>, context: QueryContext<RxDocType>): BipartiteQuery<RxDocType>;
22
+ export declare function buildLogicalOperator<RxDocType>(operator: 'or' | 'nor' | 'and', conditions: MangoQuerySelector<RxDocumentData<RxDocType>>[], context: QueryContext<RxDocType>, logicalDepth: number): SqlFragment | null;
12
23
  //# sourceMappingURL=builder.d.ts.map
@@ -1,18 +1,17 @@
1
1
  import type { Database } from 'bun:sqlite';
2
- import type { SqlFragment } from './operators';
3
- import { SieveCache } from './sieve-cache';
2
+ import type { SqlFragment } from './sql-operators';
3
+ import { SieveCache } from '../utils/sieve-cache';
4
+ import type { ColumnInfo } from './schema-to-field-type';
4
5
  export declare const MAX_QUERY_CACHE_SIZE = 5000;
5
6
  export declare const MAX_REGEX_CACHE_SIZE = 100;
6
7
  export declare const MAX_INDEX_CACHE_SIZE = 1000;
8
+ export declare const MAX_COLUMN_INFO_CACHE_SIZE = 200;
7
9
  export declare function getQueryCache(database: Database): SieveCache<string, SqlFragment | null>;
8
- export declare function getGlobalCache(): SieveCache<string, SqlFragment | null>;
9
- export declare function getCacheSize(): number;
10
- export declare function clearCache(): void;
11
10
  export interface RegexCacheEntry {
12
11
  regex: RegExp;
13
12
  }
14
- export declare function getRegexCache(): SieveCache<string, RegexCacheEntry>;
15
- export declare function clearRegexCache(): void;
16
- export declare function getIndexCache(): SieveCache<string, boolean>;
17
- export declare function clearIndexCache(): void;
13
+ export declare function getRegexCache(database: Database): SieveCache<string, RegexCacheEntry>;
14
+ export declare function getIndexCache(database: Database): SieveCache<string, boolean>;
15
+ export declare function getJsRegexCache(database: Database): SieveCache<string, RegexCacheEntry>;
16
+ export declare function getColumnInfoCache(database: Database): SieveCache<string, ColumnInfo>;
18
17
  //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { MangoQuerySelector } from 'rxdb';
2
+ import type { Database } from 'bun:sqlite';
3
+ type MatcherFn<T = unknown> = (doc: T, selector: MangoQuerySelector<T>, database: Database) => boolean;
4
+ type OperatorFn = (value: unknown, arg: unknown, matcher?: MatcherFn, database?: Database) => boolean;
5
+ export declare const arrayOps: Record<string, OperatorFn>;
6
+ export {};
7
+ //# sourceMappingURL=array.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { MangoQuerySelector } from 'rxdb';
2
+ import type { Database } from 'bun:sqlite';
3
+ type MatcherFn<T = unknown> = (doc: T, selector: MangoQuerySelector<T>, database: Database) => boolean;
4
+ type OperatorFn = (value: unknown, arg: unknown, matcher?: MatcherFn, database?: Database) => boolean;
5
+ export declare const comparisonOps: Record<string, OperatorFn>;
6
+ export {};
7
+ //# sourceMappingURL=comparison.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { MangoQuerySelector } from 'rxdb';
2
+ import type { Database } from 'bun:sqlite';
3
+ type MatcherFn<T = unknown> = (doc: T, selector: MangoQuerySelector<T>, database: Database) => boolean;
4
+ type OperatorFn = (value: unknown, arg: unknown, matcher?: MatcherFn, database?: Database) => boolean;
5
+ export declare const evaluationOps: Record<string, OperatorFn>;
6
+ export {};
7
+ //# sourceMappingURL=evaluation.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { RxDocumentData, MangoQuerySelector } from 'rxdb';
2
+ import type { Database } from 'bun:sqlite';
3
+ type MatcherFn<T = unknown> = (doc: T, selector: MangoQuerySelector<T>, database: Database) => boolean;
4
+ export declare function isOperatorObject(obj: unknown): obj is Record<string, unknown>;
5
+ export declare function matchesOperators(value: unknown, condition: Record<string, unknown>, matcher: MatcherFn, database: Database): boolean;
6
+ export declare function matchesSelector<RxDocType>(doc: RxDocumentData<RxDocType>, selector: MangoQuerySelector<RxDocumentData<RxDocType>>, database: Database): boolean;
7
+ export {};
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { Database } from 'bun:sqlite';
2
+ export declare function matchesRegex(value: unknown, pattern: string, options: string | undefined, database: Database): boolean;
3
+ //# sourceMappingURL=js-regex-matcher.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { SqlFragment } from './operators';
1
+ import type { SqlFragment } from './sql-operators';
2
2
  export declare class NoOpCache<K, V> {
3
3
  get size(): number;
4
4
  has(_key: K): boolean;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Operator Registry - Single Source of Truth for MongoDB Query Operators
3
+ *
4
+ * Separates top-level operators (query structure) from field-level operators (value constraints).
5
+ * This separation prevents the "unsupported operator trap" where unknown operators are treated as field names.
6
+ *
7
+ * Architecture:
8
+ * - Top-level operators: Control query structure ($and, $or, $nor, $not)
9
+ * - Field-level operators: Apply constraints to field values ($eq, $gt, $regex, etc.)
10
+ *
11
+ * Design Principles:
12
+ * 1. Single Source of Truth: All supported operators defined in one place
13
+ * 2. Explicit Validation: Unknown operators return null → trigger Mingo fallback
14
+ * 3. Type Safety: Clear separation prevents mixing operator scopes
15
+ * 4. Maintainability: Adding new operators requires updating only this file
16
+ */
17
+ /**
18
+ * Top-level operators that control query structure.
19
+ * These appear at the root of a query selector.
20
+ *
21
+ * Examples:
22
+ * - { $and: [{ age: 30 }, { active: true }] }
23
+ * - { $or: [{ name: 'Alice' }, { name: 'Bob' }] }
24
+ * - { $not: { age: { $gt: 25 } } }
25
+ */
26
+ export declare const TOP_LEVEL_OPERATORS: Set<string>;
27
+ /**
28
+ * Field-level operators that apply constraints to field values.
29
+ * These appear inside field expressions.
30
+ *
31
+ * Examples:
32
+ * - { age: { $gt: 25 } }
33
+ * - { name: { $regex: '^A' } }
34
+ * - { tags: { $elemMatch: { $eq: 'admin' } } }
35
+ */
36
+ export declare const FIELD_LEVEL_OPERATORS: Set<string>;
37
+ /**
38
+ * Checks if a key is a supported top-level operator.
39
+ *
40
+ * @param key - The key to check (e.g., '$and', '$text', 'age')
41
+ * @returns true if the key is a supported top-level operator
42
+ *
43
+ * @example
44
+ * isTopLevelOperator('$and') // true
45
+ * isTopLevelOperator('$text') // false (unsupported)
46
+ * isTopLevelOperator('age') // false (field name)
47
+ */
48
+ export declare function isTopLevelOperator(key: string): boolean;
49
+ /**
50
+ * Checks if a key is a supported field-level operator.
51
+ *
52
+ * @param key - The key to check (e.g., '$eq', '$bitsAllSet', 'name')
53
+ * @returns true if the key is a supported field-level operator
54
+ *
55
+ * @example
56
+ * isFieldLevelOperator('$eq') // true
57
+ * isFieldLevelOperator('$bitsAllSet') // false (unsupported)
58
+ * isFieldLevelOperator('name') // false (field name)
59
+ */
60
+ export declare function isFieldLevelOperator(key: string): boolean;
61
+ //# sourceMappingURL=operator-registry.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { QueryContext } from './builder';
2
+ export interface SqlFragment {
3
+ sql: string;
4
+ args: (string | number | boolean)[];
5
+ }
6
+ export declare function extractRegexPrefix(pattern: string): string | null;
7
+ export declare function smartRegexToLike<RxDocType>(field: string, pattern: string, options: string | undefined, context: QueryContext<RxDocType>, fieldName: string): SqlFragment | null;
8
+ //# sourceMappingURL=regex-to-sql.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { RxJsonSchema, RxDocumentData } from 'rxdb';
2
+ export interface ColumnInfo {
3
+ column?: string;
4
+ jsonPath?: string;
5
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'unknown';
6
+ elementType?: 'string' | 'number' | 'boolean' | 'object';
7
+ }
8
+ export declare function getColumnInfo<RxDocType>(path: string, schema: RxJsonSchema<RxDocumentData<RxDocType>>): ColumnInfo;
9
+ //# sourceMappingURL=schema-to-field-type.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { SqlFragment } from './primitives';
2
+ import type { SqlResult } from './result';
3
+ import type { ColumnInfo } from '../schema-to-field-type';
4
+ export declare function translateIn(field: string, values: unknown[], columnInfo?: ColumnInfo): SqlResult<SqlFragment>;
5
+ export declare function translateNin(field: string, values: unknown[], columnInfo?: ColumnInfo): SqlResult<SqlFragment>;
6
+ export declare function translateSize(jsonColumn: string, jsonPath: string, size: number, isDirectPath?: boolean, columnInfo?: ColumnInfo): SqlResult<SqlFragment>;
7
+ //# sourceMappingURL=array.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { SqlFragment } from './primitives';
2
+ import type { SqlResult } from './result';
3
+ import type { ColumnInfo } from '../schema-to-field-type';
4
+ export declare function translateEq(field: string, value: unknown, columnInfo?: ColumnInfo): SqlResult<SqlFragment>;
5
+ export declare function translateNe(field: string, value: unknown, columnInfo?: ColumnInfo): SqlResult<SqlFragment>;
6
+ export declare function translateGt(field: string, value: unknown, columnInfo?: ColumnInfo): SqlResult<SqlFragment>;
7
+ export declare function translateGte(field: string, value: unknown, columnInfo?: ColumnInfo): SqlResult<SqlFragment>;
8
+ export declare function translateLt(field: string, value: unknown, columnInfo?: ColumnInfo): SqlResult<SqlFragment>;
9
+ export declare function translateLte(field: string, value: unknown, columnInfo?: ColumnInfo): SqlResult<SqlFragment>;
10
+ //# sourceMappingURL=comparison.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { SqlFragment } from './primitives';
2
+ import type { SqlResult } from './result';
3
+ import type { QueryContext } from '../builder';
4
+ export declare function translateExists(field: string, exists: boolean): SqlResult<SqlFragment>;
5
+ export declare function translateRegex<RxDocType>(field: string, pattern: string, options: string | undefined, context: QueryContext<RxDocType>, fieldName: string): SqlResult<SqlFragment>;
6
+ export declare function translateType<RxDocType>(jsonColumn: string, fieldName: string, type: string | number, isDirectPath?: boolean, context?: QueryContext<RxDocType>): SqlResult<SqlFragment>;
7
+ export declare function translateMod(field: string, value: unknown): SqlResult<SqlFragment>;
8
+ //# sourceMappingURL=evaluation.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare function getTypeExpression(field: string): string;
2
+ //# sourceMappingURL=field-utils.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { SqlFragment, PathSegment } from './primitives';
2
+ import { parsePath, buildJsonPath, normalizeValueForSQLite } from './primitives';
3
+ import { translateEq, translateNe, translateGt, translateGte, translateLt, translateLte } from './comparison';
4
+ import { translateIn, translateNin, translateSize } from './array';
5
+ import { translateExists, translateRegex, translateType, translateMod } from './evaluation';
6
+ import { translateElemMatch, wrapWithArrayTraversal, wrapWithNot, resetQueryBudget, type ElemMatchCriteria } from './traversal';
7
+ import type { QueryContext } from '../builder';
8
+ export { SqlFragment, PathSegment, ElemMatchCriteria };
9
+ export { parsePath, buildJsonPath, normalizeValueForSQLite };
10
+ export { translateEq, translateNe, translateGt, translateGte, translateLt, translateLte };
11
+ export { translateIn, translateNin, translateSize };
12
+ export { translateExists, translateRegex, translateType, translateMod };
13
+ export { translateElemMatch, wrapWithArrayTraversal, wrapWithNot, resetQueryBudget };
14
+ export type { SqlResult } from './result';
15
+ export declare function translateLeafOperator<RxDocType>(op: string, field: string, value: unknown, context: QueryContext<RxDocType>, actualFieldName: string): SqlFragment | null;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { SqlFragment } from './primitives';
2
+ import type { SqlResult } from './result';
3
+ export declare function buildNullAwareInClause(field: string, values: unknown[], operator: 'IN' | 'NOT IN'): SqlResult<SqlFragment>;
4
+ //# sourceMappingURL=null-aware.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare function shouldUseFieldLevelNull(op: string, value: unknown): boolean;
2
+ //# sourceMappingURL=null-semantics.d.ts.map
@@ -0,0 +1,17 @@
1
+ import type { RxJsonSchema } from 'rxdb';
2
+ export interface SqlFragment {
3
+ sql: string;
4
+ args: (string | number | boolean | bigint | null)[];
5
+ }
6
+ export type PathSegment = {
7
+ type: 'property';
8
+ key: string;
9
+ } | {
10
+ type: 'index';
11
+ index: number;
12
+ };
13
+ export declare function parsePath(fieldName: string, schema?: RxJsonSchema<any>): PathSegment[];
14
+ export declare function buildJsonPath(fieldName: string, schema?: RxJsonSchema<any>): string;
15
+ export declare function normalizeValueForSQLite(value: unknown): string | number | boolean | bigint | null;
16
+ export declare function isArrayOrObject(value: unknown): boolean;
17
+ //# sourceMappingURL=primitives.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare function resetQueryBudget(): void;
2
+ export declare function canAllocateVirtualTable(): boolean;
3
+ export declare function allocateVirtualTable(): boolean;
4
+ //# sourceMappingURL=query-budget.d.ts.map
@@ -0,0 +1,34 @@
1
+ export type SqlResult<T = SqlFragment> = {
2
+ ok: true;
3
+ value: T;
4
+ } | {
5
+ ok: false;
6
+ reason: string;
7
+ location: string;
8
+ context?: unknown;
9
+ } | {
10
+ ok: false;
11
+ fallback: true;
12
+ reason: string;
13
+ context?: unknown;
14
+ };
15
+ export interface SqlFragment {
16
+ sql: string;
17
+ args: (string | number | boolean | bigint | null)[];
18
+ }
19
+ export declare function ok<T>(value: T): SqlResult<T>;
20
+ export declare function fail(reason: string, location: string, context?: unknown): SqlResult<never>;
21
+ export declare function jsFallback(reason: string, context?: unknown): SqlResult<never>;
22
+ export declare function isOk<T>(result: SqlResult<T>): result is {
23
+ ok: true;
24
+ value: T;
25
+ };
26
+ export declare function isJsFallback(result: SqlResult<unknown>): result is {
27
+ ok: false;
28
+ fallback: true;
29
+ reason: string;
30
+ context?: unknown;
31
+ };
32
+ export declare function unwrap<T>(result: SqlResult<T>): T | null;
33
+ export declare function getError(result: SqlResult<unknown>): string | null;
34
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { SqlFragment } from './primitives';
2
+ import { resetQueryBudget } from './query-budget';
3
+ import type { SqlResult } from './result';
4
+ import type { QueryContext } from '../builder';
5
+ import { type SchemaType } from '../sql-typeguard';
6
+ export { resetQueryBudget };
7
+ export declare function getElementFragment(op: string, value: unknown, elementType?: SchemaType): SqlResult<SqlFragment>;
8
+ export declare function buildElemMatchConditions<RxDocType>(criteria: Record<string, unknown>, context: QueryContext<RxDocType>, baseFieldName: string): SqlResult<SqlFragment>;
9
+ export type ElemMatchCriteria = string | number | boolean | null | Record<string, unknown>;
10
+ export declare function translateElemMatch<RxDocType>(field: string, criteria: ElemMatchCriteria, context: QueryContext<RxDocType>, actualFieldName: string): SqlResult<SqlFragment>;
11
+ export declare function wrapWithArrayTraversal(elementFragment: SqlFragment, jsonPath: string, op: string, depth?: number, recursive?: boolean): SqlResult<SqlFragment>;
12
+ export declare function wrapWithNot(innerFragment: SqlFragment): SqlResult<SqlFragment>;
13
+ //# sourceMappingURL=traversal.d.ts.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Type compatibility checker for MongoDB-like query operators.
3
+ * Determines when type guards are needed for SQL translation.
4
+ */
5
+ import type { SqlFragment } from './sql-operators/primitives';
6
+ export type SchemaType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'unknown';
7
+ export interface ColumnInfo {
8
+ type: SchemaType;
9
+ isArray?: boolean;
10
+ }
11
+ export declare class TypeChecker {
12
+ /**
13
+ * Check if schema type is compatible with value type.
14
+ * MongoDB has NO type coercion: "25" !== 25
15
+ */
16
+ static isCompatible(schemaType: SchemaType, valueType: SchemaType): boolean;
17
+ /**
18
+ * Early rejection for type mismatches on known fields.
19
+ * MongoDB semantics: type mismatch = no matches (or all matches for $ne).
20
+ *
21
+ * Returns SqlFragment if type mismatch detected, null otherwise.
22
+ */
23
+ static earlyRejectTypeMismatch(columnInfo: ColumnInfo | undefined, value: unknown, op: string): SqlFragment | null;
24
+ /**
25
+ * Determine if a type guard is needed for SQL comparison.
26
+ * Returns true when types don't match or schema info is missing.
27
+ */
28
+ static needsGuard(columnInfo: ColumnInfo | undefined, value: unknown): boolean;
29
+ /**
30
+ * Check if value type matches expected schema type.
31
+ * Used for validation and error messages.
32
+ */
33
+ static matchesSchema(columnInfo: ColumnInfo | undefined, value: unknown): boolean;
34
+ }
35
+ //# sourceMappingURL=sql-typeguard.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare function addTypeGuard(field: string, value: unknown, comparisonSql: string): string;
2
+ //# sourceMappingURL=type-guards.d.ts.map
@@ -0,0 +1,21 @@
1
+ import type { RxJsonSchema } from 'rxdb';
2
+ import type { SqlFragment } from './sql-operators';
3
+ /**
4
+ * Handles queries on fields with unknown types (not in schema).
5
+ *
6
+ * Strategy: Use JavaScript matcher instead of SQL.
7
+ * Reason: Benchmarks show JS is 2-9x faster than SQLite json_each() for unknown types.
8
+ *
9
+ * This module provides the core logic for traversing nested paths with implicit array handling.
10
+ */
11
+ /**
12
+ * Get nested value from object, with implicit array traversal.
13
+ *
14
+ * Examples:
15
+ * - getNestedValue({a: {b: 1}}, 'a.b') → 1
16
+ * - getNestedValue({a: [{b: 1}, {b: 2}]}, 'a.b') → [1, 2]
17
+ * - getNestedValue({a: [[{b: 1}]]}, 'a.b') → [1]
18
+ */
19
+ export declare function getNestedValue(obj: unknown, path: string): unknown;
20
+ export declare function buildUnknownTypeQuery(fieldPath: string, scalarFragment: SqlFragment, arrayFragment: SqlFragment, schema: RxJsonSchema<any>): SqlFragment | null;
21
+ //# sourceMappingURL=value-from-unknowntype.d.ts.map
@@ -6,12 +6,11 @@ export type QueryWithParams = {
6
6
  export declare class StatementManager {
7
7
  private db;
8
8
  private staticStatements;
9
- private static readonly MAX_STATEMENTS;
10
9
  private closed;
11
10
  constructor(db: Database);
12
11
  private checkClosed;
13
- private evictOldest;
14
12
  all<T = unknown>(queryWithParams: QueryWithParams): T[];
13
+ values<T = unknown[]>(queryWithParams: QueryWithParams): T[];
15
14
  get(queryWithParams: QueryWithParams): unknown;
16
15
  run(queryWithParams: QueryWithParams): Changes;
17
16
  close(): void;
@@ -0,0 +1,7 @@
1
+ export interface QueryTelemetry {
2
+ sqlFallbackCount: number;
3
+ sqlSuccessCount: number;
4
+ jsEvaluationCount: number;
5
+ }
6
+ export declare function logSqlFallback(selector: unknown, reason: string): void;
7
+ //# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { RxDocumentData, MangoQuerySortPart } from 'rxdb';
2
+ export declare class TopKHeap<RxDocType> {
3
+ private heap;
4
+ private maxSize;
5
+ private compareFn;
6
+ constructor(maxSize: number, sort: MangoQuerySortPart<RxDocType>[], getBsonType: (val: any) => number, getNestedValue: (obj: RxDocumentData<RxDocType>, path: string) => unknown);
7
+ insert(doc: RxDocumentData<RxDocType>): void;
8
+ private bubbleUp;
9
+ private bubbleDown;
10
+ getSorted(): RxDocumentData<RxDocType>[];
11
+ size(): number;
12
+ }
13
+ //# sourceMappingURL=top-k-heap.d.ts.map
@@ -22,6 +22,13 @@ export interface BunSQLiteStorageSettings {
22
22
  * @experimental Alpha feature - opt-in for testing
23
23
  */
24
24
  useStoredColumns?: false | 'virtual' | 'stored';
25
+ /**
26
+ * Enable strict MongoDB/Mingo type checking behavior.
27
+ * - false (default): RxDB-friendly mode - Date queries match ISO string fields with GLOB validation
28
+ * - true: Strict mode - Date queries only match Date fields (MongoDB/Mingo spec compliance)
29
+ * @default false
30
+ */
31
+ strict?: boolean;
25
32
  }
26
33
  export interface BunSQLiteInternals {
27
34
  db: Database;
@@ -0,0 +1,26 @@
1
+ export declare class SieveCache<K, V> {
2
+ #private;
3
+ constructor(capacity: number);
4
+ get size(): number;
5
+ has(key: K): boolean;
6
+ get(key: K): V | undefined;
7
+ set(key: K, value: V): this;
8
+ delete(key: K): boolean;
9
+ clear(): void;
10
+ forEach(callbackfn: (value: V, key: K, map: SieveCache<K, V>) => void, thisArg?: any): void;
11
+ entries(): IterableIterator<[K, V]>;
12
+ keys(): IterableIterator<K>;
13
+ values(): IterableIterator<V>;
14
+ getStats(): {
15
+ hits: number;
16
+ misses: number;
17
+ total: number;
18
+ hitRate: number;
19
+ size: number;
20
+ capacity: number;
21
+ };
22
+ resetStats(): void;
23
+ [Symbol.iterator](): IterableIterator<[K, V]>;
24
+ get [Symbol.toStringTag](): string;
25
+ }
26
+ //# sourceMappingURL=sieve-cache.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-sqlite-for-rxdb",
3
- "version": "1.8.0",
3
+ "version": "1.8.3-beta",
4
4
  "author": "adam2am",
5
5
  "repository": {
6
6
  "type": "git",