@yydb/light-db 0.0.0 → 0.0.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.
- package/dist/api/database.d.ts +48 -0
- package/dist/api/database.d.ts.map +1 -0
- package/dist/api/database.js +120 -0
- package/dist/api/database.js.map +1 -0
- package/dist/api/index.d.ts +7 -22
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +5 -52
- package/dist/api/index.js.map +1 -1
- package/dist/api/schema.d.ts +33 -0
- package/dist/api/schema.d.ts.map +1 -0
- package/dist/api/schema.js +80 -0
- package/dist/api/schema.js.map +1 -0
- package/dist/api/transaction.d.ts +26 -0
- package/dist/api/transaction.d.ts.map +1 -0
- package/dist/api/transaction.js +52 -0
- package/dist/api/transaction.js.map +1 -0
- package/dist/api/types.d.ts +55 -148
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js +6 -5
- package/dist/api/types.js.map +1 -1
- package/dist/codec/binary.d.ts +196 -0
- package/dist/codec/binary.d.ts.map +1 -0
- package/dist/codec/binary.js +342 -0
- package/dist/codec/binary.js.map +1 -0
- package/dist/codec/checksum.d.ts +21 -0
- package/dist/codec/checksum.d.ts.map +1 -0
- package/dist/codec/checksum.js +46 -0
- package/dist/codec/checksum.js.map +1 -0
- package/dist/codec/index.d.ts +12 -0
- package/dist/codec/index.d.ts.map +1 -0
- package/dist/codec/index.js +10 -0
- package/dist/codec/index.js.map +1 -0
- package/dist/codec/page.d.ts +114 -0
- package/dist/codec/page.d.ts.map +1 -0
- package/dist/codec/page.js +225 -0
- package/dist/codec/page.js.map +1 -0
- package/dist/codec/record.d.ts +62 -0
- package/dist/codec/record.d.ts.map +1 -0
- package/dist/codec/record.js +82 -0
- package/dist/codec/record.js.map +1 -0
- package/dist/core/broadcast.d.ts +39 -0
- package/dist/core/broadcast.d.ts.map +1 -0
- package/dist/core/broadcast.js +54 -0
- package/dist/core/broadcast.js.map +1 -0
- package/dist/core/checkpoint.d.ts +23 -0
- package/dist/core/checkpoint.d.ts.map +1 -0
- package/dist/core/checkpoint.js +49 -0
- package/dist/core/checkpoint.js.map +1 -0
- package/dist/core/engine.d.ts +142 -0
- package/dist/core/engine.d.ts.map +1 -0
- package/dist/core/engine.js +304 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lease.d.ts +32 -0
- package/dist/core/lease.d.ts.map +1 -0
- package/dist/core/lease.js +81 -0
- package/dist/core/lease.js.map +1 -0
- package/dist/core/records.d.ts +49 -0
- package/dist/core/records.d.ts.map +1 -0
- package/dist/core/records.js +70 -0
- package/dist/core/records.js.map +1 -0
- package/dist/core/recovery.d.ts +43 -0
- package/dist/core/recovery.d.ts.map +1 -0
- package/dist/core/recovery.js +99 -0
- package/dist/core/recovery.js.map +1 -0
- package/dist/core/wal.d.ts +50 -0
- package/dist/core/wal.d.ts.map +1 -0
- package/dist/core/wal.js +114 -0
- package/dist/core/wal.js.map +1 -0
- package/dist/errors/index.d.ts +44 -66
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +43 -128
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +14 -215
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -724
- package/dist/index.js.map +1 -1
- package/dist/storage/StorageAdapter.d.ts +97 -0
- package/dist/storage/StorageAdapter.d.ts.map +1 -0
- package/dist/storage/StorageAdapter.js +9 -0
- package/dist/storage/StorageAdapter.js.map +1 -0
- package/dist/storage/index.d.ts +9 -8
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +8 -151
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/indexeddb/IndexedDbStorageAdapter.d.ts +140 -0
- package/dist/storage/indexeddb/IndexedDbStorageAdapter.d.ts.map +1 -0
- package/dist/storage/indexeddb/IndexedDbStorageAdapter.js +403 -0
- package/dist/storage/indexeddb/IndexedDbStorageAdapter.js.map +1 -0
- package/dist/storage/memory/MemoryStorageAdapter.d.ts +76 -0
- package/dist/storage/memory/MemoryStorageAdapter.d.ts.map +1 -0
- package/dist/storage/memory/MemoryStorageAdapter.js +212 -0
- package/dist/storage/memory/MemoryStorageAdapter.js.map +1 -0
- package/dist/storage/opfs/OpfsStorageAdapter.d.ts +141 -0
- package/dist/storage/opfs/OpfsStorageAdapter.d.ts.map +1 -0
- package/dist/storage/opfs/OpfsStorageAdapter.js +400 -0
- package/dist/storage/opfs/OpfsStorageAdapter.js.map +1 -0
- package/package.json +48 -36
- package/readme.md +80 -94
- package/dist/api/LightDB.d.ts +0 -194
- package/dist/api/LightDB.d.ts.map +0 -1
- package/dist/api/LightDB.js +0 -299
- package/dist/api/LightDB.js.map +0 -1
- package/dist/api/Transaction.d.ts +0 -100
- package/dist/api/Transaction.d.ts.map +0 -1
- package/dist/api/Transaction.js +0 -263
- package/dist/api/Transaction.js.map +0 -1
- package/dist/collection/Collection.d.ts +0 -235
- package/dist/collection/Collection.d.ts.map +0 -1
- package/dist/collection/Collection.js +0 -671
- package/dist/collection/Collection.js.map +0 -1
- package/dist/collection/QueryBuilder.d.ts +0 -225
- package/dist/collection/QueryBuilder.d.ts.map +0 -1
- package/dist/collection/QueryBuilder.js +0 -475
- package/dist/collection/QueryBuilder.js.map +0 -1
- package/dist/collection/QueryParser.d.ts +0 -117
- package/dist/collection/QueryParser.d.ts.map +0 -1
- package/dist/collection/QueryParser.js +0 -438
- package/dist/collection/QueryParser.js.map +0 -1
- package/dist/collection/index.d.ts +0 -42
- package/dist/collection/index.d.ts.map +0 -1
- package/dist/collection/index.js +0 -41
- package/dist/collection/index.js.map +0 -1
- package/dist/collection/types.d.ts +0 -365
- package/dist/collection/types.d.ts.map +0 -1
- package/dist/collection/types.js +0 -7
- package/dist/collection/types.js.map +0 -1
- package/dist/constants/index.d.ts +0 -51
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/index.js +0 -68
- package/dist/constants/index.js.map +0 -1
- package/dist/indexes/BPlusTree.d.ts +0 -181
- package/dist/indexes/BPlusTree.d.ts.map +0 -1
- package/dist/indexes/BPlusTree.js +0 -528
- package/dist/indexes/BPlusTree.js.map +0 -1
- package/dist/indexes/IndexManager.d.ts +0 -236
- package/dist/indexes/IndexManager.d.ts.map +0 -1
- package/dist/indexes/IndexManager.js +0 -502
- package/dist/indexes/IndexManager.js.map +0 -1
- package/dist/indexes/PrimaryIndex.d.ts +0 -240
- package/dist/indexes/PrimaryIndex.d.ts.map +0 -1
- package/dist/indexes/PrimaryIndex.js +0 -354
- package/dist/indexes/PrimaryIndex.js.map +0 -1
- package/dist/indexes/SecondaryIndex.d.ts +0 -204
- package/dist/indexes/SecondaryIndex.d.ts.map +0 -1
- package/dist/indexes/SecondaryIndex.js +0 -480
- package/dist/indexes/SecondaryIndex.js.map +0 -1
- package/dist/indexes/errors.d.ts +0 -66
- package/dist/indexes/errors.d.ts.map +0 -1
- package/dist/indexes/errors.js +0 -117
- package/dist/indexes/errors.js.map +0 -1
- package/dist/indexes/index.d.ts +0 -52
- package/dist/indexes/index.d.ts.map +0 -1
- package/dist/indexes/index.js +0 -131
- package/dist/indexes/index.js.map +0 -1
- package/dist/indexes/types.d.ts +0 -246
- package/dist/indexes/types.d.ts.map +0 -1
- package/dist/indexes/types.js +0 -30
- package/dist/indexes/types.js.map +0 -1
- package/dist/performance/BatchWALWriter.d.ts +0 -185
- package/dist/performance/BatchWALWriter.d.ts.map +0 -1
- package/dist/performance/BatchWALWriter.js +0 -490
- package/dist/performance/BatchWALWriter.js.map +0 -1
- package/dist/performance/ColumnarStorage.d.ts +0 -138
- package/dist/performance/ColumnarStorage.d.ts.map +0 -1
- package/dist/performance/ColumnarStorage.js +0 -875
- package/dist/performance/ColumnarStorage.js.map +0 -1
- package/dist/performance/LazyQuery.d.ts +0 -307
- package/dist/performance/LazyQuery.d.ts.map +0 -1
- package/dist/performance/LazyQuery.js +0 -588
- package/dist/performance/LazyQuery.js.map +0 -1
- package/dist/performance/OptimizedBuffer.d.ts +0 -375
- package/dist/performance/OptimizedBuffer.d.ts.map +0 -1
- package/dist/performance/OptimizedBuffer.js +0 -730
- package/dist/performance/OptimizedBuffer.js.map +0 -1
- package/dist/performance/RWLock.d.ts +0 -260
- package/dist/performance/RWLock.d.ts.map +0 -1
- package/dist/performance/RWLock.js +0 -570
- package/dist/performance/RWLock.js.map +0 -1
- package/dist/performance/index.d.ts +0 -41
- package/dist/performance/index.d.ts.map +0 -1
- package/dist/performance/index.js +0 -162
- package/dist/performance/index.js.map +0 -1
- package/dist/performance/types.d.ts +0 -247
- package/dist/performance/types.d.ts.map +0 -1
- package/dist/performance/types.js +0 -26
- package/dist/performance/types.js.map +0 -1
- package/dist/storage/Checkpoint.d.ts +0 -128
- package/dist/storage/Checkpoint.d.ts.map +0 -1
- package/dist/storage/Checkpoint.js +0 -251
- package/dist/storage/Checkpoint.js.map +0 -1
- package/dist/storage/LightFile.d.ts +0 -227
- package/dist/storage/LightFile.d.ts.map +0 -1
- package/dist/storage/LightFile.js +0 -526
- package/dist/storage/LightFile.js.map +0 -1
- package/dist/storage/Recovery.d.ts +0 -172
- package/dist/storage/Recovery.d.ts.map +0 -1
- package/dist/storage/Recovery.js +0 -399
- package/dist/storage/Recovery.js.map +0 -1
- package/dist/storage/SHMFile.d.ts +0 -243
- package/dist/storage/SHMFile.d.ts.map +0 -1
- package/dist/storage/SHMFile.js +0 -436
- package/dist/storage/SHMFile.js.map +0 -1
- package/dist/storage/StorageEngine.d.ts +0 -146
- package/dist/storage/StorageEngine.d.ts.map +0 -1
- package/dist/storage/StorageEngine.js +0 -353
- package/dist/storage/StorageEngine.js.map +0 -1
- package/dist/storage/WALFile.d.ts +0 -248
- package/dist/storage/WALFile.d.ts.map +0 -1
- package/dist/storage/WALFile.js +0 -597
- package/dist/storage/WALFile.js.map +0 -1
- package/dist/types/index.d.ts +0 -220
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -7
- package/dist/types/index.js.map +0 -1
- package/dist/utils/binary.d.ts +0 -271
- package/dist/utils/binary.d.ts.map +0 -1
- package/dist/utils/binary.js +0 -454
- package/dist/utils/binary.js.map +0 -1
- package/dist/utils/file.d.ts +0 -166
- package/dist/utils/file.d.ts.map +0 -1
- package/dist/utils/file.js +0 -346
- package/dist/utils/file.js.map +0 -1
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -39
- package/dist/utils/index.js.map +0 -1
package/dist/errors/index.js
CHANGED
|
@@ -1,132 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
* 稳定错误模型
|
|
3
|
+
*
|
|
4
|
+
* 与 `@yydb/yydb` / `@yydb/yydb-client` 共用同一组错误码:宿主只按 `code` 分支,
|
|
5
|
+
* `message` 只用于显示。
|
|
6
|
+
*/
|
|
7
|
+
/** 浏览器产品对外的稳定错误码 */
|
|
8
|
+
export const LightDbErrorCodes = {
|
|
9
|
+
/** I/O 失败 */
|
|
10
|
+
io: 'yydb.io',
|
|
11
|
+
/** 持久化数据损坏 */
|
|
12
|
+
corrupt: 'yydb.corrupt',
|
|
13
|
+
/** Schema 文档与已持久化内容冲突 */
|
|
14
|
+
schemaConflict: 'yydb.schema.conflict',
|
|
15
|
+
/** Schema 文档不合法 */
|
|
16
|
+
schemaInvalid: 'yydb.schema.invalid',
|
|
17
|
+
/** 宿主不支持该能力 */
|
|
18
|
+
unsupported: 'yydb.unsupported',
|
|
19
|
+
/** 会话或数据库已关闭 */
|
|
20
|
+
sessionClosed: 'yydb.session.closed',
|
|
21
|
+
/** 单写者租约不可用(例如缺少 Web Locks) */
|
|
22
|
+
leaseUnavailable: 'yydb.lease.unavailable',
|
|
23
|
+
/** 存储配额不足 */
|
|
24
|
+
quotaExceeded: 'yydb.quota.exceeded',
|
|
25
|
+
};
|
|
26
|
+
/** 相同参数重试即可成功的错误码 */
|
|
27
|
+
const RETRYABLE_CODES = new Set([LightDbErrorCodes.leaseUnavailable]);
|
|
28
|
+
/**
|
|
29
|
+
* 携带稳定错误码的数据库错误
|
|
30
|
+
*/
|
|
31
|
+
export class LightDbError extends Error {
|
|
32
|
+
/** 稳定错误码 */
|
|
33
|
+
code;
|
|
34
|
+
/** 失败的操作 */
|
|
35
|
+
operation;
|
|
36
|
+
/** 是否可以用相同参数重试 */
|
|
37
|
+
retryable;
|
|
38
|
+
constructor(code, message, options = {}) {
|
|
39
|
+
super(message, { cause: options.cause });
|
|
40
|
+
this.name = 'LightDbError';
|
|
25
41
|
this.code = code;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Object.setPrototypeOf(this, StorageError.prototype);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.StorageError = StorageError;
|
|
33
|
-
/**
|
|
34
|
-
* 文件操作错误
|
|
35
|
-
*/
|
|
36
|
-
class FileOperationError extends StorageError {
|
|
37
|
-
constructor(message, filePath, operation) {
|
|
38
|
-
super(message, "FILE_OPERATION_ERROR", { filePath, operation });
|
|
39
|
-
this.name = "FileOperationError";
|
|
40
|
-
Object.setPrototypeOf(this, FileOperationError.prototype);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.FileOperationError = FileOperationError;
|
|
44
|
-
/**
|
|
45
|
-
* 文件格式错误
|
|
46
|
-
*/
|
|
47
|
-
class FileFormatError extends StorageError {
|
|
48
|
-
constructor(message, filePath, expected, actual) {
|
|
49
|
-
super(message, "FILE_FORMAT_ERROR", { filePath, expected, actual });
|
|
50
|
-
this.name = "FileFormatError";
|
|
51
|
-
Object.setPrototypeOf(this, FileFormatError.prototype);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.FileFormatError = FileFormatError;
|
|
55
|
-
/**
|
|
56
|
-
* 校验和错误
|
|
57
|
-
*/
|
|
58
|
-
class ChecksumError extends StorageError {
|
|
59
|
-
constructor(message, expected, actual, position) {
|
|
60
|
-
super(message, "CHECKSUM_ERROR", { expected, actual, position });
|
|
61
|
-
this.name = "ChecksumError";
|
|
62
|
-
Object.setPrototypeOf(this, ChecksumError.prototype);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.ChecksumError = ChecksumError;
|
|
66
|
-
/**
|
|
67
|
-
* WAL 错误
|
|
68
|
-
*/
|
|
69
|
-
class WalError extends StorageError {
|
|
70
|
-
constructor(message, lsn, offset) {
|
|
71
|
-
super(message, "WAL_ERROR", { lsn: lsn?.toString(), offset });
|
|
72
|
-
this.name = "WALError";
|
|
73
|
-
Object.setPrototypeOf(this, WalError.prototype);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.WalError = WalError;
|
|
77
|
-
/**
|
|
78
|
-
* 恢复错误
|
|
79
|
-
*/
|
|
80
|
-
class RecoveryError extends StorageError {
|
|
81
|
-
constructor(message, phase, details) {
|
|
82
|
-
super(message, "RECOVERY_ERROR", { phase, details });
|
|
83
|
-
this.name = "RecoveryError";
|
|
84
|
-
Object.setPrototypeOf(this, RecoveryError.prototype);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.RecoveryError = RecoveryError;
|
|
88
|
-
/**
|
|
89
|
-
* 检查点错误
|
|
90
|
-
*/
|
|
91
|
-
class CheckpointError extends StorageError {
|
|
92
|
-
constructor(message, lsn) {
|
|
93
|
-
super(message, "CHECKPOINT_ERROR", { lsn: lsn?.toString() });
|
|
94
|
-
this.name = "CheckpointError";
|
|
95
|
-
Object.setPrototypeOf(this, CheckpointError.prototype);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.CheckpointError = CheckpointError;
|
|
99
|
-
/**
|
|
100
|
-
* 页面错误
|
|
101
|
-
*/
|
|
102
|
-
class PageError extends StorageError {
|
|
103
|
-
constructor(message, pageId, details) {
|
|
104
|
-
super(message, "PAGE_ERROR", { pageId, details });
|
|
105
|
-
this.name = "PageError";
|
|
106
|
-
Object.setPrototypeOf(this, PageError.prototype);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.PageError = PageError;
|
|
110
|
-
/**
|
|
111
|
-
* 序列化错误
|
|
112
|
-
*/
|
|
113
|
-
class SerializationError extends StorageError {
|
|
114
|
-
constructor(message, data) {
|
|
115
|
-
super(message, "SERIALIZATION_ERROR", { data });
|
|
116
|
-
this.name = "SerializationError";
|
|
117
|
-
Object.setPrototypeOf(this, SerializationError.prototype);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.SerializationError = SerializationError;
|
|
121
|
-
/**
|
|
122
|
-
* 配置错误
|
|
123
|
-
*/
|
|
124
|
-
class ConfigurationError extends StorageError {
|
|
125
|
-
constructor(message, option, value) {
|
|
126
|
-
super(message, "CONFIGURATION_ERROR", { option, value });
|
|
127
|
-
this.name = "ConfigurationError";
|
|
128
|
-
Object.setPrototypeOf(this, ConfigurationError.prototype);
|
|
42
|
+
this.operation = options.operation ?? 'unknown';
|
|
43
|
+
this.retryable = RETRYABLE_CODES.has(code);
|
|
44
|
+
Object.setPrototypeOf(this, LightDbError.prototype);
|
|
129
45
|
}
|
|
130
46
|
}
|
|
131
|
-
|
|
132
|
-
//# sourceMappingURL=index.js.map
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
package/dist/errors/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oBAAoB;AACpB,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,aAAa;IACb,EAAE,EAAE,SAAS;IACb,cAAc;IACd,OAAO,EAAE,cAAc;IACvB,yBAAyB;IACzB,cAAc,EAAE,sBAAsB;IACtC,mBAAmB;IACnB,aAAa,EAAE,qBAAqB;IACpC,eAAe;IACf,WAAW,EAAE,kBAAkB;IAC/B,gBAAgB;IAChB,aAAa,EAAE,qBAAqB;IACpC,+BAA+B;IAC/B,gBAAgB,EAAE,wBAAwB;IAC1C,aAAa;IACb,aAAa,EAAE,qBAAqB;CAC9B,CAAC;AAEX,qBAAqB;AACrB,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAY3F;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACnC,YAAY;IACI,IAAI,CAAS;IAE7B,YAAY;IACI,SAAS,CAAS;IAElC,kBAAkB;IACF,SAAS,CAAU;IAEnC,YAAY,IAAY,EAAE,OAAe,EAAE,UAA+B,EAAE;QACxE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,SAAS,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;CACJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,220 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* `@yydb/light-db`
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 浏览器专用的纯 TypeScript 数据库,与 `@yydb/yydb` 保持同构的用户 API。
|
|
5
|
+
* 公共类型只有 `Uint8Array` 与 `Promise`,不依赖 Node `Buffer`、文件系统或 WASM。
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
PAGE_HEADER_SIZE,
|
|
21
|
-
OperationType,
|
|
22
|
-
FILE_EXTENSIONS,
|
|
23
|
-
} from "./constants";
|
|
24
|
-
export {
|
|
25
|
-
LightHeader,
|
|
26
|
-
Record,
|
|
27
|
-
Page,
|
|
28
|
-
WalRecord,
|
|
29
|
-
ShmHeader,
|
|
30
|
-
ShmEntry,
|
|
31
|
-
StorageEngineOptions,
|
|
32
|
-
FsyncStrategy,
|
|
33
|
-
CheckpointResult,
|
|
34
|
-
RecoveryResult,
|
|
35
|
-
StorageStats,
|
|
36
|
-
WriteResult,
|
|
37
|
-
BatchWriteResult,
|
|
38
|
-
HashIteratorResult,
|
|
39
|
-
FileHandle,
|
|
40
|
-
PageMap,
|
|
41
|
-
RecordMap,
|
|
42
|
-
WalRecordIterator,
|
|
43
|
-
} from "./types";
|
|
44
|
-
export {
|
|
45
|
-
StorageError,
|
|
46
|
-
FileOperationError,
|
|
47
|
-
FileFormatError,
|
|
48
|
-
ChecksumError,
|
|
49
|
-
WalError,
|
|
50
|
-
RecoveryError,
|
|
51
|
-
CheckpointError,
|
|
52
|
-
PageError,
|
|
53
|
-
SerializationError,
|
|
54
|
-
ConfigurationError,
|
|
55
|
-
} from "./errors";
|
|
56
|
-
export { BinaryUtils, BufferWriter, BufferReader, FileUtils, FileHandleWrapper } from "./utils";
|
|
57
|
-
export { LightFileSerializer, LightFileManager, PageManager } from "./storage";
|
|
58
|
-
export { WalRecordSerializer, WalWriter, WalReader, WalManager } from "./storage";
|
|
59
|
-
export { ShmSerializer, ShmHashTable, ShmFileManager, WalIndexManager } from "./storage";
|
|
60
|
-
export { CheckpointManager, AutoCheckpointScheduler, IncrementalCheckpointManager, CheckpointOptions } from "./storage";
|
|
61
|
-
export { RecoveryManager, FastRecoveryManager, RecoveryValidator, RecoveryPhase, RecoveryContext } from "./storage";
|
|
62
|
-
export { StorageEngine, createStorageEngine } from "./storage";
|
|
63
|
-
import type { StorageEngineOptions } from "./types";
|
|
64
|
-
import { StorageEngine as StorageEngineClass } from "./storage";
|
|
65
|
-
/**
|
|
66
|
-
* 打开存储引擎
|
|
67
|
-
*
|
|
68
|
-
* @param basePath - 数据库文件存储路径
|
|
69
|
-
* @param dbName - 数据库名称
|
|
70
|
-
* @param options - 配置选项
|
|
71
|
-
* @returns 初始化完成的存储引擎实例
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* import { openStorageEngine } from '@yydb/light-db';
|
|
76
|
-
*
|
|
77
|
-
* const engine = await openStorageEngine('./data', 'mydb', {
|
|
78
|
-
* pageSize: 4096,
|
|
79
|
-
* walThreshold: 16 * 1024 * 1024,
|
|
80
|
-
* autoCheckpoint: true
|
|
81
|
-
* });
|
|
82
|
-
*
|
|
83
|
-
* // 插入数据
|
|
84
|
-
* await engine.insert('key1', Buffer.from('value1'));
|
|
85
|
-
*
|
|
86
|
-
* // 读取数据
|
|
87
|
-
* const value = await engine.get('key1');
|
|
88
|
-
*
|
|
89
|
-
* // 关闭引擎
|
|
90
|
-
* await engine.close();
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
export declare function openStorageEngine(basePath: string, dbName: string, options?: StorageEngineOptions): Promise<StorageEngineClass>;
|
|
94
|
-
export {
|
|
95
|
-
IndexKey,
|
|
96
|
-
IndexValue,
|
|
97
|
-
RangeCondition,
|
|
98
|
-
EqualityCondition,
|
|
99
|
-
QueryCondition,
|
|
100
|
-
IndexType,
|
|
101
|
-
IndexOptions,
|
|
102
|
-
PrimaryIndexOptions,
|
|
103
|
-
SecondaryIndexOptions,
|
|
104
|
-
IndexStats,
|
|
105
|
-
IndexQueryResult,
|
|
106
|
-
BPlusTreeNodeType,
|
|
107
|
-
BPlusTreeNode,
|
|
108
|
-
BPlusTreeLeafNode,
|
|
109
|
-
BPlusTreeInternalNode,
|
|
110
|
-
IndexOperationResult,
|
|
111
|
-
IndexBatchResult,
|
|
112
|
-
IndexIteratorOptions,
|
|
113
|
-
IndexEntry,
|
|
114
|
-
IndexChangeRecord,
|
|
115
|
-
IndexManagerOptions,
|
|
116
|
-
Comparator,
|
|
117
|
-
KeyExtractor,
|
|
118
|
-
ValueExtractor,
|
|
119
|
-
} from "./indexes";
|
|
120
|
-
export {
|
|
121
|
-
IndexError,
|
|
122
|
-
DuplicateKeyError,
|
|
123
|
-
KeyNotFoundError,
|
|
124
|
-
IndexNotFoundError,
|
|
125
|
-
IndexExistsError,
|
|
126
|
-
IndexConfigError,
|
|
127
|
-
IndexOperationError,
|
|
128
|
-
IndexConsistencyError,
|
|
129
|
-
RangeQueryError,
|
|
130
|
-
} from "./indexes";
|
|
131
|
-
export { BPlusTree } from "./indexes";
|
|
132
|
-
export { PrimaryIndex, PrimaryIndexConfig } from "./indexes";
|
|
133
|
-
export { SecondaryIndex, SecondaryIndexConfig } from "./indexes";
|
|
134
|
-
export { IndexManager, CollectionIndexConfig } from "./indexes";
|
|
135
|
-
export {
|
|
136
|
-
PrimaryKeyType,
|
|
137
|
-
Document,
|
|
138
|
-
ComparisonOperators,
|
|
139
|
-
ArrayOperators,
|
|
140
|
-
ExistenceOperators,
|
|
141
|
-
RegexOperators,
|
|
142
|
-
FieldCondition,
|
|
143
|
-
LogicalOperators,
|
|
144
|
-
QueryFilter,
|
|
145
|
-
UpdateOperators,
|
|
146
|
-
UpdateOperation,
|
|
147
|
-
SortDirection,
|
|
148
|
-
SortCondition,
|
|
149
|
-
QueryOptions,
|
|
150
|
-
InsertOptions,
|
|
151
|
-
UpdateOptions,
|
|
152
|
-
DeleteOptions,
|
|
153
|
-
InsertResult,
|
|
154
|
-
InsertManyResult,
|
|
155
|
-
UpdateResult,
|
|
156
|
-
DeleteResult,
|
|
157
|
-
FindResult,
|
|
158
|
-
IndexConfig,
|
|
159
|
-
CollectionOptions,
|
|
160
|
-
CollectionStats,
|
|
161
|
-
CollectionEventType,
|
|
162
|
-
CollectionEventListener,
|
|
163
|
-
CursorOptions,
|
|
164
|
-
AggregationStage,
|
|
165
|
-
} from "./collection";
|
|
166
|
-
export { QueryParser, QueryParseResult } from "./collection";
|
|
167
|
-
export { QueryBuilder, QueryExecutor } from "./collection";
|
|
168
|
-
export { Collection, CollectionError } from "./collection";
|
|
169
|
-
export {
|
|
170
|
-
LightDBOptions,
|
|
171
|
-
CollectionCreateOptions,
|
|
172
|
-
TransactionContext,
|
|
173
|
-
TransactionCollection,
|
|
174
|
-
TransactionCallback,
|
|
175
|
-
TransactionOptions,
|
|
176
|
-
TransactionState,
|
|
177
|
-
TransactionResult,
|
|
178
|
-
DatabaseStats,
|
|
179
|
-
DatabaseConfig,
|
|
180
|
-
ILightDB,
|
|
181
|
-
DefineCollectionSchema,
|
|
182
|
-
CollectionSchema,
|
|
183
|
-
} from "./api";
|
|
184
|
-
export { TransactionError, Transaction, TransactionManager } from "./api";
|
|
185
|
-
export { LightDB, defineCollectionSchema, openDatabase } from "./api";
|
|
186
|
-
export {
|
|
187
|
-
ColumnType,
|
|
188
|
-
ColumnDefinition,
|
|
189
|
-
ColumnarStorageOptions,
|
|
190
|
-
ColumnarStorageStats,
|
|
191
|
-
ColumnStats,
|
|
192
|
-
BatchWriteOptions,
|
|
193
|
-
BatchWriteStats,
|
|
194
|
-
BatchFlushResult,
|
|
195
|
-
FsyncStrategyType,
|
|
196
|
-
RWLockOptions,
|
|
197
|
-
RWLockStats,
|
|
198
|
-
LazyQueryOptions,
|
|
199
|
-
LazyQueryStats,
|
|
200
|
-
AggregationType,
|
|
201
|
-
AggregationResult,
|
|
202
|
-
RangeCondition as PerformanceRangeCondition,
|
|
203
|
-
BufferPoolOptions,
|
|
204
|
-
BufferPoolStats,
|
|
205
|
-
PerformanceOptions,
|
|
206
|
-
PerformanceStats,
|
|
207
|
-
} from "./performance";
|
|
208
|
-
export { ColumnarStorage } from "./performance";
|
|
209
|
-
export {
|
|
210
|
-
BufferPool,
|
|
211
|
-
getGlobalBufferPool,
|
|
212
|
-
OptimizedBufferWriter,
|
|
213
|
-
OptimizedBufferReader,
|
|
214
|
-
FastSerializer,
|
|
215
|
-
BufferConcatenator,
|
|
216
|
-
} from "./performance";
|
|
217
|
-
export { WalRecordEntry, BatchWalWriter, BatchWriteManager } from "./performance";
|
|
218
|
-
export { ReadLockHandle, WriteLockHandle, RWLock, RWLockManager, ReentrantRWLock } from "./performance";
|
|
219
|
-
export { LazyQueryIterator, LazyQueryBuilder, lazy, lazyIterator, GeneratorUtils } from "./performance";
|
|
220
|
-
//# sourceMappingURL=index.d.ts.map
|
|
9
|
+
export { LightDbError, LightDbErrorCodes } from './errors';
|
|
10
|
+
export type { LightDbErrorOptions } from './errors';
|
|
11
|
+
export { BinaryUtils, ByteWriter, ByteReader, ChecksumMismatchError, crc32, checksumMatches, DEFAULT_PAGE_SIZE, SNAPSHOT_MAGIC, SNAPSHOT_VERSION, SNAPSHOT_HEADER_SIZE, PAGE_HEADER_SIZE, RecordTooLargeError, SnapshotFormatError, WalOperation, encodeSnapshot, decodeSnapshot, encodeWalRecord, decodeWalRecord, } from './codec';
|
|
12
|
+
export type { SnapshotHeader, StoredRecord, Page, WalRecord, WalDecodeResult } from './codec';
|
|
13
|
+
export { STORAGE_FILES, MemoryStorageAdapter, MemoryStorageBackend, OpfsStorageAdapter, OpfsStorageAdapterFactory, isOpfsAvailable, IndexedDbStorageAdapter, IndexedDbStorageAdapterFactory, isIndexedDbAvailable, } from './storage';
|
|
14
|
+
export type { StorageAdapter, StorageAdapterFactory, StorageAdapterKind, StorageFile, StorageHandle, StorageOpenMode } from './storage';
|
|
15
|
+
export { StorageEngine, DEFAULT_WAL_THRESHOLD, acquireWriterLease, listenDatabaseEvents } from './core';
|
|
16
|
+
export type { CheckpointResult, LeaseMode, RecoveryOutcome, StorageEngineOptions, StorageEngineStats, TransactionState, DatabaseEvent, DatabaseEventType, WriterLease, } from './core';
|
|
17
|
+
export { BrowserDatabase, openLightDatabase, Transaction, SCHEMA_KEY, RESERVED_KEY_PREFIX, documentVersion, parseSchemaDocument, encodeSchema, decodeSchema, } from './api';
|
|
18
|
+
export type { LightDatabase, LightDatabaseOptions, SchemaVersion } from './api';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGpD,OAAO,EACH,WAAW,EACX,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,GAClB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG9F,OAAO,EACH,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,eAAe,EACf,uBAAuB,EACvB,8BAA8B,EAC9B,oBAAoB,GACvB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGxI,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AACxG,YAAY,EACR,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,WAAW,GACd,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,YAAY,GACf,MAAM,OAAO,CAAC;AACf,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC"}
|