@remix-run/file-storage 0.13.0 → 0.13.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.
@@ -1,7 +1,7 @@
1
1
  import * as fs from 'node:fs';
2
2
  import * as fsp from 'node:fs/promises';
3
3
  import * as path from 'node:path';
4
- import { openFile, writeFile } from '@remix-run/fs';
4
+ import { openLazyFile, writeFile } from '@remix-run/fs';
5
5
  /**
6
6
  * Creates a `FileStorage` that is backed by a filesystem directory using node:fs.
7
7
  *
@@ -52,7 +52,7 @@ export function createFsFileStorage(directory) {
52
52
  };
53
53
  await fsp.writeFile(metaPath, JSON.stringify(meta));
54
54
  let metaData = await readMetadata(metaPath);
55
- return openFile(filePath, {
55
+ return openLazyFile(filePath, {
56
56
  lastModified: metaData.lastModified,
57
57
  name: metaData.name,
58
58
  type: metaData.type,
@@ -63,7 +63,7 @@ export function createFsFileStorage(directory) {
63
63
  let { filePath, metaPath } = await getPaths(key);
64
64
  try {
65
65
  let meta = await readMetadata(metaPath);
66
- return openFile(filePath, {
66
+ return openLazyFile(filePath, {
67
67
  lastModified: meta.lastModified,
68
68
  name: meta.name,
69
69
  type: meta.type,
@@ -4,12 +4,14 @@
4
4
  export interface FileStorage {
5
5
  /**
6
6
  * Get a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) at the given key.
7
+ *
7
8
  * @param key The key to look up
8
9
  * @returns The file with the given key, or `null` if no such key exists
9
10
  */
10
11
  get(key: string): File | null | Promise<File | null>;
11
12
  /**
12
13
  * Check if a file with the given key exists.
14
+ *
13
15
  * @param key The key to look up
14
16
  * @returns `true` if a file with the given key exists, `false` otherwise
15
17
  */
@@ -75,28 +77,32 @@ export interface FileStorage {
75
77
  */
76
78
  list<T extends ListOptions>(options?: T): ListResult<T> | Promise<ListResult<T>>;
77
79
  /**
78
- * Put a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in storage and return
79
- * a new file backed by this storage.
80
+ * Put a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in storage and return a
81
+ * new file backed by this storage.
82
+ *
80
83
  * @param key The key to store the file under
81
84
  * @param file The file to store
82
- * @returns A new File object backed by this storage
85
+ * @returns A new `File` object backed by this storage
83
86
  */
84
87
  put(key: string, file: File): File | Promise<File>;
85
88
  /**
86
89
  * Remove the file with the given key from storage.
90
+ *
87
91
  * @param key The key to remove
88
- * @returns A promise that resolves when the file has been removed
89
92
  */
90
93
  remove(key: string): void | Promise<void>;
91
94
  /**
92
95
  * Put a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in storage at the given
93
96
  * key.
97
+ *
94
98
  * @param key The key to store the file under
95
99
  * @param file The file to store
96
- * @returns A promise that resolves when the file has been stored
97
100
  */
98
101
  set(key: string, file: File): void | Promise<void>;
99
102
  }
103
+ /**
104
+ * A reference to a file in storage by its key.
105
+ */
100
106
  export interface FileKey {
101
107
  /**
102
108
  * The key of the file in storage.
@@ -124,6 +130,9 @@ export interface FileMetadata extends FileKey {
124
130
  */
125
131
  type: string;
126
132
  }
133
+ /**
134
+ * Options for listing files in storage.
135
+ */
127
136
  export interface ListOptions {
128
137
  /**
129
138
  * An opaque string that allows you to paginate over the keys in storage.
@@ -142,6 +151,9 @@ export interface ListOptions {
142
151
  */
143
152
  prefix?: string;
144
153
  }
154
+ /**
155
+ * The result of listing files in storage.
156
+ */
145
157
  export interface ListResult<T extends ListOptions> {
146
158
  /**
147
159
  * An opaque string that allows you to paginate over the keys in storage. Pass this back in the
@@ -1 +1 @@
1
- {"version":3,"file":"file-storage.d.ts","sourceRoot":"","sources":["../../src/lib/file-storage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAA;IACpD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GA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E,MAAM,CAAA;IACpB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,WAAW;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC,SAAS;QAAE,eAAe,EAAE,IAAI,CAAA;KAAE,GAAG,YAAY,GAAG,OAAO,CAAC,EAAE,CAAA;CACxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/file-storage",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "Key/value storage for JavaScript File objects",
5
5
  "author": "Michael Jackson <mjijackson@gmail.com>",
6
6
  "repository": {
@@ -33,14 +33,14 @@
33
33
  },
34
34
  "./package.json": "./package.json"
35
35
  },
36
- "peerDependencies": {
37
- "@remix-run/fs": "^0.1.0",
38
- "@remix-run/lazy-file": "^4.0.0"
36
+ "dependencies": {
37
+ "@remix-run/fs": "^0.4.1",
38
+ "@remix-run/lazy-file": "^5.0.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^24.6.0",
42
- "typescript": "^5.9.3",
43
- "@remix-run/form-data-parser": "^0.14.0"
42
+ "@typescript/native-preview": "7.0.0-dev.20251125.1",
43
+ "@remix-run/form-data-parser": "0.14.0"
44
44
  },
45
45
  "keywords": [
46
46
  "file",
@@ -49,9 +49,9 @@
49
49
  "fs"
50
50
  ],
51
51
  "scripts": {
52
- "build": "tsc -p tsconfig.build.json",
52
+ "build": "tsgo -p tsconfig.build.json",
53
53
  "clean": "git clean -fdX",
54
- "test": "node --disable-warning=ExperimentalWarning --test './src/**/*.test.ts'",
55
- "typecheck": "tsc --noEmit"
54
+ "test": "node --disable-warning=ExperimentalWarning --test",
55
+ "typecheck": "tsgo --noEmit"
56
56
  }
57
57
  }
@@ -1,7 +1,7 @@
1
1
  import * as fs from 'node:fs'
2
2
  import * as fsp from 'node:fs/promises'
3
3
  import * as path from 'node:path'
4
- import { openFile, writeFile } from '@remix-run/fs'
4
+ import { openLazyFile, writeFile } from '@remix-run/fs'
5
5
 
6
6
  import type { FileStorage, FileMetadata, ListOptions, ListResult } from '../file-storage.ts'
7
7
 
@@ -69,7 +69,7 @@ export function createFsFileStorage(directory: string): FileStorage {
69
69
 
70
70
  let metaData = await readMetadata(metaPath)
71
71
 
72
- return openFile(filePath, {
72
+ return openLazyFile(filePath, {
73
73
  lastModified: metaData.lastModified,
74
74
  name: metaData.name,
75
75
  type: metaData.type,
@@ -83,7 +83,7 @@ export function createFsFileStorage(directory: string): FileStorage {
83
83
  try {
84
84
  let meta = await readMetadata(metaPath)
85
85
 
86
- return openFile(filePath, {
86
+ return openLazyFile(filePath, {
87
87
  lastModified: meta.lastModified,
88
88
  name: meta.name,
89
89
  type: meta.type,
@@ -4,12 +4,14 @@
4
4
  export interface FileStorage {
5
5
  /**
6
6
  * Get a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) at the given key.
7
+ *
7
8
  * @param key The key to look up
8
9
  * @returns The file with the given key, or `null` if no such key exists
9
10
  */
10
11
  get(key: string): File | null | Promise<File | null>
11
12
  /**
12
13
  * Check if a file with the given key exists.
14
+ *
13
15
  * @param key The key to look up
14
16
  * @returns `true` if a file with the given key exists, `false` otherwise
15
17
  */
@@ -75,29 +77,33 @@ export interface FileStorage {
75
77
  */
76
78
  list<T extends ListOptions>(options?: T): ListResult<T> | Promise<ListResult<T>>
77
79
  /**
78
- * Put a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in storage and return
79
- * a new file backed by this storage.
80
+ * Put a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in storage and return a
81
+ * new file backed by this storage.
82
+ *
80
83
  * @param key The key to store the file under
81
84
  * @param file The file to store
82
- * @returns A new File object backed by this storage
85
+ * @returns A new `File` object backed by this storage
83
86
  */
84
87
  put(key: string, file: File): File | Promise<File>
85
88
  /**
86
89
  * Remove the file with the given key from storage.
90
+ *
87
91
  * @param key The key to remove
88
- * @returns A promise that resolves when the file has been removed
89
92
  */
90
93
  remove(key: string): void | Promise<void>
91
94
  /**
92
95
  * Put a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in storage at the given
93
96
  * key.
97
+ *
94
98
  * @param key The key to store the file under
95
99
  * @param file The file to store
96
- * @returns A promise that resolves when the file has been stored
97
100
  */
98
101
  set(key: string, file: File): void | Promise<void>
99
102
  }
100
103
 
104
+ /**
105
+ * A reference to a file in storage by its key.
106
+ */
101
107
  export interface FileKey {
102
108
  /**
103
109
  * The key of the file in storage.
@@ -127,6 +133,9 @@ export interface FileMetadata extends FileKey {
127
133
  type: string
128
134
  }
129
135
 
136
+ /**
137
+ * Options for listing files in storage.
138
+ */
130
139
  export interface ListOptions {
131
140
  /**
132
141
  * An opaque string that allows you to paginate over the keys in storage.
@@ -146,6 +155,9 @@ export interface ListOptions {
146
155
  prefix?: string
147
156
  }
148
157
 
158
+ /**
159
+ * The result of listing files in storage.
160
+ */
149
161
  export interface ListResult<T extends ListOptions> {
150
162
  /**
151
163
  * An opaque string that allows you to paginate over the keys in storage. Pass this back in the