alepha 0.12.1 → 0.13.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.
Files changed (198) hide show
  1. package/dist/api-notifications/index.d.ts +111 -111
  2. package/dist/api-users/index.d.ts +1240 -1240
  3. package/dist/api-verifications/index.d.ts +94 -94
  4. package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
  5. package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
  6. package/dist/cli/index.d.ts +3 -11
  7. package/dist/cli/index.js +106 -74
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/email/index.js +71 -73
  10. package/dist/email/index.js.map +1 -1
  11. package/dist/orm/index.d.ts +1 -1
  12. package/dist/orm/index.js.map +1 -1
  13. package/dist/queue/index.d.ts +4 -4
  14. package/dist/redis/index.d.ts +10 -10
  15. package/dist/retry/index.d.ts +1 -1
  16. package/dist/retry/index.js +2 -2
  17. package/dist/retry/index.js.map +1 -1
  18. package/dist/scheduler/index.d.ts +6 -6
  19. package/dist/server/index.js +1 -1
  20. package/dist/server/index.js.map +1 -1
  21. package/dist/server-auth/index.d.ts +193 -193
  22. package/dist/server-health/index.d.ts +17 -17
  23. package/dist/server-links/index.d.ts +34 -34
  24. package/dist/server-metrics/index.js +170 -174
  25. package/dist/server-metrics/index.js.map +1 -1
  26. package/dist/server-security/index.d.ts +9 -9
  27. package/dist/vite/index.js +4 -5
  28. package/dist/vite/index.js.map +1 -1
  29. package/dist/websocket/index.d.ts +7 -7
  30. package/package.json +52 -103
  31. package/src/cli/apps/AlephaPackageBuilderCli.ts +7 -2
  32. package/src/cli/assets/appRouterTs.ts +9 -0
  33. package/src/cli/assets/indexHtml.ts +2 -1
  34. package/src/cli/assets/mainBrowserTs.ts +10 -0
  35. package/src/cli/commands/CoreCommands.ts +6 -5
  36. package/src/cli/commands/DrizzleCommands.ts +65 -57
  37. package/src/cli/commands/VerifyCommands.ts +1 -1
  38. package/src/cli/services/ProjectUtils.ts +44 -38
  39. package/src/orm/providers/DrizzleKitProvider.ts +1 -1
  40. package/src/retry/descriptors/$retry.ts +5 -3
  41. package/src/server/providers/NodeHttpServerProvider.ts +1 -1
  42. package/src/vite/helpers/boot.ts +3 -3
  43. package/dist/api-files/index.cjs +0 -1293
  44. package/dist/api-files/index.cjs.map +0 -1
  45. package/dist/api-files/index.d.cts +0 -829
  46. package/dist/api-jobs/index.cjs +0 -274
  47. package/dist/api-jobs/index.cjs.map +0 -1
  48. package/dist/api-jobs/index.d.cts +0 -654
  49. package/dist/api-notifications/index.cjs +0 -380
  50. package/dist/api-notifications/index.cjs.map +0 -1
  51. package/dist/api-notifications/index.d.cts +0 -289
  52. package/dist/api-parameters/index.cjs +0 -66
  53. package/dist/api-parameters/index.cjs.map +0 -1
  54. package/dist/api-parameters/index.d.cts +0 -84
  55. package/dist/api-users/index.cjs +0 -6009
  56. package/dist/api-users/index.cjs.map +0 -1
  57. package/dist/api-users/index.d.cts +0 -4740
  58. package/dist/api-verifications/index.cjs +0 -407
  59. package/dist/api-verifications/index.cjs.map +0 -1
  60. package/dist/api-verifications/index.d.cts +0 -207
  61. package/dist/batch/index.cjs +0 -408
  62. package/dist/batch/index.cjs.map +0 -1
  63. package/dist/batch/index.d.cts +0 -330
  64. package/dist/bin/index.cjs +0 -17
  65. package/dist/bin/index.cjs.map +0 -1
  66. package/dist/bin/index.d.cts +0 -1
  67. package/dist/bucket/index.cjs +0 -303
  68. package/dist/bucket/index.cjs.map +0 -1
  69. package/dist/bucket/index.d.cts +0 -355
  70. package/dist/cache/index.cjs +0 -241
  71. package/dist/cache/index.cjs.map +0 -1
  72. package/dist/cache/index.d.cts +0 -202
  73. package/dist/cache-redis/index.cjs +0 -84
  74. package/dist/cache-redis/index.cjs.map +0 -1
  75. package/dist/cache-redis/index.d.cts +0 -40
  76. package/dist/cli/chunk-DSlc6foC.cjs +0 -43
  77. package/dist/cli/dist-BBPjuQ56.js +0 -2778
  78. package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
  79. package/dist/cli/index.cjs +0 -1241
  80. package/dist/cli/index.cjs.map +0 -1
  81. package/dist/cli/index.d.cts +0 -422
  82. package/dist/command/index.cjs +0 -693
  83. package/dist/command/index.cjs.map +0 -1
  84. package/dist/command/index.d.cts +0 -340
  85. package/dist/core/index.cjs +0 -2264
  86. package/dist/core/index.cjs.map +0 -1
  87. package/dist/core/index.d.cts +0 -1927
  88. package/dist/datetime/index.cjs +0 -318
  89. package/dist/datetime/index.cjs.map +0 -1
  90. package/dist/datetime/index.d.cts +0 -145
  91. package/dist/email/index.cjs +0 -10874
  92. package/dist/email/index.cjs.map +0 -1
  93. package/dist/email/index.d.cts +0 -186
  94. package/dist/fake/index.cjs +0 -34641
  95. package/dist/fake/index.cjs.map +0 -1
  96. package/dist/fake/index.d.cts +0 -74
  97. package/dist/file/index.cjs +0 -1212
  98. package/dist/file/index.cjs.map +0 -1
  99. package/dist/file/index.d.cts +0 -698
  100. package/dist/lock/index.cjs +0 -226
  101. package/dist/lock/index.cjs.map +0 -1
  102. package/dist/lock/index.d.cts +0 -361
  103. package/dist/lock-redis/index.cjs +0 -113
  104. package/dist/lock-redis/index.cjs.map +0 -1
  105. package/dist/lock-redis/index.d.cts +0 -24
  106. package/dist/logger/index.cjs +0 -521
  107. package/dist/logger/index.cjs.map +0 -1
  108. package/dist/logger/index.d.cts +0 -281
  109. package/dist/orm/index.cjs +0 -2986
  110. package/dist/orm/index.cjs.map +0 -1
  111. package/dist/orm/index.d.cts +0 -2213
  112. package/dist/queue/index.cjs +0 -1044
  113. package/dist/queue/index.cjs.map +0 -1
  114. package/dist/queue/index.d.cts +0 -1265
  115. package/dist/queue-redis/index.cjs +0 -873
  116. package/dist/queue-redis/index.cjs.map +0 -1
  117. package/dist/queue-redis/index.d.cts +0 -82
  118. package/dist/redis/index.cjs +0 -153
  119. package/dist/redis/index.cjs.map +0 -1
  120. package/dist/redis/index.d.cts +0 -82
  121. package/dist/retry/index.cjs +0 -146
  122. package/dist/retry/index.cjs.map +0 -1
  123. package/dist/retry/index.d.cts +0 -172
  124. package/dist/router/index.cjs +0 -111
  125. package/dist/router/index.cjs.map +0 -1
  126. package/dist/router/index.d.cts +0 -46
  127. package/dist/scheduler/index.cjs +0 -576
  128. package/dist/scheduler/index.cjs.map +0 -1
  129. package/dist/scheduler/index.d.cts +0 -145
  130. package/dist/security/index.cjs +0 -2402
  131. package/dist/security/index.cjs.map +0 -1
  132. package/dist/security/index.d.cts +0 -598
  133. package/dist/server/index.cjs +0 -1680
  134. package/dist/server/index.cjs.map +0 -1
  135. package/dist/server/index.d.cts +0 -810
  136. package/dist/server-auth/index.cjs +0 -3146
  137. package/dist/server-auth/index.cjs.map +0 -1
  138. package/dist/server-auth/index.d.cts +0 -1164
  139. package/dist/server-cache/index.cjs +0 -252
  140. package/dist/server-cache/index.cjs.map +0 -1
  141. package/dist/server-cache/index.d.cts +0 -164
  142. package/dist/server-compress/index.cjs +0 -141
  143. package/dist/server-compress/index.cjs.map +0 -1
  144. package/dist/server-compress/index.d.cts +0 -38
  145. package/dist/server-cookies/index.cjs +0 -234
  146. package/dist/server-cookies/index.cjs.map +0 -1
  147. package/dist/server-cookies/index.d.cts +0 -144
  148. package/dist/server-cors/index.cjs +0 -201
  149. package/dist/server-cors/index.cjs.map +0 -1
  150. package/dist/server-cors/index.d.cts +0 -140
  151. package/dist/server-health/index.cjs +0 -62
  152. package/dist/server-health/index.cjs.map +0 -1
  153. package/dist/server-health/index.d.cts +0 -58
  154. package/dist/server-helmet/index.cjs +0 -131
  155. package/dist/server-helmet/index.cjs.map +0 -1
  156. package/dist/server-helmet/index.d.cts +0 -97
  157. package/dist/server-links/index.cjs +0 -992
  158. package/dist/server-links/index.cjs.map +0 -1
  159. package/dist/server-links/index.d.cts +0 -513
  160. package/dist/server-metrics/index.cjs +0 -4535
  161. package/dist/server-metrics/index.cjs.map +0 -1
  162. package/dist/server-metrics/index.d.cts +0 -35
  163. package/dist/server-multipart/index.cjs +0 -237
  164. package/dist/server-multipart/index.cjs.map +0 -1
  165. package/dist/server-multipart/index.d.cts +0 -50
  166. package/dist/server-proxy/index.cjs +0 -186
  167. package/dist/server-proxy/index.cjs.map +0 -1
  168. package/dist/server-proxy/index.d.cts +0 -234
  169. package/dist/server-rate-limit/index.cjs +0 -241
  170. package/dist/server-rate-limit/index.cjs.map +0 -1
  171. package/dist/server-rate-limit/index.d.cts +0 -183
  172. package/dist/server-security/index.cjs +0 -316
  173. package/dist/server-security/index.cjs.map +0 -1
  174. package/dist/server-security/index.d.cts +0 -173
  175. package/dist/server-static/index.cjs +0 -170
  176. package/dist/server-static/index.cjs.map +0 -1
  177. package/dist/server-static/index.d.cts +0 -121
  178. package/dist/server-swagger/index.cjs +0 -1021
  179. package/dist/server-swagger/index.cjs.map +0 -1
  180. package/dist/server-swagger/index.d.cts +0 -382
  181. package/dist/sms/index.cjs +0 -221
  182. package/dist/sms/index.cjs.map +0 -1
  183. package/dist/sms/index.d.cts +0 -130
  184. package/dist/thread/index.cjs +0 -350
  185. package/dist/thread/index.cjs.map +0 -1
  186. package/dist/thread/index.d.cts +0 -260
  187. package/dist/topic/index.cjs +0 -282
  188. package/dist/topic/index.cjs.map +0 -1
  189. package/dist/topic/index.d.cts +0 -523
  190. package/dist/topic-redis/index.cjs +0 -71
  191. package/dist/topic-redis/index.cjs.map +0 -1
  192. package/dist/topic-redis/index.d.cts +0 -42
  193. package/dist/vite/index.cjs +0 -1077
  194. package/dist/vite/index.cjs.map +0 -1
  195. package/dist/vite/index.d.cts +0 -542
  196. package/dist/websocket/index.cjs +0 -1117
  197. package/dist/websocket/index.cjs.map +0 -1
  198. package/dist/websocket/index.d.cts +0 -861
@@ -1,698 +0,0 @@
1
- import * as alepha0 from "alepha";
2
- import { FileLike, StreamLike } from "alepha";
3
- import { Readable } from "node:stream";
4
-
5
- //#region src/file/providers/FileSystemProvider.d.ts
6
- /**
7
- * Options for creating a file from a URL
8
- */
9
- interface CreateFileFromUrlOptions {
10
- /**
11
- * The URL to load the file from (file://, http://, or https://)
12
- */
13
- url: string;
14
- /**
15
- * The MIME type of the file (optional, will be detected from filename if not provided)
16
- */
17
- type?: string;
18
- /**
19
- * The name of the file (optional, will be extracted from URL if not provided)
20
- */
21
- name?: string;
22
- }
23
- /**
24
- * Options for creating a file from a path (URL with file:// scheme)
25
- */
26
- interface CreateFileFromPathOptions {
27
- /**
28
- * The path to the file on the local filesystem
29
- */
30
- path: string;
31
- /**
32
- * The MIME type of the file (optional, will be detected from filename if not provided)
33
- */
34
- type?: string;
35
- /**
36
- * The name of the file (optional, will be extracted from URL if not provided)
37
- */
38
- name?: string;
39
- }
40
- /**
41
- * Options for creating a file from a Buffer
42
- */
43
- interface CreateFileFromBufferOptions {
44
- /**
45
- * The Buffer containing the file data
46
- */
47
- buffer: Buffer;
48
- /**
49
- * The MIME type of the file (optional, will be detected from name if not provided)
50
- */
51
- type?: string;
52
- /**
53
- * The name of the file (required for proper content type detection)
54
- */
55
- name?: string;
56
- }
57
- /**
58
- * Options for creating a file from a stream
59
- */
60
- interface CreateFileFromStreamOptions {
61
- /**
62
- * The readable stream containing the file data
63
- */
64
- stream: StreamLike;
65
- /**
66
- * The MIME type of the file (optional, will be detected from name if not provided)
67
- */
68
- type?: string;
69
- /**
70
- * The name of the file (required for proper content type detection)
71
- */
72
- name?: string;
73
- /**
74
- * The size of the file in bytes (optional)
75
- */
76
- size?: number;
77
- }
78
- /**
79
- * Options for creating a file from text content
80
- */
81
- interface CreateFileFromTextOptions {
82
- /**
83
- * The text content to create the file from
84
- */
85
- text: string;
86
- /**
87
- * The MIME type of the file (default: text/plain)
88
- */
89
- type?: string;
90
- /**
91
- * The name of the file (default: "file.txt")
92
- */
93
- name?: string;
94
- }
95
- interface CreateFileFromResponseOptions {
96
- /**
97
- * The Response object containing the file data
98
- */
99
- response: Response;
100
- /**
101
- * Override the name (optional, uses filename from Content-Disposition header if not provided)
102
- */
103
- name?: string;
104
- /**
105
- * Override the MIME type (optional, uses file.type if not provided)
106
- */
107
- type?: string;
108
- }
109
- /**
110
- * Options for creating a file from a Web File object
111
- */
112
- interface CreateFileFromWebFileOptions {
113
- /**
114
- * The Web File object
115
- */
116
- file: File;
117
- /**
118
- * Override the MIME type (optional, uses file.type if not provided)
119
- */
120
- type?: string;
121
- /**
122
- * Override the name (optional, uses file.name if not provided)
123
- */
124
- name?: string;
125
- /**
126
- * Override the size (optional, uses file.size if not provided)
127
- */
128
- size?: number;
129
- }
130
- /**
131
- * Options for creating a file from an ArrayBuffer
132
- */
133
- interface CreateFileFromArrayBufferOptions {
134
- /**
135
- * The ArrayBuffer containing the file data
136
- */
137
- arrayBuffer: ArrayBuffer;
138
- /**
139
- * The MIME type of the file (optional, will be detected from name if not provided)
140
- */
141
- type?: string;
142
- /**
143
- * The name of the file (required for proper content type detection)
144
- */
145
- name?: string;
146
- }
147
- /**
148
- * Union type for all createFile options
149
- */
150
- type CreateFileOptions = CreateFileFromUrlOptions | CreateFileFromPathOptions | CreateFileFromBufferOptions | CreateFileFromStreamOptions | CreateFileFromTextOptions | CreateFileFromWebFileOptions | CreateFileFromResponseOptions | CreateFileFromArrayBufferOptions;
151
- /**
152
- * Options for rm (remove) operation
153
- */
154
- interface RmOptions {
155
- /**
156
- * If true, removes directories and their contents recursively
157
- */
158
- recursive?: boolean;
159
- /**
160
- * If true, no error will be thrown if the path does not exist
161
- */
162
- force?: boolean;
163
- }
164
- /**
165
- * Options for cp (copy) operation
166
- */
167
- interface CpOptions {
168
- /**
169
- * If true, copy directories recursively
170
- */
171
- recursive?: boolean;
172
- /**
173
- * If true, overwrite existing destination
174
- */
175
- force?: boolean;
176
- }
177
- /**
178
- * Options for mkdir operation
179
- */
180
- interface MkdirOptions {
181
- /**
182
- * If true, creates parent directories as needed
183
- */
184
- recursive?: boolean;
185
- /**
186
- * File mode (permission and sticky bits)
187
- */
188
- mode?: number;
189
- }
190
- /**
191
- * Options for ls (list) operation
192
- */
193
- interface LsOptions {
194
- /**
195
- * If true, list contents of directories recursively
196
- */
197
- recursive?: boolean;
198
- /**
199
- * If true, include hidden files (starting with .)
200
- */
201
- hidden?: boolean;
202
- }
203
- /**
204
- * FileSystem interface providing utilities for working with files.
205
- */
206
- declare abstract class FileSystemProvider {
207
- /**
208
- * Creates a FileLike object from various sources.
209
- *
210
- * @param options - Options for creating the file
211
- * @returns A FileLike object
212
- */
213
- abstract createFile(options: CreateFileOptions): FileLike;
214
- /**
215
- * Removes a file or directory.
216
- *
217
- * @param path - The path to remove
218
- * @param options - Remove options
219
- */
220
- abstract rm(path: string, options?: RmOptions): Promise<void>;
221
- /**
222
- * Copies a file or directory.
223
- *
224
- * @param src - Source path
225
- * @param dest - Destination path
226
- * @param options - Copy options
227
- */
228
- abstract cp(src: string, dest: string, options?: CpOptions): Promise<void>;
229
- /**
230
- * Moves/renames a file or directory.
231
- *
232
- * @param src - Source path
233
- * @param dest - Destination path
234
- */
235
- abstract mv(src: string, dest: string): Promise<void>;
236
- /**
237
- * Creates a directory.
238
- *
239
- * @param path - The directory path to create
240
- * @param options - Mkdir options
241
- */
242
- abstract mkdir(path: string, options?: MkdirOptions): Promise<void>;
243
- /**
244
- * Lists files in a directory.
245
- *
246
- * @param path - The directory path to list
247
- * @param options - List options
248
- * @returns Array of filenames
249
- */
250
- abstract ls(path: string, options?: LsOptions): Promise<string[]>;
251
- /**
252
- * Checks if a file or directory exists.
253
- *
254
- * @param path - The path to check
255
- * @returns True if the path exists, false otherwise
256
- */
257
- abstract exists(path: string): Promise<boolean>;
258
- /**
259
- * Reads the content of a file.
260
- *
261
- * @param path - The file path to read
262
- * @returns The file content as a Buffer
263
- */
264
- abstract readFile(path: string): Promise<Buffer>;
265
- /**
266
- * Writes data to a file.
267
- *
268
- * @param path - The file path to write to
269
- * @param data - The data to write (Buffer or string)
270
- */
271
- abstract writeFile(path: string, data: Uint8Array | Buffer | string | FileLike): Promise<void>;
272
- }
273
- //#endregion
274
- //#region src/file/services/FileDetector.d.ts
275
- interface FileTypeResult {
276
- /**
277
- * The detected MIME type
278
- */
279
- mimeType: string;
280
- /**
281
- * The detected file extension
282
- */
283
- extension: string;
284
- /**
285
- * Whether the file type was verified by magic bytes
286
- */
287
- verified: boolean;
288
- /**
289
- * The stream (potentially wrapped to allow re-reading)
290
- */
291
- stream: Readable;
292
- }
293
- /**
294
- * Service for detecting file types and getting content types.
295
- *
296
- * @example
297
- * ```typescript
298
- * const detector = alepha.inject(FileDetector);
299
- *
300
- * // Get content type from filename
301
- * const mimeType = detector.getContentType("image.png"); // "image/png"
302
- *
303
- * // Detect file type by magic bytes
304
- * const stream = createReadStream('image.png');
305
- * const result = await detector.detectFileType(stream, 'image.png');
306
- * console.log(result.mimeType); // 'image/png'
307
- * console.log(result.verified); // true if magic bytes match
308
- * ```
309
- */
310
- declare class FileDetector {
311
- /**
312
- * Magic byte signatures for common file formats.
313
- * Each signature is represented as an array of bytes or null (wildcard).
314
- */
315
- protected static readonly MAGIC_BYTES: Record<string, {
316
- signature: (number | null)[];
317
- mimeType: string;
318
- }[]>;
319
- /**
320
- * All possible format signatures for checking against actual file content
321
- */
322
- protected static readonly ALL_SIGNATURES: {
323
- signature: (number | null)[];
324
- mimeType: string;
325
- ext: string;
326
- }[];
327
- /**
328
- * MIME type map for file extensions.
329
- *
330
- * Can be used to get the content type of file based on its extension.
331
- * Feel free to add more mime types in your project!
332
- */
333
- static readonly mimeMap: Record<string, string>;
334
- /**
335
- * Reverse MIME type map for looking up extensions from MIME types.
336
- * Prefers shorter, more common extensions when multiple exist.
337
- */
338
- protected static readonly reverseMimeMap: Record<string, string>;
339
- /**
340
- * Returns the file extension for a given MIME type.
341
- *
342
- * @param mimeType - The MIME type to look up
343
- * @returns The file extension (without dot), or "bin" if not found
344
- *
345
- * @example
346
- * ```typescript
347
- * const detector = alepha.inject(FileDetector);
348
- * const ext = detector.getExtensionFromMimeType("image/png"); // "png"
349
- * const ext2 = detector.getExtensionFromMimeType("application/octet-stream"); // "bin"
350
- * ```
351
- */
352
- getExtensionFromMimeType(mimeType: string): string;
353
- /**
354
- * Returns the content type of file based on its filename.
355
- *
356
- * @param filename - The filename to check
357
- * @returns The MIME type
358
- *
359
- * @example
360
- * ```typescript
361
- * const detector = alepha.inject(FileDetector);
362
- * const mimeType = detector.getContentType("image.png"); // "image/png"
363
- * ```
364
- */
365
- getContentType(filename: string): string;
366
- /**
367
- * Detects the file type by checking magic bytes against the stream content.
368
- *
369
- * @param stream - The readable stream to check
370
- * @param filename - The filename (used to get the extension)
371
- * @returns File type information including MIME type, extension, and verification status
372
- *
373
- * @example
374
- * ```typescript
375
- * const detector = alepha.inject(FileDetector);
376
- * const stream = createReadStream('image.png');
377
- * const result = await detector.detectFileType(stream, 'image.png');
378
- * console.log(result.mimeType); // 'image/png'
379
- * console.log(result.verified); // true if magic bytes match
380
- * ```
381
- */
382
- detectFileType(stream: Readable, filename: string): Promise<FileTypeResult>;
383
- /**
384
- * Reads all bytes from a stream and returns the first N bytes along with a new stream containing all data.
385
- * This approach reads the entire stream upfront to avoid complex async handling issues.
386
- *
387
- * @protected
388
- */
389
- protected peekBytes(stream: Readable, numBytes: number): Promise<{
390
- buffer: Buffer;
391
- stream: Readable;
392
- }>;
393
- /**
394
- * Checks if a buffer matches a magic byte signature.
395
- *
396
- * @protected
397
- */
398
- protected matchesSignature(buffer: Buffer, signature: (number | null)[]): boolean;
399
- }
400
- //#endregion
401
- //#region src/file/providers/NodeFileSystemProvider.d.ts
402
- /**
403
- * Node.js implementation of FileSystem interface.
404
- *
405
- * @example
406
- * ```typescript
407
- * const fs = alepha.inject(NodeFileSystemProvider);
408
- *
409
- * // Create from URL
410
- * const file1 = fs.createFile({ url: "file:///path/to/file.png" });
411
- *
412
- * // Create from Buffer
413
- * const file2 = fs.createFile({ buffer: Buffer.from("hello"), name: "hello.txt" });
414
- *
415
- * // Create from text
416
- * const file3 = fs.createFile({ text: "Hello, world!", name: "greeting.txt" });
417
- *
418
- * // File operations
419
- * await fs.mkdir("/tmp/mydir", { recursive: true });
420
- * await fs.cp("/src/file.txt", "/dest/file.txt");
421
- * await fs.mv("/old/path.txt", "/new/path.txt");
422
- * const files = await fs.ls("/tmp");
423
- * await fs.rm("/tmp/file.txt");
424
- * ```
425
- */
426
- declare class NodeFileSystemProvider implements FileSystemProvider {
427
- protected detector: FileDetector;
428
- /**
429
- * Creates a FileLike object from various sources.
430
- *
431
- * @param options - Options for creating the file
432
- * @returns A FileLike object
433
- *
434
- * @example
435
- * ```typescript
436
- * const fs = alepha.inject(NodeFileSystemProvider);
437
- *
438
- * // From URL
439
- * const file1 = fs.createFile({ url: "https://example.com/image.png" });
440
- *
441
- * // From Buffer
442
- * const file2 = fs.createFile({
443
- * buffer: Buffer.from("hello"),
444
- * name: "hello.txt",
445
- * type: "text/plain"
446
- * });
447
- *
448
- * // From text
449
- * const file3 = fs.createFile({ text: "Hello!", name: "greeting.txt" });
450
- *
451
- * // From stream with detection
452
- * const stream = createReadStream("/path/to/file.png");
453
- * const file4 = fs.createFile({ stream, name: "image.png" });
454
- * ```
455
- */
456
- createFile(options: CreateFileOptions): FileLike;
457
- /**
458
- * Removes a file or directory.
459
- *
460
- * @param path - The path to remove
461
- * @param options - Remove options
462
- *
463
- * @example
464
- * ```typescript
465
- * const fs = alepha.inject(NodeFileSystemProvider);
466
- *
467
- * // Remove a file
468
- * await fs.rm("/tmp/file.txt");
469
- *
470
- * // Remove a directory recursively
471
- * await fs.rm("/tmp/mydir", { recursive: true });
472
- *
473
- * // Remove with force (no error if doesn't exist)
474
- * await fs.rm("/tmp/maybe-exists.txt", { force: true });
475
- * ```
476
- */
477
- rm(path: string, options?: RmOptions): Promise<void>;
478
- /**
479
- * Copies a file or directory.
480
- *
481
- * @param src - Source path
482
- * @param dest - Destination path
483
- * @param options - Copy options
484
- *
485
- * @example
486
- * ```typescript
487
- * const fs = alepha.inject(NodeFileSystemProvider);
488
- *
489
- * // Copy a file
490
- * await fs.cp("/src/file.txt", "/dest/file.txt");
491
- *
492
- * // Copy a directory recursively
493
- * await fs.cp("/src/dir", "/dest/dir", { recursive: true });
494
- *
495
- * // Copy with force (overwrite existing)
496
- * await fs.cp("/src/file.txt", "/dest/file.txt", { force: true });
497
- * ```
498
- */
499
- cp(src: string, dest: string, options?: CpOptions): Promise<void>;
500
- /**
501
- * Moves/renames a file or directory.
502
- *
503
- * @param src - Source path
504
- * @param dest - Destination path
505
- *
506
- * @example
507
- * ```typescript
508
- * const fs = alepha.inject(NodeFileSystemProvider);
509
- *
510
- * // Move/rename a file
511
- * await fs.mv("/old/path.txt", "/new/path.txt");
512
- *
513
- * // Move a directory
514
- * await fs.mv("/old/dir", "/new/dir");
515
- * ```
516
- */
517
- mv(src: string, dest: string): Promise<void>;
518
- /**
519
- * Creates a directory.
520
- *
521
- * @param path - The directory path to create
522
- * @param options - Mkdir options
523
- *
524
- * @example
525
- * ```typescript
526
- * const fs = alepha.inject(NodeFileSystemProvider);
527
- *
528
- * // Create a directory
529
- * await fs.mkdir("/tmp/mydir");
530
- *
531
- * // Create nested directories
532
- * await fs.mkdir("/tmp/path/to/dir", { recursive: true });
533
- *
534
- * // Create with specific permissions
535
- * await fs.mkdir("/tmp/mydir", { mode: 0o755 });
536
- * ```
537
- */
538
- mkdir(path: string, options?: MkdirOptions): Promise<void>;
539
- /**
540
- * Lists files in a directory.
541
- *
542
- * @param path - The directory path to list
543
- * @param options - List options
544
- * @returns Array of filenames
545
- *
546
- * @example
547
- * ```typescript
548
- * const fs = alepha.inject(NodeFileSystemProvider);
549
- *
550
- * // List files in a directory
551
- * const files = await fs.ls("/tmp");
552
- * console.log(files); // ["file1.txt", "file2.txt", "subdir"]
553
- *
554
- * // List with hidden files
555
- * const allFiles = await fs.ls("/tmp", { hidden: true });
556
- *
557
- * // List recursively
558
- * const allFilesRecursive = await fs.ls("/tmp", { recursive: true });
559
- * ```
560
- */
561
- ls(path: string, options?: LsOptions): Promise<string[]>;
562
- /**
563
- * Checks if a file or directory exists.
564
- *
565
- * @param path - The path to check
566
- * @returns True if the path exists, false otherwise
567
- *
568
- * @example
569
- * ```typescript
570
- * const fs = alepha.inject(NodeFileSystemProvider);
571
- *
572
- * if (await fs.exists("/tmp/file.txt")) {
573
- * console.log("File exists");
574
- * }
575
- * ```
576
- */
577
- exists(path: string): Promise<boolean>;
578
- /**
579
- * Reads the content of a file.
580
- *
581
- * @param path - The file path to read
582
- * @returns The file content as a Buffer
583
- *
584
- * @example
585
- * ```typescript
586
- * const fs = alepha.inject(NodeFileSystemProvider);
587
- *
588
- * const buffer = await fs.readFile("/tmp/file.txt");
589
- * console.log(buffer.toString("utf-8"));
590
- * ```
591
- */
592
- readFile(path: string): Promise<Buffer>;
593
- /**
594
- * Writes data to a file.
595
- *
596
- * @param path - The file path to write to
597
- * @param data - The data to write (Buffer or string)
598
- *
599
- * @example
600
- * ```typescript
601
- * const fs = alepha.inject(NodeFileSystemProvider);
602
- *
603
- * // Write string
604
- * await fs.writeFile("/tmp/file.txt", "Hello, world!");
605
- *
606
- * // Write Buffer
607
- * await fs.writeFile("/tmp/file.bin", Buffer.from([0x01, 0x02, 0x03]));
608
- * ```
609
- */
610
- writeFile(path: string, data: Uint8Array | Buffer | string | FileLike): Promise<void>;
611
- /**
612
- * Creates a FileLike object from a Web File.
613
- *
614
- * @protected
615
- */
616
- protected createFileFromWebFile(source: File, options?: {
617
- type?: string;
618
- name?: string;
619
- size?: number;
620
- }): FileLike;
621
- /**
622
- * Creates a FileLike object from a Buffer.
623
- *
624
- * @protected
625
- */
626
- protected createFileFromBuffer(source: Buffer, options?: {
627
- type?: string;
628
- name?: string;
629
- }): FileLike;
630
- /**
631
- * Creates a FileLike object from a stream.
632
- *
633
- * @protected
634
- */
635
- protected createFileFromStream(source: StreamLike, options?: {
636
- type?: string;
637
- name?: string;
638
- size?: number;
639
- }): FileLike & {
640
- _buffer: null | Buffer;
641
- };
642
- /**
643
- * Creates a FileLike object from a URL.
644
- *
645
- * @protected
646
- */
647
- protected createFileFromUrl(url: string, options?: {
648
- type?: string;
649
- name?: string;
650
- }): FileLike;
651
- /**
652
- * Gets a streaming response from a URL.
653
- *
654
- * @protected
655
- */
656
- protected getStreamingResponse(url: string): Readable;
657
- /**
658
- * Loads data from a URL.
659
- *
660
- * @protected
661
- */
662
- protected loadFromUrl(url: string): Promise<Buffer>;
663
- /**
664
- * Creates a stream from a URL.
665
- *
666
- * @protected
667
- */
668
- protected createStreamFromUrl(url: string): Readable;
669
- /**
670
- * Converts a stream-like object to a Buffer.
671
- *
672
- * @protected
673
- */
674
- protected streamToBuffer(streamLike: StreamLike): Promise<Buffer>;
675
- /**
676
- * Converts a Node.js Buffer to an ArrayBuffer.
677
- *
678
- * @protected
679
- */
680
- protected bufferToArrayBuffer(buffer: Buffer): ArrayBuffer;
681
- }
682
- //#endregion
683
- //#region src/file/index.d.ts
684
- /**
685
- * Provides file system capabilities for Alepha applications with support for multiple file sources and operations.
686
- *
687
- * The file module enables working with files from various sources (URLs, buffers, streams) and provides
688
- * utilities for file type detection, content type determination, and common file system operations.
689
- *
690
- * @see {@link FileDetector}
691
- * @see {@link FileSystemProvider}
692
- * @see {@link NodeFileSystemProvider}
693
- * @module alepha.file
694
- */
695
- declare const AlephaFile: alepha0.Service<alepha0.Module>;
696
- //#endregion
697
- export { AlephaFile, CpOptions, CreateFileFromArrayBufferOptions, CreateFileFromBufferOptions, CreateFileFromPathOptions, CreateFileFromResponseOptions, CreateFileFromStreamOptions, CreateFileFromTextOptions, CreateFileFromUrlOptions, CreateFileFromWebFileOptions, CreateFileOptions, FileDetector, FileSystemProvider, FileTypeResult, LsOptions, MkdirOptions, NodeFileSystemProvider, RmOptions };
698
- //# sourceMappingURL=index.d.cts.map