@hold-baby/bucket-db 0.2.0 → 0.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/README.md +234 -19
- package/dist/cache/lru-cache.d.ts +47 -0
- package/dist/cache/lru-cache.d.ts.map +1 -0
- package/dist/cache/lru-cache.js +110 -0
- package/dist/cache/lru-cache.js.map +1 -0
- package/dist/core/bucket-db.d.ts +20 -0
- package/dist/core/bucket-db.d.ts.map +1 -0
- package/dist/core/bucket-db.js +32 -0
- package/dist/core/bucket-db.js.map +1 -0
- package/dist/core/collection.d.ts +26 -0
- package/dist/core/collection.d.ts.map +1 -0
- package/dist/core/collection.js +213 -0
- package/dist/core/collection.js.map +1 -0
- package/dist/core/wal.d.ts +45 -0
- package/dist/core/wal.d.ts.map +1 -0
- package/dist/core/wal.js +80 -0
- package/dist/core/wal.js.map +1 -0
- package/dist/index/shard-manager.d.ts +36 -0
- package/dist/index/shard-manager.d.ts.map +1 -0
- package/dist/index/shard-manager.js +177 -0
- package/dist/index/shard-manager.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/query/evaluator.d.ts +10 -0
- package/dist/query/evaluator.d.ts.map +1 -0
- package/dist/query/evaluator.js +127 -0
- package/dist/query/evaluator.js.map +1 -0
- package/dist/storage/fs-adapter.d.ts +24 -0
- package/dist/storage/fs-adapter.d.ts.map +1 -0
- package/dist/storage/fs-adapter.js +208 -0
- package/dist/storage/fs-adapter.js.map +1 -0
- package/dist/storage/memory-adapter.d.ts +22 -0
- package/dist/storage/memory-adapter.d.ts.map +1 -0
- package/dist/storage/memory-adapter.js +78 -0
- package/dist/storage/memory-adapter.js.map +1 -0
- package/dist/storage/oss-adapter.d.ts +26 -0
- package/dist/storage/oss-adapter.d.ts.map +1 -0
- package/dist/storage/oss-adapter.js +145 -0
- package/dist/storage/oss-adapter.js.map +1 -0
- package/dist/storage/s3-adapter.d.ts +26 -0
- package/dist/storage/s3-adapter.d.ts.map +1 -0
- package/dist/storage/s3-adapter.js +170 -0
- package/dist/storage/s3-adapter.js.map +1 -0
- package/dist/types/collection.d.ts +40 -0
- package/dist/types/collection.d.ts.map +1 -0
- package/dist/types/collection.js +2 -0
- package/dist/types/collection.js.map +1 -0
- package/{src/types/document.ts → dist/types/document.d.ts} +6 -10
- package/dist/types/document.d.ts.map +1 -0
- package/dist/types/document.js +2 -0
- package/dist/types/document.js.map +1 -0
- package/dist/types/errors.d.ts +32 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +48 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/query.d.ts +37 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/query.js +2 -0
- package/dist/types/query.js.map +1 -0
- package/dist/types/storage.d.ts +45 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +2 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/utils/hash.d.ts +13 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +23 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/path-validator.d.ts +46 -0
- package/dist/utils/path-validator.d.ts.map +1 -0
- package/dist/utils/path-validator.js +99 -0
- package/dist/utils/path-validator.js.map +1 -0
- package/llms.txt +46 -0
- package/package.json +14 -3
- package/src/core/bucket-db.ts +0 -43
- package/src/core/collection.ts +0 -173
- package/src/index/shard-manager.ts +0 -142
- package/src/index.ts +0 -37
- package/src/query/evaluator.ts +0 -87
- package/src/storage/ali-oss.d.ts +0 -43
- package/src/storage/fs-adapter.ts +0 -222
- package/src/storage/memory-adapter.ts +0 -105
- package/src/storage/oss-adapter.ts +0 -122
- package/src/storage/s3-adapter.ts +0 -151
- package/src/types/collection.ts +0 -34
- package/src/types/errors.ts +0 -49
- package/src/types/index.ts +0 -36
- package/src/types/query.ts +0 -50
- package/src/types/storage.ts +0 -46
- package/src/utils/hash.ts +0 -24
- package/tests/core/bucket-db.test.d.ts +0 -2
- package/tests/core/bucket-db.test.d.ts.map +0 -1
- package/tests/core/bucket-db.test.js +0 -34
- package/tests/core/bucket-db.test.js.map +0 -1
- package/tests/core/bucket-db.test.ts +0 -50
- package/tests/core/collection.test.d.ts +0 -2
- package/tests/core/collection.test.d.ts.map +0 -1
- package/tests/core/collection.test.js +0 -148
- package/tests/core/collection.test.js.map +0 -1
- package/tests/core/collection.test.ts +0 -195
- package/tests/core/dbpath.test.ts +0 -52
- package/tests/index/shard-manager.test.d.ts +0 -2
- package/tests/index/shard-manager.test.d.ts.map +0 -1
- package/tests/index/shard-manager.test.js +0 -106
- package/tests/index/shard-manager.test.js.map +0 -1
- package/tests/index/shard-manager.test.ts +0 -129
- package/tests/query/evaluator.test.d.ts +0 -2
- package/tests/query/evaluator.test.d.ts.map +0 -1
- package/tests/query/evaluator.test.js +0 -87
- package/tests/query/evaluator.test.js.map +0 -1
- package/tests/query/evaluator.test.ts +0 -104
- package/tests/storage/fs-adapter.test.ts +0 -111
- package/tests/storage/memory-adapter.test.d.ts +0 -2
- package/tests/storage/memory-adapter.test.d.ts.map +0 -1
- package/tests/storage/memory-adapter.test.js +0 -65
- package/tests/storage/memory-adapter.test.js.map +0 -1
- package/tests/storage/memory-adapter.test.ts +0 -84
- package/tests/storage/oss-adapter.test.d.ts +0 -2
- package/tests/storage/oss-adapter.test.d.ts.map +0 -1
- package/tests/storage/oss-adapter.test.js +0 -34
- package/tests/storage/oss-adapter.test.js.map +0 -1
- package/tests/storage/oss-adapter.test.ts +0 -40
- package/tests/storage/s3-adapter.test.d.ts +0 -2
- package/tests/storage/s3-adapter.test.d.ts.map +0 -1
- package/tests/storage/s3-adapter.test.js +0 -51
- package/tests/storage/s3-adapter.test.js.map +0 -1
- package/tests/storage/s3-adapter.test.ts +0 -62
- package/tests/utils/hash.test.d.ts +0 -2
- package/tests/utils/hash.test.d.ts.map +0 -1
- package/tests/utils/hash.test.js +0 -36
- package/tests/utils/hash.test.js.map +0 -1
- package/tests/utils/hash.test.ts +0 -42
- package/tsconfig.json +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oss-adapter.js","sourceRoot":"","sources":["../../src/storage/oss-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,SAAS,CAAC;AAO1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,UAAU;IACb,MAAM,CAAM;IACZ,MAAM,CAAS;IAEvB,YAAY,MAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC;YACpB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,WAAW;YAC3C,eAAe,EAAE,MAAM,CAAC,WAAW,CAAC,eAAe;YACnD,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,KAAU;QACjC,uCAAuC;QACvC,MAAM,cAAc,GAAG,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,YAAY,EAAE,sBAAsB,CAAC,CAAC;QACtG,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAEvD,OAAO,CACL,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;YACnC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;YAC3C,KAAK,CAAC,IAAI,KAAK,WAAW;YAC1B,KAAK,CAAC,IAAI,KA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AAK,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAc;QAC3B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;QAEjD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACtC,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAChC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;YACtB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE5C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StorageAdapter, StorageObject, PutOptions, StorageAdapterConfig } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* S3 storage adapter with retry logic and timeout configuration
|
|
4
|
+
*/
|
|
5
|
+
export declare class S3Adapter implements StorageAdapter {
|
|
6
|
+
private client;
|
|
7
|
+
private bucket;
|
|
8
|
+
constructor(config: StorageAdapterConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Check if an error is retryable (temporary network issue or rate limit)
|
|
11
|
+
*/
|
|
12
|
+
private isRetryableError;
|
|
13
|
+
/**
|
|
14
|
+
* Retry wrapper with exponential backoff
|
|
15
|
+
*/
|
|
16
|
+
private withRetry;
|
|
17
|
+
get(key: string): Promise<StorageObject>;
|
|
18
|
+
put(key: string, data: any, options?: PutOptions): Promise<{
|
|
19
|
+
etag: string;
|
|
20
|
+
}>;
|
|
21
|
+
delete(key: string): Promise<void>;
|
|
22
|
+
exists(key: string): Promise<boolean>;
|
|
23
|
+
listKeys(prefix: string): Promise<string[]>;
|
|
24
|
+
batchGet(keys: string[]): Promise<Map<string, StorageObject>>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=s3-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-adapter.d.ts","sourceRoot":"","sources":["../../src/storage/s3-adapter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,UAAU,EACV,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,qBAAa,SAAU,YAAW,cAAc;IAC9C,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,oBAAoB;IAcxC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;OAEG;YACW,SAAS;IAmBjB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA6BxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IA0B5E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAalC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBrC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgB3C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAuBpE"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { S3Client, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadObjectCommand, ListObjectsV2Command, } from '@aws-sdk/client-s3';
|
|
2
|
+
import { StorageError } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* S3 storage adapter with retry logic and timeout configuration
|
|
5
|
+
*/
|
|
6
|
+
export class S3Adapter {
|
|
7
|
+
client;
|
|
8
|
+
bucket;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.bucket = config.bucket;
|
|
11
|
+
this.client = new S3Client({
|
|
12
|
+
region: config.region,
|
|
13
|
+
credentials: config.credentials,
|
|
14
|
+
endpoint: config.endpoint,
|
|
15
|
+
maxAttempts: 1, // Disable SDK's built-in retry, use our custom retry logic
|
|
16
|
+
requestHandler: {
|
|
17
|
+
connectionTimeout: 3000,
|
|
18
|
+
requestTimeout: 3000,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if an error is retryable (temporary network issue or rate limit)
|
|
24
|
+
*/
|
|
25
|
+
isRetryableError(error) {
|
|
26
|
+
// AWS SDK error codes for retryable errors
|
|
27
|
+
const retryableCodes = ['RequestTimeout', 'ServiceUnavailable', 'ThrottlingException', 'RequestThrottled'];
|
|
28
|
+
const retryableStatusCodes = [429, 500, 502, 503, 504];
|
|
29
|
+
return (retryableCodes.includes(error.name) ||
|
|
30
|
+
retryableStatusCodes.includes(error.$metadata?.httpStatusCode) ||
|
|
31
|
+
error.code === 'ETIMEDOUT' ||
|
|
32
|
+
error.code === 'ECONNRESET');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Retry wrapper with exponential backoff
|
|
36
|
+
*/
|
|
37
|
+
async withRetry(fn) {
|
|
38
|
+
const maxRetries = 3;
|
|
39
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
40
|
+
try {
|
|
41
|
+
return await fn();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (this.isRetryableError(error) && attempt < maxRetries - 1) {
|
|
45
|
+
// Exponential backoff with jitter: 100ms * 2^attempt + random(0-50ms)
|
|
46
|
+
const baseDelay = 100 * Math.pow(2, attempt);
|
|
47
|
+
const jitter = Math.random() * 50;
|
|
48
|
+
await new Promise(resolve => setTimeout(resolve, baseDelay + jitter));
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
throw new Error('Unreachable');
|
|
55
|
+
}
|
|
56
|
+
async get(key) {
|
|
57
|
+
return this.withRetry(async () => {
|
|
58
|
+
try {
|
|
59
|
+
const command = new GetObjectCommand({
|
|
60
|
+
Bucket: this.bucket,
|
|
61
|
+
Key: key,
|
|
62
|
+
});
|
|
63
|
+
const response = await this.client.send(command);
|
|
64
|
+
const body = await response.Body?.transformToString();
|
|
65
|
+
if (!body) {
|
|
66
|
+
throw new StorageError(`Empty response for key: ${key}`);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
data: JSON.parse(body),
|
|
70
|
+
etag: response.ETag?.replace(/"/g, '') || '',
|
|
71
|
+
lastModified: response.LastModified || new Date(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error.name === 'NoSuchKey') {
|
|
76
|
+
throw new StorageError(`Object not found: ${key}`);
|
|
77
|
+
}
|
|
78
|
+
throw new StorageError(`Failed to get object: ${error.message}`, error);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async put(key, data, options) {
|
|
83
|
+
return this.withRetry(async () => {
|
|
84
|
+
try {
|
|
85
|
+
const command = new PutObjectCommand({
|
|
86
|
+
Bucket: this.bucket,
|
|
87
|
+
Key: key,
|
|
88
|
+
Body: JSON.stringify(data),
|
|
89
|
+
ContentType: 'application/json',
|
|
90
|
+
IfMatch: options?.ifMatch,
|
|
91
|
+
IfNoneMatch: options?.ifNoneMatch,
|
|
92
|
+
});
|
|
93
|
+
const response = await this.client.send(command);
|
|
94
|
+
return {
|
|
95
|
+
etag: response.ETag?.replace(/"/g, '') || '',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (error.name === 'PreconditionFailed') {
|
|
100
|
+
throw new StorageError('PreconditionFailed: ETag mismatch');
|
|
101
|
+
}
|
|
102
|
+
throw new StorageError(`Failed to put object: ${error.message}`, error);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async delete(key) {
|
|
107
|
+
try {
|
|
108
|
+
const command = new DeleteObjectCommand({
|
|
109
|
+
Bucket: this.bucket,
|
|
110
|
+
Key: key,
|
|
111
|
+
});
|
|
112
|
+
await this.client.send(command);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
throw new StorageError(`Failed to delete object: ${error.message}`, error);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async exists(key) {
|
|
119
|
+
try {
|
|
120
|
+
const command = new HeadObjectCommand({
|
|
121
|
+
Bucket: this.bucket,
|
|
122
|
+
Key: key,
|
|
123
|
+
});
|
|
124
|
+
await this.client.send(command);
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
if (error.name === 'NotFound' || error.name === 'NoSuchKey') {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
throw new StorageError(`Failed to check existence: ${error.message}`, error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async listKeys(prefix) {
|
|
135
|
+
return this.withRetry(async () => {
|
|
136
|
+
try {
|
|
137
|
+
const command = new ListObjectsV2Command({
|
|
138
|
+
Bucket: this.bucket,
|
|
139
|
+
Prefix: prefix,
|
|
140
|
+
});
|
|
141
|
+
const response = await this.client.send(command);
|
|
142
|
+
return (response.Contents || []).map(obj => obj.Key).filter(Boolean);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
throw new StorageError(`Failed to list keys: ${error.message}`, error);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async batchGet(keys) {
|
|
150
|
+
const results = new Map();
|
|
151
|
+
// Fetch in parallel
|
|
152
|
+
const promises = keys.map(async (key) => {
|
|
153
|
+
try {
|
|
154
|
+
const obj = await this.get(key);
|
|
155
|
+
return { key, obj };
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const settled = await Promise.all(promises);
|
|
162
|
+
for (const result of settled) {
|
|
163
|
+
if (result) {
|
|
164
|
+
results.set(result.key, result.obj);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return results;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=s3-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-adapter.js","sourceRoot":"","sources":["../../src/storage/s3-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,SAAS;IACZ,MAAM,CAAW;IACjB,MAAM,CAAS;IAEvB,YAAY,MAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAC;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,WAAW,EAAE,CAAC,EAAE,2DAA2D;YAC3E,cA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,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAc;QAC3B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;QAEjD,oBAAoB;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACtC,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAChC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;YACtB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE5C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Document, InsertDocument, UpdateDocument } from './document.js';
|
|
2
|
+
import type { QueryFilter, QueryOptions, UpdateOptions } from './query.js';
|
|
3
|
+
/**
|
|
4
|
+
* Collection interface for type-safe CRUD operations
|
|
5
|
+
*/
|
|
6
|
+
export interface ICollection<T extends Document> {
|
|
7
|
+
insert(data: InsertDocument<T>): Promise<T>;
|
|
8
|
+
findById(id: string): Promise<T | null>;
|
|
9
|
+
find(filter: QueryFilter<T>, options?: QueryOptions): Promise<T[]>;
|
|
10
|
+
update(id: string, data: UpdateDocument<T>, options?: UpdateOptions): Promise<T>;
|
|
11
|
+
delete(id: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Collection metadata
|
|
15
|
+
*/
|
|
16
|
+
export interface CollectionMeta {
|
|
17
|
+
name: string;
|
|
18
|
+
version: number;
|
|
19
|
+
indexShardCount: number;
|
|
20
|
+
indexedFields: string[];
|
|
21
|
+
createdAt: string;
|
|
22
|
+
documentCount: number;
|
|
23
|
+
lastUpdated: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Index shard structure
|
|
27
|
+
*/
|
|
28
|
+
export interface IndexShard {
|
|
29
|
+
shardId: string;
|
|
30
|
+
documents: Record<string, any>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Shard metadata for performance optimization
|
|
34
|
+
*/
|
|
35
|
+
export interface ShardMetadata {
|
|
36
|
+
shardId: string;
|
|
37
|
+
docCount: number;
|
|
38
|
+
lastUpdated: string;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/types/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,QAAQ;IAC7C,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACxC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACnE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/types/collection.ts"],"names":[],"mappings":""}
|
|
@@ -2,21 +2,17 @@
|
|
|
2
2
|
* Base document type with system fields
|
|
3
3
|
*/
|
|
4
4
|
export interface Document {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
id: string;
|
|
6
|
+
_etag?: string;
|
|
7
|
+
_createdAt?: string;
|
|
8
|
+
_updatedAt?: string;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
11
|
* Type for inserting new documents (omits system fields)
|
|
13
12
|
*/
|
|
14
|
-
export type InsertDocument<T extends Document> = Omit<
|
|
15
|
-
T,
|
|
16
|
-
'id' | '_etag' | '_createdAt' | '_updatedAt'
|
|
17
|
-
>;
|
|
18
|
-
|
|
13
|
+
export type InsertDocument<T extends Document> = Omit<T, 'id' | '_etag' | '_createdAt' | '_updatedAt'>;
|
|
19
14
|
/**
|
|
20
15
|
* Type for updating documents (partial update without id)
|
|
21
16
|
*/
|
|
22
17
|
export type UpdateDocument<T extends Document> = Partial<Omit<T, 'id'>>;
|
|
18
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/types/document.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,QAAQ,IAAI,IAAI,CACnD,CAAC,EACD,IAAI,GAAG,OAAO,GAAG,YAAY,GAAG,YAAY,CAC7C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/types/document.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for BucketDB
|
|
3
|
+
*/
|
|
4
|
+
export declare class BucketDBError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Document not found error
|
|
9
|
+
*/
|
|
10
|
+
export declare class DocumentNotFoundError extends BucketDBError {
|
|
11
|
+
constructor(id: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Concurrent update conflict error
|
|
15
|
+
*/
|
|
16
|
+
export declare class ConcurrentUpdateError extends BucketDBError {
|
|
17
|
+
constructor(message?: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validation error
|
|
21
|
+
*/
|
|
22
|
+
export declare class ValidationError extends BucketDBError {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Storage error
|
|
27
|
+
*/
|
|
28
|
+
export declare class StorageError extends BucketDBError {
|
|
29
|
+
readonly cause?: Error | undefined;
|
|
30
|
+
constructor(message: string, cause?: Error | undefined);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,EAAE,EAAE,MAAM;CAIvB;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,GAAE,MAAmD;CAIzE;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,aAAa;aACA,KAAK,CAAC,EAAE,KAAK;gBAA9C,OAAO,EAAE,MAAM,EAAkB,KAAK,CAAC,EAAE,KAAK,YAAA;CAI3D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for BucketDB
|
|
3
|
+
*/
|
|
4
|
+
export class BucketDBError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'BucketDBError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Document not found error
|
|
12
|
+
*/
|
|
13
|
+
export class DocumentNotFoundError extends BucketDBError {
|
|
14
|
+
constructor(id) {
|
|
15
|
+
super(`Document not found: ${id}`);
|
|
16
|
+
this.name = 'DocumentNotFoundError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Concurrent update conflict error
|
|
21
|
+
*/
|
|
22
|
+
export class ConcurrentUpdateError extends BucketDBError {
|
|
23
|
+
constructor(message = 'Concurrent update conflict, please retry') {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'ConcurrentUpdateError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validation error
|
|
30
|
+
*/
|
|
31
|
+
export class ValidationError extends BucketDBError {
|
|
32
|
+
constructor(message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = 'ValidationError';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Storage error
|
|
39
|
+
*/
|
|
40
|
+
export class StorageError extends BucketDBError {
|
|
41
|
+
cause;
|
|
42
|
+
constructor(message, cause) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.cause = cause;
|
|
45
|
+
this.name = 'StorageError';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD,YAAY,EAAU;QACpB,KAAK,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD,YAAY,UAAkB,0CAA0C;QACtE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,aAAa;IACA;IAA7C,YAAY,OAAe,EAAkB,KAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,UAAK,GAAL,KAAK,CAAQ;QAExD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { Document, InsertDocument, UpdateDocument } from './document.js';
|
|
2
|
+
export type { QueryOperator, QueryValue, QueryFilter, QueryOptions, UpdateOptions, } from './query.js';
|
|
3
|
+
export type { StorageObject, PutOptions, StorageAdapter, StorageCredentials, StorageAdapterConfig, } from './storage.js';
|
|
4
|
+
export type { ICollection, CollectionMeta, IndexShard, ShardMetadata, } from './collection.js';
|
|
5
|
+
export { BucketDBError, DocumentNotFoundError, ConcurrentUpdateError, ValidationError, StorageError, } from './errors.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG9E,YAAY,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,aAAa,EACb,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,aAAa,GACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AA6BA,gBAAgB;AAChB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported query operators
|
|
3
|
+
*/
|
|
4
|
+
export type QueryOperator = '$eq' | '$ne' | '$gt' | '$gte' | '$lt' | '$lte' | '$in' | '$nin';
|
|
5
|
+
/**
|
|
6
|
+
* Query value can be direct value or operator object
|
|
7
|
+
*/
|
|
8
|
+
export type QueryValue<T> = T | {
|
|
9
|
+
$eq?: T;
|
|
10
|
+
$ne?: T;
|
|
11
|
+
$gt?: T;
|
|
12
|
+
$gte?: T;
|
|
13
|
+
$lt?: T;
|
|
14
|
+
$lte?: T;
|
|
15
|
+
$in?: T[];
|
|
16
|
+
$nin?: T[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Query filter for type-safe queries
|
|
20
|
+
*/
|
|
21
|
+
export type QueryFilter<T> = {
|
|
22
|
+
[K in keyof T]?: QueryValue<T[K]>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Query options for pagination and sorting
|
|
26
|
+
*/
|
|
27
|
+
export interface QueryOptions {
|
|
28
|
+
limit?: number;
|
|
29
|
+
offset?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Update options with optimistic locking
|
|
33
|
+
*/
|
|
34
|
+
export interface UpdateOptions {
|
|
35
|
+
etag?: string;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/types/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,KAAK,GACL,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IACpB,CAAC,GACD;IACE,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;CACZ,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/types/query.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage object returned by adapter
|
|
3
|
+
*/
|
|
4
|
+
export interface StorageObject {
|
|
5
|
+
data: any;
|
|
6
|
+
etag: string;
|
|
7
|
+
lastModified: Date;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Put options for conditional writes
|
|
11
|
+
*/
|
|
12
|
+
export interface PutOptions {
|
|
13
|
+
ifMatch?: string;
|
|
14
|
+
ifNoneMatch?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Storage adapter interface (abstraction for S3/OSS)
|
|
18
|
+
*/
|
|
19
|
+
export interface StorageAdapter {
|
|
20
|
+
get(key: string): Promise<StorageObject>;
|
|
21
|
+
put(key: string, data: any, options?: PutOptions): Promise<{
|
|
22
|
+
etag: string;
|
|
23
|
+
}>;
|
|
24
|
+
delete(key: string): Promise<void>;
|
|
25
|
+
exists(key: string): Promise<boolean>;
|
|
26
|
+
listKeys(prefix: string): Promise<string[]>;
|
|
27
|
+
batchGet(keys: string[]): Promise<Map<string, StorageObject>>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Storage credentials
|
|
31
|
+
*/
|
|
32
|
+
export interface StorageCredentials {
|
|
33
|
+
accessKeyId: string;
|
|
34
|
+
secretAccessKey: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Storage adapter configuration
|
|
38
|
+
*/
|
|
39
|
+
export interface StorageAdapterConfig {
|
|
40
|
+
bucket: string;
|
|
41
|
+
region: string;
|
|
42
|
+
credentials: StorageCredentials;
|
|
43
|
+
endpoint?: string;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/types/storage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,kBAAkB,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/types/storage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple string hash function (DJB2 algorithm)
|
|
3
|
+
*/
|
|
4
|
+
export declare function hashString(str: string): number;
|
|
5
|
+
/**
|
|
6
|
+
* Get shard ID for a document ID
|
|
7
|
+
*/
|
|
8
|
+
export declare function getShardId(docId: string, shardCount: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Format shard ID as zero-padded string (e.g., "00", "01", "15")
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatShardId(shardId: number): string;
|
|
13
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/utils/hash.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple string hash function (DJB2 algorithm)
|
|
3
|
+
*/
|
|
4
|
+
export function hashString(str) {
|
|
5
|
+
let hash = 5381;
|
|
6
|
+
for (let i = 0; i < str.length; i++) {
|
|
7
|
+
hash = (hash * 33) ^ str.charCodeAt(i);
|
|
8
|
+
}
|
|
9
|
+
return hash >>> 0; // Convert to unsigned 32-bit integer
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get shard ID for a document ID
|
|
13
|
+
*/
|
|
14
|
+
export function getShardId(docId, shardCount) {
|
|
15
|
+
return hashString(docId) % shardCount;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Format shard ID as zero-padded string (e.g., "00", "01", "15")
|
|
19
|
+
*/
|
|
20
|
+
export function formatShardId(shardId) {
|
|
21
|
+
return shardId.toString().padStart(2, '0');
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/utils/hash.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,qCAAqC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,UAAkB;IAC1D,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ValidationError for path validation failures
|
|
3
|
+
*/
|
|
4
|
+
export declare class PathValidationError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Sanitize and validate path components to prevent directory traversal attacks
|
|
9
|
+
* This is for SINGLE path components (like collection names, document IDs)
|
|
10
|
+
*
|
|
11
|
+
* @param input - Path component to sanitize
|
|
12
|
+
* @returns Sanitized path component
|
|
13
|
+
* @throws PathValidationError if validation fails
|
|
14
|
+
*/
|
|
15
|
+
export declare function sanitizePathComponent(input: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Validate that a target path is within the allowed base path
|
|
18
|
+
* Prevents directory traversal attacks by ensuring the resolved path
|
|
19
|
+
* doesn't escape the base directory
|
|
20
|
+
*
|
|
21
|
+
* @param basePath - Base directory path
|
|
22
|
+
* @param targetPath - Target path to validate
|
|
23
|
+
* @throws PathValidationError if path escapes base directory
|
|
24
|
+
*/
|
|
25
|
+
export declare function validatePathWithinBase(basePath: string, targetPath: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Safely join path components with validation
|
|
28
|
+
* This is for joining SINGLE components (not full paths with slashes)
|
|
29
|
+
*
|
|
30
|
+
* @param basePath - Base directory path
|
|
31
|
+
* @param components - Path components to join
|
|
32
|
+
* @returns Validated full path
|
|
33
|
+
* @throws PathValidationError if validation fails
|
|
34
|
+
*/
|
|
35
|
+
export declare function safePathJoin(basePath: string, ...components: string[]): string;
|
|
36
|
+
/**
|
|
37
|
+
* Safely join a key (which may contain slashes) with base path
|
|
38
|
+
* Validates the result doesn't escape base directory
|
|
39
|
+
*
|
|
40
|
+
* @param basePath - Base directory path
|
|
41
|
+
* @param key - Storage key (may contain path separators)
|
|
42
|
+
* @returns Validated full path
|
|
43
|
+
* @throws PathValidationError if validation fails
|
|
44
|
+
*/
|
|
45
|
+
export declare function safeKeyPath(basePath: string, key: string): string;
|
|
46
|
+
//# sourceMappingURL=path-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-validator.d.ts","sourceRoot":"","sources":["../../src/utils/path-validator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA6B3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAUjF;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAW9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAejE"}
|