@concavejs/docstore-memory 0.0.1-alpha.8
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/dist/index.d.ts +1 -0
- package/dist/index.js +6553 -0
- package/dist/memory-docstore.d.ts +87 -0
- package/package.json +30 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { JSONValue as JsonValue } from "convex/values";
|
|
2
|
+
import { type ArrayBufferHex, type DatabaseIndexUpdate, type DocStore, type DocumentLogEntry, type DocumentPrevTsQuery, type GlobalKey, type IndexKeyBytes, type InternalDocumentId, type Interval, type LatestDocument, Order, type ResolvedDocument, type TimestampRange, type SearchIndexDefinition, type VectorIndexDefinition } from "@concavejs/core/docstore";
|
|
3
|
+
import { TimestampOracle } from "@concavejs/core/utils";
|
|
4
|
+
export type SerializedDocumentLogEntry = {
|
|
5
|
+
ts: string;
|
|
6
|
+
id: InternalDocumentId;
|
|
7
|
+
value: ResolvedDocument | null;
|
|
8
|
+
prev_ts: string | null;
|
|
9
|
+
};
|
|
10
|
+
export type SerializedIndexRevision = {
|
|
11
|
+
ts: string;
|
|
12
|
+
update: {
|
|
13
|
+
index_id: ArrayBufferHex;
|
|
14
|
+
keyHex: string;
|
|
15
|
+
value: {
|
|
16
|
+
type: "Deleted";
|
|
17
|
+
} | {
|
|
18
|
+
type: "NonClustered";
|
|
19
|
+
doc_id: InternalDocumentId;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type MemoryDocStoreSnapshot = {
|
|
24
|
+
documents: SerializedDocumentLogEntry[];
|
|
25
|
+
indexes: SerializedIndexRevision[];
|
|
26
|
+
globals: Array<{
|
|
27
|
+
key: GlobalKey;
|
|
28
|
+
value: JsonValue;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* In-memory DocStore implementation for browser/RN and tests.
|
|
33
|
+
*
|
|
34
|
+
* Supports the full DocStore contract with MVCC semantics, index scans,
|
|
35
|
+
* basic search, and vector search.
|
|
36
|
+
*/
|
|
37
|
+
export declare class MemoryDocStore implements DocStore {
|
|
38
|
+
readonly timestampOracle: TimestampOracle;
|
|
39
|
+
private readonly documentRevisions;
|
|
40
|
+
private readonly indexRevisions;
|
|
41
|
+
private readonly globals;
|
|
42
|
+
private readonly searchConfigsById;
|
|
43
|
+
private readonly vectorConfigsById;
|
|
44
|
+
setupSchema(options?: {
|
|
45
|
+
searchIndexes?: SearchIndexDefinition[];
|
|
46
|
+
vectorIndexes?: VectorIndexDefinition[];
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
write(documents: DocumentLogEntry[], indexes: Set<{
|
|
49
|
+
ts: bigint;
|
|
50
|
+
update: DatabaseIndexUpdate;
|
|
51
|
+
}>, conflictStrategy: "Error" | "Overwrite"): Promise<void>;
|
|
52
|
+
index_scan(indexId: ArrayBufferHex, tableId: string, readTimestamp: bigint, interval: Interval, order: Order): AsyncGenerator<[IndexKeyBytes, LatestDocument]>;
|
|
53
|
+
load_documents(range: TimestampRange, order: Order): AsyncGenerator<DocumentLogEntry>;
|
|
54
|
+
getGlobal(key: GlobalKey): Promise<JsonValue | null>;
|
|
55
|
+
writeGlobal(key: GlobalKey, value: JsonValue): Promise<void>;
|
|
56
|
+
previous_revisions(queries: Set<{
|
|
57
|
+
id: InternalDocumentId;
|
|
58
|
+
ts: bigint;
|
|
59
|
+
}>): Promise<Map<string, DocumentLogEntry>>;
|
|
60
|
+
previous_revisions_of_documents(queries: Set<DocumentPrevTsQuery>): Promise<Map<string, DocumentLogEntry>>;
|
|
61
|
+
count(tableId: string): Promise<number>;
|
|
62
|
+
get(id: InternalDocumentId, readTimestamp?: bigint): Promise<LatestDocument | null>;
|
|
63
|
+
scan(tableId: string, readTimestamp?: bigint): Promise<LatestDocument[]>;
|
|
64
|
+
scanPaginated(tableId: string, cursor: string | null, limit: number, order: Order, readTimestamp?: bigint): Promise<{
|
|
65
|
+
documents: LatestDocument[];
|
|
66
|
+
nextCursor: string | null;
|
|
67
|
+
hasMore: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
search(indexId: ArrayBufferHex, searchQuery: string, filters: Map<string, unknown>, options?: {
|
|
70
|
+
limit?: number;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
doc: LatestDocument;
|
|
73
|
+
score: number;
|
|
74
|
+
}[]>;
|
|
75
|
+
vectorSearch(indexId: ArrayBufferHex, vector: number[], limit: number, filters: Map<string, string>): Promise<{
|
|
76
|
+
doc: LatestDocument;
|
|
77
|
+
score: number;
|
|
78
|
+
}[]>;
|
|
79
|
+
exportSnapshot(): MemoryDocStoreSnapshot;
|
|
80
|
+
importSnapshot(snapshot: MemoryDocStoreSnapshot, mode?: "replace" | "merge"): void;
|
|
81
|
+
static fromSnapshot(snapshot: MemoryDocStoreSnapshot): MemoryDocStore;
|
|
82
|
+
private validateDocumentWrites;
|
|
83
|
+
private validateIndexWrites;
|
|
84
|
+
private applyDocumentWrite;
|
|
85
|
+
private applyIndexWrite;
|
|
86
|
+
private resolveVectorConfig;
|
|
87
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@concavejs/docstore-memory",
|
|
3
|
+
"version": "0.0.1-alpha.8",
|
|
4
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "rm -rf dist && bun build ./src/index.ts --outfile dist/index.js --target browser --format esm && tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationMap false --outDir dist",
|
|
21
|
+
"test": "bun test --run --passWithNoTests"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@concavejs/core": "0.0.1-alpha.8",
|
|
25
|
+
"convex": "^1.27.3"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.9.3"
|
|
29
|
+
}
|
|
30
|
+
}
|