@fireproof/core 0.20.0-dev-preview-53 → 0.20.0-dev-preview-55
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/deno.json +2 -4
- package/index.cjs +410 -405
- package/index.cjs.map +1 -1
- package/index.d.cts +60 -44
- package/index.d.ts +60 -44
- package/index.js +361 -356
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +4 -6
- package/react/index.cjs.map +1 -1
- package/react/index.d.cts +1 -2
- package/react/index.d.ts +1 -2
- package/react/index.js.map +1 -1
- package/react/metafile-cjs.json +1 -1
- package/react/metafile-esm.json +1 -1
- package/tests/blockstore/interceptor-gateway.test.ts +120 -3
- package/tests/fireproof/database.test.ts +53 -0
@@ -86,6 +86,13 @@ describe("basic Ledger with record", function () {
|
|
86
86
|
const e = await db.get("hello").catch((e) => e);
|
87
87
|
expect(e.message).toMatch(/Not found/);
|
88
88
|
});
|
89
|
+
it("should remove as an alias for del", async () => {
|
90
|
+
const ok = await db.remove("hello");
|
91
|
+
expect(ok.id).toBe("hello");
|
92
|
+
|
93
|
+
const e = await db.get("hello").catch((e) => e);
|
94
|
+
expect(e.message).toMatch(/Not found/);
|
95
|
+
});
|
89
96
|
it("has changes", async () => {
|
90
97
|
const { rows } = await db.changes([]);
|
91
98
|
expect(rows.length).toBe(1);
|
@@ -197,6 +204,13 @@ describe("named Ledger with record", function () {
|
|
197
204
|
const e = await db.get("hello").catch((e) => e);
|
198
205
|
expect(e.message).toMatch(/Not found/);
|
199
206
|
});
|
207
|
+
it("should remove as an alias for del", async () => {
|
208
|
+
const ok = await db.remove("hello");
|
209
|
+
expect(ok.id).toBe("hello");
|
210
|
+
|
211
|
+
const e = await db.get("hello").catch((e) => e);
|
212
|
+
expect(e.message).toMatch(/Not found/);
|
213
|
+
});
|
200
214
|
it("has changes", async () => {
|
201
215
|
const { rows } = await db.changes([]);
|
202
216
|
expect(rows.length).toBe(1);
|
@@ -542,6 +556,45 @@ describe("ledger with files input", () => {
|
|
542
556
|
// expect(file.name).toBe('fireproof.png') // see https://github.com/fireproof-storage/fireproof/issues/70
|
543
557
|
});
|
544
558
|
|
559
|
+
it("should preserve lastModified timestamp", async () => {
|
560
|
+
// Create a custom timestamp
|
561
|
+
const customTimestamp = Date.now() - 86400000; // 1 day ago
|
562
|
+
|
563
|
+
// Create a new file with the custom timestamp
|
564
|
+
const blob = new Blob(["test content"], { type: "text/plain" });
|
565
|
+
const file = new File([blob], "test.txt", {
|
566
|
+
type: "text/plain",
|
567
|
+
lastModified: customTimestamp,
|
568
|
+
});
|
569
|
+
|
570
|
+
// Store the file in the database
|
571
|
+
const newDoc = {
|
572
|
+
_id: "test-timestamp",
|
573
|
+
type: "files",
|
574
|
+
_files: {
|
575
|
+
test: file,
|
576
|
+
},
|
577
|
+
};
|
578
|
+
|
579
|
+
await db.put(newDoc);
|
580
|
+
|
581
|
+
// Retrieve the file from the database
|
582
|
+
const retrievedDoc = await db.get("test-timestamp");
|
583
|
+
const files = retrievedDoc._files as DocFiles;
|
584
|
+
const fileMeta = files.test as DocFileMeta;
|
585
|
+
|
586
|
+
// Verify the file has the correct metadata
|
587
|
+
expect(fileMeta).toBeTruthy();
|
588
|
+
expect(fileMeta.type).toBe("text/plain");
|
589
|
+
expect(typeof fileMeta.file).toBe("function");
|
590
|
+
|
591
|
+
// Get the actual file
|
592
|
+
const retrievedFile = (await fileMeta.file?.()) as File;
|
593
|
+
|
594
|
+
// Check if lastModified is preserved
|
595
|
+
expect(retrievedFile.lastModified).toBe(customTimestamp);
|
596
|
+
});
|
597
|
+
|
545
598
|
it("should update the file document data without changing the files", async () => {
|
546
599
|
interface Doc {
|
547
600
|
type: string;
|