katanakit-js 5.1.0 → 5.1.1
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/README.md +139 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/services/faker.service.d.ts +160 -0
- package/dist/core/services/faker.service.d.ts.map +1 -0
- package/dist/core/services/faker.service.js +235 -0
- package/dist/core/services/faker.service.js.map +1 -0
- package/dist/infrastructure/filesystem/filesystem.service.d.ts +238 -0
- package/dist/infrastructure/filesystem/filesystem.service.d.ts.map +1 -0
- package/dist/infrastructure/filesystem/filesystem.service.js +403 -0
- package/dist/infrastructure/filesystem/filesystem.service.js.map +1 -0
- package/dist/infrastructure/filesystem/path.service.d.ts +115 -0
- package/dist/infrastructure/filesystem/path.service.d.ts.map +1 -0
- package/dist/infrastructure/filesystem/path.service.js +154 -0
- package/dist/infrastructure/filesystem/path.service.js.map +1 -0
- package/dist/infrastructure/index.d.ts +2 -0
- package/dist/infrastructure/index.d.ts.map +1 -1
- package/dist/infrastructure/index.js +2 -0
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/schemas/faker.schema.d.ts +12 -0
- package/dist/schemas/faker.schema.d.ts.map +1 -0
- package/dist/schemas/faker.schema.js +12 -0
- package/dist/schemas/faker.schema.js.map +1 -0
- package/dist/schemas/filesystem.schema.d.ts +64 -0
- package/dist/schemas/filesystem.schema.d.ts.map +1 -0
- package/dist/schemas/filesystem.schema.js +54 -0
- package/dist/schemas/filesystem.schema.js.map +1 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/types/index.d.ts +26 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { ZodType } from "zod";
|
|
2
|
+
import type { FileEncoding, FileStats, FilesystemResult, ReadDirEntry, ReadDirOptions, WriteFileOptions } from "../../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Reads a text file.
|
|
5
|
+
*
|
|
6
|
+
* @param path - File path (relative paths resolve against `process.cwd()`).
|
|
7
|
+
* @param encoding - Text encoding (default: `"utf8"`).
|
|
8
|
+
* @returns Safe Result with the file contents as a string.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { useReadFile } from "katanakit-js";
|
|
13
|
+
*
|
|
14
|
+
* const result = await useReadFile("data/books.json");
|
|
15
|
+
* if (result.ok) console.log(result.data);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function useReadFile(path: string, encoding?: FileEncoding): Promise<FilesystemResult<string>>;
|
|
19
|
+
/**
|
|
20
|
+
* Reads a file as raw bytes (no encoding).
|
|
21
|
+
*
|
|
22
|
+
* @param path - File path.
|
|
23
|
+
* @returns Safe Result with the contents as a `Uint8Array`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const result = await useReadFileBuffer("assets/logo.png");
|
|
28
|
+
* if (result.ok) upload(result.data);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function useReadFileBuffer(path: string): Promise<FilesystemResult<Uint8Array>>;
|
|
32
|
+
/**
|
|
33
|
+
* Writes (or overwrites) a file, creating it when missing.
|
|
34
|
+
*
|
|
35
|
+
* @param path - Destination file path.
|
|
36
|
+
* @param data - Text or bytes to write.
|
|
37
|
+
* @param options - Encoding, mode and flag overrides.
|
|
38
|
+
* @returns Safe Result with the written path.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const result = await useWriteFile("logs/app.log", "started\n");
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function useWriteFile(path: string, data: string | Uint8Array, options?: WriteFileOptions): Promise<FilesystemResult<string>>;
|
|
46
|
+
/**
|
|
47
|
+
* Appends text or bytes to a file, creating it when missing.
|
|
48
|
+
*
|
|
49
|
+
* @param path - Destination file path.
|
|
50
|
+
* @param data - Text or bytes to append.
|
|
51
|
+
* @param options - Encoding, mode and flag overrides.
|
|
52
|
+
* @returns Safe Result with the written path.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* await useAppendFile("logs/app.log", "request handled\n");
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function useAppendFile(path: string, data: string | Uint8Array, options?: WriteFileOptions): Promise<FilesystemResult<string>>;
|
|
60
|
+
/**
|
|
61
|
+
* Reads and parses a JSON file, optionally validating it with a Zod schema.
|
|
62
|
+
*
|
|
63
|
+
* @typeParam T - Expected parsed (and validated) shape.
|
|
64
|
+
* @param path - File path.
|
|
65
|
+
* @param schema - Optional Zod schema; invalid shapes fail with `ERR_VALIDATION`.
|
|
66
|
+
* @returns Safe Result with the parsed data, or `ERR_INVALID_JSON` / `ERR_VALIDATION`.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { z } from "zod";
|
|
71
|
+
*
|
|
72
|
+
* const BookSchema = z.object({ title: z.string() });
|
|
73
|
+
* const result = await useReadJsonFile("data/books.json", BookSchema);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function useReadJsonFile<T = unknown>(path: string, schema?: ZodType<T>): Promise<FilesystemResult<T>>;
|
|
77
|
+
/**
|
|
78
|
+
* Serializes data to JSON and writes it to a file (pretty-printed by default).
|
|
79
|
+
*
|
|
80
|
+
* @param path - Destination file path.
|
|
81
|
+
* @param data - Value to serialize (`JSON.stringify` rules apply).
|
|
82
|
+
* @param options - Set `pretty: false` for compact output.
|
|
83
|
+
* @returns Safe Result with the written path.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* await useWriteJsonFile("data/books.json", books);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function useWriteJsonFile(path: string, data: unknown, options?: {
|
|
91
|
+
pretty?: boolean;
|
|
92
|
+
}): Promise<FilesystemResult<string>>;
|
|
93
|
+
/**
|
|
94
|
+
* Lists a directory with type flags resolved per entry.
|
|
95
|
+
*
|
|
96
|
+
* @param path - Directory path.
|
|
97
|
+
* @param options - `recursive: true` walks nested directories.
|
|
98
|
+
* @returns Safe Result with `{ name, path, isFile, isDirectory }` entries.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const result = await useReadDir("content", { recursive: true });
|
|
103
|
+
* if (result.ok) result.data.filter((entry) => entry.isFile);
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function useReadDir(path: string, options?: ReadDirOptions): Promise<FilesystemResult<ReadDirEntry[]>>;
|
|
107
|
+
/**
|
|
108
|
+
* Creates a directory (and any missing parents).
|
|
109
|
+
*
|
|
110
|
+
* @param path - Directory path to ensure.
|
|
111
|
+
* @returns Safe Result with the directory path.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* await useEnsureDir("data/cache/books");
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function useEnsureDir(path: string): Promise<FilesystemResult<string>>;
|
|
119
|
+
/**
|
|
120
|
+
* Checks whether a path exists and is accessible.
|
|
121
|
+
* Never throws: returns `false` for missing paths and non-Node runtimes.
|
|
122
|
+
*
|
|
123
|
+
* @param path - Path to check.
|
|
124
|
+
* @returns `true` when the path exists.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* if (await useFileExists("data/books.json")) {
|
|
129
|
+
* // read it
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function useFileExists(path: string): Promise<boolean>;
|
|
134
|
+
/**
|
|
135
|
+
* Returns a portable stats subset for a file or directory.
|
|
136
|
+
*
|
|
137
|
+
* @param path - Path to inspect (follows symlinks).
|
|
138
|
+
* @returns Safe Result with size, type flags and epoch-ms timestamps.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const result = await useGetFileStats("assets/logo.png");
|
|
143
|
+
* if (result.ok) console.log(result.data.size);
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function useGetFileStats(path: string): Promise<FilesystemResult<FileStats>>;
|
|
147
|
+
/**
|
|
148
|
+
* Copies a file. Existing destinations are overwritten unless
|
|
149
|
+
* `overwrite: false` is passed (`COPYFILE_EXCL`).
|
|
150
|
+
*
|
|
151
|
+
* @param source - Source file path.
|
|
152
|
+
* @param destination - Destination file path.
|
|
153
|
+
* @param options - Set `overwrite: false` to fail when the target exists.
|
|
154
|
+
* @returns Safe Result with the destination path.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* await useCopyFile("data/books.json", "backup/books.json");
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export declare function useCopyFile(source: string, destination: string, options?: {
|
|
162
|
+
overwrite?: boolean;
|
|
163
|
+
}): Promise<FilesystemResult<string>>;
|
|
164
|
+
/**
|
|
165
|
+
* Moves (renames) a file or directory.
|
|
166
|
+
*
|
|
167
|
+
* @param source - Source path.
|
|
168
|
+
* @param destination - Destination path.
|
|
169
|
+
* @returns Safe Result with the destination path.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* await useMoveFile("data/draft.json", "data/books.json");
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export declare function useMoveFile(source: string, destination: string): Promise<FilesystemResult<string>>;
|
|
177
|
+
/**
|
|
178
|
+
* Removes a file.
|
|
179
|
+
*
|
|
180
|
+
* @param path - File path to remove.
|
|
181
|
+
* @returns Safe Result with the removed path.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* await useRemoveFile("data/cache/books.json");
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export declare function useRemoveFile(path: string): Promise<FilesystemResult<string>>;
|
|
189
|
+
/**
|
|
190
|
+
* Removes a directory tree. Recursive by default; `force: false`
|
|
191
|
+
* surfaces `ENOENT` instead of ignoring missing paths.
|
|
192
|
+
*
|
|
193
|
+
* @param path - Directory path to remove.
|
|
194
|
+
* @param options - `recursive` (default `true`) and `force` (default `false`).
|
|
195
|
+
* @returns Safe Result with the removed path.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* await useRemoveDir("data/cache");
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export declare function useRemoveDir(path: string, options?: {
|
|
203
|
+
force?: boolean;
|
|
204
|
+
recursive?: boolean;
|
|
205
|
+
}): Promise<FilesystemResult<string>>;
|
|
206
|
+
/**
|
|
207
|
+
* Reads a file resolved from the caller's module directory — the
|
|
208
|
+
* `__dirname` + relative path pattern, without `__dirname`.
|
|
209
|
+
*
|
|
210
|
+
* @param importMetaUrl - Your module's `import.meta.url`.
|
|
211
|
+
* @param relativePath - Path relative to that module (e.g. `"../data/books.json"`).
|
|
212
|
+
* @param encoding - Text encoding (default: `"utf8"`).
|
|
213
|
+
* @returns Safe Result with the file contents as a string.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* const css = await useReadModuleFile(import.meta.url, "./theme.css");
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export declare function useReadModuleFile(importMetaUrl: string, relativePath: string, encoding?: FileEncoding): Promise<FilesystemResult<string>>;
|
|
221
|
+
/**
|
|
222
|
+
* Reads and parses a JSON file resolved from the caller's module directory,
|
|
223
|
+
* optionally validating it with a Zod schema.
|
|
224
|
+
*
|
|
225
|
+
* @typeParam T - Expected parsed (and validated) shape.
|
|
226
|
+
* @param importMetaUrl - Your module's `import.meta.url`.
|
|
227
|
+
* @param relativePath - Path relative to that module.
|
|
228
|
+
* @param schema - Optional Zod schema for runtime validation.
|
|
229
|
+
* @returns Safe Result with the parsed data.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* const result = await useReadModuleJson<Book[]>(import.meta.url, "../data/books.json");
|
|
234
|
+
* if (result.ok) initBooks(result.data);
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export declare function useReadModuleJson<T = unknown>(importMetaUrl: string, relativePath: string, schema?: ZodType<T>): Promise<FilesystemResult<T>>;
|
|
238
|
+
//# sourceMappingURL=filesystem.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.service.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/filesystem/filesystem.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,KAAK,EACX,YAAY,EACZ,SAAS,EAET,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,MAAM,sBAAsB,CAAC;AA6G9B;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,YAAqB,GAC7B,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAEnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAE3F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,OAAO,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,g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M,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/B,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAMnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAChC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAKnC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAKnF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAChD,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAQnC;AAQD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACtC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,QAAQ,GAAE,YAAqB,GAC7B,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAKnC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAClD,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACjB,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAK9B"}
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { useGetDirname, useIsNode, useJoinPath, useResolvePath } from "./path.service.js";
|
|
2
|
+
/** Internal error carrying `code`/`details` through `runFs`. */
|
|
3
|
+
class FilesystemOperationError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
details;
|
|
6
|
+
path;
|
|
7
|
+
constructor(code, message, path, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "FilesystemOperationError";
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.path = path;
|
|
12
|
+
this.details = details;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Normalizes any thrown value into a serializable {@link FilesystemError}. */
|
|
16
|
+
function toFilesystemError(error, fallbackPath) {
|
|
17
|
+
if (error instanceof FilesystemOperationError) {
|
|
18
|
+
return {
|
|
19
|
+
code: error.code,
|
|
20
|
+
message: error.message,
|
|
21
|
+
path: error.path ?? fallbackPath,
|
|
22
|
+
details: error.details,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const errno = error;
|
|
26
|
+
return {
|
|
27
|
+
code: typeof errno?.code === "string" ? errno.code : "ERR_FILESYSTEM",
|
|
28
|
+
message: error instanceof Error ? error.message : "Unknown filesystem error",
|
|
29
|
+
path: typeof errno?.path === "string" ? errno.path : fallbackPath,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Safe Result used when `node:fs` is not available (browser/edge). */
|
|
33
|
+
function createUnavailableError() {
|
|
34
|
+
return {
|
|
35
|
+
code: "ERR_FS_UNAVAILABLE",
|
|
36
|
+
message: "[Filesystem] A Node.js-compatible runtime is required for filesystem operations.",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Internal runner: guards the runtime, loads `node:fs/promises` lazily and
|
|
41
|
+
* wraps the operation into a Safe Result (`{ data, error, ok }`).
|
|
42
|
+
*/
|
|
43
|
+
async function runFs(targetPath, operation) {
|
|
44
|
+
if (!useIsNode()) {
|
|
45
|
+
return { data: null, error: createUnavailableError(), ok: false };
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const fs = await import("node:fs/promises");
|
|
49
|
+
return { data: await operation(fs), error: null, ok: true };
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return { data: null, error: toFilesystemError(error, targetPath), ok: false };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Parses JSON text, optionally validating it against a Zod schema. */
|
|
56
|
+
function parseJson(raw, path, schema) {
|
|
57
|
+
let parsed;
|
|
58
|
+
try {
|
|
59
|
+
parsed = JSON.parse(raw);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw new FilesystemOperationError("ERR_INVALID_JSON", `[Filesystem] Invalid JSON in "${path}": ${error instanceof Error ? error.message : "parse error"}`, path);
|
|
63
|
+
}
|
|
64
|
+
if (!schema)
|
|
65
|
+
return parsed;
|
|
66
|
+
const result = schema.safeParse(parsed);
|
|
67
|
+
if (!result.success) {
|
|
68
|
+
throw new FilesystemOperationError("ERR_VALIDATION", `[Filesystem] JSON in "${path}" does not match the expected schema.`, path, result.error.issues);
|
|
69
|
+
}
|
|
70
|
+
return result.data;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Reads a text file.
|
|
74
|
+
*
|
|
75
|
+
* @param path - File path (relative paths resolve against `process.cwd()`).
|
|
76
|
+
* @param encoding - Text encoding (default: `"utf8"`).
|
|
77
|
+
* @returns Safe Result with the file contents as a string.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { useReadFile } from "katanakit-js";
|
|
82
|
+
*
|
|
83
|
+
* const result = await useReadFile("data/books.json");
|
|
84
|
+
* if (result.ok) console.log(result.data);
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export async function useReadFile(path, encoding = "utf8") {
|
|
88
|
+
return runFs(path, (fs) => fs.readFile(path, encoding));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Reads a file as raw bytes (no encoding).
|
|
92
|
+
*
|
|
93
|
+
* @param path - File path.
|
|
94
|
+
* @returns Safe Result with the contents as a `Uint8Array`.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const result = await useReadFileBuffer("assets/logo.png");
|
|
99
|
+
* if (result.ok) upload(result.data);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export async function useReadFileBuffer(path) {
|
|
103
|
+
return runFs(path, (fs) => fs.readFile(path));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Writes (or overwrites) a file, creating it when missing.
|
|
107
|
+
*
|
|
108
|
+
* @param path - Destination file path.
|
|
109
|
+
* @param data - Text or bytes to write.
|
|
110
|
+
* @param options - Encoding, mode and flag overrides.
|
|
111
|
+
* @returns Safe Result with the written path.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const result = await useWriteFile("logs/app.log", "started\n");
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export async function useWriteFile(path, data, options) {
|
|
119
|
+
return runFs(path, async (fs) => {
|
|
120
|
+
await fs.writeFile(path, data, options);
|
|
121
|
+
return path;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Appends text or bytes to a file, creating it when missing.
|
|
126
|
+
*
|
|
127
|
+
* @param path - Destination file path.
|
|
128
|
+
* @param data - Text or bytes to append.
|
|
129
|
+
* @param options - Encoding, mode and flag overrides.
|
|
130
|
+
* @returns Safe Result with the written path.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* await useAppendFile("logs/app.log", "request handled\n");
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export async function useAppendFile(path, data, options) {
|
|
138
|
+
return runFs(path, async (fs) => {
|
|
139
|
+
await fs.appendFile(path, data, options);
|
|
140
|
+
return path;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Reads and parses a JSON file, optionally validating it with a Zod schema.
|
|
145
|
+
*
|
|
146
|
+
* @typeParam T - Expected parsed (and validated) shape.
|
|
147
|
+
* @param path - File path.
|
|
148
|
+
* @param schema - Optional Zod schema; invalid shapes fail with `ERR_VALIDATION`.
|
|
149
|
+
* @returns Safe Result with the parsed data, or `ERR_INVALID_JSON` / `ERR_VALIDATION`.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import { z } from "zod";
|
|
154
|
+
*
|
|
155
|
+
* const BookSchema = z.object({ title: z.string() });
|
|
156
|
+
* const result = await useReadJsonFile("data/books.json", BookSchema);
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export async function useReadJsonFile(path, schema) {
|
|
160
|
+
return runFs(path, async (fs) => parseJson(await fs.readFile(path, "utf8"), path, schema));
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Serializes data to JSON and writes it to a file (pretty-printed by default).
|
|
164
|
+
*
|
|
165
|
+
* @param path - Destination file path.
|
|
166
|
+
* @param data - Value to serialize (`JSON.stringify` rules apply).
|
|
167
|
+
* @param options - Set `pretty: false` for compact output.
|
|
168
|
+
* @returns Safe Result with the written path.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* await useWriteJsonFile("data/books.json", books);
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export async function useWriteJsonFile(path, data, options) {
|
|
176
|
+
return runFs(path, async (fs) => {
|
|
177
|
+
const spaces = options?.pretty === false ? undefined : 2;
|
|
178
|
+
await fs.writeFile(path, `${JSON.stringify(data, null, spaces)}\n`, "utf8");
|
|
179
|
+
return path;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Lists a directory with type flags resolved per entry.
|
|
184
|
+
*
|
|
185
|
+
* @param path - Directory path.
|
|
186
|
+
* @param options - `recursive: true` walks nested directories.
|
|
187
|
+
* @returns Safe Result with `{ name, path, isFile, isDirectory }` entries.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* const result = await useReadDir("content", { recursive: true });
|
|
192
|
+
* if (result.ok) result.data.filter((entry) => entry.isFile);
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
export async function useReadDir(path, options) {
|
|
196
|
+
return runFs(path, async (fs) => {
|
|
197
|
+
const entries = await fs.readdir(path, {
|
|
198
|
+
recursive: options?.recursive ?? false,
|
|
199
|
+
withFileTypes: true,
|
|
200
|
+
});
|
|
201
|
+
return Promise.all(entries.map(async (entry) => ({
|
|
202
|
+
name: entry.name,
|
|
203
|
+
path: await useJoinPath(entry.parentPath ?? path, entry.name),
|
|
204
|
+
isFile: entry.isFile(),
|
|
205
|
+
isDirectory: entry.isDirectory(),
|
|
206
|
+
})));
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Creates a directory (and any missing parents).
|
|
211
|
+
*
|
|
212
|
+
* @param path - Directory path to ensure.
|
|
213
|
+
* @returns Safe Result with the directory path.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* await useEnsureDir("data/cache/books");
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export async function useEnsureDir(path) {
|
|
221
|
+
return runFs(path, async (fs) => {
|
|
222
|
+
await fs.mkdir(path, { recursive: true });
|
|
223
|
+
return path;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Checks whether a path exists and is accessible.
|
|
228
|
+
* Never throws: returns `false` for missing paths and non-Node runtimes.
|
|
229
|
+
*
|
|
230
|
+
* @param path - Path to check.
|
|
231
|
+
* @returns `true` when the path exists.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* if (await useFileExists("data/books.json")) {
|
|
236
|
+
* // read it
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
export async function useFileExists(path) {
|
|
241
|
+
if (!useIsNode())
|
|
242
|
+
return false;
|
|
243
|
+
try {
|
|
244
|
+
const fs = await import("node:fs/promises");
|
|
245
|
+
await fs.access(path);
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Returns a portable stats subset for a file or directory.
|
|
254
|
+
*
|
|
255
|
+
* @param path - Path to inspect (follows symlinks).
|
|
256
|
+
* @returns Safe Result with size, type flags and epoch-ms timestamps.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* const result = await useGetFileStats("assets/logo.png");
|
|
261
|
+
* if (result.ok) console.log(result.data.size);
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
export async function useGetFileStats(path) {
|
|
265
|
+
return runFs(path, async (fs) => {
|
|
266
|
+
const stats = await fs.stat(path);
|
|
267
|
+
return {
|
|
268
|
+
size: stats.size,
|
|
269
|
+
isFile: stats.isFile(),
|
|
270
|
+
isDirectory: stats.isDirectory(),
|
|
271
|
+
isSymbolicLink: stats.isSymbolicLink(),
|
|
272
|
+
createdAt: stats.birthtimeMs,
|
|
273
|
+
modifiedAt: stats.mtimeMs,
|
|
274
|
+
accessedAt: stats.atimeMs,
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Copies a file. Existing destinations are overwritten unless
|
|
280
|
+
* `overwrite: false` is passed (`COPYFILE_EXCL`).
|
|
281
|
+
*
|
|
282
|
+
* @param source - Source file path.
|
|
283
|
+
* @param destination - Destination file path.
|
|
284
|
+
* @param options - Set `overwrite: false` to fail when the target exists.
|
|
285
|
+
* @returns Safe Result with the destination path.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* await useCopyFile("data/books.json", "backup/books.json");
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
export async function useCopyFile(source, destination, options) {
|
|
293
|
+
return runFs(source, async (fs) => {
|
|
294
|
+
const mode = options?.overwrite === false ? fs.constants.COPYFILE_EXCL : 0;
|
|
295
|
+
await fs.copyFile(source, destination, mode);
|
|
296
|
+
return destination;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Moves (renames) a file or directory.
|
|
301
|
+
*
|
|
302
|
+
* @param source - Source path.
|
|
303
|
+
* @param destination - Destination path.
|
|
304
|
+
* @returns Safe Result with the destination path.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```ts
|
|
308
|
+
* await useMoveFile("data/draft.json", "data/books.json");
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
export async function useMoveFile(source, destination) {
|
|
312
|
+
return runFs(source, async (fs) => {
|
|
313
|
+
await fs.rename(source, destination);
|
|
314
|
+
return destination;
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Removes a file.
|
|
319
|
+
*
|
|
320
|
+
* @param path - File path to remove.
|
|
321
|
+
* @returns Safe Result with the removed path.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```ts
|
|
325
|
+
* await useRemoveFile("data/cache/books.json");
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
export async function useRemoveFile(path) {
|
|
329
|
+
return runFs(path, async (fs) => {
|
|
330
|
+
await fs.unlink(path);
|
|
331
|
+
return path;
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Removes a directory tree. Recursive by default; `force: false`
|
|
336
|
+
* surfaces `ENOENT` instead of ignoring missing paths.
|
|
337
|
+
*
|
|
338
|
+
* @param path - Directory path to remove.
|
|
339
|
+
* @param options - `recursive` (default `true`) and `force` (default `false`).
|
|
340
|
+
* @returns Safe Result with the removed path.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* await useRemoveDir("data/cache");
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
export async function useRemoveDir(path, options) {
|
|
348
|
+
return runFs(path, async (fs) => {
|
|
349
|
+
await fs.rm(path, {
|
|
350
|
+
force: options?.force ?? false,
|
|
351
|
+
recursive: options?.recursive ?? true,
|
|
352
|
+
});
|
|
353
|
+
return path;
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
/** Resolves `relativePath` against the directory of `importMetaUrl`. */
|
|
357
|
+
async function resolveModulePath(importMetaUrl, relativePath) {
|
|
358
|
+
const base = await useGetDirname(importMetaUrl);
|
|
359
|
+
return useResolvePath(base, relativePath);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Reads a file resolved from the caller's module directory — the
|
|
363
|
+
* `__dirname` + relative path pattern, without `__dirname`.
|
|
364
|
+
*
|
|
365
|
+
* @param importMetaUrl - Your module's `import.meta.url`.
|
|
366
|
+
* @param relativePath - Path relative to that module (e.g. `"../data/books.json"`).
|
|
367
|
+
* @param encoding - Text encoding (default: `"utf8"`).
|
|
368
|
+
* @returns Safe Result with the file contents as a string.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts
|
|
372
|
+
* const css = await useReadModuleFile(import.meta.url, "./theme.css");
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
export async function useReadModuleFile(importMetaUrl, relativePath, encoding = "utf8") {
|
|
376
|
+
return runFs(relativePath, async (fs) => {
|
|
377
|
+
const absolute = await resolveModulePath(importMetaUrl, relativePath);
|
|
378
|
+
return fs.readFile(absolute, encoding);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Reads and parses a JSON file resolved from the caller's module directory,
|
|
383
|
+
* optionally validating it with a Zod schema.
|
|
384
|
+
*
|
|
385
|
+
* @typeParam T - Expected parsed (and validated) shape.
|
|
386
|
+
* @param importMetaUrl - Your module's `import.meta.url`.
|
|
387
|
+
* @param relativePath - Path relative to that module.
|
|
388
|
+
* @param schema - Optional Zod schema for runtime validation.
|
|
389
|
+
* @returns Safe Result with the parsed data.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```ts
|
|
393
|
+
* const result = await useReadModuleJson<Book[]>(import.meta.url, "../data/books.json");
|
|
394
|
+
* if (result.ok) initBooks(result.data);
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
export async function useReadModuleJson(importMetaUrl, relativePath, schema) {
|
|
398
|
+
return runFs(relativePath, async (fs) => {
|
|
399
|
+
const absolute = await resolveModulePath(importMetaUrl, relativePath);
|
|
400
|
+
return parseJson(await fs.readFile(absolute, "utf8"), absolute, schema);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
//# sourceMappingURL=filesystem.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.service.js","sourceRoot":"","sources":["../../../src/infrastructure/filesystem/filesystem.service.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAW1F,gEAAgE;AAChE,MAAM,wBAAyB,SAAQ,KAAK;IAClC,IAAI,CAAS;IACb,OAAO,CAAW;IAClB,IAAI,CAAU;IAEvB,YAAY,IAAY,EAAE,OAAe,EAAE,IAAa,EAAE,OAAiB;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD;AAQD,+EAA+E;AAC/E,SAAS,iBAAiB,CAAC,KAAc,EAAE,YAAqB;IAC/D,IAAI,KAAK,YAAY,wBAAwB,EAAE,CAAC;QAC/C,OAAO;YACN,IAAI,EAAE,KAAK,CAAC,IA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