@stowage/adapter-fs 0.0.0 → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alexander Kaufmann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # @stowage/adapter-fs
2
+
3
+ A storage rooted in one directory of the local file system.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @stowage/adapter-fs
9
+ ```
10
+
11
+ ## Example
12
+
13
+ ```ts
14
+ import { fsStorage } from "@stowage/adapter-fs";
15
+
16
+ const storage = fsStorage({ root: "/var/lib/my-app/storage" });
17
+
18
+ await storage.put("reports/2026/q3.csv", "region,revenue\n");
19
+
20
+ for await (const entry of storage.list({ prefix: "reports/" })) {
21
+ console.log(entry.key, entry.size, entry.lastModified);
22
+ }
23
+ ```
24
+
25
+ ## Runtimes
26
+
27
+ Node 24 and later, Bun and Deno, on Linux and macOS. `workerd` and Windows are not promised. CI last ran green on Bun 1.4.2 and Deno 2.9.6.
28
+
29
+ The bundle measures 5.7 kB minified and gzipped, `@stowage/core` included.
30
+
31
+ ## Limits
32
+
33
+ - `keyBytesPreserved` is not declared: a key comes back Unicode-equivalent to what was written
34
+ ([spec 4.9](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#49-capabilities)).
35
+ - `presignedUrls` is not declared: `FsStorage` has neither `presignGet` nor `presignPut`
36
+ ([spec 4.9](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#49-capabilities)).
37
+ - `userMetadata` is not declared: `put` with a non-empty `userMetadata` is `Unsupported`, and reads
38
+ return `{}`
39
+ ([spec 4.9](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#49-capabilities)).
40
+ - `userMetadataTokenKeys` is not declared: without `userMetadata`, a key beyond identifiers is
41
+ `Unsupported` naming `userMetadata` like any other
42
+ ([spec 4.9](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#49-capabilities)).
43
+ - A key segment longer than 255 bytes is `InvalidKey`, and so is a key whose whole path is longer
44
+ than the file system holds. macOS bounds one path at 1024 bytes with the root counted in
45
+ ([spec 6](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#6-stowageadapter-fs)).
46
+ - A name the file system refuses to create is `InvalidKey` on `put` and on the destination of
47
+ `copy` and `move`. APFS refuses every noncharacter, so a key holding `U+FFFE` is written on
48
+ Linux and refused on macOS
49
+ ([spec 6](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#6-stowageadapter-fs)).
50
+ - APFS keeps a name in the Unicode form it was written in, and folds the forms when it looks a name
51
+ up, so a key in NFD reaches the object its NFC form wrote. A case-insensitive file system collides
52
+ keys that differ in case alone. Nothing repairs either
53
+ ([spec 6](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#6-stowageadapter-fs)).
54
+ - The content type is derived from the key's extension, and is `application/octet-stream` where the
55
+ extension is unknown or absent. The `contentType` handed to `put` is not stored, so `stat` may
56
+ report another one
57
+ ([spec 6](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#6-stowageadapter-fs)).
58
+ - No `etag` is set
59
+ ([spec 4.4](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#44-object-descriptions)).
60
+
61
+ ## Notes
62
+
63
+ `put` takes no `Blob`. A caller holding one passes its stream
64
+ ([spec 4.2](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#42-bodies)):
65
+
66
+ ```ts
67
+ import { fsStorage } from "@stowage/adapter-fs";
68
+
69
+ const storage = fsStorage({ root: "/var/lib/my-app/storage" });
70
+ const blob = new Blob(["region,revenue\n"], { type: "text/csv" });
71
+
72
+ await storage.put("reports/2026/q4.csv", blob.stream());
73
+ ```
74
+
75
+ stowage reports no progress
76
+ ([spec 12](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#12-non-goals)).
77
+ A caller who wants it counts the bytes on their way into `put`:
78
+
79
+ ```ts
80
+ import { fsStorage } from "@stowage/adapter-fs";
81
+
82
+ const storage = fsStorage({ root: "/var/lib/my-app/storage" });
83
+
84
+ function countBytes(report: (bytes: number) => void): TransformStream<Uint8Array, Uint8Array> {
85
+ let bytes = 0;
86
+
87
+ return new TransformStream({
88
+ transform(chunk, controller) {
89
+ bytes += chunk.byteLength;
90
+ report(bytes);
91
+ controller.enqueue(chunk);
92
+ },
93
+ });
94
+ }
95
+
96
+ const response = await fetch("https://example.com/video.mp4");
97
+
98
+ if (response.body === null) throw new Error("The response carries no body");
99
+
100
+ await storage.put("videos/intro.mp4", response.body.pipeThrough(countBytes(console.log)));
101
+ ```
102
+
103
+ ## Specification
104
+
105
+ [`docs/spec.md` at `@stowage/adapter-fs@0.2.0`](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/docs/spec.md#6-stowageadapter-fs)
106
+ is the contract: a caller may rely on what it states and on nothing else this package happens to
107
+ export. The [terms it uses](https://github.com/stowage-js/stowage/blob/@stowage/adapter-fs@0.2.0/CONTEXT.md)
108
+ and the [decisions behind it](https://github.com/stowage-js/stowage/tree/@stowage/adapter-fs@0.2.0/docs/adr)
109
+ are at the same tag.
110
+
111
+ ## License
112
+
113
+ MIT
@@ -0,0 +1,14 @@
1
+ import { Storage } from "@stowage/core";
2
+ //#region src/index.d.ts
3
+ export interface FsAdapterOptions {
4
+ /**
5
+ * An absolute path to an existing directory. Construction performs no I/O, so an operation
6
+ * against a root that does not exist rejects with `NotFound`.
7
+ */
8
+ root: string;
9
+ }
10
+ export interface FsStorage extends Storage {
11
+ readonly provider: "fs";
12
+ }
13
+ export declare function fsStorage(options: FsAdapterOptions): FsStorage;
14
+ //#endregion