@chrtco/sdk 0.4.1 → 0.6.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.
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Pluggable filesystem surface used by the offline endpoints.
3
+ *
4
+ * The core SDK is zero-dependency and can't import `node:*`. Callers bring
5
+ * their own adapter — `@chrtco/sdk/node` ships the Node 18+ implementation;
6
+ * future adapters (Bun/Deno-native, React Native, browser-OPFS) slot in the
7
+ * same shape without touching the endpoint code.
8
+ *
9
+ * Paths are plain strings. All methods are async. Streaming SHA-256 lives on
10
+ * the adapter so each runtime can use its native streaming digest primitive
11
+ * (Node: `crypto.createHash`; browser-OPFS: chunked `SubtleCrypto` etc.).
12
+ */
13
+ interface FileSystemAdapter {
14
+ exists(path: string): Promise<boolean>;
15
+ stat(path: string): Promise<{
16
+ size: number;
17
+ }>;
18
+ /** Returns a WritableStream for the given path. `append: true` opens in append mode; otherwise the file is truncated. */
19
+ writeStream(path: string, opts?: {
20
+ append?: boolean;
21
+ }): Promise<WritableStream<Uint8Array>>;
22
+ rename(from: string, to: string): Promise<void>;
23
+ unlink(path: string): Promise<void>;
24
+ mkdir(path: string, opts?: {
25
+ recursive?: boolean;
26
+ }): Promise<void>;
27
+ readFile(path: string): Promise<Uint8Array>;
28
+ writeFile(path: string, data: Uint8Array): Promise<void>;
29
+ /** Compute SHA-256 of the file at `path`. Lowercase hex. Must stream for large files. */
30
+ sha256(path: string): Promise<string>;
31
+ }
32
+
33
+ export type { FileSystemAdapter as F };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Pluggable filesystem surface used by the offline endpoints.
3
+ *
4
+ * The core SDK is zero-dependency and can't import `node:*`. Callers bring
5
+ * their own adapter — `@chrtco/sdk/node` ships the Node 18+ implementation;
6
+ * future adapters (Bun/Deno-native, React Native, browser-OPFS) slot in the
7
+ * same shape without touching the endpoint code.
8
+ *
9
+ * Paths are plain strings. All methods are async. Streaming SHA-256 lives on
10
+ * the adapter so each runtime can use its native streaming digest primitive
11
+ * (Node: `crypto.createHash`; browser-OPFS: chunked `SubtleCrypto` etc.).
12
+ */
13
+ interface FileSystemAdapter {
14
+ exists(path: string): Promise<boolean>;
15
+ stat(path: string): Promise<{
16
+ size: number;
17
+ }>;
18
+ /** Returns a WritableStream for the given path. `append: true` opens in append mode; otherwise the file is truncated. */
19
+ writeStream(path: string, opts?: {
20
+ append?: boolean;
21
+ }): Promise<WritableStream<Uint8Array>>;
22
+ rename(from: string, to: string): Promise<void>;
23
+ unlink(path: string): Promise<void>;
24
+ mkdir(path: string, opts?: {
25
+ recursive?: boolean;
26
+ }): Promise<void>;
27
+ readFile(path: string): Promise<Uint8Array>;
28
+ writeFile(path: string, data: Uint8Array): Promise<void>;
29
+ /** Compute SHA-256 of the file at `path`. Lowercase hex. Must stream for large files. */
30
+ sha256(path: string): Promise<string>;
31
+ }
32
+
33
+ export type { FileSystemAdapter as F };