bun-sqlite-for-rxdb 1.0.1 → 1.3.1
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/CHANGELOG.md +422 -0
- package/dist/connection-pool.d.ts +4 -0
- package/{src/index.ts → dist/index.d.ts} +1 -0
- package/dist/index.js +13560 -0
- package/dist/instance.d.ts +43 -0
- package/dist/query/builder.d.ts +7 -0
- package/dist/query/operators.d.ts +28 -0
- package/dist/query/regex-matcher.d.ts +2 -0
- package/dist/query/schema-mapper.d.ts +8 -0
- package/dist/query/smart-regex.d.ts +7 -0
- package/dist/rxdb-helpers.d.ts +28 -0
- package/dist/src/connection-pool.d.ts +4 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/instance.d.ts +44 -0
- package/dist/src/query/builder.d.ts +6 -0
- package/dist/src/query/operators.d.ts +27 -0
- package/dist/src/query/regex-matcher.d.ts +2 -0
- package/dist/src/query/schema-mapper.d.ts +8 -0
- package/dist/src/query/smart-regex.d.ts +7 -0
- package/dist/src/rxdb-helpers.d.ts +28 -0
- package/dist/src/statement-manager.d.ts +20 -0
- package/dist/src/storage.d.ts +4 -0
- package/dist/src/transaction-queue.d.ts +3 -0
- package/dist/src/types.d.ts +20 -0
- package/dist/src/utils/stable-stringify.d.ts +16 -0
- package/dist/statement-manager.d.ts +15 -0
- package/dist/storage.d.ts +4 -0
- package/dist/types.d.ts +13 -0
- package/package.json +18 -9
- package/.serena/project.yml +0 -84
- package/ROADMAP.md +0 -532
- package/benchmarks/benchmark.ts +0 -145
- package/benchmarks/case-insensitive-10runs.ts +0 -156
- package/benchmarks/fts5-1m-scale.ts +0 -126
- package/benchmarks/fts5-before-after.ts +0 -104
- package/benchmarks/indexed-benchmark.ts +0 -141
- package/benchmarks/new-operators-benchmark.ts +0 -140
- package/benchmarks/query-builder-benchmark.ts +0 -88
- package/benchmarks/query-builder-consistency.ts +0 -109
- package/benchmarks/raw-better-sqlite3-10m.ts +0 -85
- package/benchmarks/raw-better-sqlite3.ts +0 -86
- package/benchmarks/raw-bun-sqlite-10m.ts +0 -85
- package/benchmarks/raw-bun-sqlite.ts +0 -86
- package/benchmarks/regex-10runs-all.ts +0 -216
- package/benchmarks/regex-comparison-benchmark.ts +0 -161
- package/benchmarks/regex-real-comparison.ts +0 -213
- package/benchmarks/run-10x.sh +0 -19
- package/benchmarks/smart-regex-benchmark.ts +0 -148
- package/benchmarks/sql-vs-mingo-benchmark.ts +0 -210
- package/benchmarks/sql-vs-mingo-comparison.ts +0 -175
- package/benchmarks/text-vs-jsonb.ts +0 -167
- package/benchmarks/wal-benchmark.ts +0 -112
- package/docs/architectural-patterns.md +0 -1336
- package/docs/id1-testsuite-journey.md +0 -839
- package/docs/official-test-suite-setup.md +0 -393
- package/nul +0 -0
- package/src/changestream.test.ts +0 -182
- package/src/cleanup.test.ts +0 -110
- package/src/collection-isolation.test.ts +0 -74
- package/src/connection-pool.test.ts +0 -102
- package/src/connection-pool.ts +0 -38
- package/src/findDocumentsById.test.ts +0 -122
- package/src/instance.ts +0 -382
- package/src/multi-instance-events.test.ts +0 -204
- package/src/query/and-operator.test.ts +0 -39
- package/src/query/builder.test.ts +0 -96
- package/src/query/builder.ts +0 -154
- package/src/query/elemMatch-operator.test.ts +0 -24
- package/src/query/exists-operator.test.ts +0 -28
- package/src/query/in-operators.test.ts +0 -54
- package/src/query/mod-operator.test.ts +0 -22
- package/src/query/nested-query.test.ts +0 -198
- package/src/query/not-operators.test.ts +0 -49
- package/src/query/operators.test.ts +0 -70
- package/src/query/operators.ts +0 -185
- package/src/query/or-operator.test.ts +0 -68
- package/src/query/regex-escaping-regression.test.ts +0 -43
- package/src/query/regex-operator.test.ts +0 -44
- package/src/query/schema-mapper.ts +0 -27
- package/src/query/size-operator.test.ts +0 -22
- package/src/query/smart-regex.ts +0 -52
- package/src/query/type-operator.test.ts +0 -37
- package/src/query-cache.test.ts +0 -286
- package/src/rxdb-helpers.test.ts +0 -348
- package/src/rxdb-helpers.ts +0 -262
- package/src/schema-version-isolation.test.ts +0 -126
- package/src/statement-manager.ts +0 -69
- package/src/storage.test.ts +0 -589
- package/src/storage.ts +0 -21
- package/src/types.ts +0 -14
- package/test/rxdb-test-suite.ts +0 -27
- package/tsconfig.json +0 -31
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import type { RxStorageInstance, RxStorageInstanceCreationParams, BulkWriteRow, RxDocumentData, RxStorageBulkWriteResponse, RxStorageQueryResult, RxStorageCountResult, EventBulk, RxStorageChangeEvent, PreparedQuery, RxJsonSchema, RxStorageDefaultCheckpoint } from 'rxdb';
|
|
3
|
+
import type { BunSQLiteStorageSettings, BunSQLiteInternals } from './types';
|
|
4
|
+
export declare class BunSQLiteStorageInstance<RxDocType> implements RxStorageInstance<RxDocType, BunSQLiteInternals, BunSQLiteStorageSettings> {
|
|
5
|
+
private db;
|
|
6
|
+
private stmtManager;
|
|
7
|
+
private changeStream$;
|
|
8
|
+
readonly databaseName: string;
|
|
9
|
+
readonly collectionName: string;
|
|
10
|
+
readonly schema: Readonly<RxJsonSchema<RxDocumentData<RxDocType>>>;
|
|
11
|
+
readonly internals: Readonly<BunSQLiteInternals>;
|
|
12
|
+
readonly options: Readonly<BunSQLiteStorageSettings>;
|
|
13
|
+
private primaryPath;
|
|
14
|
+
private tableName;
|
|
15
|
+
closed?: Promise<void>;
|
|
16
|
+
constructor(params: RxStorageInstanceCreationParams<RxDocType, BunSQLiteStorageSettings>, settings?: BunSQLiteStorageSettings);
|
|
17
|
+
private initTable;
|
|
18
|
+
bulkWrite(documentWrites: BulkWriteRow<RxDocType>[], context: string): Promise<RxStorageBulkWriteResponse<RxDocType>>;
|
|
19
|
+
findDocumentsById(ids: string[], withDeleted: boolean): Promise<RxDocumentData<RxDocType>[]>;
|
|
20
|
+
query(preparedQuery: PreparedQuery<RxDocType>): Promise<RxStorageQueryResult<RxDocType>>;
|
|
21
|
+
private matchesSelector;
|
|
22
|
+
private sortDocuments;
|
|
23
|
+
private getNestedValue;
|
|
24
|
+
count(preparedQuery: PreparedQuery<RxDocType>): Promise<RxStorageCountResult>;
|
|
25
|
+
changeStream(): Observable<EventBulk<RxStorageChangeEvent<RxDocumentData<RxDocType>>, RxStorageDefaultCheckpoint>>;
|
|
26
|
+
cleanup(minimumDeletedTime: number): Promise<boolean>;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
remove(): Promise<void>;
|
|
29
|
+
private attachmentMapKey;
|
|
30
|
+
getAttachmentData(documentId: string, attachmentId: string, digest: string): Promise<string>;
|
|
31
|
+
getChangedDocumentsSince(limit: number, checkpoint?: {
|
|
32
|
+
id: string;
|
|
33
|
+
lwt: number;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
documents: RxDocumentData<RxDocType>[];
|
|
36
|
+
checkpoint: {
|
|
37
|
+
id: string;
|
|
38
|
+
lwt: number;
|
|
39
|
+
} | null;
|
|
40
|
+
}>;
|
|
41
|
+
private queryWithOurMemory;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=instance.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RxJsonSchema, MangoQuerySelector, RxDocumentData } from 'rxdb';
|
|
2
|
+
import type { SqlFragment } from './operators';
|
|
3
|
+
export declare function canTranslateToSQL<RxDocType>(selector: MangoQuerySelector<RxDocumentData<RxDocType>>, schema?: RxJsonSchema<RxDocumentData<RxDocType>>): boolean;
|
|
4
|
+
export declare function getCacheSize(): number;
|
|
5
|
+
export declare function clearCache(): void;
|
|
6
|
+
export declare function buildWhereClause<RxDocType>(selector: MangoQuerySelector<RxDocumentData<RxDocType>>, schema: RxJsonSchema<RxDocumentData<RxDocType>>, collectionName: string): SqlFragment;
|
|
7
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RxJsonSchema, RxDocumentData } from 'rxdb';
|
|
2
|
+
export interface SqlFragment {
|
|
3
|
+
sql: string;
|
|
4
|
+
args: (string | number | boolean | null)[];
|
|
5
|
+
}
|
|
6
|
+
type QueryValue = string | number | boolean | null;
|
|
7
|
+
type OperatorExpression = {
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type ElemMatchCriteria = QueryValue | OperatorExpression;
|
|
11
|
+
export declare function translateEq(field: string, value: unknown): SqlFragment;
|
|
12
|
+
export declare function translateNe(field: string, value: unknown): SqlFragment;
|
|
13
|
+
export declare function translateGt(field: string, value: unknown): SqlFragment;
|
|
14
|
+
export declare function translateGte(field: string, value: unknown): SqlFragment;
|
|
15
|
+
export declare function translateLt(field: string, value: unknown): SqlFragment;
|
|
16
|
+
export declare function translateLte(field: string, value: unknown): SqlFragment;
|
|
17
|
+
export declare function translateIn(field: string, values: unknown[]): SqlFragment;
|
|
18
|
+
export declare function translateNin(field: string, values: unknown[]): SqlFragment;
|
|
19
|
+
export declare function translateExists(field: string, exists: boolean): SqlFragment;
|
|
20
|
+
export declare function translateRegex<RxDocType>(field: string, pattern: string, options: string | undefined, schema: RxJsonSchema<RxDocumentData<RxDocType>>, fieldName: string): SqlFragment | null;
|
|
21
|
+
export declare function translateElemMatch(field: string, criteria: ElemMatchCriteria): SqlFragment | null;
|
|
22
|
+
export declare function translateNot(field: string, criteria: unknown): SqlFragment;
|
|
23
|
+
export declare function translateType(jsonColumn: string, // rename from tableName — it's the JSON column ("data", "payload", etc.)
|
|
24
|
+
fieldName: string, type: string): SqlFragment | null;
|
|
25
|
+
export declare function translateSize(field: string, size: number): SqlFragment;
|
|
26
|
+
export declare function translateMod(field: string, [divisor, remainder]: [number, number]): SqlFragment;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RxJsonSchema, RxDocumentData } from 'rxdb';
|
|
2
|
+
export interface ColumnInfo {
|
|
3
|
+
column?: string;
|
|
4
|
+
jsonPath?: string;
|
|
5
|
+
type: 'string' | 'number' | 'boolean' | 'unknown';
|
|
6
|
+
}
|
|
7
|
+
export declare function getColumnInfo<RxDocType>(path: string, schema: RxJsonSchema<RxDocumentData<RxDocType>>): ColumnInfo;
|
|
8
|
+
//# sourceMappingURL=schema-mapper.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RxJsonSchema, RxDocumentData } from 'rxdb';
|
|
2
|
+
export interface SqlFragment {
|
|
3
|
+
sql: string;
|
|
4
|
+
args: (string | number | boolean)[];
|
|
5
|
+
}
|
|
6
|
+
export declare function smartRegexToLike<RxDocType>(field: string, pattern: string, options: string | undefined, schema: RxJsonSchema<RxDocumentData<RxDocType>>, fieldName: string): SqlFragment | null;
|
|
7
|
+
//# sourceMappingURL=smart-regex.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RxStorageInstance, BulkWriteRow, RxDocumentData, RxStorageWriteError, EventBulk, RxStorageChangeEvent, RxStorageInstanceCreationParams, RxStorageDefaultCheckpoint, RxAttachmentWriteData } from 'rxdb';
|
|
2
|
+
export interface AttachmentOperation {
|
|
3
|
+
documentId: string;
|
|
4
|
+
attachmentId: string;
|
|
5
|
+
attachmentData: RxAttachmentWriteData;
|
|
6
|
+
digest: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AttachmentRemoveOperation {
|
|
9
|
+
documentId: string;
|
|
10
|
+
attachmentId: string;
|
|
11
|
+
digest: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function getAttachmentSize(attachmentBase64String: string): number;
|
|
14
|
+
export declare function attachmentWriteDataToNormalData(writeData: RxAttachmentWriteData): any;
|
|
15
|
+
export declare function stripAttachmentsDataFromDocument<T>(doc: RxDocumentData<T>): RxDocumentData<T>;
|
|
16
|
+
export declare function stripAttachmentsDataFromRow<T>(writeRow: BulkWriteRow<T>): BulkWriteRow<T>;
|
|
17
|
+
export declare function categorizeBulkWriteRows<RxDocType>(storageInstance: RxStorageInstance<RxDocType, any, any>, primaryPath: string, docsInDb: Map<string, RxDocumentData<RxDocType>>, bulkWriteRows: BulkWriteRow<RxDocType>[], context: string): {
|
|
18
|
+
bulkInsertDocs: BulkWriteRow<RxDocType>[];
|
|
19
|
+
bulkUpdateDocs: BulkWriteRow<RxDocType>[];
|
|
20
|
+
errors: RxStorageWriteError<RxDocType>[];
|
|
21
|
+
eventBulk: EventBulk<RxStorageChangeEvent<RxDocumentData<RxDocType>>, RxStorageDefaultCheckpoint>;
|
|
22
|
+
newestRow?: BulkWriteRow<RxDocType>;
|
|
23
|
+
attachmentsAdd: AttachmentOperation[];
|
|
24
|
+
attachmentsRemove: AttachmentRemoveOperation[];
|
|
25
|
+
attachmentsUpdate: AttachmentOperation[];
|
|
26
|
+
};
|
|
27
|
+
export declare function ensureRxStorageInstanceParamsAreCorrect(params: RxStorageInstanceCreationParams<any, any>): void;
|
|
28
|
+
//# sourceMappingURL=rxdb-helpers.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import type { RxStorageInstance, RxStorageInstanceCreationParams, BulkWriteRow, RxDocumentData, RxStorageBulkWriteResponse, RxStorageQueryResult, RxStorageCountResult, EventBulk, RxStorageChangeEvent, PreparedQuery, RxJsonSchema, RxStorageDefaultCheckpoint } from 'rxdb';
|
|
3
|
+
import type { BunSQLiteStorageSettings, BunSQLiteInternals } from './types';
|
|
4
|
+
export declare class BunSQLiteStorageInstance<RxDocType> implements RxStorageInstance<RxDocType, BunSQLiteInternals, BunSQLiteStorageSettings> {
|
|
5
|
+
private db;
|
|
6
|
+
private stmtManager;
|
|
7
|
+
private changeStream$;
|
|
8
|
+
readonly databaseName: string;
|
|
9
|
+
readonly collectionName: string;
|
|
10
|
+
readonly schema: Readonly<RxJsonSchema<RxDocumentData<RxDocType>>>;
|
|
11
|
+
readonly internals: Readonly<BunSQLiteInternals>;
|
|
12
|
+
readonly options: Readonly<BunSQLiteStorageSettings>;
|
|
13
|
+
private primaryPath;
|
|
14
|
+
private tableName;
|
|
15
|
+
closed?: Promise<void>;
|
|
16
|
+
constructor(params: RxStorageInstanceCreationParams<RxDocType, BunSQLiteStorageSettings>, settings?: BunSQLiteStorageSettings);
|
|
17
|
+
private initTable;
|
|
18
|
+
bulkWrite(documentWrites: BulkWriteRow<RxDocType>[], context: string): Promise<RxStorageBulkWriteResponse<RxDocType>>;
|
|
19
|
+
findDocumentsById(ids: string[], withDeleted: boolean): Promise<RxDocumentData<RxDocType>[]>;
|
|
20
|
+
query(preparedQuery: PreparedQuery<RxDocType>): Promise<RxStorageQueryResult<RxDocType>>;
|
|
21
|
+
private matchesSelector;
|
|
22
|
+
private sortDocuments;
|
|
23
|
+
private getNestedValue;
|
|
24
|
+
count(preparedQuery: PreparedQuery<RxDocType>): Promise<RxStorageCountResult>;
|
|
25
|
+
changeStream(): Observable<EventBulk<RxStorageChangeEvent<RxDocumentData<RxDocType>>, RxStorageDefaultCheckpoint>>;
|
|
26
|
+
cleanup(minimumDeletedTime: number): Promise<boolean>;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
remove(): Promise<void>;
|
|
29
|
+
private attachmentMapKey;
|
|
30
|
+
getAttachmentData(documentId: string, attachmentId: string, digest: string): Promise<string>;
|
|
31
|
+
getChangedDocumentsSince(limit: number, checkpoint?: {
|
|
32
|
+
id: string;
|
|
33
|
+
lwt: number;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
documents: RxDocumentData<RxDocType>[];
|
|
36
|
+
checkpoint: {
|
|
37
|
+
id: string;
|
|
38
|
+
lwt: number;
|
|
39
|
+
} | null;
|
|
40
|
+
}>;
|
|
41
|
+
private queryWithOurMemory;
|
|
42
|
+
private matchesRegexSelector;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=instance.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RxJsonSchema, MangoQuerySelector, RxDocumentData } from 'rxdb';
|
|
2
|
+
import type { SqlFragment } from './operators';
|
|
3
|
+
export declare function getCacheSize(): number;
|
|
4
|
+
export declare function clearCache(): void;
|
|
5
|
+
export declare function buildWhereClause<RxDocType>(selector: MangoQuerySelector<RxDocumentData<RxDocType>>, schema: RxJsonSchema<RxDocumentData<RxDocType>>, collectionName: string): SqlFragment | null;
|
|
6
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RxJsonSchema, RxDocumentData } from 'rxdb';
|
|
2
|
+
export interface SqlFragment {
|
|
3
|
+
sql: string;
|
|
4
|
+
args: (string | number | boolean | null)[];
|
|
5
|
+
}
|
|
6
|
+
type QueryValue = string | number | boolean | null;
|
|
7
|
+
type OperatorExpression = {
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type ElemMatchCriteria = QueryValue | OperatorExpression;
|
|
11
|
+
export declare function translateEq(field: string, value: unknown): SqlFragment;
|
|
12
|
+
export declare function translateNe(field: string, value: unknown): SqlFragment;
|
|
13
|
+
export declare function translateGt(field: string, value: unknown): SqlFragment;
|
|
14
|
+
export declare function translateGte(field: string, value: unknown): SqlFragment;
|
|
15
|
+
export declare function translateLt(field: string, value: unknown): SqlFragment;
|
|
16
|
+
export declare function translateLte(field: string, value: unknown): SqlFragment;
|
|
17
|
+
export declare function translateIn(field: string, values: unknown[]): SqlFragment;
|
|
18
|
+
export declare function translateNin(field: string, values: unknown[]): SqlFragment;
|
|
19
|
+
export declare function translateExists(field: string, exists: boolean): SqlFragment;
|
|
20
|
+
export declare function translateRegex<RxDocType>(field: string, pattern: string, options: string | undefined, schema: RxJsonSchema<RxDocumentData<RxDocType>>, fieldName: string): SqlFragment | null;
|
|
21
|
+
export declare function translateElemMatch(field: string, criteria: ElemMatchCriteria): SqlFragment | null;
|
|
22
|
+
export declare function translateNot(field: string, criteria: unknown): SqlFragment | null;
|
|
23
|
+
export declare function translateType(jsonColumn: string, fieldName: string, type: string): SqlFragment | null;
|
|
24
|
+
export declare function translateSize(field: string, size: number): SqlFragment;
|
|
25
|
+
export declare function translateMod(field: string, value: unknown): SqlFragment | null;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RxJsonSchema, RxDocumentData } from 'rxdb';
|
|
2
|
+
export interface ColumnInfo {
|
|
3
|
+
column?: string;
|
|
4
|
+
jsonPath?: string;
|
|
5
|
+
type: 'string' | 'number' | 'boolean' | 'unknown';
|
|
6
|
+
}
|
|
7
|
+
export declare function getColumnInfo<RxDocType>(path: string, schema: RxJsonSchema<RxDocumentData<RxDocType>>): ColumnInfo;
|
|
8
|
+
//# sourceMappingURL=schema-mapper.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RxJsonSchema, RxDocumentData } from 'rxdb';
|
|
2
|
+
export interface SqlFragment {
|
|
3
|
+
sql: string;
|
|
4
|
+
args: (string | number | boolean)[];
|
|
5
|
+
}
|
|
6
|
+
export declare function smartRegexToLike<RxDocType>(field: string, pattern: string, options: string | undefined, schema: RxJsonSchema<RxDocumentData<RxDocType>>, fieldName: string): SqlFragment | null;
|
|
7
|
+
//# sourceMappingURL=smart-regex.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RxDocumentData, RxStorageWriteError, BulkWriteRow, RxAttachmentWriteData, RxAttachmentData, RxStorageInstance, RxStorageInstanceCreationParams, EventBulk, RxStorageChangeEvent, RxStorageDefaultCheckpoint } from 'rxdb';
|
|
2
|
+
export interface AttachmentOperation {
|
|
3
|
+
documentId: string;
|
|
4
|
+
attachmentId: string;
|
|
5
|
+
attachmentData: RxAttachmentWriteData;
|
|
6
|
+
digest: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AttachmentRemoveOperation {
|
|
9
|
+
documentId: string;
|
|
10
|
+
attachmentId: string;
|
|
11
|
+
digest: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function getAttachmentSize(attachmentBase64String: string): number;
|
|
14
|
+
export declare function attachmentWriteDataToNormalData(writeData: RxAttachmentWriteData): RxAttachmentData;
|
|
15
|
+
export declare function stripAttachmentsDataFromDocument<T>(doc: RxDocumentData<T>): RxDocumentData<T>;
|
|
16
|
+
export declare function stripAttachmentsDataFromRow<T>(writeRow: BulkWriteRow<T>): BulkWriteRow<T>;
|
|
17
|
+
export declare function categorizeBulkWriteRows<RxDocType>(storageInstance: RxStorageInstance<RxDocType, any, any>, primaryPath: string, docsInDb: Map<string, RxDocumentData<RxDocType>>, bulkWriteRows: BulkWriteRow<RxDocType>[], context: string): {
|
|
18
|
+
bulkInsertDocs: BulkWriteRow<RxDocType>[];
|
|
19
|
+
bulkUpdateDocs: BulkWriteRow<RxDocType>[];
|
|
20
|
+
errors: RxStorageWriteError<RxDocType>[];
|
|
21
|
+
eventBulk: EventBulk<RxStorageChangeEvent<RxDocumentData<RxDocType>>, RxStorageDefaultCheckpoint>;
|
|
22
|
+
newestRow?: BulkWriteRow<RxDocType>;
|
|
23
|
+
attachmentsAdd: AttachmentOperation[];
|
|
24
|
+
attachmentsRemove: AttachmentRemoveOperation[];
|
|
25
|
+
attachmentsUpdate: AttachmentOperation[];
|
|
26
|
+
};
|
|
27
|
+
export declare function ensureRxStorageInstanceParamsAreCorrect(params: RxStorageInstanceCreationParams<any, any>): void;
|
|
28
|
+
//# sourceMappingURL=rxdb-helpers.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Database, Changes, SQLQueryBindings } from 'bun:sqlite';
|
|
2
|
+
export type QueryWithParams = {
|
|
3
|
+
query: string;
|
|
4
|
+
params: SQLQueryBindings[];
|
|
5
|
+
};
|
|
6
|
+
export declare class StatementManager {
|
|
7
|
+
private db;
|
|
8
|
+
private staticStatements;
|
|
9
|
+
private static readonly MAX_STATEMENTS;
|
|
10
|
+
private closed;
|
|
11
|
+
constructor(db: Database);
|
|
12
|
+
private checkClosed;
|
|
13
|
+
private evictOldest;
|
|
14
|
+
all<T = unknown>(queryWithParams: QueryWithParams): T[];
|
|
15
|
+
get(queryWithParams: QueryWithParams): unknown;
|
|
16
|
+
run(queryWithParams: QueryWithParams): Changes;
|
|
17
|
+
close(): void;
|
|
18
|
+
private isStaticSQL;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=statement-manager.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RxStorage } from 'rxdb';
|
|
2
|
+
import type { BunSQLiteStorageSettings, BunSQLiteInternals } from './types';
|
|
3
|
+
export declare function getRxStorageBunSQLite(settings?: BunSQLiteStorageSettings): RxStorage<BunSQLiteInternals, BunSQLiteStorageSettings>;
|
|
4
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Database } from 'bun:sqlite';
|
|
2
|
+
export interface BunSQLiteStorageSettings {
|
|
3
|
+
/**
|
|
4
|
+
* Database file path. Use ':memory:' for in-memory database.
|
|
5
|
+
* @default ':memory:'
|
|
6
|
+
*/
|
|
7
|
+
filename?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Memory-mapped I/O size in bytes. Set to 0 to disable.
|
|
10
|
+
* Enables 2-5x faster reads for large databases (>500MB).
|
|
11
|
+
* Trade-off: I/O errors become signals (SIGBUS) instead of returnable errors.
|
|
12
|
+
* @default 268435456 (256MB)
|
|
13
|
+
*/
|
|
14
|
+
mmapSize?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface BunSQLiteInternals {
|
|
17
|
+
db: Database;
|
|
18
|
+
primaryPath: string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun-optimized deterministic JSON stringification.
|
|
3
|
+
* Phase 1: Basic implementation with core optimizations + edge case handling.
|
|
4
|
+
*
|
|
5
|
+
* Performance target: >21,000 ops/sec (baseline)
|
|
6
|
+
* Optimizations:
|
|
7
|
+
* - Manual loops (no .map() overhead)
|
|
8
|
+
* - Custom insertion sort for small arrays (<200 elements)
|
|
9
|
+
* - String escape fast path
|
|
10
|
+
* - Direct string concatenation
|
|
11
|
+
* - Circular reference detection
|
|
12
|
+
* - BigInt support
|
|
13
|
+
* - Non-plain object handling (Date, RegExp, Error)
|
|
14
|
+
*/
|
|
15
|
+
export declare function stableStringify(value: unknown): string;
|
|
16
|
+
//# sourceMappingURL=stable-stringify.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Database, Changes } from 'bun:sqlite';
|
|
2
|
+
export type QueryWithParams = {
|
|
3
|
+
query: string;
|
|
4
|
+
params: any[];
|
|
5
|
+
};
|
|
6
|
+
export declare class StatementManager {
|
|
7
|
+
private db;
|
|
8
|
+
private staticStatements;
|
|
9
|
+
constructor(db: Database);
|
|
10
|
+
all(queryWithParams: QueryWithParams): any[];
|
|
11
|
+
run(queryWithParams: QueryWithParams): Changes;
|
|
12
|
+
close(): void;
|
|
13
|
+
private isStaticSQL;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=statement-manager.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RxStorage } from 'rxdb';
|
|
2
|
+
import type { BunSQLiteStorageSettings, BunSQLiteInternals } from './types';
|
|
3
|
+
export declare function getRxStorageBunSQLite(settings?: BunSQLiteStorageSettings): RxStorage<BunSQLiteInternals, BunSQLiteStorageSettings>;
|
|
4
|
+
//# sourceMappingURL=storage.d.ts.map
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Database } from 'bun:sqlite';
|
|
2
|
+
export interface BunSQLiteStorageSettings {
|
|
3
|
+
/**
|
|
4
|
+
* Database file path. Use ':memory:' for in-memory database.
|
|
5
|
+
* @default ':memory:'
|
|
6
|
+
*/
|
|
7
|
+
filename?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface BunSQLiteInternals {
|
|
10
|
+
db: Database;
|
|
11
|
+
primaryPath: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-sqlite-for-rxdb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"author": "adam2am",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/adam2am/bun-sqlite-for-rxdb.git"
|
|
8
8
|
},
|
|
9
9
|
"main": "dist/index.js",
|
|
10
|
+
"dependencies": {},
|
|
10
11
|
"devDependencies": {
|
|
11
12
|
"@types/better-sqlite3": "^7.6.13",
|
|
12
13
|
"@types/bun": "latest",
|
|
13
|
-
"@types/fast-stable-stringify": "^1.0.0",
|
|
14
14
|
"better-sqlite3": "^12.6.2",
|
|
15
15
|
"rxdb": "^16.21.1",
|
|
16
16
|
"typescript": "^5.0.0"
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"rxdb": "^16.0.0 || ^17.0.0-beta"
|
|
20
20
|
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"bun": ">=1.0.0"
|
|
23
|
+
},
|
|
21
24
|
"description": "RxDB storage adapter for Bun's native SQLite (bun:sqlite)",
|
|
22
25
|
"keywords": [
|
|
23
26
|
"rxdb",
|
|
@@ -30,15 +33,21 @@
|
|
|
30
33
|
"reactive"
|
|
31
34
|
],
|
|
32
35
|
"license": "MIT",
|
|
36
|
+
"files": [
|
|
37
|
+
"dist/",
|
|
38
|
+
"!dist/test/",
|
|
39
|
+
"!dist/**/*.test.d.ts",
|
|
40
|
+
"!dist/**/*.test.d.ts.map",
|
|
41
|
+
"!dist/**/*.d.ts.map",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE",
|
|
44
|
+
"CHANGELOG.md"
|
|
45
|
+
],
|
|
33
46
|
"scripts": {
|
|
34
|
-
"build": "bun build src/index.ts --outdir dist --target bun",
|
|
47
|
+
"build": "bun build src/index.ts --outdir dist --target bun && tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
35
48
|
"test": "bun test src/",
|
|
36
49
|
"typecheck": "tsc --noEmit"
|
|
37
50
|
},
|
|
38
51
|
"type": "module",
|
|
39
|
-
"types": "dist/index.d.ts"
|
|
40
|
-
|
|
41
|
-
"fast-stable-stringify": "^1.0.0",
|
|
42
|
-
"mingo": "^7.2.0"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
52
|
+
"types": "dist/index.d.ts"
|
|
53
|
+
}
|
package/.serena/project.yml
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# list of languages for which language servers are started; choose from:
|
|
2
|
-
# al bash clojure cpp csharp csharp_omnisharp
|
|
3
|
-
# dart elixir elm erlang fortran go
|
|
4
|
-
# haskell java julia kotlin lua markdown
|
|
5
|
-
# nix perl php python python_jedi r
|
|
6
|
-
# rego ruby ruby_solargraph rust scala swift
|
|
7
|
-
# terraform typescript typescript_vts yaml zig
|
|
8
|
-
# Note:
|
|
9
|
-
# - For C, use cpp
|
|
10
|
-
# - For JavaScript, use typescript
|
|
11
|
-
# Special requirements:
|
|
12
|
-
# - csharp: Requires the presence of a .sln file in the project folder.
|
|
13
|
-
# When using multiple languages, the first language server that supports a given file will be used for that file.
|
|
14
|
-
# The first language is the default language and the respective language server will be used as a fallback.
|
|
15
|
-
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
|
|
16
|
-
languages:
|
|
17
|
-
- typescript
|
|
18
|
-
|
|
19
|
-
# the encoding used by text files in the project
|
|
20
|
-
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
|
|
21
|
-
encoding: "utf-8"
|
|
22
|
-
|
|
23
|
-
# whether to use the project's gitignore file to ignore files
|
|
24
|
-
# Added on 2025-04-07
|
|
25
|
-
ignore_all_files_in_gitignore: true
|
|
26
|
-
|
|
27
|
-
# list of additional paths to ignore
|
|
28
|
-
# same syntax as gitignore, so you can use * and **
|
|
29
|
-
# Was previously called `ignored_dirs`, please update your config if you are using that.
|
|
30
|
-
# Added (renamed) on 2025-04-07
|
|
31
|
-
ignored_paths: []
|
|
32
|
-
|
|
33
|
-
# whether the project is in read-only mode
|
|
34
|
-
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
|
35
|
-
# Added on 2025-04-18
|
|
36
|
-
read_only: false
|
|
37
|
-
|
|
38
|
-
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
|
|
39
|
-
# Below is the complete list of tools for convenience.
|
|
40
|
-
# To make sure you have the latest list of tools, and to view their descriptions,
|
|
41
|
-
# execute `uv run scripts/print_tool_overview.py`.
|
|
42
|
-
#
|
|
43
|
-
# * `activate_project`: Activates a project by name.
|
|
44
|
-
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
|
|
45
|
-
# * `create_text_file`: Creates/overwrites a file in the project directory.
|
|
46
|
-
# * `delete_lines`: Deletes a range of lines within a file.
|
|
47
|
-
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
|
|
48
|
-
# * `execute_shell_command`: Executes a shell command.
|
|
49
|
-
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
|
|
50
|
-
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
|
|
51
|
-
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
|
|
52
|
-
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
|
|
53
|
-
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
|
|
54
|
-
# * `initial_instructions`: Gets the initial instructions for the current project.
|
|
55
|
-
# Should only be used in settings where the system prompt cannot be set,
|
|
56
|
-
# e.g. in clients you have no control over, like Claude Desktop.
|
|
57
|
-
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
|
|
58
|
-
# * `insert_at_line`: Inserts content at a given line in a file.
|
|
59
|
-
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
|
|
60
|
-
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
|
|
61
|
-
# * `list_memories`: Lists memories in Serena's project-specific memory store.
|
|
62
|
-
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
|
|
63
|
-
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
|
|
64
|
-
# * `read_file`: Reads a file within the project directory.
|
|
65
|
-
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
|
|
66
|
-
# * `remove_project`: Removes a project from the Serena configuration.
|
|
67
|
-
# * `replace_lines`: Replaces a range of lines within a file with new content.
|
|
68
|
-
# * `replace_symbol_body`: Replaces the full definition of a symbol.
|
|
69
|
-
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
|
|
70
|
-
# * `search_for_pattern`: Performs a search for a pattern in the project.
|
|
71
|
-
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
|
|
72
|
-
# * `switch_modes`: Activates modes by providing a list of their names
|
|
73
|
-
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
|
|
74
|
-
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
|
|
75
|
-
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
|
|
76
|
-
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
|
|
77
|
-
excluded_tools: []
|
|
78
|
-
|
|
79
|
-
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
|
80
|
-
# (contrary to the memories, which are loaded on demand).
|
|
81
|
-
initial_prompt: ""
|
|
82
|
-
|
|
83
|
-
project_name: "bun-sqlite-for-rxdb"
|
|
84
|
-
included_optional_tools: []
|