@crawlee/fs-storage-native 0.1.5-beta.1 → 0.1.5-beta.2

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.
Files changed (3) hide show
  1. package/index.d.ts +9 -9
  2. package/lib.js +35 -1
  3. package/package.json +5 -5
package/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export interface DatasetMetadata {
2
2
  id: string;
3
3
  name: string | null;
4
- accessedAt: string;
5
- createdAt: string;
6
- modifiedAt: string;
4
+ accessedAt: Date;
5
+ createdAt: Date;
6
+ modifiedAt: Date;
7
7
  itemCount: number;
8
8
  }
9
9
 
@@ -19,9 +19,9 @@ export interface DatasetItemsListPage {
19
19
  export interface KeyValueStoreMetadata {
20
20
  id: string;
21
21
  name: string | null;
22
- accessedAt: string;
23
- createdAt: string;
24
- modifiedAt: string;
22
+ accessedAt: Date;
23
+ createdAt: Date;
24
+ modifiedAt: Date;
25
25
  }
26
26
 
27
27
  export interface KeyValueStoreRecord {
@@ -47,9 +47,9 @@ export interface KeyValueStoreRecordMetadata {
47
47
  export interface RequestQueueMetadata {
48
48
  id: string;
49
49
  name: string | null;
50
- accessedAt: string;
51
- createdAt: string;
52
- modifiedAt: string;
50
+ accessedAt: Date;
51
+ createdAt: Date;
52
+ modifiedAt: Date;
53
53
  hadMultipleClients: boolean;
54
54
  handledRequestCount: number;
55
55
  pendingRequestCount: number;
package/lib.js CHANGED
@@ -2,7 +2,41 @@ import { createReadStream, createWriteStream } from 'fs';
2
2
  import { unlink } from 'fs/promises';
3
3
  import { Readable, Writable } from 'stream';
4
4
 
5
- import { DatasetItemIterator, FileSystemKeyValueStoreClient, KvsKeyIterator } from './index.js';
5
+ import {
6
+ DatasetItemIterator,
7
+ FileSystemDatasetClient,
8
+ FileSystemKeyValueStoreClient,
9
+ FileSystemRequestQueueClient,
10
+ KvsKeyIterator,
11
+ } from './index.js';
12
+
13
+ // The core library stores datetimes as ISO-8601 strings (the on-disk format),
14
+ // so they cross the FFI boundary as strings. Convert the standard metadata
15
+ // datetime fields to native JS `Date`s before handing the object to callers.
16
+ const METADATA_DATE_FIELDS = ['accessedAt', 'createdAt', 'modifiedAt'];
17
+
18
+ function convertMetadataDates(meta) {
19
+ if (meta) {
20
+ for (const field of METADATA_DATE_FIELDS) {
21
+ if (typeof meta[field] === 'string') {
22
+ meta[field] = new Date(meta[field]);
23
+ }
24
+ }
25
+ }
26
+ return meta;
27
+ }
28
+
29
+ // Wrap getMetadata on each client to coerce datetime strings into `Date`s.
30
+ for (const Client of [
31
+ FileSystemDatasetClient,
32
+ FileSystemKeyValueStoreClient,
33
+ FileSystemRequestQueueClient,
34
+ ]) {
35
+ const origGetMetadata = Client.prototype.getMetadata;
36
+ Client.prototype.getMetadata = async function (...args) {
37
+ return convertMetadataDates(await origGetMetadata.apply(this, args));
38
+ };
39
+ }
6
40
 
7
41
  // Add Symbol.asyncIterator to DatasetItemIterator so users can write:
8
42
  // for await (const item of client.iterateItems()) { ... }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/fs-storage-native",
3
- "version": "0.1.5-beta.1",
3
+ "version": "0.1.5-beta.2",
4
4
  "description": "Low-level Rust-powered napi-rs bindings for Crawlee's filesystem storage. Not intended for direct use in crawlers — depend on @crawlee/fs-storage instead.",
5
5
  "homepage": "https://github.com/apify/crawlee-storage",
6
6
  "license": "Apache-2.0",
@@ -46,10 +46,10 @@
46
46
  "vitest": "^3"
47
47
  },
48
48
  "optionalDependencies": {
49
- "@crawlee/fs-storage-native-darwin-arm64": "0.1.5-beta.1",
50
- "@crawlee/fs-storage-native-darwin-x64": "0.1.5-beta.1",
51
- "@crawlee/fs-storage-native-linux-x64-gnu": "0.1.5-beta.1",
52
- "@crawlee/fs-storage-native-win32-x64-msvc": "0.1.5-beta.1"
49
+ "@crawlee/fs-storage-native-darwin-arm64": "0.1.5-beta.2",
50
+ "@crawlee/fs-storage-native-darwin-x64": "0.1.5-beta.2",
51
+ "@crawlee/fs-storage-native-linux-x64-gnu": "0.1.5-beta.2",
52
+ "@crawlee/fs-storage-native-win32-x64-msvc": "0.1.5-beta.2"
53
53
  },
54
54
  "napi": {
55
55
  "binaryName": "fs-storage-native",