alepha 0.14.3 → 0.15.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/README.md +2 -5
- package/dist/api/audits/index.d.ts +620 -811
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/files/index.d.ts +185 -377
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +0 -1
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +245 -435
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/notifications/index.d.ts +238 -429
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/parameters/index.d.ts +236 -427
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/users/index.browser.js +1 -2
- package/dist/api/users/index.browser.js.map +1 -1
- package/dist/api/users/index.d.ts +1010 -1196
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +178 -151
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +17 -17
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/batch/index.d.ts +122 -122
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +1 -2
- package/dist/batch/index.js.map +1 -1
- package/dist/bucket/index.d.ts +163 -163
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/cache/core/index.d.ts +46 -46
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cli/index.d.ts +384 -285
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1113 -623
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +299 -300
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +13 -9
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +445 -103
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +733 -625
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +446 -103
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +445 -103
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.d.ts +44 -44
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js +4 -4
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/index.d.ts +97 -50
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +129 -33
- package/dist/email/index.js.map +1 -1
- package/dist/fake/index.d.ts +7981 -14
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/file/index.d.ts +523 -390
- package/dist/file/index.d.ts.map +1 -1
- package/dist/file/index.js +253 -1
- package/dist/file/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +208 -208
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/logger/index.d.ts +25 -26
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +12 -2
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +197 -197
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/chunk-DtkW-qnP.js +38 -0
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.bun.js +2814 -0
- package/dist/orm/index.bun.js.map +1 -0
- package/dist/orm/index.d.ts +1228 -1216
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +2041 -1967
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +248 -248
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/redis/index.bun.js +285 -0
- package/dist/redis/index.bun.js.map +1 -0
- package/dist/redis/index.d.ts +118 -136
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +18 -38
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.d.ts +69 -69
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts +25 -25
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/security/index.browser.js +5 -1
- package/dist/security/index.browser.js.map +1 -1
- package/dist/security/index.d.ts +417 -254
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +386 -86
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +110 -110
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +20 -20
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.d.ts +62 -47
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/cache/index.js +56 -3
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/compress/index.d.ts +6 -0
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/compress/index.js +36 -1
- package/dist/server/compress/index.js.map +1 -1
- package/dist/server/cookies/index.d.ts +6 -6
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js +3 -3
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.browser.js +2 -2
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +242 -150
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +294 -125
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +11 -12
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/health/index.d.ts +0 -1
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/helmet/index.d.ts +2 -2
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +123 -124
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +1 -2
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/multipart/index.d.ts +6 -6
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/proxy/index.d.ts +102 -103
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.d.ts +16 -16
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/static/index.d.ts +44 -44
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/static/index.js +4 -0
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +48 -49
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js +3 -5
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +13 -11
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +7 -7
- package/dist/sms/index.js.map +1 -1
- package/dist/thread/index.d.ts +71 -72
- package/dist/thread/index.d.ts.map +1 -1
- package/dist/topic/core/index.d.ts +318 -318
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/redis/index.d.ts +6 -6
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/vite/index.d.ts +5805 -249
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +599 -513
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +6 -6
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +247 -247
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +6 -6
- package/dist/websocket/index.js.map +1 -1
- package/package.json +9 -14
- package/src/api/files/controllers/AdminFileStatsController.ts +0 -1
- package/src/api/users/atoms/realmAuthSettingsAtom.ts +5 -0
- package/src/api/users/controllers/{UserRealmController.ts → RealmController.ts} +11 -11
- package/src/api/users/entities/users.ts +1 -1
- package/src/api/users/index.ts +8 -8
- package/src/api/users/primitives/{$userRealm.ts → $realm.ts} +17 -19
- package/src/api/users/providers/{UserRealmProvider.ts → RealmProvider.ts} +26 -30
- package/src/api/users/schemas/{userRealmConfigSchema.ts → realmConfigSchema.ts} +2 -2
- package/src/api/users/services/CredentialService.ts +7 -7
- package/src/api/users/services/IdentityService.ts +4 -4
- package/src/api/users/services/RegistrationService.spec.ts +25 -27
- package/src/api/users/services/RegistrationService.ts +38 -27
- package/src/api/users/services/SessionCrudService.ts +3 -3
- package/src/api/users/services/SessionService.spec.ts +3 -3
- package/src/api/users/services/SessionService.ts +28 -9
- package/src/api/users/services/UserService.ts +7 -7
- package/src/batch/providers/BatchProvider.ts +1 -2
- package/src/cli/apps/AlephaCli.ts +0 -2
- package/src/cli/apps/AlephaPackageBuilderCli.ts +38 -19
- package/src/cli/assets/apiHelloControllerTs.ts +18 -0
- package/src/cli/assets/apiIndexTs.ts +16 -0
- package/src/cli/assets/claudeMd.ts +303 -0
- package/src/cli/assets/mainBrowserTs.ts +2 -2
- package/src/cli/assets/mainServerTs.ts +24 -0
- package/src/cli/assets/webAppRouterTs.ts +15 -0
- package/src/cli/assets/webHelloComponentTsx.ts +16 -0
- package/src/cli/assets/webIndexTs.ts +16 -0
- package/src/cli/atoms/buildOptions.ts +88 -0
- package/src/cli/commands/build.ts +70 -87
- package/src/cli/commands/db.ts +21 -22
- package/src/cli/commands/deploy.ts +17 -5
- package/src/cli/commands/dev.ts +22 -14
- package/src/cli/commands/format.ts +8 -2
- package/src/cli/commands/gen/env.ts +53 -0
- package/src/cli/commands/gen/openapi.ts +1 -1
- package/src/cli/commands/gen/resource.ts +15 -0
- package/src/cli/commands/gen.ts +7 -1
- package/src/cli/commands/init.ts +74 -30
- package/src/cli/commands/lint.ts +8 -2
- package/src/cli/commands/test.ts +8 -3
- package/src/cli/commands/typecheck.ts +5 -1
- package/src/cli/commands/verify.ts +5 -3
- package/src/cli/defineConfig.ts +49 -7
- package/src/cli/index.ts +0 -1
- package/src/cli/services/AlephaCliUtils.ts +39 -589
- package/src/cli/services/PackageManagerUtils.ts +301 -0
- package/src/cli/services/ProjectScaffolder.ts +306 -0
- package/src/command/helpers/Runner.spec.ts +2 -2
- package/src/command/helpers/Runner.ts +16 -4
- package/src/command/primitives/$command.ts +0 -6
- package/src/command/providers/CliProvider.ts +1 -3
- package/src/core/Alepha.ts +42 -0
- package/src/core/__tests__/Alepha-graph.spec.ts +4 -0
- package/src/core/index.shared.ts +1 -0
- package/src/core/index.ts +2 -0
- package/src/core/primitives/$hook.ts +6 -2
- package/src/core/primitives/$module.spec.ts +4 -0
- package/src/core/providers/AlsProvider.ts +1 -1
- package/src/core/providers/CodecManager.spec.ts +12 -6
- package/src/core/providers/CodecManager.ts +26 -6
- package/src/core/providers/EventManager.ts +169 -13
- package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +621 -0
- package/src/core/providers/KeylessJsonSchemaCodec.ts +407 -0
- package/src/core/providers/StateManager.spec.ts +27 -16
- package/src/email/providers/LocalEmailProvider.spec.ts +111 -87
- package/src/email/providers/LocalEmailProvider.ts +52 -15
- package/src/email/providers/NodemailerEmailProvider.ts +167 -56
- package/src/file/errors/FileError.ts +7 -0
- package/src/file/index.ts +9 -1
- package/src/file/providers/MemoryFileSystemProvider.ts +393 -0
- package/src/logger/index.ts +15 -3
- package/src/mcp/transports/StdioMcpTransport.ts +1 -1
- package/src/orm/index.browser.ts +1 -19
- package/src/orm/index.bun.ts +77 -0
- package/src/orm/index.shared-server.ts +22 -0
- package/src/orm/index.shared.ts +15 -0
- package/src/orm/index.ts +13 -39
- package/src/orm/providers/drivers/BunPostgresProvider.ts +3 -5
- package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -1
- package/src/orm/providers/drivers/CloudflareD1Provider.ts +4 -0
- package/src/orm/providers/drivers/DatabaseProvider.ts +4 -0
- package/src/orm/providers/drivers/PglitePostgresProvider.ts +4 -0
- package/src/orm/services/Repository.ts +8 -0
- package/src/queue/core/providers/WorkerProvider.spec.ts +48 -32
- package/src/redis/index.bun.ts +35 -0
- package/src/redis/providers/BunRedisProvider.ts +12 -43
- package/src/redis/providers/BunRedisSubscriberProvider.ts +2 -3
- package/src/redis/providers/NodeRedisProvider.ts +16 -34
- package/src/{server/security → security}/__tests__/BasicAuth.spec.ts +11 -11
- package/src/{server/security → security}/__tests__/ServerSecurityProvider-realm.spec.ts +21 -16
- package/src/{server/security/providers → security/__tests__}/ServerSecurityProvider.spec.ts +5 -5
- package/src/security/index.browser.ts +5 -0
- package/src/security/index.ts +90 -7
- package/src/security/primitives/{$realm.spec.ts → $issuer.spec.ts} +11 -11
- package/src/security/primitives/{$realm.ts → $issuer.ts} +20 -17
- package/src/security/primitives/$role.ts +5 -5
- package/src/security/primitives/$serviceAccount.spec.ts +5 -5
- package/src/security/primitives/$serviceAccount.ts +3 -3
- package/src/{server/security → security}/providers/ServerSecurityProvider.ts +5 -7
- package/src/server/auth/primitives/$auth.ts +10 -10
- package/src/server/auth/primitives/$authCredentials.ts +3 -3
- package/src/server/auth/primitives/$authGithub.ts +3 -3
- package/src/server/auth/primitives/$authGoogle.ts +3 -3
- package/src/server/auth/providers/ServerAuthProvider.ts +13 -13
- package/src/server/cache/providers/ServerCacheProvider.spec.ts +183 -0
- package/src/server/cache/providers/ServerCacheProvider.ts +95 -10
- package/src/server/compress/providers/ServerCompressProvider.ts +61 -2
- package/src/server/cookies/providers/ServerCookiesProvider.ts +3 -3
- package/src/server/core/helpers/ServerReply.ts +2 -2
- package/src/server/core/providers/NodeHttpServerProvider.ts +25 -6
- package/src/server/core/providers/ServerBodyParserProvider.ts +19 -23
- package/src/server/core/providers/ServerLoggerProvider.ts +23 -19
- package/src/server/core/providers/ServerProvider.ts +155 -22
- package/src/server/core/providers/ServerRouterProvider.ts +259 -115
- package/src/server/core/providers/ServerTimingProvider.ts +2 -2
- package/src/server/links/index.ts +1 -1
- package/src/server/links/providers/LinkProvider.ts +1 -1
- package/src/server/static/providers/ServerStaticProvider.ts +10 -0
- package/src/server/swagger/index.ts +1 -1
- package/src/server/swagger/providers/ServerSwaggerProvider.ts +5 -8
- package/src/sms/providers/LocalSmsProvider.spec.ts +153 -111
- package/src/sms/providers/LocalSmsProvider.ts +8 -7
- package/src/vite/helpers/boot.ts +28 -17
- package/src/vite/helpers/importViteReact.ts +13 -0
- package/src/vite/index.ts +1 -21
- package/src/vite/plugins/viteAlephaDev.ts +16 -1
- package/src/vite/plugins/viteAlephaSsrPreload.ts +222 -0
- package/src/vite/tasks/buildClient.ts +11 -0
- package/src/vite/tasks/buildServer.ts +59 -4
- package/src/vite/tasks/devServer.ts +71 -0
- package/src/vite/tasks/generateCloudflare.ts +7 -0
- package/src/vite/tasks/index.ts +2 -1
- package/dist/server/security/index.browser.js +0 -13
- package/dist/server/security/index.browser.js.map +0 -1
- package/dist/server/security/index.d.ts +0 -173
- package/dist/server/security/index.d.ts.map +0 -1
- package/dist/server/security/index.js +0 -311
- package/dist/server/security/index.js.map +0 -1
- package/src/cli/assets/appRouterTs.ts +0 -9
- package/src/cli/assets/mainTs.ts +0 -13
- package/src/cli/assets/viteConfigTs.ts +0 -14
- package/src/cli/commands/run.ts +0 -24
- package/src/server/security/index.browser.ts +0 -10
- package/src/server/security/index.ts +0 -94
- package/src/vite/plugins/viteAlepha.ts +0 -37
- package/src/vite/plugins/viteAlephaBuild.ts +0 -281
- /package/src/{server/security → security}/primitives/$basicAuth.ts +0 -0
- /package/src/{server/security → security}/providers/ServerBasicAuthProvider.ts +0 -0
package/dist/file/index.d.ts
CHANGED
|
@@ -2,22 +2,27 @@ import * as alepha0 from "alepha";
|
|
|
2
2
|
import { FileLike, StreamLike } from "alepha";
|
|
3
3
|
import { Readable } from "node:stream";
|
|
4
4
|
|
|
5
|
+
//#region ../../src/file/errors/FileError.d.ts
|
|
6
|
+
declare class FileError extends Error {
|
|
7
|
+
constructor(message: string, cause?: Error);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
5
10
|
//#region ../../src/file/providers/FileSystemProvider.d.ts
|
|
6
11
|
/**
|
|
7
12
|
* Options for creating a file from a URL
|
|
8
13
|
*/
|
|
9
14
|
interface CreateFileFromUrlOptions {
|
|
10
15
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
* The URL to load the file from (file://, http://, or https://)
|
|
17
|
+
*/
|
|
13
18
|
url: string;
|
|
14
19
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
* The MIME type of the file (optional, will be detected from filename if not provided)
|
|
21
|
+
*/
|
|
17
22
|
type?: string;
|
|
18
23
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
* The name of the file (optional, will be extracted from URL if not provided)
|
|
25
|
+
*/
|
|
21
26
|
name?: string;
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
@@ -25,16 +30,16 @@ interface CreateFileFromUrlOptions {
|
|
|
25
30
|
*/
|
|
26
31
|
interface CreateFileFromPathOptions {
|
|
27
32
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
* The path to the file on the local filesystem
|
|
34
|
+
*/
|
|
30
35
|
path: string;
|
|
31
36
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
* The MIME type of the file (optional, will be detected from filename if not provided)
|
|
38
|
+
*/
|
|
34
39
|
type?: string;
|
|
35
40
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
* The name of the file (optional, will be extracted from URL if not provided)
|
|
42
|
+
*/
|
|
38
43
|
name?: string;
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
@@ -42,16 +47,16 @@ interface CreateFileFromPathOptions {
|
|
|
42
47
|
*/
|
|
43
48
|
interface CreateFileFromBufferOptions {
|
|
44
49
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
* The Buffer containing the file data
|
|
51
|
+
*/
|
|
47
52
|
buffer: Buffer;
|
|
48
53
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
* The MIME type of the file (optional, will be detected from name if not provided)
|
|
55
|
+
*/
|
|
51
56
|
type?: string;
|
|
52
57
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
* The name of the file (required for proper content type detection)
|
|
59
|
+
*/
|
|
55
60
|
name?: string;
|
|
56
61
|
}
|
|
57
62
|
/**
|
|
@@ -59,20 +64,20 @@ interface CreateFileFromBufferOptions {
|
|
|
59
64
|
*/
|
|
60
65
|
interface CreateFileFromStreamOptions {
|
|
61
66
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
* The readable stream containing the file data
|
|
68
|
+
*/
|
|
64
69
|
stream: StreamLike;
|
|
65
70
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
* The MIME type of the file (optional, will be detected from name if not provided)
|
|
72
|
+
*/
|
|
68
73
|
type?: string;
|
|
69
74
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
* The name of the file (required for proper content type detection)
|
|
76
|
+
*/
|
|
72
77
|
name?: string;
|
|
73
78
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
* The size of the file in bytes (optional)
|
|
80
|
+
*/
|
|
76
81
|
size?: number;
|
|
77
82
|
}
|
|
78
83
|
/**
|
|
@@ -80,30 +85,30 @@ interface CreateFileFromStreamOptions {
|
|
|
80
85
|
*/
|
|
81
86
|
interface CreateFileFromTextOptions {
|
|
82
87
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
* The text content to create the file from
|
|
89
|
+
*/
|
|
85
90
|
text: string;
|
|
86
91
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
* The MIME type of the file (default: text/plain)
|
|
93
|
+
*/
|
|
89
94
|
type?: string;
|
|
90
95
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
* The name of the file (default: "file.txt")
|
|
97
|
+
*/
|
|
93
98
|
name?: string;
|
|
94
99
|
}
|
|
95
100
|
interface CreateFileFromResponseOptions {
|
|
96
101
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
* The Response object containing the file data
|
|
103
|
+
*/
|
|
99
104
|
response: Response;
|
|
100
105
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
* Override the name (optional, uses filename from Content-Disposition header if not provided)
|
|
107
|
+
*/
|
|
103
108
|
name?: string;
|
|
104
109
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
* Override the MIME type (optional, uses file.type if not provided)
|
|
111
|
+
*/
|
|
107
112
|
type?: string;
|
|
108
113
|
}
|
|
109
114
|
/**
|
|
@@ -111,20 +116,20 @@ interface CreateFileFromResponseOptions {
|
|
|
111
116
|
*/
|
|
112
117
|
interface CreateFileFromWebFileOptions {
|
|
113
118
|
/**
|
|
114
|
-
|
|
115
|
-
|
|
119
|
+
* The Web File object
|
|
120
|
+
*/
|
|
116
121
|
file: File;
|
|
117
122
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
* Override the MIME type (optional, uses file.type if not provided)
|
|
124
|
+
*/
|
|
120
125
|
type?: string;
|
|
121
126
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
* Override the name (optional, uses file.name if not provided)
|
|
128
|
+
*/
|
|
124
129
|
name?: string;
|
|
125
130
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
* Override the size (optional, uses file.size if not provided)
|
|
132
|
+
*/
|
|
128
133
|
size?: number;
|
|
129
134
|
}
|
|
130
135
|
/**
|
|
@@ -132,16 +137,16 @@ interface CreateFileFromWebFileOptions {
|
|
|
132
137
|
*/
|
|
133
138
|
interface CreateFileFromArrayBufferOptions {
|
|
134
139
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
* The ArrayBuffer containing the file data
|
|
141
|
+
*/
|
|
137
142
|
arrayBuffer: ArrayBuffer;
|
|
138
143
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
* The MIME type of the file (optional, will be detected from name if not provided)
|
|
145
|
+
*/
|
|
141
146
|
type?: string;
|
|
142
147
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
* The name of the file (required for proper content type detection)
|
|
149
|
+
*/
|
|
145
150
|
name?: string;
|
|
146
151
|
}
|
|
147
152
|
/**
|
|
@@ -153,12 +158,12 @@ type CreateFileOptions = CreateFileFromUrlOptions | CreateFileFromPathOptions |
|
|
|
153
158
|
*/
|
|
154
159
|
interface RmOptions {
|
|
155
160
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
161
|
+
* If true, removes directories and their contents recursively
|
|
162
|
+
*/
|
|
158
163
|
recursive?: boolean;
|
|
159
164
|
/**
|
|
160
|
-
|
|
161
|
-
|
|
165
|
+
* If true, no error will be thrown if the path does not exist
|
|
166
|
+
*/
|
|
162
167
|
force?: boolean;
|
|
163
168
|
}
|
|
164
169
|
/**
|
|
@@ -166,12 +171,12 @@ interface RmOptions {
|
|
|
166
171
|
*/
|
|
167
172
|
interface CpOptions {
|
|
168
173
|
/**
|
|
169
|
-
|
|
170
|
-
|
|
174
|
+
* If true, copy directories recursively
|
|
175
|
+
*/
|
|
171
176
|
recursive?: boolean;
|
|
172
177
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
178
|
+
* If true, overwrite existing destination
|
|
179
|
+
*/
|
|
175
180
|
force?: boolean;
|
|
176
181
|
}
|
|
177
182
|
/**
|
|
@@ -179,12 +184,12 @@ interface CpOptions {
|
|
|
179
184
|
*/
|
|
180
185
|
interface MkdirOptions {
|
|
181
186
|
/**
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
* If true, creates parent directories as needed
|
|
188
|
+
*/
|
|
184
189
|
recursive?: boolean;
|
|
185
190
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
191
|
+
* File mode (permission and sticky bits)
|
|
192
|
+
*/
|
|
188
193
|
mode?: number;
|
|
189
194
|
}
|
|
190
195
|
/**
|
|
@@ -192,12 +197,12 @@ interface MkdirOptions {
|
|
|
192
197
|
*/
|
|
193
198
|
interface LsOptions {
|
|
194
199
|
/**
|
|
195
|
-
|
|
196
|
-
|
|
200
|
+
* If true, list contents of directories recursively
|
|
201
|
+
*/
|
|
197
202
|
recursive?: boolean;
|
|
198
203
|
/**
|
|
199
|
-
|
|
200
|
-
|
|
204
|
+
* If true, include hidden files (starting with .)
|
|
205
|
+
*/
|
|
201
206
|
hidden?: boolean;
|
|
202
207
|
}
|
|
203
208
|
/**
|
|
@@ -205,96 +210,224 @@ interface LsOptions {
|
|
|
205
210
|
*/
|
|
206
211
|
declare abstract class FileSystemProvider {
|
|
207
212
|
/**
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
* Joins multiple path segments into a single path.
|
|
214
|
+
*
|
|
215
|
+
* @param paths - The path segments to join
|
|
216
|
+
* @returns The joined path
|
|
217
|
+
*/
|
|
213
218
|
abstract join(...paths: string[]): string;
|
|
214
219
|
/**
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
* Creates a FileLike object from various sources.
|
|
221
|
+
*
|
|
222
|
+
* @param options - Options for creating the file
|
|
223
|
+
* @returns A FileLike object
|
|
224
|
+
*/
|
|
220
225
|
abstract createFile(options: CreateFileOptions): FileLike;
|
|
221
226
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
+
* Removes a file or directory.
|
|
228
|
+
*
|
|
229
|
+
* @param path - The path to remove
|
|
230
|
+
* @param options - Remove options
|
|
231
|
+
*/
|
|
227
232
|
abstract rm(path: string, options?: RmOptions): Promise<void>;
|
|
228
233
|
/**
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
* Copies a file or directory.
|
|
235
|
+
*
|
|
236
|
+
* @param src - Source path
|
|
237
|
+
* @param dest - Destination path
|
|
238
|
+
* @param options - Copy options
|
|
239
|
+
*/
|
|
235
240
|
abstract cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
236
241
|
/**
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
* Moves/renames a file or directory.
|
|
243
|
+
*
|
|
244
|
+
* @param src - Source path
|
|
245
|
+
* @param dest - Destination path
|
|
246
|
+
*/
|
|
242
247
|
abstract mv(src: string, dest: string): Promise<void>;
|
|
243
248
|
/**
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
* Creates a directory.
|
|
250
|
+
*
|
|
251
|
+
* @param path - The directory path to create
|
|
252
|
+
* @param options - Mkdir options
|
|
253
|
+
*/
|
|
249
254
|
abstract mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
250
255
|
/**
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
256
|
+
* Lists files in a directory.
|
|
257
|
+
*
|
|
258
|
+
* @param path - The directory path to list
|
|
259
|
+
* @param options - List options
|
|
260
|
+
* @returns Array of filenames
|
|
261
|
+
*/
|
|
257
262
|
abstract ls(path: string, options?: LsOptions): Promise<string[]>;
|
|
258
263
|
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
+
* Checks if a file or directory exists.
|
|
265
|
+
*
|
|
266
|
+
* @param path - The path to check
|
|
267
|
+
* @returns True if the path exists, false otherwise
|
|
268
|
+
*/
|
|
264
269
|
abstract exists(path: string): Promise<boolean>;
|
|
265
270
|
/**
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
+
* Reads the content of a file.
|
|
272
|
+
*
|
|
273
|
+
* @param path - The file path to read
|
|
274
|
+
* @returns The file content as a Buffer
|
|
275
|
+
*/
|
|
271
276
|
abstract readFile(path: string): Promise<Buffer>;
|
|
272
277
|
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
+
* Writes data to a file.
|
|
279
|
+
*
|
|
280
|
+
* @param path - The file path to write to
|
|
281
|
+
* @param data - The data to write (Buffer or string)
|
|
282
|
+
*/
|
|
278
283
|
abstract writeFile(path: string, data: Uint8Array | Buffer | string | FileLike): Promise<void>;
|
|
279
284
|
}
|
|
280
285
|
//#endregion
|
|
286
|
+
//#region ../../src/file/providers/MemoryFileSystemProvider.d.ts
|
|
287
|
+
interface MemoryFileSystemProviderOptions {
|
|
288
|
+
/**
|
|
289
|
+
* Error to throw on mkdir operations (for testing error handling)
|
|
290
|
+
*/
|
|
291
|
+
mkdirError?: Error | null;
|
|
292
|
+
/**
|
|
293
|
+
* Error to throw on writeFile operations (for testing error handling)
|
|
294
|
+
*/
|
|
295
|
+
writeFileError?: Error | null;
|
|
296
|
+
/**
|
|
297
|
+
* Error to throw on readFile operations (for testing error handling)
|
|
298
|
+
*/
|
|
299
|
+
readFileError?: Error | null;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* In-memory implementation of FileSystemProvider for testing.
|
|
303
|
+
*
|
|
304
|
+
* This provider stores all files and directories in memory, making it ideal for
|
|
305
|
+
* unit tests that need to verify file operations without touching the real file system.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* // In tests, substitute the real FileSystemProvider with MemoryFileSystemProvider
|
|
310
|
+
* const alepha = Alepha.create().with({
|
|
311
|
+
* provide: FileSystemProvider,
|
|
312
|
+
* use: MemoryFileSystemProvider,
|
|
313
|
+
* });
|
|
314
|
+
*
|
|
315
|
+
* // Run code that uses FileSystemProvider
|
|
316
|
+
* const service = alepha.inject(MyService);
|
|
317
|
+
* await service.saveFile("test.txt", "Hello World");
|
|
318
|
+
*
|
|
319
|
+
* // Verify the file was written
|
|
320
|
+
* const memoryFs = alepha.inject(MemoryFileSystemProvider);
|
|
321
|
+
* expect(memoryFs.files.get("test.txt")?.toString()).toBe("Hello World");
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
declare class MemoryFileSystemProvider implements FileSystemProvider {
|
|
325
|
+
/**
|
|
326
|
+
* In-memory storage for files (path -> content)
|
|
327
|
+
*/
|
|
328
|
+
files: Map<string, Buffer<ArrayBufferLike>>;
|
|
329
|
+
/**
|
|
330
|
+
* In-memory storage for directories
|
|
331
|
+
*/
|
|
332
|
+
directories: Set<string>;
|
|
333
|
+
/**
|
|
334
|
+
* Track mkdir calls for test assertions
|
|
335
|
+
*/
|
|
336
|
+
mkdirCalls: Array<{
|
|
337
|
+
path: string;
|
|
338
|
+
options?: MkdirOptions;
|
|
339
|
+
}>;
|
|
340
|
+
/**
|
|
341
|
+
* Track writeFile calls for test assertions
|
|
342
|
+
*/
|
|
343
|
+
writeFileCalls: Array<{
|
|
344
|
+
path: string;
|
|
345
|
+
data: string;
|
|
346
|
+
}>;
|
|
347
|
+
/**
|
|
348
|
+
* Track join calls for test assertions
|
|
349
|
+
*/
|
|
350
|
+
joinCalls: Array<string[]>;
|
|
351
|
+
/**
|
|
352
|
+
* Error to throw on mkdir (for testing error handling)
|
|
353
|
+
*/
|
|
354
|
+
mkdirError: Error | null;
|
|
355
|
+
/**
|
|
356
|
+
* Error to throw on writeFile (for testing error handling)
|
|
357
|
+
*/
|
|
358
|
+
writeFileError: Error | null;
|
|
359
|
+
/**
|
|
360
|
+
* Error to throw on readFile (for testing error handling)
|
|
361
|
+
*/
|
|
362
|
+
readFileError: Error | null;
|
|
363
|
+
constructor(options?: MemoryFileSystemProviderOptions);
|
|
364
|
+
/**
|
|
365
|
+
* Join path segments using forward slashes.
|
|
366
|
+
*/
|
|
367
|
+
join(...paths: string[]): string;
|
|
368
|
+
/**
|
|
369
|
+
* Create a FileLike object from various sources.
|
|
370
|
+
*/
|
|
371
|
+
createFile(options: CreateFileOptions): FileLike;
|
|
372
|
+
/**
|
|
373
|
+
* Remove a file or directory from memory.
|
|
374
|
+
*/
|
|
375
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
376
|
+
/**
|
|
377
|
+
* Copy a file or directory in memory.
|
|
378
|
+
*/
|
|
379
|
+
cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
380
|
+
/**
|
|
381
|
+
* Move/rename a file or directory in memory.
|
|
382
|
+
*/
|
|
383
|
+
mv(src: string, dest: string): Promise<void>;
|
|
384
|
+
/**
|
|
385
|
+
* Create a directory in memory.
|
|
386
|
+
*/
|
|
387
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
388
|
+
/**
|
|
389
|
+
* List files in a directory.
|
|
390
|
+
*/
|
|
391
|
+
ls(path: string, options?: LsOptions): Promise<string[]>;
|
|
392
|
+
/**
|
|
393
|
+
* Check if a file or directory exists in memory.
|
|
394
|
+
*/
|
|
395
|
+
exists(path: string): Promise<boolean>;
|
|
396
|
+
/**
|
|
397
|
+
* Read a file from memory.
|
|
398
|
+
*/
|
|
399
|
+
readFile(path: string): Promise<Buffer>;
|
|
400
|
+
/**
|
|
401
|
+
* Write a file to memory.
|
|
402
|
+
*/
|
|
403
|
+
writeFile(path: string, data: Uint8Array | Buffer | string | FileLike): Promise<void>;
|
|
404
|
+
/**
|
|
405
|
+
* Reset all in-memory state (useful between tests).
|
|
406
|
+
*/
|
|
407
|
+
reset(): void;
|
|
408
|
+
/**
|
|
409
|
+
* Get the content of a file as a string (convenience method for testing).
|
|
410
|
+
*/
|
|
411
|
+
getFileContent(path: string): string | undefined;
|
|
412
|
+
}
|
|
413
|
+
//#endregion
|
|
281
414
|
//#region ../../src/file/services/FileDetector.d.ts
|
|
282
415
|
interface FileTypeResult {
|
|
283
416
|
/**
|
|
284
|
-
|
|
285
|
-
|
|
417
|
+
* The detected MIME type
|
|
418
|
+
*/
|
|
286
419
|
mimeType: string;
|
|
287
420
|
/**
|
|
288
|
-
|
|
289
|
-
|
|
421
|
+
* The detected file extension
|
|
422
|
+
*/
|
|
290
423
|
extension: string;
|
|
291
424
|
/**
|
|
292
|
-
|
|
293
|
-
|
|
425
|
+
* Whether the file type was verified by magic bytes
|
|
426
|
+
*/
|
|
294
427
|
verified: boolean;
|
|
295
428
|
/**
|
|
296
|
-
|
|
297
|
-
|
|
429
|
+
* The stream (potentially wrapped to allow re-reading)
|
|
430
|
+
*/
|
|
298
431
|
stream: Readable;
|
|
299
432
|
}
|
|
300
433
|
/**
|
|
@@ -316,92 +449,92 @@ interface FileTypeResult {
|
|
|
316
449
|
*/
|
|
317
450
|
declare class FileDetector {
|
|
318
451
|
/**
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
452
|
+
* Magic byte signatures for common file formats.
|
|
453
|
+
* Each signature is represented as an array of bytes or null (wildcard).
|
|
454
|
+
*/
|
|
322
455
|
protected static readonly MAGIC_BYTES: Record<string, {
|
|
323
456
|
signature: (number | null)[];
|
|
324
457
|
mimeType: string;
|
|
325
458
|
}[]>;
|
|
326
459
|
/**
|
|
327
|
-
|
|
328
|
-
|
|
460
|
+
* All possible format signatures for checking against actual file content
|
|
461
|
+
*/
|
|
329
462
|
protected static readonly ALL_SIGNATURES: {
|
|
330
463
|
signature: (number | null)[];
|
|
331
464
|
mimeType: string;
|
|
332
465
|
ext: string;
|
|
333
466
|
}[];
|
|
334
467
|
/**
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
468
|
+
* MIME type map for file extensions.
|
|
469
|
+
*
|
|
470
|
+
* Can be used to get the content type of file based on its extension.
|
|
471
|
+
* Feel free to add more mime types in your project!
|
|
472
|
+
*/
|
|
340
473
|
static readonly mimeMap: Record<string, string>;
|
|
341
474
|
/**
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
475
|
+
* Reverse MIME type map for looking up extensions from MIME types.
|
|
476
|
+
* Prefers shorter, more common extensions when multiple exist.
|
|
477
|
+
*/
|
|
345
478
|
protected static readonly reverseMimeMap: Record<string, string>;
|
|
346
479
|
/**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
480
|
+
* Returns the file extension for a given MIME type.
|
|
481
|
+
*
|
|
482
|
+
* @param mimeType - The MIME type to look up
|
|
483
|
+
* @returns The file extension (without dot), or "bin" if not found
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* const detector = alepha.inject(FileDetector);
|
|
488
|
+
* const ext = detector.getExtensionFromMimeType("image/png"); // "png"
|
|
489
|
+
* const ext2 = detector.getExtensionFromMimeType("application/octet-stream"); // "bin"
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
359
492
|
getExtensionFromMimeType(mimeType: string): string;
|
|
360
493
|
/**
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
494
|
+
* Returns the content type of file based on its filename.
|
|
495
|
+
*
|
|
496
|
+
* @param filename - The filename to check
|
|
497
|
+
* @returns The MIME type
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* const detector = alepha.inject(FileDetector);
|
|
502
|
+
* const mimeType = detector.getContentType("image.png"); // "image/png"
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
372
505
|
getContentType(filename: string): string;
|
|
373
506
|
/**
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
507
|
+
* Detects the file type by checking magic bytes against the stream content.
|
|
508
|
+
*
|
|
509
|
+
* @param stream - The readable stream to check
|
|
510
|
+
* @param filename - The filename (used to get the extension)
|
|
511
|
+
* @returns File type information including MIME type, extension, and verification status
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```typescript
|
|
515
|
+
* const detector = alepha.inject(FileDetector);
|
|
516
|
+
* const stream = createReadStream('image.png');
|
|
517
|
+
* const result = await detector.detectFileType(stream, 'image.png');
|
|
518
|
+
* console.log(result.mimeType); // 'image/png'
|
|
519
|
+
* console.log(result.verified); // true if magic bytes match
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
389
522
|
detectFileType(stream: Readable, filename: string): Promise<FileTypeResult>;
|
|
390
523
|
/**
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
524
|
+
* Reads all bytes from a stream and returns the first N bytes along with a new stream containing all data.
|
|
525
|
+
* This approach reads the entire stream upfront to avoid complex async handling issues.
|
|
526
|
+
*
|
|
527
|
+
* @protected
|
|
528
|
+
*/
|
|
396
529
|
protected peekBytes(stream: Readable, numBytes: number): Promise<{
|
|
397
530
|
buffer: Buffer;
|
|
398
531
|
stream: Readable;
|
|
399
532
|
}>;
|
|
400
533
|
/**
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
534
|
+
* Checks if a buffer matches a magic byte signature.
|
|
535
|
+
*
|
|
536
|
+
* @protected
|
|
537
|
+
*/
|
|
405
538
|
protected matchesSignature(buffer: Buffer, signature: (number | null)[]): boolean;
|
|
406
539
|
}
|
|
407
540
|
//#endregion
|
|
@@ -434,212 +567,212 @@ declare class NodeFileSystemProvider implements FileSystemProvider {
|
|
|
434
567
|
protected detector: FileDetector;
|
|
435
568
|
join(...paths: string[]): string;
|
|
436
569
|
/**
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
570
|
+
* Creates a FileLike object from various sources.
|
|
571
|
+
*
|
|
572
|
+
* @param options - Options for creating the file
|
|
573
|
+
* @returns A FileLike object
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* ```typescript
|
|
577
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
578
|
+
*
|
|
579
|
+
* // From URL
|
|
580
|
+
* const file1 = fs.createFile({ url: "https://example.com/image.png" });
|
|
581
|
+
*
|
|
582
|
+
* // From Buffer
|
|
583
|
+
* const file2 = fs.createFile({
|
|
584
|
+
* buffer: Buffer.from("hello"),
|
|
585
|
+
* name: "hello.txt",
|
|
586
|
+
* type: "text/plain"
|
|
587
|
+
* });
|
|
588
|
+
*
|
|
589
|
+
* // From text
|
|
590
|
+
* const file3 = fs.createFile({ text: "Hello!", name: "greeting.txt" });
|
|
591
|
+
*
|
|
592
|
+
* // From stream with detection
|
|
593
|
+
* const stream = createReadStream("/path/to/file.png");
|
|
594
|
+
* const file4 = fs.createFile({ stream, name: "image.png" });
|
|
595
|
+
* ```
|
|
596
|
+
*/
|
|
464
597
|
createFile(options: CreateFileOptions): FileLike;
|
|
465
598
|
/**
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
599
|
+
* Removes a file or directory.
|
|
600
|
+
*
|
|
601
|
+
* @param path - The path to remove
|
|
602
|
+
* @param options - Remove options
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```typescript
|
|
606
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
607
|
+
*
|
|
608
|
+
* // Remove a file
|
|
609
|
+
* await fs.rm("/tmp/file.txt");
|
|
610
|
+
*
|
|
611
|
+
* // Remove a directory recursively
|
|
612
|
+
* await fs.rm("/tmp/mydir", { recursive: true });
|
|
613
|
+
*
|
|
614
|
+
* // Remove with force (no error if doesn't exist)
|
|
615
|
+
* await fs.rm("/tmp/maybe-exists.txt", { force: true });
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
485
618
|
rm(path: string, options?: RmOptions): Promise<void>;
|
|
486
619
|
/**
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
620
|
+
* Copies a file or directory.
|
|
621
|
+
*
|
|
622
|
+
* @param src - Source path
|
|
623
|
+
* @param dest - Destination path
|
|
624
|
+
* @param options - Copy options
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```typescript
|
|
628
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
629
|
+
*
|
|
630
|
+
* // Copy a file
|
|
631
|
+
* await fs.cp("/src/file.txt", "/dest/file.txt");
|
|
632
|
+
*
|
|
633
|
+
* // Copy a directory recursively
|
|
634
|
+
* await fs.cp("/src/dir", "/dest/dir", { recursive: true });
|
|
635
|
+
*
|
|
636
|
+
* // Copy with force (overwrite existing)
|
|
637
|
+
* await fs.cp("/src/file.txt", "/dest/file.txt", { force: true });
|
|
638
|
+
* ```
|
|
639
|
+
*/
|
|
507
640
|
cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
508
641
|
/**
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
642
|
+
* Moves/renames a file or directory.
|
|
643
|
+
*
|
|
644
|
+
* @param src - Source path
|
|
645
|
+
* @param dest - Destination path
|
|
646
|
+
*
|
|
647
|
+
* @example
|
|
648
|
+
* ```typescript
|
|
649
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
650
|
+
*
|
|
651
|
+
* // Move/rename a file
|
|
652
|
+
* await fs.mv("/old/path.txt", "/new/path.txt");
|
|
653
|
+
*
|
|
654
|
+
* // Move a directory
|
|
655
|
+
* await fs.mv("/old/dir", "/new/dir");
|
|
656
|
+
* ```
|
|
657
|
+
*/
|
|
525
658
|
mv(src: string, dest: string): Promise<void>;
|
|
526
659
|
/**
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
660
|
+
* Creates a directory.
|
|
661
|
+
*
|
|
662
|
+
* @param path - The directory path to create
|
|
663
|
+
* @param options - Mkdir options
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* ```typescript
|
|
667
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
668
|
+
*
|
|
669
|
+
* // Create a directory
|
|
670
|
+
* await fs.mkdir("/tmp/mydir");
|
|
671
|
+
*
|
|
672
|
+
* // Create nested directories
|
|
673
|
+
* await fs.mkdir("/tmp/path/to/dir", { recursive: true });
|
|
674
|
+
*
|
|
675
|
+
* // Create with specific permissions
|
|
676
|
+
* await fs.mkdir("/tmp/mydir", { mode: 0o755 });
|
|
677
|
+
* ```
|
|
678
|
+
*/
|
|
546
679
|
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
547
680
|
/**
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
681
|
+
* Lists files in a directory.
|
|
682
|
+
*
|
|
683
|
+
* @param path - The directory path to list
|
|
684
|
+
* @param options - List options
|
|
685
|
+
* @returns Array of filenames
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* ```typescript
|
|
689
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
690
|
+
*
|
|
691
|
+
* // List files in a directory
|
|
692
|
+
* const files = await fs.ls("/tmp");
|
|
693
|
+
* console.log(files); // ["file1.txt", "file2.txt", "subdir"]
|
|
694
|
+
*
|
|
695
|
+
* // List with hidden files
|
|
696
|
+
* const allFiles = await fs.ls("/tmp", { hidden: true });
|
|
697
|
+
*
|
|
698
|
+
* // List recursively
|
|
699
|
+
* const allFilesRecursive = await fs.ls("/tmp", { recursive: true });
|
|
700
|
+
* ```
|
|
701
|
+
*/
|
|
569
702
|
ls(path: string, options?: LsOptions): Promise<string[]>;
|
|
570
703
|
/**
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
704
|
+
* Checks if a file or directory exists.
|
|
705
|
+
*
|
|
706
|
+
* @param path - The path to check
|
|
707
|
+
* @returns True if the path exists, false otherwise
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```typescript
|
|
711
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
712
|
+
*
|
|
713
|
+
* if (await fs.exists("/tmp/file.txt")) {
|
|
714
|
+
* console.log("File exists");
|
|
715
|
+
* }
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
585
718
|
exists(path: string): Promise<boolean>;
|
|
586
719
|
/**
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
720
|
+
* Reads the content of a file.
|
|
721
|
+
*
|
|
722
|
+
* @param path - The file path to read
|
|
723
|
+
* @returns The file content as a Buffer
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* ```typescript
|
|
727
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
728
|
+
*
|
|
729
|
+
* const buffer = await fs.readFile("/tmp/file.txt");
|
|
730
|
+
* console.log(buffer.toString("utf-8"));
|
|
731
|
+
* ```
|
|
732
|
+
*/
|
|
600
733
|
readFile(path: string): Promise<Buffer>;
|
|
601
734
|
/**
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
735
|
+
* Writes data to a file.
|
|
736
|
+
*
|
|
737
|
+
* @param path - The file path to write to
|
|
738
|
+
* @param data - The data to write (Buffer or string)
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
* ```typescript
|
|
742
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
743
|
+
*
|
|
744
|
+
* // Write string
|
|
745
|
+
* await fs.writeFile("/tmp/file.txt", "Hello, world!");
|
|
746
|
+
*
|
|
747
|
+
* // Write Buffer
|
|
748
|
+
* await fs.writeFile("/tmp/file.bin", Buffer.from([0x01, 0x02, 0x03]));
|
|
749
|
+
* ```
|
|
750
|
+
*/
|
|
618
751
|
writeFile(path: string, data: Uint8Array | Buffer | string | FileLike): Promise<void>;
|
|
619
752
|
/**
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
753
|
+
* Creates a FileLike object from a Web File.
|
|
754
|
+
*
|
|
755
|
+
* @protected
|
|
756
|
+
*/
|
|
624
757
|
protected createFileFromWebFile(source: File, options?: {
|
|
625
758
|
type?: string;
|
|
626
759
|
name?: string;
|
|
627
760
|
size?: number;
|
|
628
761
|
}): FileLike;
|
|
629
762
|
/**
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
763
|
+
* Creates a FileLike object from a Buffer.
|
|
764
|
+
*
|
|
765
|
+
* @protected
|
|
766
|
+
*/
|
|
634
767
|
protected createFileFromBuffer(source: Buffer, options?: {
|
|
635
768
|
type?: string;
|
|
636
769
|
name?: string;
|
|
637
770
|
}): FileLike;
|
|
638
771
|
/**
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
772
|
+
* Creates a FileLike object from a stream.
|
|
773
|
+
*
|
|
774
|
+
* @protected
|
|
775
|
+
*/
|
|
643
776
|
protected createFileFromStream(source: StreamLike, options?: {
|
|
644
777
|
type?: string;
|
|
645
778
|
name?: string;
|
|
@@ -648,43 +781,43 @@ declare class NodeFileSystemProvider implements FileSystemProvider {
|
|
|
648
781
|
_buffer: null | Buffer;
|
|
649
782
|
};
|
|
650
783
|
/**
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
784
|
+
* Creates a FileLike object from a URL.
|
|
785
|
+
*
|
|
786
|
+
* @protected
|
|
787
|
+
*/
|
|
655
788
|
protected createFileFromUrl(url: string, options?: {
|
|
656
789
|
type?: string;
|
|
657
790
|
name?: string;
|
|
658
791
|
}): FileLike;
|
|
659
792
|
/**
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
793
|
+
* Gets a streaming response from a URL.
|
|
794
|
+
*
|
|
795
|
+
* @protected
|
|
796
|
+
*/
|
|
664
797
|
protected getStreamingResponse(url: string): Readable;
|
|
665
798
|
/**
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
799
|
+
* Loads data from a URL.
|
|
800
|
+
*
|
|
801
|
+
* @protected
|
|
802
|
+
*/
|
|
670
803
|
protected loadFromUrl(url: string): Promise<Buffer>;
|
|
671
804
|
/**
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
805
|
+
* Creates a stream from a URL.
|
|
806
|
+
*
|
|
807
|
+
* @protected
|
|
808
|
+
*/
|
|
676
809
|
protected createStreamFromUrl(url: string): Readable;
|
|
677
810
|
/**
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
811
|
+
* Converts a stream-like object to a Buffer.
|
|
812
|
+
*
|
|
813
|
+
* @protected
|
|
814
|
+
*/
|
|
682
815
|
protected streamToBuffer(streamLike: StreamLike): Promise<Buffer>;
|
|
683
816
|
/**
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
817
|
+
* Converts a Node.js Buffer to an ArrayBuffer.
|
|
818
|
+
*
|
|
819
|
+
* @protected
|
|
820
|
+
*/
|
|
688
821
|
protected bufferToArrayBuffer(buffer: Buffer): ArrayBuffer;
|
|
689
822
|
}
|
|
690
823
|
//#endregion
|
|
@@ -702,5 +835,5 @@ declare class NodeFileSystemProvider implements FileSystemProvider {
|
|
|
702
835
|
*/
|
|
703
836
|
declare const AlephaFile: alepha0.Service<alepha0.Module>;
|
|
704
837
|
//#endregion
|
|
705
|
-
export { AlephaFile, CpOptions, CreateFileFromArrayBufferOptions, CreateFileFromBufferOptions, CreateFileFromPathOptions, CreateFileFromResponseOptions, CreateFileFromStreamOptions, CreateFileFromTextOptions, CreateFileFromUrlOptions, CreateFileFromWebFileOptions, CreateFileOptions, FileDetector, FileSystemProvider, FileTypeResult, LsOptions, MkdirOptions, NodeFileSystemProvider, RmOptions };
|
|
838
|
+
export { AlephaFile, CpOptions, CreateFileFromArrayBufferOptions, CreateFileFromBufferOptions, CreateFileFromPathOptions, CreateFileFromResponseOptions, CreateFileFromStreamOptions, CreateFileFromTextOptions, CreateFileFromUrlOptions, CreateFileFromWebFileOptions, CreateFileOptions, FileDetector, FileError, FileSystemProvider, FileTypeResult, LsOptions, MemoryFileSystemProvider, MemoryFileSystemProviderOptions, MkdirOptions, NodeFileSystemProvider, RmOptions };
|
|
706
839
|
//# sourceMappingURL=index.d.ts.map
|