@fireproof/core 0.20.0-dev-preview-53 → 0.20.0-dev-preview-54

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireproof/core",
3
- "version": "0.20.0-dev-preview-53",
3
+ "version": "0.20.0-dev-preview-54",
4
4
  "description": "Live ledger for the web.",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -72,20 +72,18 @@
72
72
  },
73
73
  "devDependencies": {},
74
74
  "peerDependencies": {
75
- "@adviser/cement": "~0.4.0",
75
+ "@adviser/cement": "~0.4.1",
76
76
  "@fireproof/vendor": "~2.0.0",
77
77
  "react": ">=18.0.0"
78
78
  },
79
79
  "dependencies": {
80
- "@adviser/cement": "~0.4.0",
80
+ "@adviser/cement": "~0.4.1",
81
81
  "@fireproof/vendor": "~2.0.1",
82
82
  "@ipld/car": "^5.4.0",
83
83
  "@ipld/dag-cbor": "^9.2.2",
84
84
  "@ipld/dag-json": "^10.2.3",
85
85
  "cborg": "^4.2.8",
86
- "ipfs-unixfs-exporter": "^13.6.2",
87
86
  "multiformats": "^13.3.2",
88
- "@ipld/unixfs": "^3.0.0",
89
87
  "charwise": "^3.0.1",
90
88
  "prolly-trees": "^1.0.4",
91
89
  "idb": "^8.0.2",
@@ -542,6 +542,45 @@ describe("ledger with files input", () => {
542
542
  // expect(file.name).toBe('fireproof.png') // see https://github.com/fireproof-storage/fireproof/issues/70
543
543
  });
544
544
 
545
+ it("should preserve lastModified timestamp", async () => {
546
+ // Create a custom timestamp
547
+ const customTimestamp = Date.now() - 86400000; // 1 day ago
548
+
549
+ // Create a new file with the custom timestamp
550
+ const blob = new Blob(["test content"], { type: "text/plain" });
551
+ const file = new File([blob], "test.txt", {
552
+ type: "text/plain",
553
+ lastModified: customTimestamp,
554
+ });
555
+
556
+ // Store the file in the database
557
+ const newDoc = {
558
+ _id: "test-timestamp",
559
+ type: "files",
560
+ _files: {
561
+ test: file,
562
+ },
563
+ };
564
+
565
+ await db.put(newDoc);
566
+
567
+ // Retrieve the file from the database
568
+ const retrievedDoc = await db.get("test-timestamp");
569
+ const files = retrievedDoc._files as DocFiles;
570
+ const fileMeta = files.test as DocFileMeta;
571
+
572
+ // Verify the file has the correct metadata
573
+ expect(fileMeta).toBeTruthy();
574
+ expect(fileMeta.type).toBe("text/plain");
575
+ expect(typeof fileMeta.file).toBe("function");
576
+
577
+ // Get the actual file
578
+ const retrievedFile = (await fileMeta.file?.()) as File;
579
+
580
+ // Check if lastModified is preserved
581
+ expect(retrievedFile.lastModified).toBe(customTimestamp);
582
+ });
583
+
545
584
  it("should update the file document data without changing the files", async () => {
546
585
  interface Doc {
547
586
  type: string;