alepha 0.21.2 → 0.22.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 +0 -1
- package/dist/api/audits/index.browser.js.map +1 -1
- package/dist/api/audits/index.d.ts +393 -403
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +25 -56
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.browser.js +31 -1
- package/dist/api/files/index.browser.js.map +1 -1
- package/dist/api/files/index.d.ts +313 -208
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +152 -42
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.browser.js +2 -2
- package/dist/api/jobs/index.browser.js.map +1 -1
- package/dist/api/jobs/index.d.ts +289 -292
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +39 -33
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/keys/index.d.ts +211 -216
- package/dist/api/keys/index.d.ts.map +1 -1
- package/dist/api/keys/index.js.map +1 -1
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +188 -195
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/oauth/index.d.ts +71 -76
- package/dist/api/oauth/index.d.ts.map +1 -1
- package/dist/api/oauth/index.js.map +1 -1
- package/dist/api/organizations/index.browser.js.map +1 -1
- package/dist/api/organizations/index.d.ts +104 -109
- package/dist/api/organizations/index.d.ts.map +1 -1
- package/dist/api/organizations/index.js.map +1 -1
- package/dist/api/parameters/index.browser.js +43 -16
- package/dist/api/parameters/index.browser.js.map +1 -1
- package/dist/api/parameters/index.d.ts +488 -344
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +175 -35
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/payments/index.d.ts +396 -402
- package/dist/api/payments/index.d.ts.map +1 -1
- package/dist/api/payments/index.js.map +1 -1
- package/dist/api/subscriptions/index.d.ts +644 -652
- package/dist/api/subscriptions/index.d.ts.map +1 -1
- package/dist/api/subscriptions/index.js +1 -1
- package/dist/api/subscriptions/index.js.map +1 -1
- package/dist/api/users/index.browser.js +7 -0
- package/dist/api/users/index.browser.js.map +1 -1
- package/dist/api/users/index.d.ts +1073 -1006
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +283 -61
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.browser.js.map +1 -1
- package/dist/api/verifications/index.d.ts +134 -140
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/api/verifications/index.js.map +1 -1
- package/dist/background/index.d.ts +95 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +121 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/index.workerd.js +110 -0
- package/dist/background/index.workerd.js.map +1 -0
- package/dist/batch/index.d.ts +5 -7
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js.map +1 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/bucket/index.d.ts +76 -54
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/bucket/index.js +58 -11
- package/dist/bucket/index.js.map +1 -1
- package/dist/bucket/index.workerd.js +200 -5
- package/dist/bucket/index.workerd.js.map +1 -1
- package/dist/cache/core/index.d.ts +7 -10
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cache/core/index.workerd.js.map +1 -1
- package/dist/cache/database/index.d.ts +22 -26
- package/dist/cache/database/index.d.ts.map +1 -1
- package/dist/cache/database/index.js.map +1 -1
- package/dist/cache/redis/index.d.ts +4 -7
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cache/redis/index.js.map +1 -1
- package/dist/captcha/index.d.ts +3 -6
- package/dist/captcha/index.d.ts.map +1 -1
- package/dist/captcha/index.js.map +1 -1
- package/dist/cli/config/index.d.ts.map +1 -1
- package/dist/cli/config/index.js.map +1 -1
- package/dist/cli/core/index.d.ts +417 -214
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +325 -563
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/devtools/index.d.ts +3 -5
- package/dist/cli/devtools/index.d.ts.map +1 -1
- package/dist/cli/devtools/index.js.map +1 -1
- package/dist/cli/i18n/index.d.ts +8 -12
- package/dist/cli/i18n/index.d.ts.map +1 -1
- package/dist/cli/i18n/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +126 -1342
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +136 -2374
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/cli/platform-lib/index.d.ts +1446 -0
- package/dist/cli/platform-lib/index.d.ts.map +1 -0
- package/dist/cli/platform-lib/index.js +2597 -0
- package/dist/cli/platform-lib/index.js.map +1 -0
- package/dist/cli/vendor/index.d.ts +17 -21
- package/dist/cli/vendor/index.d.ts.map +1 -1
- package/dist/cli/vendor/index.js.map +1 -1
- package/dist/command/index.d.ts +21 -20
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +39 -10
- package/dist/command/index.js.map +1 -1
- package/dist/{containers → container}/core/index.d.ts +13 -15
- package/dist/container/core/index.d.ts.map +1 -0
- package/dist/{containers → container}/core/index.js +23 -14
- package/dist/container/core/index.js.map +1 -0
- package/dist/{containers → container}/core/index.workerd.js +37 -22
- package/dist/container/core/index.workerd.js.map +1 -0
- package/dist/core/index.browser.js +27 -1
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +48 -24
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +27 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +27 -1
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js +27 -1
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/crypto/index.browser.js.map +1 -1
- package/dist/crypto/index.d.ts +5 -8
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js.map +1 -1
- package/dist/datetime/index.d.ts +3 -4
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/brevo/index.d.ts +2 -4
- package/dist/email/brevo/index.d.ts.map +1 -1
- package/dist/email/brevo/index.js.map +1 -1
- package/dist/email/cloudflare/index.d.ts +20 -7
- package/dist/email/cloudflare/index.d.ts.map +1 -1
- package/dist/email/cloudflare/index.js +46 -9
- package/dist/email/cloudflare/index.js.map +1 -1
- package/dist/email/core/index.d.ts +6 -9
- package/dist/email/core/index.d.ts.map +1 -1
- package/dist/email/core/index.js.map +1 -1
- package/dist/email/core/index.workerd.js.map +1 -1
- package/dist/email/smtp/index.d.ts +10 -13
- package/dist/email/smtp/index.d.ts.map +1 -1
- package/dist/email/smtp/index.js +107 -32
- package/dist/email/smtp/index.js.map +1 -1
- package/dist/fake/index.d.ts +1 -2
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +9 -14
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/core/index.js.map +1 -1
- package/dist/lock/redis/index.d.ts +2 -4
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/lock/redis/index.js.map +1 -1
- package/dist/logger/index.d.ts +105 -76
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +196 -174
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +16 -20
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/core/index.browser.js.map +1 -1
- package/dist/orm/core/index.bun.js +19 -1
- package/dist/orm/core/index.bun.js.map +1 -1
- package/dist/orm/core/index.d.ts +76 -62
- package/dist/orm/core/index.d.ts.map +1 -1
- package/dist/orm/core/index.js +20 -2
- package/dist/orm/core/index.js.map +1 -1
- package/dist/orm/postgres/index.bun.js.map +1 -1
- package/dist/orm/postgres/index.d.ts +28 -20
- package/dist/orm/postgres/index.d.ts.map +1 -1
- package/dist/orm/postgres/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +12 -15
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/core/index.js.map +1 -1
- package/dist/queue/core/index.workerd.js.map +1 -1
- package/dist/queue/redis/index.d.ts +3 -5
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/queue/redis/index.js.map +1 -1
- package/dist/react/auth/index.browser.js +9 -2
- package/dist/react/auth/index.browser.js.map +1 -1
- package/dist/react/auth/index.d.ts +14 -9
- package/dist/react/auth/index.d.ts.map +1 -1
- package/dist/react/auth/index.js +9 -2
- package/dist/react/auth/index.js.map +1 -1
- package/dist/react/core/index.d.ts +7 -8
- package/dist/react/core/index.d.ts.map +1 -1
- package/dist/react/core/index.js +6 -3
- package/dist/react/core/index.js.map +1 -1
- package/dist/react/form/index.d.ts +2 -4
- package/dist/react/form/index.d.ts.map +1 -1
- package/dist/react/form/index.js.map +1 -1
- package/dist/react/head/index.browser.js.map +1 -1
- package/dist/react/head/index.d.ts +2 -4
- package/dist/react/head/index.d.ts.map +1 -1
- package/dist/react/head/index.js.map +1 -1
- package/dist/react/i18n/index.d.ts +47 -11
- package/dist/react/i18n/index.d.ts.map +1 -1
- package/dist/react/i18n/index.js +33 -1
- package/dist/react/i18n/index.js.map +1 -1
- package/dist/react/intro/index.d.ts +1 -2
- package/dist/react/intro/index.d.ts.map +1 -1
- package/dist/react/intro/index.js +2 -2
- package/dist/react/intro/index.js.map +1 -1
- package/dist/react/router/index.browser.js +65 -19
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +327 -222
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +65 -29
- package/dist/react/router/index.js.map +1 -1
- package/dist/react/testing/index.d.ts +1 -2
- package/dist/react/testing/index.d.ts.map +1 -1
- package/dist/react/testing/index.js +16 -17
- package/dist/react/testing/index.js.map +1 -1
- package/dist/react/ui/index.d.ts +20 -25
- package/dist/react/ui/index.d.ts.map +1 -1
- package/dist/react/ui/index.js.map +1 -1
- package/dist/redis/index.bun.js.map +1 -1
- package/dist/redis/index.d.ts +17 -19
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.d.ts +2 -4
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/retry/index.js.map +1 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +10 -13
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/scheduler/index.workerd.js.map +1 -1
- package/dist/security/index.browser.js.map +1 -1
- package/dist/security/index.d.ts +45 -48
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.browser.js.map +1 -1
- package/dist/server/auth/index.d.ts +167 -172
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +4 -8
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cookies/index.browser.js.map +1 -1
- package/dist/server/cookies/index.d.ts +5 -7
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +88 -73
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +19 -0
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +11 -14
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/cors/index.js.map +1 -1
- package/dist/server/etag/index.d.ts +6 -9
- package/dist/server/etag/index.d.ts.map +1 -1
- package/dist/server/etag/index.js.map +1 -1
- package/dist/server/health/index.d.ts +18 -21
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/health/index.js.map +1 -1
- package/dist/server/links/index.browser.js +2 -0
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +63 -67
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +2 -0
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +5 -7
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/proxy/index.d.ts +3 -5
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/proxy/index.js.map +1 -1
- package/dist/server/rate-limit/index.d.ts +10 -13
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/static/index.d.ts +3 -5
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +5 -8
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +3 -5
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js.map +1 -1
- package/dist/system/index.d.ts +2 -4
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js.map +1 -1
- package/dist/system/index.workerd.js.map +1 -1
- package/dist/topic/core/index.d.ts +4 -6
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/core/index.js.map +1 -1
- package/dist/topic/redis/index.d.ts +5 -8
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/topic/redis/index.js.map +1 -1
- package/package.json +45 -22
- package/src/api/audits/__tests__/AuditService.spec.ts +18 -110
- package/src/api/audits/controllers/AdminAuditController.ts +14 -0
- package/src/api/audits/services/AuditService.ts +21 -88
- package/src/api/files/__tests__/FileService.spec.ts +207 -2
- package/src/api/files/index.ts +3 -0
- package/src/api/files/schemas/fileCreatorSummarySchema.ts +22 -0
- package/src/api/files/schemas/fileResourceSchema.ts +10 -1
- package/src/api/files/services/FileService.ts +170 -72
- package/src/api/jobs/__tests__/$job.spec.ts +24 -1
- package/src/api/jobs/index.ts +4 -3
- package/src/api/jobs/primitives/$job.ts +7 -3
- package/src/api/jobs/providers/DirectJobDispatcher.ts +17 -36
- package/src/api/jobs/providers/JobProvider.ts +53 -24
- package/src/api/jobs/schemas/jobConfigAtom.ts +1 -1
- package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +4 -1
- package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +3 -1
- package/src/api/parameters/__tests__/$parameter.spec.ts +19 -2
- package/src/api/parameters/audits/ParameterAudits.ts +17 -0
- package/src/api/parameters/controllers/AdminParameterController.ts +95 -19
- package/src/api/parameters/index.ts +3 -0
- package/src/api/parameters/schemas/activateParameterBodySchema.ts +3 -3
- package/src/api/parameters/schemas/createParameterVersionBodySchema.ts +3 -2
- package/src/api/parameters/schemas/parameterCreatorSummarySchema.ts +25 -0
- package/src/api/parameters/schemas/parameterResponseSchema.ts +5 -0
- package/src/api/parameters/schemas/rollbackParameterBodySchema.ts +4 -2
- package/src/api/parameters/services/ParameterProvider.ts +69 -6
- package/src/api/subscriptions/jobs/SubscriptionJobs.ts +1 -1
- package/src/api/users/__tests__/AdminSessionController.spec.ts +37 -0
- package/src/api/users/audits/SessionAudits.ts +33 -0
- package/src/api/users/audits/UserAudits.ts +19 -43
- package/src/api/users/controllers/AdminUserController.ts +66 -1
- package/src/api/users/entities/sessions.ts +6 -0
- package/src/api/users/entities/users.ts +2 -0
- package/src/api/users/index.ts +9 -1
- package/src/api/users/primitives/$realm.ts +3 -0
- package/src/api/users/schemas/sessionResourceSchema.ts +16 -0
- package/src/api/users/schemas/updateUserSchema.ts +1 -8
- package/src/api/users/schemas/userQuerySchema.ts +7 -0
- package/src/api/users/services/CredentialService.ts +15 -6
- package/src/api/users/services/IdentityService.ts +2 -1
- package/src/api/users/services/RegistrationService.ts +2 -1
- package/src/api/users/services/SessionCrudService.ts +19 -2
- package/src/api/users/services/SessionService.ts +39 -19
- package/src/api/users/services/UserService.ts +106 -8
- package/src/background/__tests__/BackgroundTaskProvider.spec.ts +96 -0
- package/src/background/index.ts +37 -0
- package/src/background/index.workerd.ts +28 -0
- package/src/background/providers/BackgroundTaskProvider.ts +70 -0
- package/src/background/providers/WorkerdBackgroundTaskProvider.ts +43 -0
- package/src/bucket/__tests__/$bucket.spec.ts +18 -0
- package/src/bucket/__tests__/LocalFileStorageProvider.spec.ts +5 -0
- package/src/bucket/__tests__/MemoryFileStorageProvider.spec.ts +5 -0
- package/src/bucket/__tests__/NodeS3BucketProvider.spec.ts +23 -4
- package/src/bucket/__tests__/shared.ts +30 -0
- package/src/bucket/index.ts +5 -5
- package/src/bucket/index.workerd.ts +11 -4
- package/src/bucket/primitives/$bucket.ts +27 -0
- package/src/bucket/providers/FileStorageProvider.ts +13 -0
- package/src/bucket/providers/LocalFileStorageProvider.ts +17 -1
- package/src/bucket/providers/MemoryFileStorageProvider.ts +7 -0
- package/src/bucket/providers/{CloudflareR2Provider.ts → R2FileStorageProvider.ts} +10 -1
- package/src/bucket/providers/{NodeS3BucketProvider.ts → S3FileStorageProvider.ts} +27 -5
- package/src/cli/core/__tests__/BuildDockerTask.spec.ts +25 -1
- package/src/cli/core/__tests__/init.spec.ts +0 -219
- package/src/cli/core/commands/__tests__/BuildCommand.spec.ts +43 -0
- package/src/cli/core/commands/build.ts +108 -30
- package/src/cli/core/commands/init.ts +0 -12
- package/src/cli/core/commands/pack.ts +133 -0
- package/src/cli/core/index.ts +3 -0
- package/src/cli/core/providers/ViteDevServerProvider.ts +40 -16
- package/src/cli/core/services/PackageManagerUtils.ts +0 -16
- package/src/cli/core/services/ProjectScaffolder.ts +29 -291
- package/src/cli/core/tasks/BuildCloudflareTask.ts +353 -47
- package/src/cli/core/tasks/BuildDockerTask.ts +33 -3
- package/src/cli/core/tasks/BuildTask.ts +34 -0
- package/src/cli/core/templates/apiIndexTs.ts +1 -22
- package/src/cli/core/templates/mainCss.ts +0 -1
- package/src/cli/core/templates/webAppRouterTs.ts +0 -99
- package/src/cli/core/templates/webIndexTs.ts +1 -22
- package/src/cli/platform/__tests__/SecretsCommand.spec.ts +5 -3
- package/src/cli/platform/commands/SecretsCommand.ts +8 -6
- package/src/cli/platform/commands/platform.ts +192 -46
- package/src/cli/platform/index.ts +12 -52
- package/src/cli/{platform → platform-lib}/__tests__/CloudflareAdapter.spec.ts +426 -169
- package/src/cli/{platform → platform-lib}/__tests__/NamingService.spec.ts +91 -4
- package/src/cli/{platform → platform-lib}/__tests__/VercelAdapter.spec.ts +56 -85
- package/src/cli/{platform → platform-lib}/adapters/CloudflareAdapter.ts +402 -165
- package/src/cli/{platform → platform-lib}/adapters/PlatformAdapter.ts +62 -35
- package/src/cli/{platform → platform-lib}/adapters/VercelAdapter.ts +6 -10
- package/src/cli/{platform → platform-lib}/atoms/platformOptions.ts +34 -1
- package/src/cli/platform-lib/index.ts +67 -0
- package/src/cli/platform-lib/services/NamingService.ts +136 -0
- package/src/cli/{platform → platform-lib}/services/PlatformInspector.ts +60 -13
- package/src/cli/{platform → platform-lib}/services/PlatformOrchestrator.ts +54 -43
- package/src/cli/{platform → platform-lib}/services/WranglerApi.ts +4 -2
- package/src/command/__tests__/Runner.spec.ts +20 -0
- package/src/command/helpers/EnvUtils.ts +19 -3
- package/src/command/helpers/Runner.ts +12 -2
- package/src/command/providers/CliProvider.ts +34 -1
- package/src/{containers → container}/core/__tests__/$container.spec.ts +5 -5
- package/src/{containers → container}/core/index.ts +4 -4
- package/src/{containers → container}/core/index.workerd.ts +19 -3
- package/src/{containers → container}/core/primitives/$container.ts +1 -1
- package/src/{containers → container}/core/providers/CloudflareContainerProvider.ts +17 -19
- package/src/{containers → container}/core/providers/ContainerProvider.ts +16 -2
- package/src/{containers → container}/core/providers/MockContainerProvider.ts +1 -1
- package/src/core/Alepha.ts +49 -1
- package/src/core/__tests__/$env.spec.ts +42 -0
- package/src/core/__tests__/dump.spec.ts +47 -0
- package/src/email/cloudflare/__tests__/CloudflareEmailProvider.spec.ts +42 -10
- package/src/email/cloudflare/index.ts +14 -5
- package/src/email/cloudflare/providers/CloudflareEmailProvider.ts +54 -9
- package/src/logger/__tests__/Logger.spec.ts +55 -0
- package/src/logger/index.ts +13 -0
- package/src/logger/services/Logger.ts +31 -1
- package/src/orm/__tests__/orm-showcase-tests.ts +27 -0
- package/src/orm/__tests__/orm-showcase.spec.ts +12 -0
- package/src/orm/core/interfaces/PgQuery.ts +4 -1
- package/src/orm/core/services/Repository.ts +27 -11
- package/src/react/auth/hooks/useAuth.ts +10 -5
- package/src/react/core/__tests__/useQuery.browser.spec.tsx +25 -0
- package/src/react/core/hooks/useAction.ts +14 -3
- package/src/react/core/hooks/useQuery.ts +24 -4
- package/src/react/i18n/components/Translate.tsx +47 -0
- package/src/react/i18n/index.ts +2 -0
- package/src/react/intro/components/GettingStartedAdminSlide.tsx +2 -2
- package/src/react/router/__tests__/$page.spec.tsx +3 -2
- package/src/react/router/__tests__/page-can.spec.ts +18 -13
- package/src/react/router/hooks/useQueryParams.ts +114 -14
- package/src/react/router/primitives/$page.ts +85 -4
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +3 -7
- package/src/react/router/providers/ReactServerProvider.ts +4 -13
- package/src/react/ui/services/SchemaControl.ts +3 -4
- package/src/server/core/providers/ServerMultipartProvider.ts +19 -0
- package/src/server/links/providers/LinkProvider.ts +10 -0
- package/dist/containers/core/index.d.ts.map +0 -1
- package/dist/containers/core/index.js.map +0 -1
- package/dist/containers/core/index.workerd.js.map +0 -1
- package/src/cli/core/templates/componentsJsonTs.ts +0 -39
- package/src/cli/core/templates/saasAdminLayoutTsx.ts +0 -77
- package/src/cli/core/templates/saasAdminPagesTsx.ts +0 -26
- package/src/cli/core/templates/saasAuthLayoutTsx.ts +0 -22
- package/src/cli/core/templates/saasAuthPagesTsx.ts +0 -62
- package/src/cli/core/templates/saasRealmProviderTs.ts +0 -52
- package/src/cli/platform/services/NamingService.ts +0 -54
- /package/dist/orm/core/{chunk-o8xxKEmq.js → chunk-B4FMCO8f.js} +0 -0
- /package/dist/react/testing/{chunk-6Ep1yQYe.js → chunk-BpyX8vjI.js} +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/GitHubSecretStore.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/PlatformCacheProvider.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/PlatformInspector.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/PlatformOrchestrator.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/SecretFilterService.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/detectResources.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/GitHubSecretStore.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/MemorySecretStore.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/PlatformCacheProvider.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/SecretStoreProvider.ts +0 -0
- /package/src/cli/{platform → platform-lib}/schemas/cloudflare.ts +0 -0
- /package/src/cli/{platform → platform-lib}/schemas/platform.ts +0 -0
- /package/src/cli/{platform → platform-lib}/schemas/vercel.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/CloudflareApi.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/SecretFilterService.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/VercelApi.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/VercelCli.ts +0 -0
- /package/src/{containers → container}/core/interfaces/ContainerOptions.ts +0 -0
- /package/src/{containers → container}/core/providers/NodeContainerProvider.ts +0 -0
package/dist/system/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["nodeJoin","nodeBasename","fsRm","fsCp","fsMkdir","fsReadFile","fsWriteFile"],"sources":["../../src/system/providers/FileSystemProvider.ts","../../src/system/providers/NodeShellProvider.ts","../../src/system/providers/BunShellProvider.ts","../../src/system/providers/MemoryFileSystemProvider.ts","../../src/system/providers/MemoryShellProvider.ts","../../src/system/services/FileDetector.ts","../../src/system/providers/NodeFileSystemProvider.ts","../../src/system/providers/ShellProvider.ts","../../src/system/providers/WorkerdFileSystemProvider.ts","../../src/system/errors/FileError.ts","../../src/system/index.ts"],"sourcesContent":["import type { FileLike, StreamLike } from \"alepha\";\n\n/**\n * Options for creating a file from a URL\n */\nexport interface CreateFileFromUrlOptions {\n /**\n * The URL to load the file from (file://, http://, or https://)\n */\n url: string;\n /**\n * The MIME type of the file (optional, will be detected from filename if not provided)\n */\n type?: string;\n /**\n * The name of the file (optional, will be extracted from URL if not provided)\n */\n name?: string;\n}\n\n/**\n * Options for creating a file from a path (URL with file:// scheme)\n */\nexport interface CreateFileFromPathOptions {\n /**\n * The path to the file on the local filesystem\n */\n path: string;\n /**\n * The MIME type of the file (optional, will be detected from filename if not provided)\n */\n type?: string;\n /**\n * The name of the file (optional, will be extracted from URL if not provided)\n */\n name?: string;\n}\n\n/**\n * Options for creating a file from a Buffer\n */\nexport interface CreateFileFromBufferOptions {\n /**\n * The Buffer containing the file data\n */\n buffer: Buffer;\n /**\n * The MIME type of the file (optional, will be detected from name if not provided)\n */\n type?: string;\n /**\n * The name of the file (required for proper content type detection)\n */\n name?: string;\n}\n\n/**\n * Options for creating a file from a stream\n */\nexport interface CreateFileFromStreamOptions {\n /**\n * The readable stream containing the file data\n */\n stream: StreamLike;\n /**\n * The MIME type of the file (optional, will be detected from name if not provided)\n */\n type?: string;\n /**\n * The name of the file (required for proper content type detection)\n */\n name?: string;\n /**\n * The size of the file in bytes (optional)\n */\n size?: number;\n}\n\n/**\n * Options for creating a file from text content\n */\nexport interface CreateFileFromTextOptions {\n /**\n * The text content to create the file from\n */\n text: string;\n /**\n * The MIME type of the file (default: text/plain)\n */\n type?: string;\n /**\n * The name of the file (default: \"file.txt\")\n */\n name?: string;\n}\n\nexport interface CreateFileFromResponseOptions {\n /**\n * The Response object containing the file data\n */\n response: Response;\n /**\n * Override the name (optional, uses filename from Content-Disposition header if not provided)\n */\n name?: string;\n /**\n * Override the MIME type (optional, uses file.type if not provided)\n */\n type?: string;\n}\n\n/**\n * Options for creating a file from a Web File object\n */\nexport interface CreateFileFromWebFileOptions {\n /**\n * The Web File object\n */\n file: File;\n /**\n * Override the MIME type (optional, uses file.type if not provided)\n */\n type?: string;\n /**\n * Override the name (optional, uses file.name if not provided)\n */\n name?: string;\n /**\n * Override the size (optional, uses file.size if not provided)\n */\n size?: number;\n}\n\n/**\n * Options for creating a file from an ArrayBuffer\n */\nexport interface CreateFileFromArrayBufferOptions {\n /**\n * The ArrayBuffer containing the file data\n */\n arrayBuffer: ArrayBuffer;\n /**\n * The MIME type of the file (optional, will be detected from name if not provided)\n */\n type?: string;\n /**\n * The name of the file (required for proper content type detection)\n */\n name?: string;\n}\n\n/**\n * Union type for all createFile options\n */\nexport type CreateFileOptions =\n | CreateFileFromUrlOptions\n | CreateFileFromPathOptions\n | CreateFileFromBufferOptions\n | CreateFileFromStreamOptions\n | CreateFileFromTextOptions\n | CreateFileFromWebFileOptions\n | CreateFileFromResponseOptions\n | CreateFileFromArrayBufferOptions;\n\n/**\n * Options for rm (remove) operation\n */\nexport interface RmOptions {\n /**\n * If true, removes directories and their contents recursively\n */\n recursive?: boolean;\n /**\n * If true, no error will be thrown if the path does not exist\n */\n force?: boolean;\n}\n\n/**\n * Options for cp (copy) operation\n */\nexport interface CpOptions {\n /**\n * Copy directories recursively.\n *\n * @default true\n */\n recursive?: boolean;\n /**\n * If true, overwrite existing destination\n */\n force?: boolean;\n}\n\n/**\n * Options for mkdir operation\n */\nexport interface MkdirOptions {\n /**\n * If true, creates parent directories as needed\n *\n * @default true\n */\n recursive?: boolean;\n /**\n * If true, does not throw an error if the directory already exists\n *\n * @default true\n */\n force?: boolean;\n /**\n * File mode (permission and sticky bits)\n */\n mode?: number;\n}\n\n/**\n * Options for ls (list) operation\n */\nexport interface LsOptions {\n /**\n * If true, list contents of directories recursively\n */\n recursive?: boolean;\n /**\n * If true, include hidden files (starting with .)\n */\n hidden?: boolean;\n}\n\n/**\n * FileSystem interface providing utilities for working with files.\n */\nexport abstract class FileSystemProvider {\n /**\n * Joins multiple path segments into a single path.\n *\n * @param paths - The path segments to join\n * @returns The joined path\n */\n abstract join(...paths: string[]): string;\n\n /**\n * Creates a FileLike object from various sources.\n *\n * @param options - Options for creating the file\n * @returns A FileLike object\n */\n abstract createFile(options: CreateFileOptions): FileLike;\n\n /**\n * Removes a file or directory.\n *\n * @param path - The path to remove\n * @param options - Remove options\n */\n abstract rm(path: string, options?: RmOptions): Promise<void>;\n\n /**\n * Copies a file or directory.\n *\n * @param src - Source path\n * @param dest - Destination path\n * @param options - Copy options\n */\n abstract cp(src: string, dest: string, options?: CpOptions): Promise<void>;\n\n /**\n * Moves/renames a file or directory.\n *\n * @param src - Source path\n * @param dest - Destination path\n */\n abstract mv(src: string, dest: string): Promise<void>;\n\n /**\n * Creates a directory.\n *\n * @param path - The directory path to create\n * @param options - Mkdir options\n */\n abstract mkdir(path: string, options?: MkdirOptions): Promise<void>;\n\n /**\n * Lists files in a directory.\n *\n * @param path - The directory path to list\n * @param options - List options\n * @returns Array of filenames\n */\n abstract ls(path: string, options?: LsOptions): Promise<string[]>;\n\n /**\n * Checks if a file or directory exists.\n *\n * @param path - The path to check\n * @returns True if the path exists, false otherwise\n */\n abstract exists(path: string): Promise<boolean>;\n\n /**\n * Reads the content of a file.\n *\n * @param path - The file path to read\n * @returns The file content as a Buffer\n */\n abstract readFile(path: string): Promise<Buffer>;\n\n /**\n * Writes data to a file.\n *\n * @param path - The file path to write to\n * @param data - The data to write (Buffer or string)\n */\n abstract writeFile(\n path: string,\n data: Uint8Array | Buffer | string | FileLike,\n ): Promise<void>;\n\n /**\n * Reads the content of a file as a string.\n *\n * @param path - The file path to read\n * @returns The file content as a string\n */\n abstract readTextFile(path: string): Promise<string>;\n\n /**\n * Reads the content of a file as JSON.\n *\n * @param path - The file path to read\n * @returns The parsed JSON content\n */\n abstract readJsonFile<T = unknown>(path: string): Promise<T>;\n}\n","import { exec, spawn } from \"node:child_process\";\nimport { $inject, AlephaError } from \"alepha\";\nimport { $logger } from \"alepha/logger\";\nimport { FileSystemProvider } from \"./FileSystemProvider.ts\";\nimport type { ShellProvider, ShellRunOptions } from \"./ShellProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Node.js implementation of ShellProvider.\n *\n * Executes shell commands using Node.js child_process module.\n * Supports binary resolution from node_modules/.bin for local packages.\n */\nexport class NodeShellProvider implements ShellProvider {\n protected readonly log = $logger();\n protected readonly fs = $inject(FileSystemProvider);\n\n /**\n * Run a shell command or binary.\n */\n public async run(\n command: string,\n options: ShellRunOptions = {},\n ): Promise<string> {\n const { resolve = false, capture = false, root, env } = options;\n const cwd = root ?? process.cwd();\n\n this.log.debug(`Shell: ${command}`, { cwd, resolve, capture });\n\n let executable: string;\n let args: string[];\n\n if (resolve) {\n const [bin, ...rest] = this.parseCommand(command);\n executable = await this.resolveExecutable(bin, cwd);\n args = rest;\n } else {\n [executable, ...args] = this.parseCommand(command);\n }\n\n // Build properly escaped command string for shell execution\n const shellCommand = this.buildShellCommand(executable, args);\n\n if (capture) {\n return this.execCapture(shellCommand, { cwd, env });\n }\n\n return this.execInherit(executable, args, { cwd, env });\n }\n\n /**\n * Execute command with inherited stdio (streams to terminal).\n */\n protected async execInherit(\n executable: string,\n args: string[],\n options: { cwd: string; env?: Record<string, string> },\n ): Promise<string> {\n const isWindows = process.platform === \"win32\";\n\n // On Windows, use shell mode with a single command string to avoid\n // Node.js DEP0190 deprecation warning about unescaped args with shell: true\n const proc = isWindows\n ? spawn(this.buildShellCommand(executable, args), [], {\n stdio: \"inherit\",\n cwd: options.cwd,\n shell: true,\n env: { ...process.env, ...options.env },\n })\n : spawn(executable, args, {\n stdio: \"inherit\",\n cwd: options.cwd,\n env: { ...process.env, ...options.env },\n });\n\n return new Promise<string>((resolve, reject) => {\n proc.on(\"exit\", (code) => {\n if (code === 0 || code === null) {\n resolve(\"\");\n } else {\n reject(new AlephaError(`Command exited with code ${code}`));\n }\n });\n proc.on(\"error\", reject);\n });\n }\n\n /**\n * Build a shell command string with proper escaping for Windows.\n * Quotes both executable and arguments that contain spaces or special characters.\n */\n protected buildShellCommand(executable: string, args: string[]): string {\n const escapeForShell = (str: string): string => {\n // If str contains spaces or special chars, wrap in double quotes\n // and escape internal double quotes\n if (/[\\s\"&|<>^()]/.test(str)) {\n return `\"${str.replace(/\"/g, '\\\\\"')}\"`;\n }\n return str;\n };\n\n return [escapeForShell(executable), ...args.map(escapeForShell)].join(\" \");\n }\n\n /**\n * Execute command and capture stdout.\n */\n protected execCapture(\n command: string,\n options: { cwd: string; env?: Record<string, string> },\n ): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n exec(\n command,\n {\n cwd: options.cwd,\n maxBuffer: 50 * 1024 * 1024,\n env: {\n ...process.env,\n LOG_FORMAT: \"pretty\",\n ...options.env,\n },\n },\n (err, stdout) => {\n if (err) {\n (err as any).stdout = stdout;\n reject(err);\n } else {\n resolve(stdout);\n }\n },\n );\n });\n }\n\n /**\n * Resolve executable path from node_modules/.bin.\n *\n * Search order:\n * 1. Local: node_modules/.bin/\n * 2. Pnpm nested: node_modules/alepha/node_modules/.bin/\n * 3. Monorepo: Walk up to 3 parent directories\n */\n protected async resolveExecutable(\n name: string,\n root: string,\n ): Promise<string> {\n const isWindows = process.platform === \"win32\";\n // On Windows, try .cmd first (npm scripts), then .exe, then no extension\n const suffixes = isWindows ? [\".cmd\", \".exe\", \"\"] : [\"\"];\n\n for (const suffix of suffixes) {\n // 1. Local node_modules\n let execPath = await this.findExecutable(\n root,\n `node_modules/.bin/${name}${suffix}`,\n );\n if (execPath) return execPath;\n\n // 2. Pnpm nested (alepha's own node_modules)\n execPath = await this.findExecutable(\n root,\n `node_modules/alepha/node_modules/.bin/${name}${suffix}`,\n );\n if (execPath) return execPath;\n\n // 3. Monorepo: check parent directories (up to 3 levels)\n let parentDir = this.fs.join(root, \"..\");\n for (let i = 0; i < 3; i++) {\n execPath = await this.findExecutable(\n parentDir,\n `node_modules/.bin/${name}${suffix}`,\n );\n if (execPath) return execPath;\n parentDir = this.fs.join(parentDir, \"..\");\n }\n }\n\n throw new AlephaError(\n `Could not find executable for '${name}'. Make sure the package is installed.`,\n );\n }\n\n /**\n * Check if executable exists at path.\n */\n protected async findExecutable(\n root: string,\n relativePath: string,\n ): Promise<string | undefined> {\n const fullPath = this.fs.join(root, relativePath);\n if (await this.fs.exists(fullPath)) {\n return fullPath;\n }\n return undefined;\n }\n\n /**\n * Check if a command is installed and available in the system PATH.\n */\n public isInstalled(command: string): Promise<boolean> {\n return new Promise((resolve) => {\n const check =\n process.platform === \"win32\"\n ? `where ${command}`\n : `command -v ${command}`;\n exec(check, (error) => resolve(!error));\n });\n }\n\n /**\n * Parse a command string into executable and arguments.\n *\n * Handles quoted arguments properly for paths with spaces.\n * Supports both single and double quotes.\n */\n protected parseCommand(command: string): string[] {\n const result: string[] = [];\n let current = \"\";\n let inQuote: string | null = null;\n\n for (let i = 0; i < command.length; i++) {\n const char = command[i];\n\n if (inQuote) {\n if (char === inQuote) {\n inQuote = null;\n } else {\n current += char;\n }\n } else if (char === '\"' || char === \"'\") {\n inQuote = char;\n } else if (char === \" \") {\n if (current) {\n result.push(current);\n current = \"\";\n }\n } else {\n current += char;\n }\n }\n\n if (current) {\n result.push(current);\n }\n\n return result;\n }\n}\n","import { AlephaError } from \"alepha\";\nimport { NodeShellProvider } from \"./NodeShellProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Bun implementation of ShellProvider.\n *\n * Executes shell commands using Bun's native `Bun.spawn` and `Bun.which`,\n * skipping the `node:child_process` compatibility layer for better performance.\n *\n * Inherits executable resolution (`node_modules/.bin` walk) and command parsing\n * from `NodeShellProvider`.\n */\nexport class BunShellProvider extends NodeShellProvider {\n /**\n * Execute command with inherited stdio (streams to terminal).\n */\n protected override async execInherit(\n executable: string,\n args: string[],\n options: { cwd: string; env?: Record<string, string> },\n ): Promise<string> {\n const proc = Bun.spawn([executable, ...args], {\n cwd: options.cwd,\n env: { ...process.env, ...options.env },\n stdout: \"inherit\",\n stderr: \"inherit\",\n stdin: \"inherit\",\n });\n\n const code = await proc.exited;\n if (code !== 0) {\n throw new AlephaError(`Command exited with code ${code}`);\n }\n return \"\";\n }\n\n /**\n * Execute command and capture stdout.\n */\n protected override async execCapture(\n command: string,\n options: { cwd: string; env?: Record<string, string> },\n ): Promise<string> {\n const [executable, ...args] = this.parseCommand(command);\n const proc = Bun.spawn([executable, ...args], {\n cwd: options.cwd,\n env: {\n ...process.env,\n LOG_FORMAT: \"pretty\",\n ...options.env,\n },\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n\n const [stdout, stderr, code] = await Promise.all([\n new Response(proc.stdout).text(),\n new Response(proc.stderr).text(),\n proc.exited,\n ]);\n\n if (code !== 0) {\n const err = new AlephaError(\n `Command exited with code ${code}: ${stderr || stdout}`,\n );\n (err as any).stdout = stdout;\n (err as any).stderr = stderr;\n throw err;\n }\n return stdout;\n }\n\n /**\n * Check if a command is installed and available in the system PATH.\n */\n public override async isInstalled(command: string): Promise<boolean> {\n return Bun.which(command) !== null;\n }\n}\n","import { basename as nodeBasename, join as nodeJoin } from \"node:path\";\nimport { $inject, AlephaError, type FileLike, Json } from \"alepha\";\nimport type {\n CpOptions,\n CreateFileOptions,\n FileSystemProvider,\n LsOptions,\n MkdirOptions,\n RmOptions,\n} from \"./FileSystemProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface MemoryFileSystemProviderOptions {\n /**\n * Error to throw on mkdir operations (for testing error handling)\n */\n mkdirError?: Error | null;\n /**\n * Error to throw on writeFile operations (for testing error handling)\n */\n writeFileError?: Error | null;\n /**\n * Error to throw on readFile operations (for testing error handling)\n */\n readFileError?: Error | null;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * In-memory implementation of FileSystemProvider for testing.\n *\n * This provider stores all files and directories in memory, making it ideal for\n * unit tests that need to verify file operations without touching the real file system.\n *\n * @example\n * ```typescript\n * // In tests, substitute the real FileSystemProvider with MemoryFileSystemProvider\n * const alepha = Alepha.create().with({\n * provide: FileSystemProvider,\n * use: MemoryFileSystemProvider,\n * });\n *\n * // Run code that uses FileSystemProvider\n * const service = alepha.inject(MyService);\n * await service.saveFile(\"test.txt\", \"Hello World\");\n *\n * // Verify the file was written\n * const memoryFs = alepha.inject(MemoryFileSystemProvider);\n * expect(memoryFs.files.get(\"test.txt\")?.toString()).toBe(\"Hello World\");\n * ```\n */\nexport class MemoryFileSystemProvider implements FileSystemProvider {\n protected json = $inject(Json);\n\n /**\n * In-memory storage for files (path -> content)\n */\n public files = new Map<string, Buffer>();\n\n /**\n * In-memory storage for directories\n */\n public directories = new Set<string>();\n\n /**\n * Track mkdir calls for test assertions\n */\n public mkdirCalls: Array<{ path: string; options?: MkdirOptions }> = [];\n\n /**\n * Track writeFile calls for test assertions\n */\n public writeFileCalls: Array<{ path: string; data: string }> = [];\n\n /**\n * Track readFile calls for test assertions\n */\n public readFileCalls: Array<string> = [];\n\n /**\n * Track rm calls for test assertions\n */\n public rmCalls: Array<{ path: string; options?: RmOptions }> = [];\n\n /**\n * Track join calls for test assertions\n */\n public joinCalls: Array<string[]> = [];\n\n /**\n * Error to throw on mkdir (for testing error handling)\n */\n public mkdirError: Error | null = null;\n\n /**\n * Error to throw on writeFile (for testing error handling)\n */\n public writeFileError: Error | null = null;\n\n /**\n * Error to throw on readFile (for testing error handling)\n */\n public readFileError: Error | null = null;\n\n constructor(options: MemoryFileSystemProviderOptions = {}) {\n this.mkdirError = options.mkdirError ?? null;\n this.writeFileError = options.writeFileError ?? null;\n this.readFileError = options.readFileError ?? null;\n }\n\n /**\n * Join path segments using forward slashes.\n * Uses Node's path.join for proper normalization (handles .. and .)\n */\n public join(...paths: string[]): string {\n this.joinCalls.push(paths);\n return nodeJoin(...paths);\n }\n\n /**\n * Normalize path separators to forward slashes for consistent internal storage.\n * This ensures Windows paths work correctly in the in-memory file system.\n */\n protected normalizePath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n }\n\n /**\n * Create a FileLike object from various sources.\n */\n public createFile(options: CreateFileOptions): FileLike {\n if (\"path\" in options) {\n const filePath = options.path;\n const buffer = this.files.get(filePath);\n if (buffer === undefined) {\n throw new AlephaError(\n `ENOENT: no such file or directory, open '${filePath}'`,\n );\n }\n return {\n name: options.name ?? nodeBasename(filePath),\n type: options.type ?? \"application/octet-stream\",\n size: buffer.byteLength,\n lastModified: Date.now(),\n stream: () => {\n throw new AlephaError(\n \"Stream not implemented in MemoryFileSystemProvider\",\n );\n },\n arrayBuffer: async (): Promise<ArrayBuffer> =>\n buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength,\n ) as ArrayBuffer,\n text: async () => buffer.toString(\"utf-8\"),\n };\n }\n\n if (\"buffer\" in options) {\n const buffer = options.buffer;\n return {\n name: options.name ?? \"file\",\n type: options.type ?? \"application/octet-stream\",\n size: buffer.byteLength,\n lastModified: Date.now(),\n stream: () => {\n throw new AlephaError(\n \"Stream not implemented in MemoryFileSystemProvider\",\n );\n },\n arrayBuffer: async (): Promise<ArrayBuffer> =>\n buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength,\n ) as ArrayBuffer,\n text: async () => buffer.toString(\"utf-8\"),\n };\n }\n\n if (\"text\" in options) {\n const buffer = Buffer.from(options.text, \"utf-8\");\n return {\n name: options.name ?? \"file.txt\",\n type: options.type ?? \"text/plain\",\n size: buffer.byteLength,\n lastModified: Date.now(),\n stream: () => {\n throw new AlephaError(\n \"Stream not implemented in MemoryFileSystemProvider\",\n );\n },\n arrayBuffer: async (): Promise<ArrayBuffer> =>\n buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength,\n ) as ArrayBuffer,\n text: async () => options.text,\n };\n }\n\n throw new AlephaError(\n \"MemoryFileSystemProvider.createFile: unsupported options. Only buffer and text are supported.\",\n );\n }\n\n /**\n * Remove a file or directory from memory.\n */\n public async rm(path: string, options?: RmOptions): Promise<void> {\n this.rmCalls.push({ path, options });\n\n const exists = this.files.has(path) || this.directories.has(path);\n\n if (!exists && !options?.force) {\n throw new AlephaError(`ENOENT: no such file or directory, rm '${path}'`);\n }\n\n if (this.directories.has(path)) {\n if (options?.recursive) {\n // Remove directory and all contents\n this.directories.delete(path);\n for (const filePath of this.files.keys()) {\n if (filePath.startsWith(`${path}/`)) {\n this.files.delete(filePath);\n }\n }\n for (const dirPath of this.directories) {\n if (dirPath.startsWith(`${path}/`)) {\n this.directories.delete(dirPath);\n }\n }\n } else {\n throw new AlephaError(\n `EISDIR: illegal operation on a directory, rm '${path}'`,\n );\n }\n } else {\n this.files.delete(path);\n }\n }\n\n /**\n * Copy a file or directory in memory.\n */\n public async cp(\n src: string,\n dest: string,\n options?: CpOptions,\n ): Promise<void> {\n if (this.directories.has(src)) {\n this.directories.add(dest);\n for (const [filePath, content] of this.files) {\n if (filePath.startsWith(`${src}/`)) {\n const newPath = filePath.replace(src, dest);\n this.files.set(newPath, Buffer.from(content));\n }\n }\n } else if (this.files.has(src)) {\n const content = this.files.get(src)!;\n this.files.set(dest, Buffer.from(content));\n } else {\n throw new AlephaError(`ENOENT: no such file or directory, cp '${src}'`);\n }\n }\n\n /**\n * Move/rename a file or directory in memory.\n */\n public async mv(src: string, dest: string): Promise<void> {\n if (this.directories.has(src)) {\n // Move directory and contents\n this.directories.delete(src);\n this.directories.add(dest);\n for (const [filePath, content] of this.files) {\n if (filePath.startsWith(`${src}/`)) {\n const newPath = filePath.replace(src, dest);\n this.files.delete(filePath);\n this.files.set(newPath, content);\n }\n }\n } else if (this.files.has(src)) {\n const content = this.files.get(src)!;\n this.files.delete(src);\n this.files.set(dest, content);\n } else {\n throw new AlephaError(`ENOENT: no such file or directory, mv '${src}'`);\n }\n }\n\n /**\n * Create a directory in memory.\n */\n public async mkdir(path: string, options?: MkdirOptions): Promise<void> {\n this.mkdirCalls.push({ path, options });\n\n if (this.mkdirError) {\n throw this.mkdirError;\n }\n\n const normalizedPath = this.normalizePath(path);\n\n if (this.directories.has(normalizedPath) && !options?.recursive) {\n throw new AlephaError(`EEXIST: file already exists, mkdir '${path}'`);\n }\n\n this.directories.add(normalizedPath);\n\n // If recursive, create parent directories\n if (options?.recursive) {\n const parts = normalizedPath.split(\"/\").filter(Boolean);\n let current = \"\";\n for (const part of parts) {\n current = current ? `${current}/${part}` : part;\n this.directories.add(current);\n }\n }\n }\n\n /**\n * List files in a directory.\n */\n public async ls(path: string, options?: LsOptions): Promise<string[]> {\n const normalizedPath = this.normalizePath(path).replace(/\\/$/, \"\");\n const entries = new Set<string>();\n\n // Find files in the directory\n for (const filePath of this.files.keys()) {\n const normalizedFilePath = this.normalizePath(filePath);\n if (normalizedFilePath.startsWith(`${normalizedPath}/`)) {\n const relativePath = normalizedFilePath.slice(\n normalizedPath.length + 1,\n );\n const parts = relativePath.split(\"/\");\n\n if (options?.recursive) {\n entries.add(relativePath);\n } else {\n entries.add(parts[0]);\n }\n }\n }\n\n // Find subdirectories\n for (const dirPath of this.directories) {\n const normalizedDirPath = this.normalizePath(dirPath);\n if (\n normalizedDirPath.startsWith(`${normalizedPath}/`) &&\n normalizedDirPath !== normalizedPath\n ) {\n const relativePath = normalizedDirPath.slice(normalizedPath.length + 1);\n const parts = relativePath.split(\"/\");\n\n if (options?.recursive) {\n entries.add(relativePath);\n } else if (parts.length === 1) {\n entries.add(parts[0]);\n }\n }\n }\n\n let result = Array.from(entries);\n\n // Filter hidden files unless requested\n if (!options?.hidden) {\n result = result.filter((entry) => !entry.startsWith(\".\"));\n }\n\n return result.sort();\n }\n\n /**\n * Check if a file or directory exists in memory.\n */\n public async exists(path: string): Promise<boolean> {\n return this.files.has(path) || this.directories.has(path);\n }\n\n /**\n * Read a file from memory.\n */\n public async readFile(path: string): Promise<Buffer> {\n this.readFileCalls.push(path);\n\n if (this.readFileError) {\n throw this.readFileError;\n }\n\n const content = this.files.get(path);\n if (!content) {\n throw new AlephaError(\n `ENOENT: no such file or directory, open '${path}'`,\n );\n }\n return content;\n }\n\n /**\n * Read a file from memory as text.\n */\n public async readTextFile(path: string): Promise<string> {\n const buffer = await this.readFile(path);\n return buffer.toString(\"utf-8\");\n }\n\n /**\n * Read a file from memory as JSON.\n */\n public async readJsonFile<T = unknown>(path: string): Promise<T> {\n const text = await this.readTextFile(path);\n return this.json.parse(text) as T;\n }\n\n /**\n * Write a file to memory.\n */\n public async writeFile(\n path: string,\n data: Uint8Array | Buffer | string | FileLike,\n ): Promise<void> {\n const dataStr =\n typeof data === \"string\"\n ? data\n : data instanceof Buffer || data instanceof Uint8Array\n ? data.toString(\"utf-8\")\n : await data.text();\n\n this.writeFileCalls.push({ path, data: dataStr });\n\n if (this.writeFileError) {\n throw this.writeFileError;\n }\n\n const buffer =\n typeof data === \"string\"\n ? Buffer.from(data, \"utf-8\")\n : data instanceof Buffer\n ? data\n : data instanceof Uint8Array\n ? Buffer.from(data)\n : Buffer.from(await data.text(), \"utf-8\");\n\n this.files.set(path, buffer);\n }\n\n /**\n * Reset all in-memory state (useful between tests).\n */\n public reset(): void {\n this.files.clear();\n this.directories.clear();\n this.mkdirCalls = [];\n this.writeFileCalls = [];\n this.readFileCalls = [];\n this.rmCalls = [];\n this.joinCalls = [];\n this.mkdirError = null;\n this.writeFileError = null;\n this.readFileError = null;\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Test assertion helpers\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Check if a file was written during the test.\n *\n * @example\n * ```typescript\n * expect(fs.wasWritten(\"/project/tsconfig.json\")).toBe(true);\n * ```\n */\n public wasWritten(path: string): boolean {\n return this.writeFileCalls.some((call) => call.path === path);\n }\n\n /**\n * Check if a file was written with content matching a pattern.\n *\n * @example\n * ```typescript\n * expect(fs.wasWrittenMatching(\"/project/tsconfig.json\", /extends/)).toBe(true);\n * ```\n */\n public wasWrittenMatching(path: string, pattern: RegExp): boolean {\n const call = this.writeFileCalls.find((c) => c.path === path);\n return call ? pattern.test(call.data) : false;\n }\n\n /**\n * Check if a file was read during the test.\n *\n * @example\n * ```typescript\n * expect(fs.wasRead(\"/project/package.json\")).toBe(true);\n * ```\n */\n public wasRead(path: string): boolean {\n return this.readFileCalls.includes(path);\n }\n\n /**\n * Check if a file was deleted during the test.\n *\n * @example\n * ```typescript\n * expect(fs.wasDeleted(\"/project/old-file.txt\")).toBe(true);\n * ```\n */\n public wasDeleted(path: string): boolean {\n return this.rmCalls.some((call) => call.path === path);\n }\n\n /**\n * Get the content of a file as a string (convenience method for testing).\n */\n public getFileContent(path: string): string | undefined {\n return this.files.get(path)?.toString(\"utf-8\");\n }\n}\n","import { AlephaError } from \"alepha\";\nimport type { ShellProvider, ShellRunOptions } from \"./ShellProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface MemoryShellCall {\n command: string;\n options: ShellRunOptions;\n}\n\nexport interface MemoryShellProviderOptions {\n /**\n * Simulated outputs for specific commands.\n * Key is the command string, value is the stdout to return.\n */\n outputs?: Record<string, string>;\n\n /**\n * Commands that should throw an error.\n * Key is the command string, value is the error message.\n */\n errors?: Record<string, string>;\n\n /**\n * Commands that are considered \"installed\" in the system PATH.\n */\n installedCommands?: string[];\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * In-memory implementation of ShellProvider for testing.\n *\n * Records all commands that would be executed without actually running them.\n * Can be configured to return specific outputs or throw errors for testing.\n *\n * @example\n * ```typescript\n * // In tests, substitute the real ShellProvider with MemoryShellProvider\n * const alepha = Alepha.create().with({\n * provide: ShellProvider,\n * use: MemoryShellProvider,\n * });\n *\n * // Configure mock behavior\n * const shell = alepha.inject(MemoryShellProvider);\n * shell.configure({\n * outputs: { \"echo hello\": \"hello\\n\" },\n * errors: { \"failing-cmd\": \"Command failed\" },\n * });\n *\n * // Or use the fluent API\n * shell.outputs.set(\"another-cmd\", \"output\");\n * shell.errors.set(\"another-error\", \"Error message\");\n *\n * // Run code that uses ShellProvider\n * const service = alepha.inject(MyService);\n * await service.doSomething();\n *\n * // Verify commands were called\n * expect(shell.calls).toHaveLength(2);\n * expect(shell.calls[0].command).toBe(\"yarn install\");\n * ```\n */\nexport class MemoryShellProvider implements ShellProvider {\n /**\n * All recorded shell calls.\n */\n public calls: MemoryShellCall[] = [];\n\n /**\n * Simulated outputs for specific commands.\n */\n public outputs = new Map<string, string>();\n\n /**\n * Commands that should throw an error.\n */\n public errors = new Map<string, string>();\n\n /**\n * Commands considered installed in the system PATH.\n */\n public installedCommands = new Set<string>();\n\n /**\n * Configure the mock with predefined outputs, errors, and installed commands.\n */\n public configure(options: MemoryShellProviderOptions): this {\n if (options.outputs) {\n for (const [cmd, output] of Object.entries(options.outputs)) {\n this.outputs.set(cmd, output);\n }\n }\n if (options.errors) {\n for (const [cmd, error] of Object.entries(options.errors)) {\n this.errors.set(cmd, error);\n }\n }\n if (options.installedCommands) {\n for (const cmd of options.installedCommands) {\n this.installedCommands.add(cmd);\n }\n }\n return this;\n }\n\n /**\n * Record command and return simulated output.\n */\n public async run(\n command: string,\n options: ShellRunOptions = {},\n ): Promise<string> {\n this.calls.push({ command, options });\n\n // Check for configured error\n const errorMsg = this.errors.get(command);\n if (errorMsg) {\n throw new AlephaError(errorMsg);\n }\n\n // Return configured output or empty string\n return this.outputs.get(command) ?? \"\";\n }\n\n /**\n * Check if a specific command was called.\n */\n public wasCalled(command: string): boolean {\n return this.calls.some((call) => call.command === command);\n }\n\n /**\n * Check if a command matching a pattern was called.\n */\n public wasCalledMatching(pattern: RegExp): boolean {\n return this.calls.some((call) => pattern.test(call.command));\n }\n\n /**\n * Get all calls matching a pattern.\n */\n public getCallsMatching(pattern: RegExp): MemoryShellCall[] {\n return this.calls.filter((call) => pattern.test(call.command));\n }\n\n /**\n * Check if a command is installed.\n */\n public async isInstalled(command: string): Promise<boolean> {\n return this.installedCommands.has(command);\n }\n\n /**\n * Reset all recorded state.\n */\n public reset(): void {\n this.calls = [];\n this.outputs.clear();\n this.errors.clear();\n this.installedCommands.clear();\n }\n}\n","import { Readable } from \"node:stream\";\n\nexport interface FileTypeResult {\n /**\n * The detected MIME type\n */\n mimeType: string;\n /**\n * The detected file extension\n */\n extension: string;\n /**\n * Whether the file type was verified by magic bytes\n */\n verified: boolean;\n /**\n * The stream (potentially wrapped to allow re-reading)\n */\n stream: Readable;\n}\n\n/**\n * Service for detecting file types and getting content types.\n *\n * @example\n * ```typescript\n * const detector = alepha.inject(FileDetector);\n *\n * // Get content type from filename\n * const mimeType = detector.getContentType(\"image.png\"); // \"image/png\"\n *\n * // Detect file type by magic bytes\n * const stream = createReadStream('image.png');\n * const result = await detector.detectFileType(stream, 'image.png');\n * console.log(result.mimeType); // 'image/png'\n * console.log(result.verified); // true if magic bytes match\n * ```\n */\nexport class FileDetector {\n /**\n * Magic byte signatures for common file formats.\n * Each signature is represented as an array of bytes or null (wildcard).\n */\n protected static readonly MAGIC_BYTES: Record<\n string,\n { signature: (number | null)[]; mimeType: string }[]\n > = {\n // Images\n png: [\n {\n signature: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a],\n mimeType: \"image/png\",\n },\n ],\n jpg: [\n { signature: [0xff, 0xd8, 0xff, 0xe0], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe1], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe2], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe3], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe8], mimeType: \"image/jpeg\" },\n ],\n jpeg: [\n { signature: [0xff, 0xd8, 0xff, 0xe0], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe1], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe2], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe3], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe8], mimeType: \"image/jpeg\" },\n ],\n gif: [\n {\n signature: [0x47, 0x49, 0x46, 0x38, 0x37, 0x61],\n mimeType: \"image/gif\",\n }, // GIF87a\n {\n signature: [0x47, 0x49, 0x46, 0x38, 0x39, 0x61],\n mimeType: \"image/gif\",\n }, // GIF89a\n ],\n webp: [\n {\n signature: [\n 0x52,\n 0x49,\n 0x46,\n 0x46,\n null,\n null,\n null,\n null,\n 0x57,\n 0x45,\n 0x42,\n 0x50,\n ],\n mimeType: \"image/webp\",\n },\n ],\n bmp: [{ signature: [0x42, 0x4d], mimeType: \"image/bmp\" }],\n ico: [{ signature: [0x00, 0x00, 0x01, 0x00], mimeType: \"image/x-icon\" }],\n tiff: [\n { signature: [0x49, 0x49, 0x2a, 0x00], mimeType: \"image/tiff\" }, // Little-endian\n { signature: [0x4d, 0x4d, 0x00, 0x2a], mimeType: \"image/tiff\" }, // Big-endian\n ],\n tif: [\n { signature: [0x49, 0x49, 0x2a, 0x00], mimeType: \"image/tiff\" },\n { signature: [0x4d, 0x4d, 0x00, 0x2a], mimeType: \"image/tiff\" },\n ],\n\n // Documents\n pdf: [\n {\n signature: [0x25, 0x50, 0x44, 0x46, 0x2d],\n mimeType: \"application/pdf\",\n },\n ], // %PDF-\n zip: [\n { signature: [0x50, 0x4b, 0x03, 0x04], mimeType: \"application/zip\" },\n { signature: [0x50, 0x4b, 0x05, 0x06], mimeType: \"application/zip\" },\n { signature: [0x50, 0x4b, 0x07, 0x08], mimeType: \"application/zip\" },\n ],\n\n // Archives\n rar: [\n {\n signature: [0x52, 0x61, 0x72, 0x21, 0x1a, 0x07],\n mimeType: \"application/vnd.rar\",\n },\n ],\n \"7z\": [\n {\n signature: [0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c],\n mimeType: \"application/x-7z-compressed\",\n },\n ],\n tar: [\n {\n signature: [0x75, 0x73, 0x74, 0x61, 0x72],\n mimeType: \"application/x-tar\",\n },\n ],\n gz: [{ signature: [0x1f, 0x8b], mimeType: \"application/gzip\" }],\n tgz: [{ signature: [0x1f, 0x8b], mimeType: \"application/gzip\" }],\n\n // Audio\n mp3: [\n { signature: [0xff, 0xfb], mimeType: \"audio/mpeg\" },\n { signature: [0xff, 0xf3], mimeType: \"audio/mpeg\" },\n { signature: [0xff, 0xf2], mimeType: \"audio/mpeg\" },\n { signature: [0x49, 0x44, 0x33], mimeType: \"audio/mpeg\" }, // ID3\n ],\n wav: [\n {\n signature: [\n 0x52,\n 0x49,\n 0x46,\n 0x46,\n null,\n null,\n null,\n null,\n 0x57,\n 0x41,\n 0x56,\n 0x45,\n ],\n mimeType: \"audio/wav\",\n },\n ],\n ogg: [{ signature: [0x4f, 0x67, 0x67, 0x53], mimeType: \"audio/ogg\" }],\n flac: [{ signature: [0x66, 0x4c, 0x61, 0x43], mimeType: \"audio/flac\" }], // fLaC\n\n // Video\n mp4: [\n {\n signature: [null, null, null, null, 0x66, 0x74, 0x79, 0x70],\n mimeType: \"video/mp4\",\n }, // ftyp\n {\n signature: [\n null,\n null,\n null,\n null,\n 0x66,\n 0x74,\n 0x79,\n 0x70,\n 0x69,\n 0x73,\n 0x6f,\n 0x6d,\n ],\n mimeType: \"video/mp4\",\n }, // ftypisom\n {\n signature: [\n null,\n null,\n null,\n null,\n 0x66,\n 0x74,\n 0x79,\n 0x70,\n 0x6d,\n 0x70,\n 0x34,\n 0x32,\n ],\n mimeType: \"video/mp4\",\n }, // ftypmp42\n ],\n webm: [{ signature: [0x1a, 0x45, 0xdf, 0xa3], mimeType: \"video/webm\" }],\n avi: [\n {\n signature: [\n 0x52,\n 0x49,\n 0x46,\n 0x46,\n null,\n null,\n null,\n null,\n 0x41,\n 0x56,\n 0x49,\n 0x20,\n ],\n mimeType: \"video/x-msvideo\",\n },\n ],\n mov: [\n {\n signature: [\n null,\n null,\n null,\n null,\n 0x66,\n 0x74,\n 0x79,\n 0x70,\n 0x71,\n 0x74,\n 0x20,\n 0x20,\n ],\n mimeType: \"video/quicktime\",\n },\n ],\n mkv: [\n { signature: [0x1a, 0x45, 0xdf, 0xa3], mimeType: \"video/x-matroska\" },\n ],\n\n // Office (DOCX, XLSX, PPTX are all ZIP-based)\n docx: [\n {\n signature: [0x50, 0x4b, 0x03, 0x04],\n mimeType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n },\n ],\n xlsx: [\n {\n signature: [0x50, 0x4b, 0x03, 0x04],\n mimeType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n },\n ],\n pptx: [\n {\n signature: [0x50, 0x4b, 0x03, 0x04],\n mimeType:\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n },\n ],\n doc: [\n {\n signature: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1],\n mimeType: \"application/msword\",\n },\n ],\n xls: [\n {\n signature: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1],\n mimeType: \"application/vnd.ms-excel\",\n },\n ],\n ppt: [\n {\n signature: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1],\n mimeType: \"application/vnd.ms-powerpoint\",\n },\n ],\n };\n\n /**\n * All possible format signatures for checking against actual file content\n */\n protected static readonly ALL_SIGNATURES = Object.entries(\n FileDetector.MAGIC_BYTES,\n ).flatMap(([ext, signatures]) => signatures.map((sig) => ({ ext, ...sig })));\n\n /**\n * MIME type map for file extensions.\n *\n * Can be used to get the content type of file based on its extension.\n * Feel free to add more mime types in your project!\n */\n public static readonly mimeMap: Record<string, string> = {\n // Documents\n json: \"application/json\",\n txt: \"text/plain\",\n html: \"text/html\",\n htm: \"text/html\",\n xml: \"application/xml\",\n csv: \"text/csv\",\n pdf: \"application/pdf\",\n md: \"text/markdown\",\n markdown: \"text/markdown\",\n rtf: \"application/rtf\",\n\n // Styles and scripts\n css: \"text/css\",\n js: \"application/javascript\",\n mjs: \"application/javascript\",\n ts: \"application/typescript\",\n jsx: \"text/jsx\",\n tsx: \"text/tsx\",\n\n // Archives\n zip: \"application/zip\",\n rar: \"application/vnd.rar\",\n \"7z\": \"application/x-7z-compressed\",\n tar: \"application/x-tar\",\n gz: \"application/gzip\",\n tgz: \"application/gzip\",\n\n // Images\n png: \"image/png\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n gif: \"image/gif\",\n webp: \"image/webp\",\n svg: \"image/svg+xml\",\n bmp: \"image/bmp\",\n ico: \"image/x-icon\",\n tiff: \"image/tiff\",\n tif: \"image/tiff\",\n\n // Audio\n mp3: \"audio/mpeg\",\n wav: \"audio/wav\",\n ogg: \"audio/ogg\",\n m4a: \"audio/mp4\",\n aac: \"audio/aac\",\n flac: \"audio/flac\",\n\n // Video\n mp4: \"video/mp4\",\n webm: \"video/webm\",\n avi: \"video/x-msvideo\",\n mov: \"video/quicktime\",\n wmv: \"video/x-ms-wmv\",\n flv: \"video/x-flv\",\n mkv: \"video/x-matroska\",\n\n // Office\n doc: \"application/msword\",\n docx: \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n xls: \"application/vnd.ms-excel\",\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n ppt: \"application/vnd.ms-powerpoint\",\n pptx: \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n\n // Fonts\n woff: \"font/woff\",\n woff2: \"font/woff2\",\n ttf: \"font/ttf\",\n otf: \"font/otf\",\n eot: \"application/vnd.ms-fontobject\",\n };\n\n /**\n * Reverse MIME type map for looking up extensions from MIME types.\n * Prefers shorter, more common extensions when multiple exist.\n */\n protected static readonly reverseMimeMap: Record<string, string> = (() => {\n const reverse: Record<string, string> = {};\n // Process in order so common extensions come first\n for (const [ext, mimeType] of Object.entries(FileDetector.mimeMap)) {\n // Only set if not already set (prefer first/shorter extension)\n if (!reverse[mimeType]) {\n reverse[mimeType] = ext;\n }\n }\n return reverse;\n })();\n\n /**\n * Returns the file extension for a given MIME type.\n *\n * @param mimeType - The MIME type to look up\n * @returns The file extension (without dot), or \"bin\" if not found\n *\n * @example\n * ```typescript\n * const detector = alepha.inject(FileDetector);\n * const ext = detector.getExtensionFromMimeType(\"image/png\"); // \"png\"\n * const ext2 = detector.getExtensionFromMimeType(\"application/octet-stream\"); // \"bin\"\n * ```\n */\n getExtensionFromMimeType(mimeType: string): string {\n return FileDetector.reverseMimeMap[mimeType] || \"bin\";\n }\n /**\n * Returns the content type of file based on its filename.\n *\n * @param filename - The filename to check\n * @returns The MIME type\n *\n * @example\n * ```typescript\n * const detector = alepha.inject(FileDetector);\n * const mimeType = detector.getContentType(\"image.png\"); // \"image/png\"\n * ```\n */\n getContentType(filename: string): string {\n const ext = filename.toLowerCase().split(\".\").pop() || \"\";\n return FileDetector.mimeMap[ext] || \"application/octet-stream\";\n }\n\n /**\n * Detects the file type by checking magic bytes against the stream content.\n *\n * @param stream - The readable stream to check\n * @param filename - The filename (used to get the extension)\n * @returns File type information including MIME type, extension, and verification status\n *\n * @example\n * ```typescript\n * const detector = alepha.inject(FileDetector);\n * const stream = createReadStream('image.png');\n * const result = await detector.detectFileType(stream, 'image.png');\n * console.log(result.mimeType); // 'image/png'\n * console.log(result.verified); // true if magic bytes match\n * ```\n */\n async detectFileType(\n stream: Readable,\n filename: string,\n ): Promise<FileTypeResult> {\n // Get the expected MIME type from the filename extension\n const expectedMimeType = this.getContentType(filename);\n\n // Extract extension - only if filename contains a dot\n const lastDotIndex = filename.lastIndexOf(\".\");\n const ext =\n lastDotIndex > 0\n ? filename.substring(lastDotIndex + 1).toLowerCase()\n : \"\";\n\n // Read the first 16 bytes (enough for most magic byte checks)\n const { buffer, stream: newStream } = await this.peekBytes(stream, 16);\n\n // First, check if the extension's expected signature matches\n const expectedSignatures = FileDetector.MAGIC_BYTES[ext];\n if (expectedSignatures) {\n for (const { signature, mimeType } of expectedSignatures) {\n if (this.matchesSignature(buffer, signature)) {\n return {\n mimeType,\n extension: ext,\n verified: true,\n stream: newStream,\n };\n }\n }\n }\n\n // If the expected signature didn't match, try all other signatures\n for (const {\n ext: detectedExt,\n signature,\n mimeType,\n } of FileDetector.ALL_SIGNATURES) {\n if (detectedExt !== ext && this.matchesSignature(buffer, signature)) {\n return {\n mimeType,\n extension: detectedExt,\n verified: true,\n stream: newStream,\n };\n }\n }\n\n // If no magic bytes matched, fall back to extension-based detection\n // or return binary if extension is not recognized\n return {\n mimeType: expectedMimeType,\n extension: ext,\n verified: false,\n stream: newStream,\n };\n }\n\n /**\n * Reads all bytes from a stream and returns the first N bytes along with a new stream containing all data.\n * This approach reads the entire stream upfront to avoid complex async handling issues.\n *\n * @protected\n */\n protected async peekBytes(\n stream: Readable,\n numBytes: number,\n ): Promise<{ buffer: Buffer; stream: Readable }> {\n const chunks: Buffer[] = [];\n\n // Read the entire stream\n for await (const chunk of stream) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n }\n\n const allData = Buffer.concat(chunks);\n const buffer = allData.subarray(0, numBytes);\n\n // Create a new stream with all the data\n const newStream = Readable.from(allData);\n\n return { buffer, stream: newStream };\n }\n\n /**\n * Checks if a buffer matches a magic byte signature.\n *\n * @protected\n */\n protected matchesSignature(\n buffer: Buffer,\n signature: (number | null)[],\n ): boolean {\n if (buffer.length < signature.length) {\n return false;\n }\n\n for (let i = 0; i < signature.length; i++) {\n if (signature[i] !== null && buffer[i] !== signature[i]) {\n return false;\n }\n }\n\n return true;\n }\n}\n","import { createReadStream } from \"node:fs\";\nimport {\n access,\n copyFile,\n cp as fsCp,\n mkdir as fsMkdir,\n readFile as fsReadFile,\n rm as fsRm,\n writeFile as fsWriteFile,\n readdir,\n rename,\n stat,\n} from \"node:fs/promises\";\nimport { basename, join } from \"node:path\";\nimport { PassThrough, Readable } from \"node:stream\";\nimport type { ReadableStream as NodeWebStream } from \"node:stream/web\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n $inject,\n AlephaError,\n type FileLike,\n isFileLike,\n Json,\n type StreamLike,\n} from \"alepha\";\nimport { FileDetector } from \"../services/FileDetector.ts\";\nimport type {\n CpOptions,\n CreateFileOptions,\n FileSystemProvider,\n LsOptions,\n MkdirOptions,\n RmOptions,\n} from \"./FileSystemProvider.ts\";\n\n/**\n * Node.js implementation of FileSystem interface.\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Create from URL\n * const file1 = fs.createFile({ url: \"file:///path/to/file.png\" });\n *\n * // Create from Buffer\n * const file2 = fs.createFile({ buffer: Buffer.from(\"hello\"), name: \"hello.txt\" });\n *\n * // Create from text\n * const file3 = fs.createFile({ text: \"Hello, world!\", name: \"greeting.txt\" });\n *\n * // File operations\n * await fs.mkdir(\"/tmp/mydir\", { recursive: true });\n * await fs.cp(\"/src/file.txt\", \"/dest/file.txt\");\n * await fs.mv(\"/old/path.txt\", \"/new/path.txt\");\n * const files = await fs.ls(\"/tmp\");\n * await fs.rm(\"/tmp/file.txt\");\n * ```\n */\nexport class NodeFileSystemProvider implements FileSystemProvider {\n protected detector = $inject(FileDetector);\n protected json = $inject(Json);\n\n public join(...paths: string[]): string {\n return join(...paths);\n }\n\n /**\n * Creates a FileLike object from various sources.\n *\n * @param options - Options for creating the file\n * @returns A FileLike object\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // From URL\n * const file1 = fs.createFile({ url: \"https://example.com/image.png\" });\n *\n * // From Buffer\n * const file2 = fs.createFile({\n * buffer: Buffer.from(\"hello\"),\n * name: \"hello.txt\",\n * type: \"text/plain\"\n * });\n *\n * // From text\n * const file3 = fs.createFile({ text: \"Hello!\", name: \"greeting.txt\" });\n *\n * // From stream with detection\n * const stream = createReadStream(\"/path/to/file.png\");\n * const file4 = fs.createFile({ stream, name: \"image.png\" });\n * ```\n */\n createFile(options: CreateFileOptions): FileLike {\n if (\"path\" in options) {\n const filePath = options.path;\n const filename = basename(filePath);\n return this.createFileFromUrl(`file://${filePath}`, {\n type: options.type,\n name: options.name || filename,\n });\n }\n\n // Handle URL\n if (\"url\" in options) {\n return this.createFileFromUrl(options.url, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"response\" in options) {\n if (!options.response.body) {\n throw new AlephaError(\"Response has no body stream\");\n }\n const res = options.response;\n // guess size from content-length header if available\n const sizeHeader = res.headers.get(\"content-length\");\n const size = sizeHeader ? parseInt(sizeHeader, 10) : undefined;\n // guess name from content-disposition header if available\n let name = options.name;\n const contentDisposition = res.headers.get(\"content-disposition\");\n if (contentDisposition && !name) {\n const match = contentDisposition.match(/filename=\"?([^\"]+)\"?/);\n if (match) {\n name = match[1];\n }\n }\n // guess type from content-type header if available\n const type = options.type || res.headers.get(\"content-type\") || undefined;\n return this.createFileFromStream(options.response.body, {\n type,\n name,\n size,\n });\n }\n\n // Handle Web File\n if (\"file\" in options) {\n return this.createFileFromWebFile(options.file, {\n type: options.type,\n name: options.name,\n size: options.size,\n });\n }\n\n // Handle Buffer\n if (\"buffer\" in options) {\n return this.createFileFromBuffer(options.buffer, {\n type: options.type,\n name: options.name,\n });\n }\n\n // Handle ArrayBuffer\n if (\"arrayBuffer\" in options) {\n return this.createFileFromBuffer(Buffer.from(options.arrayBuffer), {\n type: options.type,\n name: options.name,\n });\n }\n\n // Handle text\n if (\"text\" in options) {\n return this.createFileFromBuffer(Buffer.from(options.text, \"utf-8\"), {\n type: options.type || \"text/plain\",\n name: options.name || \"file.txt\",\n });\n }\n\n // Handle stream\n if (\"stream\" in options) {\n return this.createFileFromStream(options.stream, {\n type: options.type,\n name: options.name,\n size: options.size,\n });\n }\n\n throw new AlephaError(\n \"Invalid createFile options: no valid source provided\",\n );\n }\n\n /**\n * Removes a file or directory.\n *\n * @param path - The path to remove\n * @param options - Remove options\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Remove a file\n * await fs.rm(\"/tmp/file.txt\");\n *\n * // Remove a directory recursively\n * await fs.rm(\"/tmp/mydir\", { recursive: true });\n *\n * // Remove with force (no error if doesn't exist)\n * await fs.rm(\"/tmp/maybe-exists.txt\", { force: true });\n * ```\n */\n async rm(path: string, options?: RmOptions): Promise<void> {\n await fsRm(path, options);\n }\n\n /**\n * Copies a file or directory.\n *\n * @param src - Source path\n * @param dest - Destination path\n * @param options - Copy options\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Copy a file\n * await fs.cp(\"/src/file.txt\", \"/dest/file.txt\");\n *\n * // Copy a directory (recursive by default)\n * await fs.cp(\"/src/dir\", \"/dest/dir\");\n *\n * // Copy with force (overwrite existing)\n * await fs.cp(\"/src/file.txt\", \"/dest/file.txt\", { force: true });\n * ```\n */\n async cp(src: string, dest: string, options?: CpOptions): Promise<void> {\n const srcStat = await stat(src);\n\n if (srcStat.isDirectory()) {\n await fsCp(src, dest, {\n recursive: options?.recursive ?? true,\n force: options?.force ?? false,\n });\n } else {\n await copyFile(src, dest);\n }\n }\n\n /**\n * Moves/renames a file or directory.\n *\n * @param src - Source path\n * @param dest - Destination path\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Move/rename a file\n * await fs.mv(\"/old/path.txt\", \"/new/path.txt\");\n *\n * // Move a directory\n * await fs.mv(\"/old/dir\", \"/new/dir\");\n * ```\n */\n async mv(src: string, dest: string): Promise<void> {\n await rename(src, dest);\n }\n\n /**\n * Creates a directory.\n *\n * @param path - The directory path to create\n * @param options - Mkdir options\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Create a directory\n * await fs.mkdir(\"/tmp/mydir\");\n *\n * // Create nested directories\n * await fs.mkdir(\"/tmp/path/to/dir\", { recursive: true });\n *\n * // Create with specific permissions\n * await fs.mkdir(\"/tmp/mydir\", { mode: 0o755 });\n * ```\n */\n async mkdir(path: string, options: MkdirOptions = {}): Promise<void> {\n const p = fsMkdir(path, {\n recursive: options.recursive ?? true,\n mode: options.mode,\n });\n\n if (options.force === false) {\n await p;\n } else {\n await p.catch(() => {});\n }\n }\n\n /**\n * Lists files in a directory.\n *\n * @param path - The directory path to list\n * @param options - List options\n * @returns Array of filenames\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // List files in a directory\n * const files = await fs.ls(\"/tmp\");\n * console.log(files); // [\"file1.txt\", \"file2.txt\", \"subdir\"]\n *\n * // List with hidden files\n * const allFiles = await fs.ls(\"/tmp\", { hidden: true });\n *\n * // List recursively\n * const allFilesRecursive = await fs.ls(\"/tmp\", { recursive: true });\n * ```\n */\n async ls(path: string, options?: LsOptions): Promise<string[]> {\n const entries = await readdir(path);\n\n // Filter out hidden files if not requested\n const filteredEntries = options?.hidden\n ? entries\n : entries.filter((e) => !e.startsWith(\".\"));\n\n // If recursive, get all nested files\n if (options?.recursive) {\n const allFiles: string[] = [];\n\n for (const entry of filteredEntries) {\n const fullPath = join(path, entry);\n const entryStat = await stat(fullPath);\n\n if (entryStat.isDirectory()) {\n // Add directory entry\n allFiles.push(entry);\n // Recursively get files from subdirectory\n const subFiles = await this.ls(fullPath, options);\n allFiles.push(...subFiles.map((f) => join(entry, f)));\n } else {\n allFiles.push(entry);\n }\n }\n\n return allFiles;\n }\n\n return filteredEntries;\n }\n\n /**\n * Checks if a file or directory exists.\n *\n * @param path - The path to check\n * @returns True if the path exists, false otherwise\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * if (await fs.exists(\"/tmp/file.txt\")) {\n * console.log(\"File exists\");\n * }\n * ```\n */\n async exists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Reads the content of a file.\n *\n * @param path - The file path to read\n * @returns The file content as a Buffer\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * const buffer = await fs.readFile(\"/tmp/file.txt\");\n * console.log(buffer.toString(\"utf-8\"));\n * ```\n */\n async readFile(path: string): Promise<Buffer> {\n return await fsReadFile(path);\n }\n\n /**\n * Writes data to a file.\n *\n * @param path - The file path to write to\n * @param data - The data to write (Buffer or string)\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Write string\n * await fs.writeFile(\"/tmp/file.txt\", \"Hello, world!\");\n *\n * // Write Buffer\n * await fs.writeFile(\"/tmp/file.bin\", Buffer.from([0x01, 0x02, 0x03]));\n * ```\n */\n async writeFile(\n path: string,\n data: Uint8Array | Buffer | string | FileLike,\n ): Promise<void> {\n if (isFileLike(data)) {\n await fsWriteFile(path, Readable.from(data.stream()));\n return;\n }\n await fsWriteFile(path, data);\n }\n\n /**\n * Reads the content of a file as a string.\n *\n * @param path - The file path to read\n * @returns The file content as a string\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n * const content = await fs.readTextFile(\"/tmp/file.txt\");\n * ```\n */\n async readTextFile(path: string): Promise<string> {\n const buffer = await this.readFile(path);\n return buffer.toString(\"utf-8\");\n }\n\n /**\n * Reads the content of a file as JSON.\n *\n * @param path - The file path to read\n * @returns The parsed JSON content\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n * const config = await fs.readJsonFile<{ name: string }>(\"/tmp/config.json\");\n * ```\n */\n async readJsonFile<T = unknown>(path: string): Promise<T> {\n const text = await this.readTextFile(path);\n return this.json.parse(text) as T;\n }\n\n /**\n * Creates a FileLike object from a Web File.\n *\n * @protected\n */\n protected createFileFromWebFile(\n source: File,\n options: {\n type?: string;\n name?: string;\n size?: number;\n } = {},\n ): FileLike {\n const name = options.name ?? source.name;\n return {\n name,\n type: options.type ?? (source.type || this.detector.getContentType(name)),\n size: options.size ?? source.size ?? 0,\n lastModified: source.lastModified || Date.now(),\n stream: () => source.stream(),\n arrayBuffer: async (): Promise<ArrayBuffer> => {\n return await source.arrayBuffer();\n },\n text: async (): Promise<string> => {\n return await source.text();\n },\n };\n }\n\n /**\n * Creates a FileLike object from a Buffer.\n *\n * @protected\n */\n protected createFileFromBuffer(\n source: Buffer,\n options: {\n type?: string;\n name?: string;\n } = {},\n ): FileLike {\n const name: string = options.name ?? \"file\";\n return {\n name,\n type: options.type ?? this.detector.getContentType(options.name ?? name),\n size: source.byteLength,\n lastModified: Date.now(),\n stream: (): Readable => Readable.from(source),\n arrayBuffer: async (): Promise<ArrayBuffer> => {\n return this.bufferToArrayBuffer(source);\n },\n text: async (): Promise<string> => {\n return source.toString(\"utf-8\");\n },\n };\n }\n\n /**\n * Creates a FileLike object from a stream.\n *\n * @protected\n */\n protected createFileFromStream(\n source: StreamLike,\n options: {\n type?: string;\n name?: string;\n size?: number;\n } = {},\n ): FileLike & { _buffer: null | Buffer } {\n let buffer: Buffer | null = null;\n\n return {\n name: options.name ?? \"file\",\n type:\n options.type ?? this.detector.getContentType(options.name ?? \"file\"),\n size: options.size ?? 0,\n lastModified: Date.now(),\n stream: () => source,\n _buffer: null as Buffer | null,\n arrayBuffer: async () => {\n buffer ??= await this.streamToBuffer(source);\n return this.bufferToArrayBuffer(buffer);\n },\n text: async () => {\n buffer ??= await this.streamToBuffer(source);\n return buffer.toString(\"utf-8\");\n },\n };\n }\n\n /**\n * Creates a FileLike object from a URL.\n *\n * @protected\n */\n protected createFileFromUrl(\n url: string,\n options: {\n type?: string;\n name?: string;\n } = {},\n ): FileLike {\n const parsedUrl = new URL(url);\n const filename =\n options.name || parsedUrl.pathname.split(\"/\").pop() || \"file\";\n let buffer: Buffer | null = null;\n\n return {\n name: filename,\n type: options.type ?? this.detector.getContentType(filename),\n size: 0, // Unknown size until loaded\n lastModified: Date.now(),\n stream: () => this.createStreamFromUrl(url),\n arrayBuffer: async () => {\n buffer ??= await this.loadFromUrl(url);\n return this.bufferToArrayBuffer(buffer);\n },\n text: async () => {\n buffer ??= await this.loadFromUrl(url);\n return buffer.toString(\"utf-8\");\n },\n filepath: url,\n };\n }\n\n /**\n * Gets a streaming response from a URL.\n *\n * @protected\n */\n protected getStreamingResponse(url: string): Readable {\n const stream = new PassThrough();\n\n fetch(url)\n .then((res) =>\n Readable.fromWeb(res.body as unknown as NodeWebStream).pipe(stream),\n )\n .catch((err) => stream.destroy(err));\n\n return stream;\n }\n\n /**\n * Loads data from a URL.\n *\n * @protected\n */\n protected async loadFromUrl(url: string): Promise<Buffer> {\n const parsedUrl = new URL(url);\n\n if (parsedUrl.protocol === \"file:\") {\n // Handle file:// URLs\n const filePath = fileURLToPath(url);\n return await fsReadFile(filePath);\n } else if (\n parsedUrl.protocol === \"http:\" ||\n parsedUrl.protocol === \"https:\"\n ) {\n // Handle HTTP/HTTPS URLs\n const response = await fetch(url);\n if (!response.ok) {\n throw new AlephaError(\n `Failed to fetch ${url}: ${response.status} ${response.statusText}`,\n );\n }\n const arrayBuffer = await response.arrayBuffer();\n return Buffer.from(arrayBuffer);\n } else {\n throw new AlephaError(`Unsupported protocol: ${parsedUrl.protocol}`);\n }\n }\n\n /**\n * Creates a stream from a URL.\n *\n * @protected\n */\n protected createStreamFromUrl(url: string): Readable {\n const parsedUrl = new URL(url);\n\n if (parsedUrl.protocol === \"file:\") {\n // For file:// URLs, create a stream that reads the file\n return createReadStream(fileURLToPath(url));\n } else if (\n parsedUrl.protocol === \"http:\" ||\n parsedUrl.protocol === \"https:\"\n ) {\n // For HTTP/HTTPS URLs, create a stream that fetches the content\n return this.getStreamingResponse(url);\n } else {\n throw new AlephaError(`Unsupported protocol: ${parsedUrl.protocol}`);\n }\n }\n\n /**\n * Converts a stream-like object to a Buffer.\n *\n * @protected\n */\n protected async streamToBuffer(streamLike: StreamLike): Promise<Buffer> {\n const stream =\n streamLike instanceof Readable\n ? streamLike\n : Readable.fromWeb(streamLike as NodeWebStream);\n\n return new Promise<Buffer>((resolve, reject) => {\n const buffer: any[] = [];\n stream.on(\"data\", (chunk) => buffer.push(Buffer.from(chunk)));\n stream.on(\"end\", () => resolve(Buffer.concat(buffer)));\n stream.on(\"error\", (err) =>\n reject(new AlephaError(\"Error converting stream\", { cause: err })),\n );\n });\n }\n\n /**\n * Converts a Node.js Buffer to an ArrayBuffer.\n *\n * @protected\n */\n protected bufferToArrayBuffer(buffer: Buffer): ArrayBuffer {\n return buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength,\n ) as ArrayBuffer;\n }\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ShellRunOptions {\n /**\n * Working directory for the command.\n */\n root?: string;\n\n /**\n * Additional environment variables.\n */\n env?: Record<string, string>;\n\n /**\n * Resolve the executable from node_modules/.bin.\n * Supports local project, pnpm nested, and monorepo structures.\n * @default false\n */\n resolve?: boolean;\n\n /**\n * Capture stdout instead of inheriting stdio.\n * When true, returns stdout as string.\n * When false, streams output to terminal.\n * @default false\n */\n capture?: boolean;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Abstract provider for executing shell commands and binaries.\n *\n * Implementations:\n * - `NodeShellProvider` - Real shell execution using Node.js child_process\n * - `MemoryShellProvider` - In-memory mock for testing\n *\n * @example\n * ```typescript\n * class MyService {\n * protected readonly shell = $inject(ShellProvider);\n *\n * async build() {\n * // Run shell command directly\n * await this.shell.run(\"yarn install\");\n *\n * // Run local binary with resolution\n * await this.shell.run(\"vite build\", { resolve: true });\n *\n * // Capture output\n * const output = await this.shell.run(\"echo hello\", { capture: true });\n * }\n * }\n * ```\n */\nexport abstract class ShellProvider {\n /**\n * Run a shell command or binary.\n *\n * @param command - The command to run\n * @param options - Execution options\n * @returns stdout if capture is true, empty string otherwise\n */\n abstract run(command: string, options?: ShellRunOptions): Promise<string>;\n\n /**\n * Check if a command is installed and available in the system PATH.\n *\n * @param command - The command name to check\n * @returns true if the command is available\n */\n abstract isInstalled(command: string): Promise<boolean>;\n}\n","import { $inject, AlephaError, type FileLike, Json } from \"alepha\";\nimport { FileDetector } from \"../services/FileDetector.ts\";\nimport type {\n CpOptions,\n CreateFileOptions,\n FileSystemProvider,\n LsOptions,\n MkdirOptions,\n RmOptions,\n} from \"./FileSystemProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Web-standard implementation of FileSystemProvider for Cloudflare Workers and other edge runtimes.\n *\n * Uses only Web APIs (ReadableStream, TextEncoder, etc.) — no Node.js-specific APIs.\n * Provides working `createFile` with proper streaming support.\n * Filesystem operations (rm, cp, mv, etc.) are not available in edge runtimes and will throw.\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(WorkerdFileSystemProvider);\n *\n * // Create from text (returns FileLike with web ReadableStream)\n * const file = fs.createFile({ text: \"Hello!\", name: \"greeting.txt\" });\n * const stream = file.stream(); // ReadableStream (web standard)\n * ```\n */\nexport class WorkerdFileSystemProvider implements FileSystemProvider {\n protected detector = $inject(FileDetector);\n protected json = $inject(Json);\n\n protected encoder = new TextEncoder();\n protected decoder = new TextDecoder();\n\n public join(...paths: string[]): string {\n const joined = paths.join(\"/\").replace(/\\/+/g, \"/\");\n const parts = joined.split(\"/\");\n const resolved: string[] = [];\n for (const part of parts) {\n if (part === \"..\") {\n resolved.pop();\n } else if (part !== \".\") {\n resolved.push(part);\n }\n }\n return resolved.join(\"/\") || \".\";\n }\n\n public createFile(options: CreateFileOptions): FileLike {\n if (\"text\" in options) {\n return this.createFileFromText(options.text, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"arrayBuffer\" in options) {\n return this.createFileFromArrayBuffer(options.arrayBuffer, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"buffer\" in options) {\n const ab =\n options.buffer instanceof ArrayBuffer\n ? options.buffer\n : options.buffer.buffer.slice(\n options.buffer.byteOffset,\n options.buffer.byteOffset + options.buffer.byteLength,\n );\n return this.createFileFromArrayBuffer(ab as ArrayBuffer, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"file\" in options) {\n return this.createFileFromWebFile(options.file, {\n type: options.type,\n name: options.name,\n size: options.size,\n });\n }\n\n if (\"response\" in options) {\n return this.createFileFromResponse(options.response, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"stream\" in options) {\n return this.createFileFromStream(options.stream as ReadableStream, {\n type: options.type,\n name: options.name,\n size: options.size,\n });\n }\n\n if (\"url\" in options) {\n return this.createFileFromUrl(options.url, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"path\" in options) {\n throw new AlephaError(\n \"WorkerdFileSystemProvider.createFile: 'path' source is not supported in edge runtimes.\",\n );\n }\n\n throw new AlephaError(\n \"WorkerdFileSystemProvider.createFile: unsupported options.\",\n );\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n protected createFileFromText(\n text: string,\n options: { type?: string; name?: string } = {},\n ): FileLike {\n const encoded = this.encoder.encode(text);\n const name = options.name ?? \"file.txt\";\n return {\n name,\n type: options.type ?? this.detector.getContentType(name),\n size: encoded.byteLength,\n lastModified: Date.now(),\n stream: () =>\n new ReadableStream({\n start(controller) {\n controller.enqueue(encoded);\n controller.close();\n },\n }),\n arrayBuffer: async () =>\n encoded.buffer.slice(\n encoded.byteOffset,\n encoded.byteOffset + encoded.byteLength,\n ) as ArrayBuffer,\n text: async () => text,\n };\n }\n\n protected createFileFromArrayBuffer(\n source: ArrayBuffer,\n options: { type?: string; name?: string } = {},\n ): FileLike {\n const name = options.name ?? \"file\";\n const bytes = new Uint8Array(source);\n return {\n name,\n type: options.type ?? this.detector.getContentType(name),\n size: source.byteLength,\n lastModified: Date.now(),\n stream: () =>\n new ReadableStream({\n start(controller) {\n controller.enqueue(bytes);\n controller.close();\n },\n }),\n arrayBuffer: async () => source,\n text: async () => this.decoder.decode(source),\n };\n }\n\n protected createFileFromWebFile(\n source: File,\n options: { type?: string; name?: string; size?: number } = {},\n ): FileLike {\n const name = options.name ?? source.name;\n return {\n name,\n type: options.type ?? (source.type || this.detector.getContentType(name)),\n size: options.size ?? source.size ?? 0,\n lastModified: source.lastModified || Date.now(),\n stream: () => source.stream(),\n arrayBuffer: async () => await source.arrayBuffer(),\n text: async () => await source.text(),\n };\n }\n\n protected createFileFromResponse(\n response: Response,\n options: { type?: string; name?: string } = {},\n ): FileLike {\n if (!response.body) {\n throw new AlephaError(\"Response has no body stream\");\n }\n\n const sizeHeader = response.headers.get(\"content-length\");\n const size = sizeHeader ? parseInt(sizeHeader, 10) : 0;\n\n let name = options.name;\n if (!name) {\n const cd = response.headers.get(\"content-disposition\");\n if (cd) {\n const match = cd.match(/filename=\"?([^\"]+)\"?/);\n if (match) {\n name = match[1];\n }\n }\n }\n name ??= \"file\";\n\n const type =\n options.type ?? response.headers.get(\"content-type\") ?? undefined;\n\n return {\n name,\n type: type ?? this.detector.getContentType(name),\n size,\n lastModified: Date.now(),\n stream: () => response.body!,\n arrayBuffer: async () => await response.arrayBuffer(),\n text: async () => await response.text(),\n };\n }\n\n protected createFileFromStream(\n source: ReadableStream,\n options: { type?: string; name?: string; size?: number } = {},\n ): FileLike {\n const name = options.name ?? \"file\";\n let buffer: ArrayBuffer | null = null;\n\n const consumeStream = async (): Promise<ArrayBuffer> => {\n if (buffer) return buffer;\n const reader = source.getReader();\n const chunks: Uint8Array[] = [];\n let done = false;\n while (!done) {\n const result = await reader.read();\n done = result.done;\n if (result.value) {\n chunks.push(result.value);\n }\n }\n const total = chunks.reduce((sum, c) => sum + c.byteLength, 0);\n const merged = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n merged.set(chunk, offset);\n offset += chunk.byteLength;\n }\n buffer = merged.buffer as ArrayBuffer;\n return buffer;\n };\n\n return {\n name,\n type: options.type ?? this.detector.getContentType(name),\n size: options.size ?? 0,\n lastModified: Date.now(),\n stream: () => source,\n arrayBuffer: consumeStream,\n text: async () => this.decoder.decode(await consumeStream()),\n };\n }\n\n protected createFileFromUrl(\n url: string,\n options: { type?: string; name?: string } = {},\n ): FileLike {\n const parsedUrl = new URL(url);\n const name = options.name ?? parsedUrl.pathname.split(\"/\").pop() ?? \"file\";\n\n return {\n name,\n type: options.type ?? this.detector.getContentType(name),\n size: 0,\n lastModified: Date.now(),\n stream: () => {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: streaming from URL is not supported. Use fetch() and createFile({ response }) instead.\",\n );\n },\n arrayBuffer: async () => {\n const res = await fetch(url);\n return await res.arrayBuffer();\n },\n text: async () => {\n const res = await fetch(url);\n return await res.text();\n },\n };\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n // Filesystem operations — not available in edge runtimes\n // -------------------------------------------------------------------------------------------------------------------\n\n public async rm(_path: string, _options?: RmOptions): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: rm() is not available in edge runtimes.\",\n );\n }\n\n public async cp(\n _src: string,\n _dest: string,\n _options?: CpOptions,\n ): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: cp() is not available in edge runtimes.\",\n );\n }\n\n public async mv(_src: string, _dest: string): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: mv() is not available in edge runtimes.\",\n );\n }\n\n public async mkdir(_path: string, _options?: MkdirOptions): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: mkdir() is not available in edge runtimes.\",\n );\n }\n\n public async ls(_path: string, _options?: LsOptions): Promise<string[]> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: ls() is not available in edge runtimes.\",\n );\n }\n\n public async exists(_path: string): Promise<boolean> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: exists() is not available in edge runtimes.\",\n );\n }\n\n public async readFile(_path: string): Promise<Buffer> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: readFile() is not available in edge runtimes.\",\n );\n }\n\n public async writeFile(\n _path: string,\n _data: Uint8Array | Buffer | string | FileLike,\n ): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: writeFile() is not available in edge runtimes.\",\n );\n }\n\n public async readTextFile(_path: string): Promise<string> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: readTextFile() is not available in edge runtimes.\",\n );\n }\n\n public async readJsonFile<T = unknown>(_path: string): Promise<T> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: readJsonFile() is not available in edge runtimes.\",\n );\n }\n}\n","export class FileError extends Error {\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = \"FileError\";\n this.cause = cause;\n }\n}\n","import { $module } from \"alepha\";\nimport { BunShellProvider } from \"./providers/BunShellProvider.ts\";\nimport { FileSystemProvider } from \"./providers/FileSystemProvider.ts\";\nimport { MemoryFileSystemProvider } from \"./providers/MemoryFileSystemProvider.ts\";\nimport { MemoryShellProvider } from \"./providers/MemoryShellProvider.ts\";\nimport { NodeFileSystemProvider } from \"./providers/NodeFileSystemProvider.ts\";\nimport { NodeShellProvider } from \"./providers/NodeShellProvider.ts\";\nimport { ShellProvider } from \"./providers/ShellProvider.ts\";\nimport { WorkerdFileSystemProvider } from \"./providers/WorkerdFileSystemProvider.ts\";\nimport { FileDetector } from \"./services/FileDetector.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./errors/FileError.ts\";\nexport * from \"./providers/BunShellProvider.ts\";\nexport * from \"./providers/FileSystemProvider.ts\";\nexport * from \"./providers/MemoryFileSystemProvider.ts\";\nexport * from \"./providers/MemoryShellProvider.ts\";\nexport * from \"./providers/NodeFileSystemProvider.ts\";\nexport * from \"./providers/NodeShellProvider.ts\";\nexport * from \"./providers/ShellProvider.ts\";\nexport * from \"./providers/WorkerdFileSystemProvider.ts\";\nexport * from \"./services/FileDetector.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * System-level abstractions for portable code across runtimes.\n *\n * **Features:**\n * - File system operations (read, write, exists, etc.)\n * - Shell command execution\n * - File type detection and MIME utilities\n * - Memory implementations for testing\n *\n * @module alepha.system\n */\nexport const AlephaSystem = $module({\n name: \"alepha.system\",\n primitives: [],\n services: [FileDetector, FileSystemProvider, ShellProvider],\n variants: [\n MemoryFileSystemProvider,\n NodeFileSystemProvider,\n WorkerdFileSystemProvider,\n MemoryShellProvider,\n NodeShellProvider,\n BunShellProvider,\n ],\n register: (alepha) => {\n const shellImpl = alepha.isTest()\n ? MemoryShellProvider\n : alepha.isBun()\n ? BunShellProvider\n : NodeShellProvider;\n return alepha\n .with({\n optional: true,\n provide: FileSystemProvider,\n use: NodeFileSystemProvider,\n })\n .with({\n optional: true,\n provide: ShellProvider,\n use: shellImpl,\n });\n },\n});\n"],"mappings":";;;;;;;;;;;;AAyOA,IAAsB,qBAAtB,MAAyC;;;;;;;;;AC3NzC,IAAa,oBAAb,MAAwD;CACtD,MAAyB,SAAS;CAClC,KAAwB,QAAQ,mBAAmB;;;;CAKnD,MAAa,IACX,SACA,UAA2B,EAAE,EACZ;EACjB,MAAM,EAAE,UAAU,OAAO,UAAU,OAAO,MAAM,QAAQ;EACxD,MAAM,MAAM,QAAQ,QAAQ,KAAK;EAEjC,KAAK,IAAI,MAAM,UAAU,WAAW;GAAE;GAAK;GAAS;GAAS,CAAC;EAE9D,IAAI;EACJ,IAAI;EAEJ,IAAI,SAAS;GACX,MAAM,CAAC,KAAK,GAAG,QAAQ,KAAK,aAAa,QAAQ;GACjD,aAAa,MAAM,KAAK,kBAAkB,KAAK,IAAI;GACnD,OAAO;SAEP,CAAC,eAAe,QAAQ,KAAK,aAAa,QAAQ;EAIpD,MAAM,eAAe,KAAK,kBAAkB,YAAY,KAAK;EAE7D,IAAI,SACF,OAAO,KAAK,YAAY,cAAc;GAAE;GAAK;GAAK,CAAC;EAGrD,OAAO,KAAK,YAAY,YAAY,MAAM;GAAE;GAAK;GAAK,CAAC;;;;;CAMzD,MAAgB,YACd,YACA,MACA,SACiB;EAKjB,MAAM,OAJY,QAAQ,aAAa,UAKnC,MAAM,KAAK,kBAAkB,YAAY,KAAK,EAAE,EAAE,EAAE;GAClD,OAAO;GACP,KAAK,QAAQ;GACb,OAAO;GACP,KAAK;IAAE,GAAG,QAAQ;IAAK,GAAG,QAAQ;IAAK;GACxC,CAAC,GACF,MAAM,YAAY,MAAM;GACtB,OAAO;GACP,KAAK,QAAQ;GACb,KAAK;IAAE,GAAG,QAAQ;IAAK,GAAG,QAAQ;IAAK;GACxC,CAAC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C;GAAE,WAAW;IAAC;IAAM;IAAM;IAAM;IAAK;GAAE,UAAU;GAAc,CAAC;EAGvE,KAAK;GACH;IACE,WAAW;KAAC;KAAM;KAAM;KAAM;KAAM;KAAM;KAAM;KAAM;KAAK;IAC3D,UAAU;IACX;GACD;IACE,WAAW;KACT;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACD,UAAU;IACX;GACD;IACE,WAAW;KACT;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACD,UAAU;IACX;GACF;EACD,MAAM,CAAC;GAAE,WAAW;IAAC;IAAM;IAAM;IAAM;IAAK;GAAE,UAAU;GAAc,CAAC;EACvE,KAAK,CACH;GACE,WAAW;IACT;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD;GACD,UAAU;GACX,CACF;EACD,KAAK,CACH;GACE,WAAW;IACT;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD;GACD,UAAU;GACX,CACF;EACD,KAAK,CACH;GAAE,WAAW;IAAC;IAAM;IAAM;IAAM;IAAK;GAAE,UAAU;GAAoB,CACtE;EAGD,MAAM,CACJ;GACE,WAAW;IAAC;IAAM;IAAM;IAAM;IAAK;GACnC,UACE;GACH,CACF;EACD,MAAM,CACJ;GACE,WAAW;IAAC;IAAM;IAAM;IAAM;IAAK;GACnC,UACE;GACH,CACF;EACD,MAAM,CACJ;GACE,WAAW;IAAC;IAAM;IAAM;IAAM;IAAK;GACnC,UACE;GACH,CACF;EACD,KAAK,CACH;GACE,WAAW;IAAC;IAAM;IAAM;IAAM;IAAM;IAAM;IAAM;IAAM;IAAK;GAC3D,UAAU;GACX,CACF;EACD,KAAK,CACH;GACE,WAAW;IAAC;IAAM;IAAM;IAAM;IAAM;IAAM;IAAM;IAAM;IAAK;GAC3D,UAAU;GACX,CACF;EACD,KAAK,CACH;GACE,WAAW;IAAC;IAAM;IA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EAC1D,MAAM,IAAI,YACR,qEACD;;CAGH,MAAa,MAAM,OAAe,UAAwC;EACxE,MAAM,IAAI,YACR,wEACD;;CAGH,MAAa,GAAG,OAAe,UAAyC;EACtE,MAAM,IAAI,YACR,qEACD;;CAGH,MAAa,OAAO,OAAiC;EACnD,MAAM,IAAI,YACR,yEACD;;CAGH,MAAa,SAAS,OAAgC;EACpD,MAAM,IAAI,YACR,2EACD;;CAGH,MAAa,UACX,OACA,OACe;EACf,MAAM,IAAI,YACR,4EACD;;CAGH,MAAa,aAAa,OAAgC;EACxD,MAAM,IAAI,YACR,+EACD;;CAGH,MAAa,aAA0B,OAA2B;EAChE,MAAM,IAAI,YACR,+EACD;;;;;AC1WL,IAAa,YAAb,cAA+B,MAAM;CACnC,YAAY,SAAiB,OAAe;EAC1C,MAAM,QAAQ;EACd,KAAK,OAAO;EACZ,KAAK,QAAQ;;;;;;;;;;;;;;;;ACiCjB,MAAa,eAAe,QAAQ;CAClC,MAAM;CACN,YAAY,EAAE;CACd,UAAU;EAAC;EAAc;EAAoB;EAAc;CAC3D,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACD;CACD,WAAW,WAAW;EACpB,MAAM,YAAY,OAAO,QAAQ,GAC7B,sBACA,OAAO,OAAO,GACZ,mBACA;EACN,OAAO,OACJ,KAAK;GACJ,UAAU;GACV,SAAS;GACT,KAAK;GACN,CAAC,CACD,KAAK;GACJ,UAAU;GACV,SAAS;GACT,KAAK;GACN,CAAC;;CAEP,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["nodeJoin","nodeBasename","fsRm","fsCp","fsMkdir","fsReadFile","fsWriteFile"],"sources":["../../src/system/providers/FileSystemProvider.ts","../../src/system/providers/NodeShellProvider.ts","../../src/system/providers/BunShellProvider.ts","../../src/system/providers/MemoryFileSystemProvider.ts","../../src/system/providers/MemoryShellProvider.ts","../../src/system/services/FileDetector.ts","../../src/system/providers/NodeFileSystemProvider.ts","../../src/system/providers/ShellProvider.ts","../../src/system/providers/WorkerdFileSystemProvider.ts","../../src/system/errors/FileError.ts","../../src/system/index.ts"],"sourcesContent":["import type { FileLike, StreamLike } from \"alepha\";\n\n/**\n * Options for creating a file from a URL\n */\nexport interface CreateFileFromUrlOptions {\n /**\n * The URL to load the file from (file://, http://, or https://)\n */\n url: string;\n /**\n * The MIME type of the file (optional, will be detected from filename if not provided)\n */\n type?: string;\n /**\n * The name of the file (optional, will be extracted from URL if not provided)\n */\n name?: string;\n}\n\n/**\n * Options for creating a file from a path (URL with file:// scheme)\n */\nexport interface CreateFileFromPathOptions {\n /**\n * The path to the file on the local filesystem\n */\n path: string;\n /**\n * The MIME type of the file (optional, will be detected from filename if not provided)\n */\n type?: string;\n /**\n * The name of the file (optional, will be extracted from URL if not provided)\n */\n name?: string;\n}\n\n/**\n * Options for creating a file from a Buffer\n */\nexport interface CreateFileFromBufferOptions {\n /**\n * The Buffer containing the file data\n */\n buffer: Buffer;\n /**\n * The MIME type of the file (optional, will be detected from name if not provided)\n */\n type?: string;\n /**\n * The name of the file (required for proper content type detection)\n */\n name?: string;\n}\n\n/**\n * Options for creating a file from a stream\n */\nexport interface CreateFileFromStreamOptions {\n /**\n * The readable stream containing the file data\n */\n stream: StreamLike;\n /**\n * The MIME type of the file (optional, will be detected from name if not provided)\n */\n type?: string;\n /**\n * The name of the file (required for proper content type detection)\n */\n name?: string;\n /**\n * The size of the file in bytes (optional)\n */\n size?: number;\n}\n\n/**\n * Options for creating a file from text content\n */\nexport interface CreateFileFromTextOptions {\n /**\n * The text content to create the file from\n */\n text: string;\n /**\n * The MIME type of the file (default: text/plain)\n */\n type?: string;\n /**\n * The name of the file (default: \"file.txt\")\n */\n name?: string;\n}\n\nexport interface CreateFileFromResponseOptions {\n /**\n * The Response object containing the file data\n */\n response: Response;\n /**\n * Override the name (optional, uses filename from Content-Disposition header if not provided)\n */\n name?: string;\n /**\n * Override the MIME type (optional, uses file.type if not provided)\n */\n type?: string;\n}\n\n/**\n * Options for creating a file from a Web File object\n */\nexport interface CreateFileFromWebFileOptions {\n /**\n * The Web File object\n */\n file: File;\n /**\n * Override the MIME type (optional, uses file.type if not provided)\n */\n type?: string;\n /**\n * Override the name (optional, uses file.name if not provided)\n */\n name?: string;\n /**\n * Override the size (optional, uses file.size if not provided)\n */\n size?: number;\n}\n\n/**\n * Options for creating a file from an ArrayBuffer\n */\nexport interface CreateFileFromArrayBufferOptions {\n /**\n * The ArrayBuffer containing the file data\n */\n arrayBuffer: ArrayBuffer;\n /**\n * The MIME type of the file (optional, will be detected from name if not provided)\n */\n type?: string;\n /**\n * The name of the file (required for proper content type detection)\n */\n name?: string;\n}\n\n/**\n * Union type for all createFile options\n */\nexport type CreateFileOptions =\n | CreateFileFromUrlOptions\n | CreateFileFromPathOptions\n | CreateFileFromBufferOptions\n | CreateFileFromStreamOptions\n | CreateFileFromTextOptions\n | CreateFileFromWebFileOptions\n | CreateFileFromResponseOptions\n | CreateFileFromArrayBufferOptions;\n\n/**\n * Options for rm (remove) operation\n */\nexport interface RmOptions {\n /**\n * If true, removes directories and their contents recursively\n */\n recursive?: boolean;\n /**\n * If true, no error will be thrown if the path does not exist\n */\n force?: boolean;\n}\n\n/**\n * Options for cp (copy) operation\n */\nexport interface CpOptions {\n /**\n * Copy directories recursively.\n *\n * @default true\n */\n recursive?: boolean;\n /**\n * If true, overwrite existing destination\n */\n force?: boolean;\n}\n\n/**\n * Options for mkdir operation\n */\nexport interface MkdirOptions {\n /**\n * If true, creates parent directories as needed\n *\n * @default true\n */\n recursive?: boolean;\n /**\n * If true, does not throw an error if the directory already exists\n *\n * @default true\n */\n force?: boolean;\n /**\n * File mode (permission and sticky bits)\n */\n mode?: number;\n}\n\n/**\n * Options for ls (list) operation\n */\nexport interface LsOptions {\n /**\n * If true, list contents of directories recursively\n */\n recursive?: boolean;\n /**\n * If true, include hidden files (starting with .)\n */\n hidden?: boolean;\n}\n\n/**\n * FileSystem interface providing utilities for working with files.\n */\nexport abstract class FileSystemProvider {\n /**\n * Joins multiple path segments into a single path.\n *\n * @param paths - The path segments to join\n * @returns The joined path\n */\n abstract join(...paths: string[]): string;\n\n /**\n * Creates a FileLike object from various sources.\n *\n * @param options - Options for creating the file\n * @returns A FileLike object\n */\n abstract createFile(options: CreateFileOptions): FileLike;\n\n /**\n * Removes a file or directory.\n *\n * @param path - The path to remove\n * @param options - Remove options\n */\n abstract rm(path: string, options?: RmOptions): Promise<void>;\n\n /**\n * Copies a file or directory.\n *\n * @param src - Source path\n * @param dest - Destination path\n * @param options - Copy options\n */\n abstract cp(src: string, dest: string, options?: CpOptions): Promise<void>;\n\n /**\n * Moves/renames a file or directory.\n *\n * @param src - Source path\n * @param dest - Destination path\n */\n abstract mv(src: string, dest: string): Promise<void>;\n\n /**\n * Creates a directory.\n *\n * @param path - The directory path to create\n * @param options - Mkdir options\n */\n abstract mkdir(path: string, options?: MkdirOptions): Promise<void>;\n\n /**\n * Lists files in a directory.\n *\n * @param path - The directory path to list\n * @param options - List options\n * @returns Array of filenames\n */\n abstract ls(path: string, options?: LsOptions): Promise<string[]>;\n\n /**\n * Checks if a file or directory exists.\n *\n * @param path - The path to check\n * @returns True if the path exists, false otherwise\n */\n abstract exists(path: string): Promise<boolean>;\n\n /**\n * Reads the content of a file.\n *\n * @param path - The file path to read\n * @returns The file content as a Buffer\n */\n abstract readFile(path: string): Promise<Buffer>;\n\n /**\n * Writes data to a file.\n *\n * @param path - The file path to write to\n * @param data - The data to write (Buffer or string)\n */\n abstract writeFile(\n path: string,\n data: Uint8Array | Buffer | string | FileLike,\n ): Promise<void>;\n\n /**\n * Reads the content of a file as a string.\n *\n * @param path - The file path to read\n * @returns The file content as a string\n */\n abstract readTextFile(path: string): Promise<string>;\n\n /**\n * Reads the content of a file as JSON.\n *\n * @param path - The file path to read\n * @returns The parsed JSON content\n */\n abstract readJsonFile<T = unknown>(path: string): Promise<T>;\n}\n","import { exec, spawn } from \"node:child_process\";\nimport { $inject, AlephaError } from \"alepha\";\nimport { $logger } from \"alepha/logger\";\nimport { FileSystemProvider } from \"./FileSystemProvider.ts\";\nimport type { ShellProvider, ShellRunOptions } from \"./ShellProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Node.js implementation of ShellProvider.\n *\n * Executes shell commands using Node.js child_process module.\n * Supports binary resolution from node_modules/.bin for local packages.\n */\nexport class NodeShellProvider implements ShellProvider {\n protected readonly log = $logger();\n protected readonly fs = $inject(FileSystemProvider);\n\n /**\n * Run a shell command or binary.\n */\n public async run(\n command: string,\n options: ShellRunOptions = {},\n ): Promise<string> {\n const { resolve = false, capture = false, root, env } = options;\n const cwd = root ?? process.cwd();\n\n this.log.debug(`Shell: ${command}`, { cwd, resolve, capture });\n\n let executable: string;\n let args: string[];\n\n if (resolve) {\n const [bin, ...rest] = this.parseCommand(command);\n executable = await this.resolveExecutable(bin, cwd);\n args = rest;\n } else {\n [executable, ...args] = this.parseCommand(command);\n }\n\n // Build properly escaped command string for shell execution\n const shellCommand = this.buildShellCommand(executable, args);\n\n if (capture) {\n return this.execCapture(shellCommand, { cwd, env });\n }\n\n return this.execInherit(executable, args, { cwd, env });\n }\n\n /**\n * Execute command with inherited stdio (streams to terminal).\n */\n protected async execInherit(\n executable: string,\n args: string[],\n options: { cwd: string; env?: Record<string, string> },\n ): Promise<string> {\n const isWindows = process.platform === \"win32\";\n\n // On Windows, use shell mode with a single command string to avoid\n // Node.js DEP0190 deprecation warning about unescaped args with shell: true\n const proc = isWindows\n ? spawn(this.buildShellCommand(executable, args), [], {\n stdio: \"inherit\",\n cwd: options.cwd,\n shell: true,\n env: { ...process.env, ...options.env },\n })\n : spawn(executable, args, {\n stdio: \"inherit\",\n cwd: options.cwd,\n env: { ...process.env, ...options.env },\n });\n\n return new Promise<string>((resolve, reject) => {\n proc.on(\"exit\", (code) => {\n if (code === 0 || code === null) {\n resolve(\"\");\n } else {\n reject(new AlephaError(`Command exited with code ${code}`));\n }\n });\n proc.on(\"error\", reject);\n });\n }\n\n /**\n * Build a shell command string with proper escaping for Windows.\n * Quotes both executable and arguments that contain spaces or special characters.\n */\n protected buildShellCommand(executable: string, args: string[]): string {\n const escapeForShell = (str: string): string => {\n // If str contains spaces or special chars, wrap in double quotes\n // and escape internal double quotes\n if (/[\\s\"&|<>^()]/.test(str)) {\n return `\"${str.replace(/\"/g, '\\\\\"')}\"`;\n }\n return str;\n };\n\n return [escapeForShell(executable), ...args.map(escapeForShell)].join(\" \");\n }\n\n /**\n * Execute command and capture stdout.\n */\n protected execCapture(\n command: string,\n options: { cwd: string; env?: Record<string, string> },\n ): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n exec(\n command,\n {\n cwd: options.cwd,\n maxBuffer: 50 * 1024 * 1024,\n env: {\n ...process.env,\n LOG_FORMAT: \"pretty\",\n ...options.env,\n },\n },\n (err, stdout) => {\n if (err) {\n (err as any).stdout = stdout;\n reject(err);\n } else {\n resolve(stdout);\n }\n },\n );\n });\n }\n\n /**\n * Resolve executable path from node_modules/.bin.\n *\n * Search order:\n * 1. Local: node_modules/.bin/\n * 2. Pnpm nested: node_modules/alepha/node_modules/.bin/\n * 3. Monorepo: Walk up to 3 parent directories\n */\n protected async resolveExecutable(\n name: string,\n root: string,\n ): Promise<string> {\n const isWindows = process.platform === \"win32\";\n // On Windows, try .cmd first (npm scripts), then .exe, then no extension\n const suffixes = isWindows ? [\".cmd\", \".exe\", \"\"] : [\"\"];\n\n for (const suffix of suffixes) {\n // 1. Local node_modules\n let execPath = await this.findExecutable(\n root,\n `node_modules/.bin/${name}${suffix}`,\n );\n if (execPath) return execPath;\n\n // 2. Pnpm nested (alepha's own node_modules)\n execPath = await this.findExecutable(\n root,\n `node_modules/alepha/node_modules/.bin/${name}${suffix}`,\n );\n if (execPath) return execPath;\n\n // 3. Monorepo: check parent directories (up to 3 levels)\n let parentDir = this.fs.join(root, \"..\");\n for (let i = 0; i < 3; i++) {\n execPath = await this.findExecutable(\n parentDir,\n `node_modules/.bin/${name}${suffix}`,\n );\n if (execPath) return execPath;\n parentDir = this.fs.join(parentDir, \"..\");\n }\n }\n\n throw new AlephaError(\n `Could not find executable for '${name}'. Make sure the package is installed.`,\n );\n }\n\n /**\n * Check if executable exists at path.\n */\n protected async findExecutable(\n root: string,\n relativePath: string,\n ): Promise<string | undefined> {\n const fullPath = this.fs.join(root, relativePath);\n if (await this.fs.exists(fullPath)) {\n return fullPath;\n }\n return undefined;\n }\n\n /**\n * Check if a command is installed and available in the system PATH.\n */\n public isInstalled(command: string): Promise<boolean> {\n return new Promise((resolve) => {\n const check =\n process.platform === \"win32\"\n ? `where ${command}`\n : `command -v ${command}`;\n exec(check, (error) => resolve(!error));\n });\n }\n\n /**\n * Parse a command string into executable and arguments.\n *\n * Handles quoted arguments properly for paths with spaces.\n * Supports both single and double quotes.\n */\n protected parseCommand(command: string): string[] {\n const result: string[] = [];\n let current = \"\";\n let inQuote: string | null = null;\n\n for (let i = 0; i < command.length; i++) {\n const char = command[i];\n\n if (inQuote) {\n if (char === inQuote) {\n inQuote = null;\n } else {\n current += char;\n }\n } else if (char === '\"' || char === \"'\") {\n inQuote = char;\n } else if (char === \" \") {\n if (current) {\n result.push(current);\n current = \"\";\n }\n } else {\n current += char;\n }\n }\n\n if (current) {\n result.push(current);\n }\n\n return result;\n }\n}\n","import { AlephaError } from \"alepha\";\nimport { NodeShellProvider } from \"./NodeShellProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Bun implementation of ShellProvider.\n *\n * Executes shell commands using Bun's native `Bun.spawn` and `Bun.which`,\n * skipping the `node:child_process` compatibility layer for better performance.\n *\n * Inherits executable resolution (`node_modules/.bin` walk) and command parsing\n * from `NodeShellProvider`.\n */\nexport class BunShellProvider extends NodeShellProvider {\n /**\n * Execute command with inherited stdio (streams to terminal).\n */\n protected override async execInherit(\n executable: string,\n args: string[],\n options: { cwd: string; env?: Record<string, string> },\n ): Promise<string> {\n const proc = Bun.spawn([executable, ...args], {\n cwd: options.cwd,\n env: { ...process.env, ...options.env },\n stdout: \"inherit\",\n stderr: \"inherit\",\n stdin: \"inherit\",\n });\n\n const code = await proc.exited;\n if (code !== 0) {\n throw new AlephaError(`Command exited with code ${code}`);\n }\n return \"\";\n }\n\n /**\n * Execute command and capture stdout.\n */\n protected override async execCapture(\n command: string,\n options: { cwd: string; env?: Record<string, string> },\n ): Promise<string> {\n const [executable, ...args] = this.parseCommand(command);\n const proc = Bun.spawn([executable, ...args], {\n cwd: options.cwd,\n env: {\n ...process.env,\n LOG_FORMAT: \"pretty\",\n ...options.env,\n },\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n\n const [stdout, stderr, code] = await Promise.all([\n new Response(proc.stdout).text(),\n new Response(proc.stderr).text(),\n proc.exited,\n ]);\n\n if (code !== 0) {\n const err = new AlephaError(\n `Command exited with code ${code}: ${stderr || stdout}`,\n );\n (err as any).stdout = stdout;\n (err as any).stderr = stderr;\n throw err;\n }\n return stdout;\n }\n\n /**\n * Check if a command is installed and available in the system PATH.\n */\n public override async isInstalled(command: string): Promise<boolean> {\n return Bun.which(command) !== null;\n }\n}\n","import { basename as nodeBasename, join as nodeJoin } from \"node:path\";\nimport { $inject, AlephaError, type FileLike, Json } from \"alepha\";\nimport type {\n CpOptions,\n CreateFileOptions,\n FileSystemProvider,\n LsOptions,\n MkdirOptions,\n RmOptions,\n} from \"./FileSystemProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface MemoryFileSystemProviderOptions {\n /**\n * Error to throw on mkdir operations (for testing error handling)\n */\n mkdirError?: Error | null;\n /**\n * Error to throw on writeFile operations (for testing error handling)\n */\n writeFileError?: Error | null;\n /**\n * Error to throw on readFile operations (for testing error handling)\n */\n readFileError?: Error | null;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * In-memory implementation of FileSystemProvider for testing.\n *\n * This provider stores all files and directories in memory, making it ideal for\n * unit tests that need to verify file operations without touching the real file system.\n *\n * @example\n * ```typescript\n * // In tests, substitute the real FileSystemProvider with MemoryFileSystemProvider\n * const alepha = Alepha.create().with({\n * provide: FileSystemProvider,\n * use: MemoryFileSystemProvider,\n * });\n *\n * // Run code that uses FileSystemProvider\n * const service = alepha.inject(MyService);\n * await service.saveFile(\"test.txt\", \"Hello World\");\n *\n * // Verify the file was written\n * const memoryFs = alepha.inject(MemoryFileSystemProvider);\n * expect(memoryFs.files.get(\"test.txt\")?.toString()).toBe(\"Hello World\");\n * ```\n */\nexport class MemoryFileSystemProvider implements FileSystemProvider {\n protected json = $inject(Json);\n\n /**\n * In-memory storage for files (path -> content)\n */\n public files = new Map<string, Buffer>();\n\n /**\n * In-memory storage for directories\n */\n public directories = new Set<string>();\n\n /**\n * Track mkdir calls for test assertions\n */\n public mkdirCalls: Array<{ path: string; options?: MkdirOptions }> = [];\n\n /**\n * Track writeFile calls for test assertions\n */\n public writeFileCalls: Array<{ path: string; data: string }> = [];\n\n /**\n * Track readFile calls for test assertions\n */\n public readFileCalls: Array<string> = [];\n\n /**\n * Track rm calls for test assertions\n */\n public rmCalls: Array<{ path: string; options?: RmOptions }> = [];\n\n /**\n * Track join calls for test assertions\n */\n public joinCalls: Array<string[]> = [];\n\n /**\n * Error to throw on mkdir (for testing error handling)\n */\n public mkdirError: Error | null = null;\n\n /**\n * Error to throw on writeFile (for testing error handling)\n */\n public writeFileError: Error | null = null;\n\n /**\n * Error to throw on readFile (for testing error handling)\n */\n public readFileError: Error | null = null;\n\n constructor(options: MemoryFileSystemProviderOptions = {}) {\n this.mkdirError = options.mkdirError ?? null;\n this.writeFileError = options.writeFileError ?? null;\n this.readFileError = options.readFileError ?? null;\n }\n\n /**\n * Join path segments using forward slashes.\n * Uses Node's path.join for proper normalization (handles .. and .)\n */\n public join(...paths: string[]): string {\n this.joinCalls.push(paths);\n return nodeJoin(...paths);\n }\n\n /**\n * Normalize path separators to forward slashes for consistent internal storage.\n * This ensures Windows paths work correctly in the in-memory file system.\n */\n protected normalizePath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n }\n\n /**\n * Create a FileLike object from various sources.\n */\n public createFile(options: CreateFileOptions): FileLike {\n if (\"path\" in options) {\n const filePath = options.path;\n const buffer = this.files.get(filePath);\n if (buffer === undefined) {\n throw new AlephaError(\n `ENOENT: no such file or directory, open '${filePath}'`,\n );\n }\n return {\n name: options.name ?? nodeBasename(filePath),\n type: options.type ?? \"application/octet-stream\",\n size: buffer.byteLength,\n lastModified: Date.now(),\n stream: () => {\n throw new AlephaError(\n \"Stream not implemented in MemoryFileSystemProvider\",\n );\n },\n arrayBuffer: async (): Promise<ArrayBuffer> =>\n buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength,\n ) as ArrayBuffer,\n text: async () => buffer.toString(\"utf-8\"),\n };\n }\n\n if (\"buffer\" in options) {\n const buffer = options.buffer;\n return {\n name: options.name ?? \"file\",\n type: options.type ?? \"application/octet-stream\",\n size: buffer.byteLength,\n lastModified: Date.now(),\n stream: () => {\n throw new AlephaError(\n \"Stream not implemented in MemoryFileSystemProvider\",\n );\n },\n arrayBuffer: async (): Promise<ArrayBuffer> =>\n buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength,\n ) as ArrayBuffer,\n text: async () => buffer.toString(\"utf-8\"),\n };\n }\n\n if (\"text\" in options) {\n const buffer = Buffer.from(options.text, \"utf-8\");\n return {\n name: options.name ?? \"file.txt\",\n type: options.type ?? \"text/plain\",\n size: buffer.byteLength,\n lastModified: Date.now(),\n stream: () => {\n throw new AlephaError(\n \"Stream not implemented in MemoryFileSystemProvider\",\n );\n },\n arrayBuffer: async (): Promise<ArrayBuffer> =>\n buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength,\n ) as ArrayBuffer,\n text: async () => options.text,\n };\n }\n\n throw new AlephaError(\n \"MemoryFileSystemProvider.createFile: unsupported options. Only buffer and text are supported.\",\n );\n }\n\n /**\n * Remove a file or directory from memory.\n */\n public async rm(path: string, options?: RmOptions): Promise<void> {\n this.rmCalls.push({ path, options });\n\n const exists = this.files.has(path) || this.directories.has(path);\n\n if (!exists && !options?.force) {\n throw new AlephaError(`ENOENT: no such file or directory, rm '${path}'`);\n }\n\n if (this.directories.has(path)) {\n if (options?.recursive) {\n // Remove directory and all contents\n this.directories.delete(path);\n for (const filePath of this.files.keys()) {\n if (filePath.startsWith(`${path}/`)) {\n this.files.delete(filePath);\n }\n }\n for (const dirPath of this.directories) {\n if (dirPath.startsWith(`${path}/`)) {\n this.directories.delete(dirPath);\n }\n }\n } else {\n throw new AlephaError(\n `EISDIR: illegal operation on a directory, rm '${path}'`,\n );\n }\n } else {\n this.files.delete(path);\n }\n }\n\n /**\n * Copy a file or directory in memory.\n */\n public async cp(\n src: string,\n dest: string,\n options?: CpOptions,\n ): Promise<void> {\n if (this.directories.has(src)) {\n this.directories.add(dest);\n for (const [filePath, content] of this.files) {\n if (filePath.startsWith(`${src}/`)) {\n const newPath = filePath.replace(src, dest);\n this.files.set(newPath, Buffer.from(content));\n }\n }\n } else if (this.files.has(src)) {\n const content = this.files.get(src)!;\n this.files.set(dest, Buffer.from(content));\n } else {\n throw new AlephaError(`ENOENT: no such file or directory, cp '${src}'`);\n }\n }\n\n /**\n * Move/rename a file or directory in memory.\n */\n public async mv(src: string, dest: string): Promise<void> {\n if (this.directories.has(src)) {\n // Move directory and contents\n this.directories.delete(src);\n this.directories.add(dest);\n for (const [filePath, content] of this.files) {\n if (filePath.startsWith(`${src}/`)) {\n const newPath = filePath.replace(src, dest);\n this.files.delete(filePath);\n this.files.set(newPath, content);\n }\n }\n } else if (this.files.has(src)) {\n const content = this.files.get(src)!;\n this.files.delete(src);\n this.files.set(dest, content);\n } else {\n throw new AlephaError(`ENOENT: no such file or directory, mv '${src}'`);\n }\n }\n\n /**\n * Create a directory in memory.\n */\n public async mkdir(path: string, options?: MkdirOptions): Promise<void> {\n this.mkdirCalls.push({ path, options });\n\n if (this.mkdirError) {\n throw this.mkdirError;\n }\n\n const normalizedPath = this.normalizePath(path);\n\n if (this.directories.has(normalizedPath) && !options?.recursive) {\n throw new AlephaError(`EEXIST: file already exists, mkdir '${path}'`);\n }\n\n this.directories.add(normalizedPath);\n\n // If recursive, create parent directories\n if (options?.recursive) {\n const parts = normalizedPath.split(\"/\").filter(Boolean);\n let current = \"\";\n for (const part of parts) {\n current = current ? `${current}/${part}` : part;\n this.directories.add(current);\n }\n }\n }\n\n /**\n * List files in a directory.\n */\n public async ls(path: string, options?: LsOptions): Promise<string[]> {\n const normalizedPath = this.normalizePath(path).replace(/\\/$/, \"\");\n const entries = new Set<string>();\n\n // Find files in the directory\n for (const filePath of this.files.keys()) {\n const normalizedFilePath = this.normalizePath(filePath);\n if (normalizedFilePath.startsWith(`${normalizedPath}/`)) {\n const relativePath = normalizedFilePath.slice(\n normalizedPath.length + 1,\n );\n const parts = relativePath.split(\"/\");\n\n if (options?.recursive) {\n entries.add(relativePath);\n } else {\n entries.add(parts[0]);\n }\n }\n }\n\n // Find subdirectories\n for (const dirPath of this.directories) {\n const normalizedDirPath = this.normalizePath(dirPath);\n if (\n normalizedDirPath.startsWith(`${normalizedPath}/`) &&\n normalizedDirPath !== normalizedPath\n ) {\n const relativePath = normalizedDirPath.slice(normalizedPath.length + 1);\n const parts = relativePath.split(\"/\");\n\n if (options?.recursive) {\n entries.add(relativePath);\n } else if (parts.length === 1) {\n entries.add(parts[0]);\n }\n }\n }\n\n let result = Array.from(entries);\n\n // Filter hidden files unless requested\n if (!options?.hidden) {\n result = result.filter((entry) => !entry.startsWith(\".\"));\n }\n\n return result.sort();\n }\n\n /**\n * Check if a file or directory exists in memory.\n */\n public async exists(path: string): Promise<boolean> {\n return this.files.has(path) || this.directories.has(path);\n }\n\n /**\n * Read a file from memory.\n */\n public async readFile(path: string): Promise<Buffer> {\n this.readFileCalls.push(path);\n\n if (this.readFileError) {\n throw this.readFileError;\n }\n\n const content = this.files.get(path);\n if (!content) {\n throw new AlephaError(\n `ENOENT: no such file or directory, open '${path}'`,\n );\n }\n return content;\n }\n\n /**\n * Read a file from memory as text.\n */\n public async readTextFile(path: string): Promise<string> {\n const buffer = await this.readFile(path);\n return buffer.toString(\"utf-8\");\n }\n\n /**\n * Read a file from memory as JSON.\n */\n public async readJsonFile<T = unknown>(path: string): Promise<T> {\n const text = await this.readTextFile(path);\n return this.json.parse(text) as T;\n }\n\n /**\n * Write a file to memory.\n */\n public async writeFile(\n path: string,\n data: Uint8Array | Buffer | string | FileLike,\n ): Promise<void> {\n const dataStr =\n typeof data === \"string\"\n ? data\n : data instanceof Buffer || data instanceof Uint8Array\n ? data.toString(\"utf-8\")\n : await data.text();\n\n this.writeFileCalls.push({ path, data: dataStr });\n\n if (this.writeFileError) {\n throw this.writeFileError;\n }\n\n const buffer =\n typeof data === \"string\"\n ? Buffer.from(data, \"utf-8\")\n : data instanceof Buffer\n ? data\n : data instanceof Uint8Array\n ? Buffer.from(data)\n : Buffer.from(await data.text(), \"utf-8\");\n\n this.files.set(path, buffer);\n }\n\n /**\n * Reset all in-memory state (useful between tests).\n */\n public reset(): void {\n this.files.clear();\n this.directories.clear();\n this.mkdirCalls = [];\n this.writeFileCalls = [];\n this.readFileCalls = [];\n this.rmCalls = [];\n this.joinCalls = [];\n this.mkdirError = null;\n this.writeFileError = null;\n this.readFileError = null;\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Test assertion helpers\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Check if a file was written during the test.\n *\n * @example\n * ```typescript\n * expect(fs.wasWritten(\"/project/tsconfig.json\")).toBe(true);\n * ```\n */\n public wasWritten(path: string): boolean {\n return this.writeFileCalls.some((call) => call.path === path);\n }\n\n /**\n * Check if a file was written with content matching a pattern.\n *\n * @example\n * ```typescript\n * expect(fs.wasWrittenMatching(\"/project/tsconfig.json\", /extends/)).toBe(true);\n * ```\n */\n public wasWrittenMatching(path: string, pattern: RegExp): boolean {\n const call = this.writeFileCalls.find((c) => c.path === path);\n return call ? pattern.test(call.data) : false;\n }\n\n /**\n * Check if a file was read during the test.\n *\n * @example\n * ```typescript\n * expect(fs.wasRead(\"/project/package.json\")).toBe(true);\n * ```\n */\n public wasRead(path: string): boolean {\n return this.readFileCalls.includes(path);\n }\n\n /**\n * Check if a file was deleted during the test.\n *\n * @example\n * ```typescript\n * expect(fs.wasDeleted(\"/project/old-file.txt\")).toBe(true);\n * ```\n */\n public wasDeleted(path: string): boolean {\n return this.rmCalls.some((call) => call.path === path);\n }\n\n /**\n * Get the content of a file as a string (convenience method for testing).\n */\n public getFileContent(path: string): string | undefined {\n return this.files.get(path)?.toString(\"utf-8\");\n }\n}\n","import { AlephaError } from \"alepha\";\nimport type { ShellProvider, ShellRunOptions } from \"./ShellProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface MemoryShellCall {\n command: string;\n options: ShellRunOptions;\n}\n\nexport interface MemoryShellProviderOptions {\n /**\n * Simulated outputs for specific commands.\n * Key is the command string, value is the stdout to return.\n */\n outputs?: Record<string, string>;\n\n /**\n * Commands that should throw an error.\n * Key is the command string, value is the error message.\n */\n errors?: Record<string, string>;\n\n /**\n * Commands that are considered \"installed\" in the system PATH.\n */\n installedCommands?: string[];\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * In-memory implementation of ShellProvider for testing.\n *\n * Records all commands that would be executed without actually running them.\n * Can be configured to return specific outputs or throw errors for testing.\n *\n * @example\n * ```typescript\n * // In tests, substitute the real ShellProvider with MemoryShellProvider\n * const alepha = Alepha.create().with({\n * provide: ShellProvider,\n * use: MemoryShellProvider,\n * });\n *\n * // Configure mock behavior\n * const shell = alepha.inject(MemoryShellProvider);\n * shell.configure({\n * outputs: { \"echo hello\": \"hello\\n\" },\n * errors: { \"failing-cmd\": \"Command failed\" },\n * });\n *\n * // Or use the fluent API\n * shell.outputs.set(\"another-cmd\", \"output\");\n * shell.errors.set(\"another-error\", \"Error message\");\n *\n * // Run code that uses ShellProvider\n * const service = alepha.inject(MyService);\n * await service.doSomething();\n *\n * // Verify commands were called\n * expect(shell.calls).toHaveLength(2);\n * expect(shell.calls[0].command).toBe(\"yarn install\");\n * ```\n */\nexport class MemoryShellProvider implements ShellProvider {\n /**\n * All recorded shell calls.\n */\n public calls: MemoryShellCall[] = [];\n\n /**\n * Simulated outputs for specific commands.\n */\n public outputs = new Map<string, string>();\n\n /**\n * Commands that should throw an error.\n */\n public errors = new Map<string, string>();\n\n /**\n * Commands considered installed in the system PATH.\n */\n public installedCommands = new Set<string>();\n\n /**\n * Configure the mock with predefined outputs, errors, and installed commands.\n */\n public configure(options: MemoryShellProviderOptions): this {\n if (options.outputs) {\n for (const [cmd, output] of Object.entries(options.outputs)) {\n this.outputs.set(cmd, output);\n }\n }\n if (options.errors) {\n for (const [cmd, error] of Object.entries(options.errors)) {\n this.errors.set(cmd, error);\n }\n }\n if (options.installedCommands) {\n for (const cmd of options.installedCommands) {\n this.installedCommands.add(cmd);\n }\n }\n return this;\n }\n\n /**\n * Record command and return simulated output.\n */\n public async run(\n command: string,\n options: ShellRunOptions = {},\n ): Promise<string> {\n this.calls.push({ command, options });\n\n // Check for configured error\n const errorMsg = this.errors.get(command);\n if (errorMsg) {\n throw new AlephaError(errorMsg);\n }\n\n // Return configured output or empty string\n return this.outputs.get(command) ?? \"\";\n }\n\n /**\n * Check if a specific command was called.\n */\n public wasCalled(command: string): boolean {\n return this.calls.some((call) => call.command === command);\n }\n\n /**\n * Check if a command matching a pattern was called.\n */\n public wasCalledMatching(pattern: RegExp): boolean {\n return this.calls.some((call) => pattern.test(call.command));\n }\n\n /**\n * Get all calls matching a pattern.\n */\n public getCallsMatching(pattern: RegExp): MemoryShellCall[] {\n return this.calls.filter((call) => pattern.test(call.command));\n }\n\n /**\n * Check if a command is installed.\n */\n public async isInstalled(command: string): Promise<boolean> {\n return this.installedCommands.has(command);\n }\n\n /**\n * Reset all recorded state.\n */\n public reset(): void {\n this.calls = [];\n this.outputs.clear();\n this.errors.clear();\n this.installedCommands.clear();\n }\n}\n","import { Readable } from \"node:stream\";\n\nexport interface FileTypeResult {\n /**\n * The detected MIME type\n */\n mimeType: string;\n /**\n * The detected file extension\n */\n extension: string;\n /**\n * Whether the file type was verified by magic bytes\n */\n verified: boolean;\n /**\n * The stream (potentially wrapped to allow re-reading)\n */\n stream: Readable;\n}\n\n/**\n * Service for detecting file types and getting content types.\n *\n * @example\n * ```typescript\n * const detector = alepha.inject(FileDetector);\n *\n * // Get content type from filename\n * const mimeType = detector.getContentType(\"image.png\"); // \"image/png\"\n *\n * // Detect file type by magic bytes\n * const stream = createReadStream('image.png');\n * const result = await detector.detectFileType(stream, 'image.png');\n * console.log(result.mimeType); // 'image/png'\n * console.log(result.verified); // true if magic bytes match\n * ```\n */\nexport class FileDetector {\n /**\n * Magic byte signatures for common file formats.\n * Each signature is represented as an array of bytes or null (wildcard).\n */\n protected static readonly MAGIC_BYTES: Record<\n string,\n { signature: (number | null)[]; mimeType: string }[]\n > = {\n // Images\n png: [\n {\n signature: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a],\n mimeType: \"image/png\",\n },\n ],\n jpg: [\n { signature: [0xff, 0xd8, 0xff, 0xe0], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe1], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe2], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe3], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe8], mimeType: \"image/jpeg\" },\n ],\n jpeg: [\n { signature: [0xff, 0xd8, 0xff, 0xe0], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe1], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe2], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe3], mimeType: \"image/jpeg\" },\n { signature: [0xff, 0xd8, 0xff, 0xe8], mimeType: \"image/jpeg\" },\n ],\n gif: [\n {\n signature: [0x47, 0x49, 0x46, 0x38, 0x37, 0x61],\n mimeType: \"image/gif\",\n }, // GIF87a\n {\n signature: [0x47, 0x49, 0x46, 0x38, 0x39, 0x61],\n mimeType: \"image/gif\",\n }, // GIF89a\n ],\n webp: [\n {\n signature: [\n 0x52,\n 0x49,\n 0x46,\n 0x46,\n null,\n null,\n null,\n null,\n 0x57,\n 0x45,\n 0x42,\n 0x50,\n ],\n mimeType: \"image/webp\",\n },\n ],\n bmp: [{ signature: [0x42, 0x4d], mimeType: \"image/bmp\" }],\n ico: [{ signature: [0x00, 0x00, 0x01, 0x00], mimeType: \"image/x-icon\" }],\n tiff: [\n { signature: [0x49, 0x49, 0x2a, 0x00], mimeType: \"image/tiff\" }, // Little-endian\n { signature: [0x4d, 0x4d, 0x00, 0x2a], mimeType: \"image/tiff\" }, // Big-endian\n ],\n tif: [\n { signature: [0x49, 0x49, 0x2a, 0x00], mimeType: \"image/tiff\" },\n { signature: [0x4d, 0x4d, 0x00, 0x2a], mimeType: \"image/tiff\" },\n ],\n\n // Documents\n pdf: [\n {\n signature: [0x25, 0x50, 0x44, 0x46, 0x2d],\n mimeType: \"application/pdf\",\n },\n ], // %PDF-\n zip: [\n { signature: [0x50, 0x4b, 0x03, 0x04], mimeType: \"application/zip\" },\n { signature: [0x50, 0x4b, 0x05, 0x06], mimeType: \"application/zip\" },\n { signature: [0x50, 0x4b, 0x07, 0x08], mimeType: \"application/zip\" },\n ],\n\n // Archives\n rar: [\n {\n signature: [0x52, 0x61, 0x72, 0x21, 0x1a, 0x07],\n mimeType: \"application/vnd.rar\",\n },\n ],\n \"7z\": [\n {\n signature: [0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c],\n mimeType: \"application/x-7z-compressed\",\n },\n ],\n tar: [\n {\n signature: [0x75, 0x73, 0x74, 0x61, 0x72],\n mimeType: \"application/x-tar\",\n },\n ],\n gz: [{ signature: [0x1f, 0x8b], mimeType: \"application/gzip\" }],\n tgz: [{ signature: [0x1f, 0x8b], mimeType: \"application/gzip\" }],\n\n // Audio\n mp3: [\n { signature: [0xff, 0xfb], mimeType: \"audio/mpeg\" },\n { signature: [0xff, 0xf3], mimeType: \"audio/mpeg\" },\n { signature: [0xff, 0xf2], mimeType: \"audio/mpeg\" },\n { signature: [0x49, 0x44, 0x33], mimeType: \"audio/mpeg\" }, // ID3\n ],\n wav: [\n {\n signature: [\n 0x52,\n 0x49,\n 0x46,\n 0x46,\n null,\n null,\n null,\n null,\n 0x57,\n 0x41,\n 0x56,\n 0x45,\n ],\n mimeType: \"audio/wav\",\n },\n ],\n ogg: [{ signature: [0x4f, 0x67, 0x67, 0x53], mimeType: \"audio/ogg\" }],\n flac: [{ signature: [0x66, 0x4c, 0x61, 0x43], mimeType: \"audio/flac\" }], // fLaC\n\n // Video\n mp4: [\n {\n signature: [null, null, null, null, 0x66, 0x74, 0x79, 0x70],\n mimeType: \"video/mp4\",\n }, // ftyp\n {\n signature: [\n null,\n null,\n null,\n null,\n 0x66,\n 0x74,\n 0x79,\n 0x70,\n 0x69,\n 0x73,\n 0x6f,\n 0x6d,\n ],\n mimeType: \"video/mp4\",\n }, // ftypisom\n {\n signature: [\n null,\n null,\n null,\n null,\n 0x66,\n 0x74,\n 0x79,\n 0x70,\n 0x6d,\n 0x70,\n 0x34,\n 0x32,\n ],\n mimeType: \"video/mp4\",\n }, // ftypmp42\n ],\n webm: [{ signature: [0x1a, 0x45, 0xdf, 0xa3], mimeType: \"video/webm\" }],\n avi: [\n {\n signature: [\n 0x52,\n 0x49,\n 0x46,\n 0x46,\n null,\n null,\n null,\n null,\n 0x41,\n 0x56,\n 0x49,\n 0x20,\n ],\n mimeType: \"video/x-msvideo\",\n },\n ],\n mov: [\n {\n signature: [\n null,\n null,\n null,\n null,\n 0x66,\n 0x74,\n 0x79,\n 0x70,\n 0x71,\n 0x74,\n 0x20,\n 0x20,\n ],\n mimeType: \"video/quicktime\",\n },\n ],\n mkv: [\n { signature: [0x1a, 0x45, 0xdf, 0xa3], mimeType: \"video/x-matroska\" },\n ],\n\n // Office (DOCX, XLSX, PPTX are all ZIP-based)\n docx: [\n {\n signature: [0x50, 0x4b, 0x03, 0x04],\n mimeType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n },\n ],\n xlsx: [\n {\n signature: [0x50, 0x4b, 0x03, 0x04],\n mimeType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n },\n ],\n pptx: [\n {\n signature: [0x50, 0x4b, 0x03, 0x04],\n mimeType:\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n },\n ],\n doc: [\n {\n signature: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1],\n mimeType: \"application/msword\",\n },\n ],\n xls: [\n {\n signature: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1],\n mimeType: \"application/vnd.ms-excel\",\n },\n ],\n ppt: [\n {\n signature: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1],\n mimeType: \"application/vnd.ms-powerpoint\",\n },\n ],\n };\n\n /**\n * All possible format signatures for checking against actual file content\n */\n protected static readonly ALL_SIGNATURES = Object.entries(\n FileDetector.MAGIC_BYTES,\n ).flatMap(([ext, signatures]) => signatures.map((sig) => ({ ext, ...sig })));\n\n /**\n * MIME type map for file extensions.\n *\n * Can be used to get the content type of file based on its extension.\n * Feel free to add more mime types in your project!\n */\n public static readonly mimeMap: Record<string, string> = {\n // Documents\n json: \"application/json\",\n txt: \"text/plain\",\n html: \"text/html\",\n htm: \"text/html\",\n xml: \"application/xml\",\n csv: \"text/csv\",\n pdf: \"application/pdf\",\n md: \"text/markdown\",\n markdown: \"text/markdown\",\n rtf: \"application/rtf\",\n\n // Styles and scripts\n css: \"text/css\",\n js: \"application/javascript\",\n mjs: \"application/javascript\",\n ts: \"application/typescript\",\n jsx: \"text/jsx\",\n tsx: \"text/tsx\",\n\n // Archives\n zip: \"application/zip\",\n rar: \"application/vnd.rar\",\n \"7z\": \"application/x-7z-compressed\",\n tar: \"application/x-tar\",\n gz: \"application/gzip\",\n tgz: \"application/gzip\",\n\n // Images\n png: \"image/png\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n gif: \"image/gif\",\n webp: \"image/webp\",\n svg: \"image/svg+xml\",\n bmp: \"image/bmp\",\n ico: \"image/x-icon\",\n tiff: \"image/tiff\",\n tif: \"image/tiff\",\n\n // Audio\n mp3: \"audio/mpeg\",\n wav: \"audio/wav\",\n ogg: \"audio/ogg\",\n m4a: \"audio/mp4\",\n aac: \"audio/aac\",\n flac: \"audio/flac\",\n\n // Video\n mp4: \"video/mp4\",\n webm: \"video/webm\",\n avi: \"video/x-msvideo\",\n mov: \"video/quicktime\",\n wmv: \"video/x-ms-wmv\",\n flv: \"video/x-flv\",\n mkv: \"video/x-matroska\",\n\n // Office\n doc: \"application/msword\",\n docx: \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n xls: \"application/vnd.ms-excel\",\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n ppt: \"application/vnd.ms-powerpoint\",\n pptx: \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n\n // Fonts\n woff: \"font/woff\",\n woff2: \"font/woff2\",\n ttf: \"font/ttf\",\n otf: \"font/otf\",\n eot: \"application/vnd.ms-fontobject\",\n };\n\n /**\n * Reverse MIME type map for looking up extensions from MIME types.\n * Prefers shorter, more common extensions when multiple exist.\n */\n protected static readonly reverseMimeMap: Record<string, string> = (() => {\n const reverse: Record<string, string> = {};\n // Process in order so common extensions come first\n for (const [ext, mimeType] of Object.entries(FileDetector.mimeMap)) {\n // Only set if not already set (prefer first/shorter extension)\n if (!reverse[mimeType]) {\n reverse[mimeType] = ext;\n }\n }\n return reverse;\n })();\n\n /**\n * Returns the file extension for a given MIME type.\n *\n * @param mimeType - The MIME type to look up\n * @returns The file extension (without dot), or \"bin\" if not found\n *\n * @example\n * ```typescript\n * const detector = alepha.inject(FileDetector);\n * const ext = detector.getExtensionFromMimeType(\"image/png\"); // \"png\"\n * const ext2 = detector.getExtensionFromMimeType(\"application/octet-stream\"); // \"bin\"\n * ```\n */\n getExtensionFromMimeType(mimeType: string): string {\n return FileDetector.reverseMimeMap[mimeType] || \"bin\";\n }\n /**\n * Returns the content type of file based on its filename.\n *\n * @param filename - The filename to check\n * @returns The MIME type\n *\n * @example\n * ```typescript\n * const detector = alepha.inject(FileDetector);\n * const mimeType = detector.getContentType(\"image.png\"); // \"image/png\"\n * ```\n */\n getContentType(filename: string): string {\n const ext = filename.toLowerCase().split(\".\").pop() || \"\";\n return FileDetector.mimeMap[ext] || \"application/octet-stream\";\n }\n\n /**\n * Detects the file type by checking magic bytes against the stream content.\n *\n * @param stream - The readable stream to check\n * @param filename - The filename (used to get the extension)\n * @returns File type information including MIME type, extension, and verification status\n *\n * @example\n * ```typescript\n * const detector = alepha.inject(FileDetector);\n * const stream = createReadStream('image.png');\n * const result = await detector.detectFileType(stream, 'image.png');\n * console.log(result.mimeType); // 'image/png'\n * console.log(result.verified); // true if magic bytes match\n * ```\n */\n async detectFileType(\n stream: Readable,\n filename: string,\n ): Promise<FileTypeResult> {\n // Get the expected MIME type from the filename extension\n const expectedMimeType = this.getContentType(filename);\n\n // Extract extension - only if filename contains a dot\n const lastDotIndex = filename.lastIndexOf(\".\");\n const ext =\n lastDotIndex > 0\n ? filename.substring(lastDotIndex + 1).toLowerCase()\n : \"\";\n\n // Read the first 16 bytes (enough for most magic byte checks)\n const { buffer, stream: newStream } = await this.peekBytes(stream, 16);\n\n // First, check if the extension's expected signature matches\n const expectedSignatures = FileDetector.MAGIC_BYTES[ext];\n if (expectedSignatures) {\n for (const { signature, mimeType } of expectedSignatures) {\n if (this.matchesSignature(buffer, signature)) {\n return {\n mimeType,\n extension: ext,\n verified: true,\n stream: newStream,\n };\n }\n }\n }\n\n // If the expected signature didn't match, try all other signatures\n for (const {\n ext: detectedExt,\n signature,\n mimeType,\n } of FileDetector.ALL_SIGNATURES) {\n if (detectedExt !== ext && this.matchesSignature(buffer, signature)) {\n return {\n mimeType,\n extension: detectedExt,\n verified: true,\n stream: newStream,\n };\n }\n }\n\n // If no magic bytes matched, fall back to extension-based detection\n // or return binary if extension is not recognized\n return {\n mimeType: expectedMimeType,\n extension: ext,\n verified: false,\n stream: newStream,\n };\n }\n\n /**\n * Reads all bytes from a stream and returns the first N bytes along with a new stream containing all data.\n * This approach reads the entire stream upfront to avoid complex async handling issues.\n *\n * @protected\n */\n protected async peekBytes(\n stream: Readable,\n numBytes: number,\n ): Promise<{ buffer: Buffer; stream: Readable }> {\n const chunks: Buffer[] = [];\n\n // Read the entire stream\n for await (const chunk of stream) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n }\n\n const allData = Buffer.concat(chunks);\n const buffer = allData.subarray(0, numBytes);\n\n // Create a new stream with all the data\n const newStream = Readable.from(allData);\n\n return { buffer, stream: newStream };\n }\n\n /**\n * Checks if a buffer matches a magic byte signature.\n *\n * @protected\n */\n protected matchesSignature(\n buffer: Buffer,\n signature: (number | null)[],\n ): boolean {\n if (buffer.length < signature.length) {\n return false;\n }\n\n for (let i = 0; i < signature.length; i++) {\n if (signature[i] !== null && buffer[i] !== signature[i]) {\n return false;\n }\n }\n\n return true;\n }\n}\n","import { createReadStream } from \"node:fs\";\nimport {\n access,\n copyFile,\n cp as fsCp,\n mkdir as fsMkdir,\n readFile as fsReadFile,\n rm as fsRm,\n writeFile as fsWriteFile,\n readdir,\n rename,\n stat,\n} from \"node:fs/promises\";\nimport { basename, join } from \"node:path\";\nimport { PassThrough, Readable } from \"node:stream\";\nimport type { ReadableStream as NodeWebStream } from \"node:stream/web\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n $inject,\n AlephaError,\n type FileLike,\n isFileLike,\n Json,\n type StreamLike,\n} from \"alepha\";\nimport { FileDetector } from \"../services/FileDetector.ts\";\nimport type {\n CpOptions,\n CreateFileOptions,\n FileSystemProvider,\n LsOptions,\n MkdirOptions,\n RmOptions,\n} from \"./FileSystemProvider.ts\";\n\n/**\n * Node.js implementation of FileSystem interface.\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Create from URL\n * const file1 = fs.createFile({ url: \"file:///path/to/file.png\" });\n *\n * // Create from Buffer\n * const file2 = fs.createFile({ buffer: Buffer.from(\"hello\"), name: \"hello.txt\" });\n *\n * // Create from text\n * const file3 = fs.createFile({ text: \"Hello, world!\", name: \"greeting.txt\" });\n *\n * // File operations\n * await fs.mkdir(\"/tmp/mydir\", { recursive: true });\n * await fs.cp(\"/src/file.txt\", \"/dest/file.txt\");\n * await fs.mv(\"/old/path.txt\", \"/new/path.txt\");\n * const files = await fs.ls(\"/tmp\");\n * await fs.rm(\"/tmp/file.txt\");\n * ```\n */\nexport class NodeFileSystemProvider implements FileSystemProvider {\n protected detector = $inject(FileDetector);\n protected json = $inject(Json);\n\n public join(...paths: string[]): string {\n return join(...paths);\n }\n\n /**\n * Creates a FileLike object from various sources.\n *\n * @param options - Options for creating the file\n * @returns A FileLike object\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // From URL\n * const file1 = fs.createFile({ url: \"https://example.com/image.png\" });\n *\n * // From Buffer\n * const file2 = fs.createFile({\n * buffer: Buffer.from(\"hello\"),\n * name: \"hello.txt\",\n * type: \"text/plain\"\n * });\n *\n * // From text\n * const file3 = fs.createFile({ text: \"Hello!\", name: \"greeting.txt\" });\n *\n * // From stream with detection\n * const stream = createReadStream(\"/path/to/file.png\");\n * const file4 = fs.createFile({ stream, name: \"image.png\" });\n * ```\n */\n createFile(options: CreateFileOptions): FileLike {\n if (\"path\" in options) {\n const filePath = options.path;\n const filename = basename(filePath);\n return this.createFileFromUrl(`file://${filePath}`, {\n type: options.type,\n name: options.name || filename,\n });\n }\n\n // Handle URL\n if (\"url\" in options) {\n return this.createFileFromUrl(options.url, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"response\" in options) {\n if (!options.response.body) {\n throw new AlephaError(\"Response has no body stream\");\n }\n const res = options.response;\n // guess size from content-length header if available\n const sizeHeader = res.headers.get(\"content-length\");\n const size = sizeHeader ? parseInt(sizeHeader, 10) : undefined;\n // guess name from content-disposition header if available\n let name = options.name;\n const contentDisposition = res.headers.get(\"content-disposition\");\n if (contentDisposition && !name) {\n const match = contentDisposition.match(/filename=\"?([^\"]+)\"?/);\n if (match) {\n name = match[1];\n }\n }\n // guess type from content-type header if available\n const type = options.type || res.headers.get(\"content-type\") || undefined;\n return this.createFileFromStream(options.response.body, {\n type,\n name,\n size,\n });\n }\n\n // Handle Web File\n if (\"file\" in options) {\n return this.createFileFromWebFile(options.file, {\n type: options.type,\n name: options.name,\n size: options.size,\n });\n }\n\n // Handle Buffer\n if (\"buffer\" in options) {\n return this.createFileFromBuffer(options.buffer, {\n type: options.type,\n name: options.name,\n });\n }\n\n // Handle ArrayBuffer\n if (\"arrayBuffer\" in options) {\n return this.createFileFromBuffer(Buffer.from(options.arrayBuffer), {\n type: options.type,\n name: options.name,\n });\n }\n\n // Handle text\n if (\"text\" in options) {\n return this.createFileFromBuffer(Buffer.from(options.text, \"utf-8\"), {\n type: options.type || \"text/plain\",\n name: options.name || \"file.txt\",\n });\n }\n\n // Handle stream\n if (\"stream\" in options) {\n return this.createFileFromStream(options.stream, {\n type: options.type,\n name: options.name,\n size: options.size,\n });\n }\n\n throw new AlephaError(\n \"Invalid createFile options: no valid source provided\",\n );\n }\n\n /**\n * Removes a file or directory.\n *\n * @param path - The path to remove\n * @param options - Remove options\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Remove a file\n * await fs.rm(\"/tmp/file.txt\");\n *\n * // Remove a directory recursively\n * await fs.rm(\"/tmp/mydir\", { recursive: true });\n *\n * // Remove with force (no error if doesn't exist)\n * await fs.rm(\"/tmp/maybe-exists.txt\", { force: true });\n * ```\n */\n async rm(path: string, options?: RmOptions): Promise<void> {\n await fsRm(path, options);\n }\n\n /**\n * Copies a file or directory.\n *\n * @param src - Source path\n * @param dest - Destination path\n * @param options - Copy options\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Copy a file\n * await fs.cp(\"/src/file.txt\", \"/dest/file.txt\");\n *\n * // Copy a directory (recursive by default)\n * await fs.cp(\"/src/dir\", \"/dest/dir\");\n *\n * // Copy with force (overwrite existing)\n * await fs.cp(\"/src/file.txt\", \"/dest/file.txt\", { force: true });\n * ```\n */\n async cp(src: string, dest: string, options?: CpOptions): Promise<void> {\n const srcStat = await stat(src);\n\n if (srcStat.isDirectory()) {\n await fsCp(src, dest, {\n recursive: options?.recursive ?? true,\n force: options?.force ?? false,\n });\n } else {\n await copyFile(src, dest);\n }\n }\n\n /**\n * Moves/renames a file or directory.\n *\n * @param src - Source path\n * @param dest - Destination path\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Move/rename a file\n * await fs.mv(\"/old/path.txt\", \"/new/path.txt\");\n *\n * // Move a directory\n * await fs.mv(\"/old/dir\", \"/new/dir\");\n * ```\n */\n async mv(src: string, dest: string): Promise<void> {\n await rename(src, dest);\n }\n\n /**\n * Creates a directory.\n *\n * @param path - The directory path to create\n * @param options - Mkdir options\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Create a directory\n * await fs.mkdir(\"/tmp/mydir\");\n *\n * // Create nested directories\n * await fs.mkdir(\"/tmp/path/to/dir\", { recursive: true });\n *\n * // Create with specific permissions\n * await fs.mkdir(\"/tmp/mydir\", { mode: 0o755 });\n * ```\n */\n async mkdir(path: string, options: MkdirOptions = {}): Promise<void> {\n const p = fsMkdir(path, {\n recursive: options.recursive ?? true,\n mode: options.mode,\n });\n\n if (options.force === false) {\n await p;\n } else {\n await p.catch(() => {});\n }\n }\n\n /**\n * Lists files in a directory.\n *\n * @param path - The directory path to list\n * @param options - List options\n * @returns Array of filenames\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // List files in a directory\n * const files = await fs.ls(\"/tmp\");\n * console.log(files); // [\"file1.txt\", \"file2.txt\", \"subdir\"]\n *\n * // List with hidden files\n * const allFiles = await fs.ls(\"/tmp\", { hidden: true });\n *\n * // List recursively\n * const allFilesRecursive = await fs.ls(\"/tmp\", { recursive: true });\n * ```\n */\n async ls(path: string, options?: LsOptions): Promise<string[]> {\n const entries = await readdir(path);\n\n // Filter out hidden files if not requested\n const filteredEntries = options?.hidden\n ? entries\n : entries.filter((e) => !e.startsWith(\".\"));\n\n // If recursive, get all nested files\n if (options?.recursive) {\n const allFiles: string[] = [];\n\n for (const entry of filteredEntries) {\n const fullPath = join(path, entry);\n const entryStat = await stat(fullPath);\n\n if (entryStat.isDirectory()) {\n // Add directory entry\n allFiles.push(entry);\n // Recursively get files from subdirectory\n const subFiles = await this.ls(fullPath, options);\n allFiles.push(...subFiles.map((f) => join(entry, f)));\n } else {\n allFiles.push(entry);\n }\n }\n\n return allFiles;\n }\n\n return filteredEntries;\n }\n\n /**\n * Checks if a file or directory exists.\n *\n * @param path - The path to check\n * @returns True if the path exists, false otherwise\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * if (await fs.exists(\"/tmp/file.txt\")) {\n * console.log(\"File exists\");\n * }\n * ```\n */\n async exists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Reads the content of a file.\n *\n * @param path - The file path to read\n * @returns The file content as a Buffer\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * const buffer = await fs.readFile(\"/tmp/file.txt\");\n * console.log(buffer.toString(\"utf-8\"));\n * ```\n */\n async readFile(path: string): Promise<Buffer> {\n return await fsReadFile(path);\n }\n\n /**\n * Writes data to a file.\n *\n * @param path - The file path to write to\n * @param data - The data to write (Buffer or string)\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n *\n * // Write string\n * await fs.writeFile(\"/tmp/file.txt\", \"Hello, world!\");\n *\n * // Write Buffer\n * await fs.writeFile(\"/tmp/file.bin\", Buffer.from([0x01, 0x02, 0x03]));\n * ```\n */\n async writeFile(\n path: string,\n data: Uint8Array | Buffer | string | FileLike,\n ): Promise<void> {\n if (isFileLike(data)) {\n await fsWriteFile(path, Readable.from(data.stream()));\n return;\n }\n await fsWriteFile(path, data);\n }\n\n /**\n * Reads the content of a file as a string.\n *\n * @param path - The file path to read\n * @returns The file content as a string\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n * const content = await fs.readTextFile(\"/tmp/file.txt\");\n * ```\n */\n async readTextFile(path: string): Promise<string> {\n const buffer = await this.readFile(path);\n return buffer.toString(\"utf-8\");\n }\n\n /**\n * Reads the content of a file as JSON.\n *\n * @param path - The file path to read\n * @returns The parsed JSON content\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(NodeFileSystemProvider);\n * const config = await fs.readJsonFile<{ name: string }>(\"/tmp/config.json\");\n * ```\n */\n async readJsonFile<T = unknown>(path: string): Promise<T> {\n const text = await this.readTextFile(path);\n return this.json.parse(text) as T;\n }\n\n /**\n * Creates a FileLike object from a Web File.\n *\n * @protected\n */\n protected createFileFromWebFile(\n source: File,\n options: {\n type?: string;\n name?: string;\n size?: number;\n } = {},\n ): FileLike {\n const name = options.name ?? source.name;\n return {\n name,\n type: options.type ?? (source.type || this.detector.getContentType(name)),\n size: options.size ?? source.size ?? 0,\n lastModified: source.lastModified || Date.now(),\n stream: () => source.stream(),\n arrayBuffer: async (): Promise<ArrayBuffer> => {\n return await source.arrayBuffer();\n },\n text: async (): Promise<string> => {\n return await source.text();\n },\n };\n }\n\n /**\n * Creates a FileLike object from a Buffer.\n *\n * @protected\n */\n protected createFileFromBuffer(\n source: Buffer,\n options: {\n type?: string;\n name?: string;\n } = {},\n ): FileLike {\n const name: string = options.name ?? \"file\";\n return {\n name,\n type: options.type ?? this.detector.getContentType(options.name ?? name),\n size: source.byteLength,\n lastModified: Date.now(),\n stream: (): Readable => Readable.from(source),\n arrayBuffer: async (): Promise<ArrayBuffer> => {\n return this.bufferToArrayBuffer(source);\n },\n text: async (): Promise<string> => {\n return source.toString(\"utf-8\");\n },\n };\n }\n\n /**\n * Creates a FileLike object from a stream.\n *\n * @protected\n */\n protected createFileFromStream(\n source: StreamLike,\n options: {\n type?: string;\n name?: string;\n size?: number;\n } = {},\n ): FileLike & { _buffer: null | Buffer } {\n let buffer: Buffer | null = null;\n\n return {\n name: options.name ?? \"file\",\n type:\n options.type ?? this.detector.getContentType(options.name ?? \"file\"),\n size: options.size ?? 0,\n lastModified: Date.now(),\n stream: () => source,\n _buffer: null as Buffer | null,\n arrayBuffer: async () => {\n buffer ??= await this.streamToBuffer(source);\n return this.bufferToArrayBuffer(buffer);\n },\n text: async () => {\n buffer ??= await this.streamToBuffer(source);\n return buffer.toString(\"utf-8\");\n },\n };\n }\n\n /**\n * Creates a FileLike object from a URL.\n *\n * @protected\n */\n protected createFileFromUrl(\n url: string,\n options: {\n type?: string;\n name?: string;\n } = {},\n ): FileLike {\n const parsedUrl = new URL(url);\n const filename =\n options.name || parsedUrl.pathname.split(\"/\").pop() || \"file\";\n let buffer: Buffer | null = null;\n\n return {\n name: filename,\n type: options.type ?? this.detector.getContentType(filename),\n size: 0, // Unknown size until loaded\n lastModified: Date.now(),\n stream: () => this.createStreamFromUrl(url),\n arrayBuffer: async () => {\n buffer ??= await this.loadFromUrl(url);\n return this.bufferToArrayBuffer(buffer);\n },\n text: async () => {\n buffer ??= await this.loadFromUrl(url);\n return buffer.toString(\"utf-8\");\n },\n filepath: url,\n };\n }\n\n /**\n * Gets a streaming response from a URL.\n *\n * @protected\n */\n protected getStreamingResponse(url: string): Readable {\n const stream = new PassThrough();\n\n fetch(url)\n .then((res) =>\n Readable.fromWeb(res.body as unknown as NodeWebStream).pipe(stream),\n )\n .catch((err) => stream.destroy(err));\n\n return stream;\n }\n\n /**\n * Loads data from a URL.\n *\n * @protected\n */\n protected async loadFromUrl(url: string): Promise<Buffer> {\n const parsedUrl = new URL(url);\n\n if (parsedUrl.protocol === \"file:\") {\n // Handle file:// URLs\n const filePath = fileURLToPath(url);\n return await fsReadFile(filePath);\n } else if (\n parsedUrl.protocol === \"http:\" ||\n parsedUrl.protocol === \"https:\"\n ) {\n // Handle HTTP/HTTPS URLs\n const response = await fetch(url);\n if (!response.ok) {\n throw new AlephaError(\n `Failed to fetch ${url}: ${response.status} ${response.statusText}`,\n );\n }\n const arrayBuffer = await response.arrayBuffer();\n return Buffer.from(arrayBuffer);\n } else {\n throw new AlephaError(`Unsupported protocol: ${parsedUrl.protocol}`);\n }\n }\n\n /**\n * Creates a stream from a URL.\n *\n * @protected\n */\n protected createStreamFromUrl(url: string): Readable {\n const parsedUrl = new URL(url);\n\n if (parsedUrl.protocol === \"file:\") {\n // For file:// URLs, create a stream that reads the file\n return createReadStream(fileURLToPath(url));\n } else if (\n parsedUrl.protocol === \"http:\" ||\n parsedUrl.protocol === \"https:\"\n ) {\n // For HTTP/HTTPS URLs, create a stream that fetches the content\n return this.getStreamingResponse(url);\n } else {\n throw new AlephaError(`Unsupported protocol: ${parsedUrl.protocol}`);\n }\n }\n\n /**\n * Converts a stream-like object to a Buffer.\n *\n * @protected\n */\n protected async streamToBuffer(streamLike: StreamLike): Promise<Buffer> {\n const stream =\n streamLike instanceof Readable\n ? streamLike\n : Readable.fromWeb(streamLike as NodeWebStream);\n\n return new Promise<Buffer>((resolve, reject) => {\n const buffer: any[] = [];\n stream.on(\"data\", (chunk) => buffer.push(Buffer.from(chunk)));\n stream.on(\"end\", () => resolve(Buffer.concat(buffer)));\n stream.on(\"error\", (err) =>\n reject(new AlephaError(\"Error converting stream\", { cause: err })),\n );\n });\n }\n\n /**\n * Converts a Node.js Buffer to an ArrayBuffer.\n *\n * @protected\n */\n protected bufferToArrayBuffer(buffer: Buffer): ArrayBuffer {\n return buffer.buffer.slice(\n buffer.byteOffset,\n buffer.byteOffset + buffer.byteLength,\n ) as ArrayBuffer;\n }\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ShellRunOptions {\n /**\n * Working directory for the command.\n */\n root?: string;\n\n /**\n * Additional environment variables.\n */\n env?: Record<string, string>;\n\n /**\n * Resolve the executable from node_modules/.bin.\n * Supports local project, pnpm nested, and monorepo structures.\n * @default false\n */\n resolve?: boolean;\n\n /**\n * Capture stdout instead of inheriting stdio.\n * When true, returns stdout as string.\n * When false, streams output to terminal.\n * @default false\n */\n capture?: boolean;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Abstract provider for executing shell commands and binaries.\n *\n * Implementations:\n * - `NodeShellProvider` - Real shell execution using Node.js child_process\n * - `MemoryShellProvider` - In-memory mock for testing\n *\n * @example\n * ```typescript\n * class MyService {\n * protected readonly shell = $inject(ShellProvider);\n *\n * async build() {\n * // Run shell command directly\n * await this.shell.run(\"yarn install\");\n *\n * // Run local binary with resolution\n * await this.shell.run(\"vite build\", { resolve: true });\n *\n * // Capture output\n * const output = await this.shell.run(\"echo hello\", { capture: true });\n * }\n * }\n * ```\n */\nexport abstract class ShellProvider {\n /**\n * Run a shell command or binary.\n *\n * @param command - The command to run\n * @param options - Execution options\n * @returns stdout if capture is true, empty string otherwise\n */\n abstract run(command: string, options?: ShellRunOptions): Promise<string>;\n\n /**\n * Check if a command is installed and available in the system PATH.\n *\n * @param command - The command name to check\n * @returns true if the command is available\n */\n abstract isInstalled(command: string): Promise<boolean>;\n}\n","import { $inject, AlephaError, type FileLike, Json } from \"alepha\";\nimport { FileDetector } from \"../services/FileDetector.ts\";\nimport type {\n CpOptions,\n CreateFileOptions,\n FileSystemProvider,\n LsOptions,\n MkdirOptions,\n RmOptions,\n} from \"./FileSystemProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Web-standard implementation of FileSystemProvider for Cloudflare Workers and other edge runtimes.\n *\n * Uses only Web APIs (ReadableStream, TextEncoder, etc.) — no Node.js-specific APIs.\n * Provides working `createFile` with proper streaming support.\n * Filesystem operations (rm, cp, mv, etc.) are not available in edge runtimes and will throw.\n *\n * @example\n * ```typescript\n * const fs = alepha.inject(WorkerdFileSystemProvider);\n *\n * // Create from text (returns FileLike with web ReadableStream)\n * const file = fs.createFile({ text: \"Hello!\", name: \"greeting.txt\" });\n * const stream = file.stream(); // ReadableStream (web standard)\n * ```\n */\nexport class WorkerdFileSystemProvider implements FileSystemProvider {\n protected detector = $inject(FileDetector);\n protected json = $inject(Json);\n\n protected encoder = new TextEncoder();\n protected decoder = new TextDecoder();\n\n public join(...paths: string[]): string {\n const joined = paths.join(\"/\").replace(/\\/+/g, \"/\");\n const parts = joined.split(\"/\");\n const resolved: string[] = [];\n for (const part of parts) {\n if (part === \"..\") {\n resolved.pop();\n } else if (part !== \".\") {\n resolved.push(part);\n }\n }\n return resolved.join(\"/\") || \".\";\n }\n\n public createFile(options: CreateFileOptions): FileLike {\n if (\"text\" in options) {\n return this.createFileFromText(options.text, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"arrayBuffer\" in options) {\n return this.createFileFromArrayBuffer(options.arrayBuffer, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"buffer\" in options) {\n const ab =\n options.buffer instanceof ArrayBuffer\n ? options.buffer\n : options.buffer.buffer.slice(\n options.buffer.byteOffset,\n options.buffer.byteOffset + options.buffer.byteLength,\n );\n return this.createFileFromArrayBuffer(ab as ArrayBuffer, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"file\" in options) {\n return this.createFileFromWebFile(options.file, {\n type: options.type,\n name: options.name,\n size: options.size,\n });\n }\n\n if (\"response\" in options) {\n return this.createFileFromResponse(options.response, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"stream\" in options) {\n return this.createFileFromStream(options.stream as ReadableStream, {\n type: options.type,\n name: options.name,\n size: options.size,\n });\n }\n\n if (\"url\" in options) {\n return this.createFileFromUrl(options.url, {\n type: options.type,\n name: options.name,\n });\n }\n\n if (\"path\" in options) {\n throw new AlephaError(\n \"WorkerdFileSystemProvider.createFile: 'path' source is not supported in edge runtimes.\",\n );\n }\n\n throw new AlephaError(\n \"WorkerdFileSystemProvider.createFile: unsupported options.\",\n );\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n protected createFileFromText(\n text: string,\n options: { type?: string; name?: string } = {},\n ): FileLike {\n const encoded = this.encoder.encode(text);\n const name = options.name ?? \"file.txt\";\n return {\n name,\n type: options.type ?? this.detector.getContentType(name),\n size: encoded.byteLength,\n lastModified: Date.now(),\n stream: () =>\n new ReadableStream({\n start(controller) {\n controller.enqueue(encoded);\n controller.close();\n },\n }),\n arrayBuffer: async () =>\n encoded.buffer.slice(\n encoded.byteOffset,\n encoded.byteOffset + encoded.byteLength,\n ) as ArrayBuffer,\n text: async () => text,\n };\n }\n\n protected createFileFromArrayBuffer(\n source: ArrayBuffer,\n options: { type?: string; name?: string } = {},\n ): FileLike {\n const name = options.name ?? \"file\";\n const bytes = new Uint8Array(source);\n return {\n name,\n type: options.type ?? this.detector.getContentType(name),\n size: source.byteLength,\n lastModified: Date.now(),\n stream: () =>\n new ReadableStream({\n start(controller) {\n controller.enqueue(bytes);\n controller.close();\n },\n }),\n arrayBuffer: async () => source,\n text: async () => this.decoder.decode(source),\n };\n }\n\n protected createFileFromWebFile(\n source: File,\n options: { type?: string; name?: string; size?: number } = {},\n ): FileLike {\n const name = options.name ?? source.name;\n return {\n name,\n type: options.type ?? (source.type || this.detector.getContentType(name)),\n size: options.size ?? source.size ?? 0,\n lastModified: source.lastModified || Date.now(),\n stream: () => source.stream(),\n arrayBuffer: async () => await source.arrayBuffer(),\n text: async () => await source.text(),\n };\n }\n\n protected createFileFromResponse(\n response: Response,\n options: { type?: string; name?: string } = {},\n ): FileLike {\n if (!response.body) {\n throw new AlephaError(\"Response has no body stream\");\n }\n\n const sizeHeader = response.headers.get(\"content-length\");\n const size = sizeHeader ? parseInt(sizeHeader, 10) : 0;\n\n let name = options.name;\n if (!name) {\n const cd = response.headers.get(\"content-disposition\");\n if (cd) {\n const match = cd.match(/filename=\"?([^\"]+)\"?/);\n if (match) {\n name = match[1];\n }\n }\n }\n name ??= \"file\";\n\n const type =\n options.type ?? response.headers.get(\"content-type\") ?? undefined;\n\n return {\n name,\n type: type ?? this.detector.getContentType(name),\n size,\n lastModified: Date.now(),\n stream: () => response.body!,\n arrayBuffer: async () => await response.arrayBuffer(),\n text: async () => await response.text(),\n };\n }\n\n protected createFileFromStream(\n source: ReadableStream,\n options: { type?: string; name?: string; size?: number } = {},\n ): FileLike {\n const name = options.name ?? \"file\";\n let buffer: ArrayBuffer | null = null;\n\n const consumeStream = async (): Promise<ArrayBuffer> => {\n if (buffer) return buffer;\n const reader = source.getReader();\n const chunks: Uint8Array[] = [];\n let done = false;\n while (!done) {\n const result = await reader.read();\n done = result.done;\n if (result.value) {\n chunks.push(result.value);\n }\n }\n const total = chunks.reduce((sum, c) => sum + c.byteLength, 0);\n const merged = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n merged.set(chunk, offset);\n offset += chunk.byteLength;\n }\n buffer = merged.buffer as ArrayBuffer;\n return buffer;\n };\n\n return {\n name,\n type: options.type ?? this.detector.getContentType(name),\n size: options.size ?? 0,\n lastModified: Date.now(),\n stream: () => source,\n arrayBuffer: consumeStream,\n text: async () => this.decoder.decode(await consumeStream()),\n };\n }\n\n protected createFileFromUrl(\n url: string,\n options: { type?: string; name?: string } = {},\n ): FileLike {\n const parsedUrl = new URL(url);\n const name = options.name ?? parsedUrl.pathname.split(\"/\").pop() ?? \"file\";\n\n return {\n name,\n type: options.type ?? this.detector.getContentType(name),\n size: 0,\n lastModified: Date.now(),\n stream: () => {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: streaming from URL is not supported. Use fetch() and createFile({ response }) instead.\",\n );\n },\n arrayBuffer: async () => {\n const res = await fetch(url);\n return await res.arrayBuffer();\n },\n text: async () => {\n const res = await fetch(url);\n return await res.text();\n },\n };\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n // Filesystem operations — not available in edge runtimes\n // -------------------------------------------------------------------------------------------------------------------\n\n public async rm(_path: string, _options?: RmOptions): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: rm() is not available in edge runtimes.\",\n );\n }\n\n public async cp(\n _src: string,\n _dest: string,\n _options?: CpOptions,\n ): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: cp() is not available in edge runtimes.\",\n );\n }\n\n public async mv(_src: string, _dest: string): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: mv() is not available in edge runtimes.\",\n );\n }\n\n public async mkdir(_path: string, _options?: MkdirOptions): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: mkdir() is not available in edge runtimes.\",\n );\n }\n\n public async ls(_path: string, _options?: LsOptions): Promise<string[]> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: ls() is not available in edge runtimes.\",\n );\n }\n\n public async exists(_path: string): Promise<boolean> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: exists() is not available in edge runtimes.\",\n );\n }\n\n public async readFile(_path: string): Promise<Buffer> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: readFile() is not available in edge runtimes.\",\n );\n }\n\n public async writeFile(\n _path: string,\n _data: Uint8Array | Buffer | string | FileLike,\n ): Promise<void> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: writeFile() is not available in edge runtimes.\",\n );\n }\n\n public async readTextFile(_path: string): Promise<string> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: readTextFile() is not available in edge runtimes.\",\n );\n }\n\n public async readJsonFile<T = unknown>(_path: string): Promise<T> {\n throw new AlephaError(\n \"WorkerdFileSystemProvider: readJsonFile() is not available in edge runtimes.\",\n );\n }\n}\n","export class FileError extends Error {\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = \"FileError\";\n this.cause = cause;\n }\n}\n","import { $module } from \"alepha\";\nimport { BunShellProvider } from \"./providers/BunShellProvider.ts\";\nimport { FileSystemProvider } from \"./providers/FileSystemProvider.ts\";\nimport { MemoryFileSystemProvider } from \"./providers/MemoryFileSystemProvider.ts\";\nimport { MemoryShellProvider } from \"./providers/MemoryShellProvider.ts\";\nimport { NodeFileSystemProvider } from \"./providers/NodeFileSystemProvider.ts\";\nimport { NodeShellProvider } from \"./providers/NodeShellProvider.ts\";\nimport { ShellProvider } from \"./providers/ShellProvider.ts\";\nimport { WorkerdFileSystemProvider } from \"./providers/WorkerdFileSystemProvider.ts\";\nimport { FileDetector } from \"./services/FileDetector.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./errors/FileError.ts\";\nexport * from \"./providers/BunShellProvider.ts\";\nexport * from \"./providers/FileSystemProvider.ts\";\nexport * from \"./providers/MemoryFileSystemProvider.ts\";\nexport * from \"./providers/MemoryShellProvider.ts\";\nexport * from \"./providers/NodeFileSystemProvider.ts\";\nexport * from \"./providers/NodeShellProvider.ts\";\nexport * from \"./providers/ShellProvider.ts\";\nexport * from \"./providers/WorkerdFileSystemProvider.ts\";\nexport * from \"./services/FileDetector.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * System-level abstractions for portable code across runtimes.\n *\n * **Features:**\n * - File system operations (read, write, exists, etc.)\n * - Shell command execution\n * - File type detection and MIME utilities\n * - Memory implementations for testing\n *\n * @module alepha.system\n */\nexport const AlephaSystem = $module({\n name: \"alepha.system\",\n primitives: [],\n services: [FileDetector, FileSystemProvider, ShellProvider],\n variants: [\n MemoryFileSystemProvider,\n NodeFileSystemProvider,\n WorkerdFileSystemProvider,\n MemoryShellProvider,\n NodeShellProvider,\n BunShellProvider,\n ],\n register: (alepha) => {\n const shellImpl = alepha.isTest()\n ? MemoryShellProvider\n : alepha.isBun()\n ? BunShellProvider\n : NodeShellProvider;\n return alepha\n .with({\n optional: true,\n provide: FileSystemProvider,\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;EAC1D;EACA,KAAK,CACH;GACE,WAAW;IACT;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA,UAAU;EACZ,CACF;EACA,KAAK,CAAC;GAAE,WAAW;IAAC;IAAM;IAAM;IAAM;GAAI;GAAG,UAAU;EAAY,CAAC;EACpE,MAAM,CAAC;GAAE,WAAW;IAAC;IAAM;IAAM;IAAM;GAAI;GAAG,UAAU;EAAa,CAAC;EAGtE,KAAK;GACH;IACE,WAAW;KAAC;KAAM;KAAM;KAAM;KAAM;KAAM;KAAM;KAAM;IAAI;IAC1D,UAAU;GACZ;GACA;IACE,WAAW;KACT;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;IACF;IACA,UAAU;GACZ;GACA;IACE,WAAW;KACT;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;IACF;IACA,UAAU;GACZ;EACF;EACA,MAAM,CAAC;GAAE,WAAW;IAAC;IAAM;IAAM;IAAM;GAAI;GAAG,UAAU;EAAa,CAAC;EACtE,KAAK,CACH;GACE,WAAW;IACT;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA,UAAU;EACZ,CACF;EACA,KAAK,CACH;GACE,WAAW;IACT;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA,UAAU;EACZ,CACF;EACA,KAAK,CACH;GAAE,WAAW;IAAC;IAAM;IAAM;IAAM;GAAI;GAAG,UAAU;EAAmB,CACtE;EAGA,MAAM,CACJ;GACE,WAAW;IAAC;IAAM;IAAM;IAAM;GAAI;GAClC,UACE;EACJ,CACF;EACA,MAAM,CACJ;GACE,WAAW;IAAC;IAAM;IAAM;IAAM;GAAI;GAClC,UACE;EACJ,CACF;EACA,MAAM,CACJ;GACE,WAAW;IAAC;IAAM;IAAM;IAAM;GAAI;GAClC,UACE;EACJ,CACF;EACA,KAAK,CACH;GACE,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