tero 0.0.9 → 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/recovery.js CHANGED
@@ -27,7 +27,7 @@ export class DataRecovery {
27
27
  this.s3Client = new S3Client(clientConfig);
28
28
  }
29
29
  catch (error) {
30
- throw new Error(`Failed to initialize cloud storage for recovery: ${error instanceof Error ? error.message : 'Unknown error'}`);
30
+ throw new Error(`Failed to initialize cloud storage for recovery: ${error instanceof Error ? error.message : 'Unknown error'}`, { cause: error });
31
31
  }
32
32
  }
33
33
  getCloudKey(filename) {
@@ -215,17 +215,27 @@ export class DataRecovery {
215
215
  async listAvailableArchives() {
216
216
  try {
217
217
  const prefix = this.getCloudKey('');
218
- const listCommand = new ListObjectsV2Command({
219
- Bucket: this.config.cloudStorage.bucket,
220
- Prefix: prefix,
221
- MaxKeys: 100
222
- });
223
- const response = await this.s3Client.send(listCommand);
224
- if (!response.Contents) {
218
+ // Paginated listing — a bucket with >1000 objects would otherwise
219
+ // silently truncate the archive list (hydrate 'snapshot' mode would
220
+ // miss the newest archive sitting past the first page).
221
+ const objects = [];
222
+ let token;
223
+ do {
224
+ const response = await this.s3Client.send(new ListObjectsV2Command({
225
+ Bucket: this.config.cloudStorage.bucket,
226
+ Prefix: prefix,
227
+ MaxKeys: 1000,
228
+ ContinuationToken: token
229
+ }));
230
+ if (response.Contents)
231
+ objects.push(...response.Contents);
232
+ token = response.IsTruncated ? response.NextContinuationToken : undefined;
233
+ } while (token);
234
+ if (objects.length === 0) {
225
235
  return [];
226
236
  }
227
237
  // Filter for archive files and sort by date (newest first)
228
- const archives = response.Contents
238
+ const archives = objects
229
239
  .filter((obj) => obj.Key && obj.Key.endsWith('.tar.gz'))
230
240
  .sort((a, b) => {
231
241
  const dateA = a.LastModified?.getTime() || 0;
@@ -243,18 +253,31 @@ export class DataRecovery {
243
253
  async listAvailableFiles() {
244
254
  try {
245
255
  const prefix = this.getCloudKey('');
246
- const listCommand = new ListObjectsV2Command({
247
- Bucket: this.config.cloudStorage.bucket,
248
- Prefix: prefix,
249
- MaxKeys: 1000
250
- });
251
- const response = await this.s3Client.send(listCommand);
252
- if (!response.Contents) {
256
+ // Paginated listing — restores from buckets with >1000 objects
257
+ // previously saw a silently truncated file list.
258
+ const objects = [];
259
+ let token;
260
+ do {
261
+ const response = await this.s3Client.send(new ListObjectsV2Command({
262
+ Bucket: this.config.cloudStorage.bucket,
263
+ Prefix: prefix,
264
+ MaxKeys: 1000,
265
+ ContinuationToken: token
266
+ }));
267
+ if (response.Contents)
268
+ objects.push(...response.Contents);
269
+ token = response.IsTruncated ? response.NextContinuationToken : undefined;
270
+ } while (token);
271
+ if (objects.length === 0) {
253
272
  return [];
254
273
  }
255
- // Filter for JSON files and extract keys
256
- const files = response.Contents
257
- .filter((obj) => obj.Key && obj.Key.endsWith('.json'))
274
+ // Filter for JSON files and extract keys (excluding metadata manifests)
275
+ const files = objects
276
+ .filter((obj) => obj.Key &&
277
+ obj.Key.endsWith('.json') &&
278
+ !obj.Key.endsWith('MANIFEST.json') &&
279
+ !obj.Key.endsWith('latest.json') &&
280
+ !obj.Key.endsWith('index.json'))
258
281
  .map((obj) => {
259
282
  const filename = obj.Key.split('/').pop();
260
283
  return filename.replace('.json', '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tero",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Tero is a JSON database that provides ACID transactions, schema validation, automated cloud backup, and automatic cloud recovery",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -33,7 +33,9 @@
33
33
  "ci": "npm run verify",
34
34
  "bench": "node bench/run-bench.js --synchronous normal",
35
35
  "bench:full": "node bench/run-bench.js --synchronous full",
36
- "bench:quick": "node bench/run-bench.js --quick --synchronous normal"
36
+ "bench:quick": "node bench/run-bench.js --quick --synchronous normal",
37
+ "bench:live": "node bench/run-live-bench.js",
38
+ "bench:live:quick": "node bench/run-live-bench.js --quick"
37
39
  },
38
40
  "files": [
39
41
  "dist/**/*"
@@ -45,21 +47,16 @@
45
47
  ],
46
48
  "license": "MIT",
47
49
  "dependencies": {
48
- "@aws-sdk/client-s3": "^3.0.0",
49
- "@aws-sdk/lib-storage": "^3.0.0",
50
+ "@aws-sdk/client-s3": "^3.1120.0",
51
+ "@aws-sdk/lib-storage": "^3.1120.0",
50
52
  "cron": "^4.3.2",
51
- "fs-ext": "^2.0.0",
52
- "glob": "^9.3.4",
53
53
  "quick-lru": "^7.0.1",
54
- "tar": "^6.1.13"
54
+ "tar": "^7.5.22"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/cron": "^2.0.1",
58
- "@types/fs-ext": "^2.0.3",
59
- "@types/glob": "^8.1.0",
60
58
  "@types/node": "^24.0.14",
61
59
  "@types/quick-lru": "^2.0.0",
62
- "@types/tar": "^6.1.13",
63
60
  "typescript": "^5.8.3"
64
61
  }
65
62
  }