@minnowdb/core 0.4.0 → 0.4.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/dist/engine/database.js
CHANGED
|
@@ -8395,6 +8395,7 @@ export class MinnowDatabase {
|
|
|
8395
8395
|
let writtenBytes = 0;
|
|
8396
8396
|
let batchBytes = 0;
|
|
8397
8397
|
let metadataBatchBytes = 0;
|
|
8398
|
+
let batchBlockCount = 0;
|
|
8398
8399
|
const batch = [];
|
|
8399
8400
|
const flush = async () => {
|
|
8400
8401
|
if (batch.length === 0 || identity === undefined)
|
|
@@ -8410,6 +8411,7 @@ export class MinnowDatabase {
|
|
|
8410
8411
|
});
|
|
8411
8412
|
batchBytes = 0;
|
|
8412
8413
|
metadataBatchBytes = 0;
|
|
8414
|
+
batchBlockCount = 0;
|
|
8413
8415
|
writtenBytes = session.stagedBytes;
|
|
8414
8416
|
options.onProgress?.({ phase: "blocks", writtenBytes, totalBytes });
|
|
8415
8417
|
};
|
|
@@ -8439,6 +8441,7 @@ export class MinnowDatabase {
|
|
|
8439
8441
|
if (batch.length > 0 &&
|
|
8440
8442
|
(batch.length >= MAX_SNAPSHOT_FRAME_BATCH_ITEMS ||
|
|
8441
8443
|
batchBytes + entry.frame.payload.byteLength > MAX_SNAPSHOT_FRAME_BATCH_BYTES ||
|
|
8444
|
+
(entry.frame.kind === "block" && batchBlockCount > 0) ||
|
|
8442
8445
|
(entry.frame.kind !== "block" &&
|
|
8443
8446
|
metadataBatchBytes + entry.frame.payload.byteLength >
|
|
8444
8447
|
MAX_SNAPSHOT_METADATA_BATCH_BYTES))) {
|
|
@@ -8449,6 +8452,9 @@ export class MinnowDatabase {
|
|
|
8449
8452
|
if (entry.frame.kind !== "block") {
|
|
8450
8453
|
metadataBatchBytes = safeWholeNumberSum([metadataBatchBytes, entry.frame.payload.byteLength], "Snapshot import metadata batch bytes");
|
|
8451
8454
|
}
|
|
8455
|
+
else {
|
|
8456
|
+
batchBlockCount += 1;
|
|
8457
|
+
}
|
|
8452
8458
|
continue;
|
|
8453
8459
|
}
|
|
8454
8460
|
if (identity === undefined)
|
|
@@ -4488,7 +4488,7 @@ function validateSnapshotFrameExportState(value) {
|
|
|
4488
4488
|
requireStorageId(value.sessionId, "snapshot frame export session id");
|
|
4489
4489
|
requireStorageId(value.ownerId, "snapshot frame export owner id");
|
|
4490
4490
|
requireStorageId(value.ledgerId, "snapshot frame export ledger id");
|
|
4491
|
-
|
|
4491
|
+
validateSnapshotStateLifetime(value.createdAt, value.expiresAt, "Snapshot frame export");
|
|
4492
4492
|
requireNonNegativeInteger(value.leaseRevision, "snapshot frame export lease revision");
|
|
4493
4493
|
requireNonNegativeInteger(value.manifestVersion, "snapshot frame export manifest version");
|
|
4494
4494
|
requireNonNegativeInteger(value.ledgerLength, "snapshot frame export ledger length");
|
|
@@ -4552,7 +4552,7 @@ function validateSnapshotFrameImportState(value) {
|
|
|
4552
4552
|
requireStorageId(value.identity, "snapshot frame import identity");
|
|
4553
4553
|
requireStorageId(value.ownerId, "snapshot frame import owner id");
|
|
4554
4554
|
requireStorageId(value.ledgerId, "snapshot frame import ledger id");
|
|
4555
|
-
|
|
4555
|
+
validateSnapshotStateLifetime(value.createdAt, value.expiresAt, "Snapshot frame import");
|
|
4556
4556
|
for (const field of [
|
|
4557
4557
|
"version",
|
|
4558
4558
|
"ledgerLength",
|
|
@@ -4612,6 +4612,18 @@ function validateSnapshotLifetime(createdAt, expiresAt, label) {
|
|
|
4612
4612
|
throw new RangeError(`${label} expiration interval is invalid`);
|
|
4613
4613
|
}
|
|
4614
4614
|
}
|
|
4615
|
+
/**
|
|
4616
|
+
* A durable state keeps the session's original creation time while a valid renewal moves its
|
|
4617
|
+
* expiry forward. The renewal WAL input carries the bounded cutoff-to-expiry interval, so state
|
|
4618
|
+
* validation must not mistake a session older than one TTL for one lease longer than the TTL.
|
|
4619
|
+
*/
|
|
4620
|
+
function validateSnapshotStateLifetime(createdAt, expiresAt, label) {
|
|
4621
|
+
requireTimestamp(createdAt, `${label} creation time`);
|
|
4622
|
+
requireTimestamp(expiresAt, `${label} expiration`);
|
|
4623
|
+
if (Date.parse(expiresAt) <= Date.parse(createdAt)) {
|
|
4624
|
+
throw new RangeError(`${label} expiration interval is invalid`);
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4615
4627
|
function validateSnapshotRenewal(input, label) {
|
|
4616
4628
|
validateId(input.ownerId);
|
|
4617
4629
|
if (input.identity !== undefined)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minnowdb/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A columnar SQL database for the browser: PostgreSQL-style SQL over durable IndexedDB or OPFS data, with no server or WebAssembly module.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Eric Wilhite",
|