alepha 0.15.0 → 0.15.2
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 +43 -98
- package/dist/api/audits/index.d.ts +630 -653
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +12 -35
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts +365 -358
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +12 -5
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +255 -248
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +10 -3
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/keys/index.d.ts +413 -0
- package/dist/api/keys/index.d.ts.map +1 -0
- package/dist/api/keys/index.js +476 -0
- package/dist/api/keys/index.js.map +1 -0
- package/dist/api/notifications/index.browser.js +4 -4
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +84 -78
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +14 -8
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.d.ts +528 -535
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +30 -37
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/users/index.d.ts +1221 -910
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +2556 -248
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +142 -136
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/api/verifications/index.js +12 -4
- package/dist/api/verifications/index.js.map +1 -1
- package/dist/batch/index.d.ts +142 -162
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +31 -44
- package/dist/batch/index.js.map +1 -1
- package/dist/bucket/index.d.ts +595 -171
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/bucket/index.js +1856 -12
- package/dist/bucket/index.js.map +1 -1
- package/dist/cache/core/index.d.ts +225 -53
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/core/index.js +213 -7
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cache/redis/index.d.ts +1 -0
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cache/redis/index.js +6 -2
- package/dist/cache/redis/index.js.map +1 -1
- package/dist/cli/index.d.ts +834 -226
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2872 -417
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +458 -310
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +2011 -76
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +309 -97
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +796 -701
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +329 -97
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +309 -97
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.d.ts +59 -44
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js +15 -0
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/index.d.ts +314 -19
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +1852 -7
- package/dist/email/index.js.map +1 -1
- package/dist/fake/index.d.ts +5500 -5418
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js +113 -42
- package/dist/fake/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +219 -212
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/core/index.js +11 -4
- package/dist/lock/core/index.js.map +1 -1
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/logger/index.d.ts +41 -90
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +15 -68
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +228 -230
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +32 -31
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/index.browser.js +12 -12
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.bun.js +90 -80
- package/dist/orm/index.bun.js.map +1 -1
- package/dist/orm/index.d.ts +1434 -1459
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +112 -130
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +262 -254
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/core/index.js +14 -6
- package/dist/queue/core/index.js.map +1 -1
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/react/auth/index.browser.js +108 -0
- package/dist/react/auth/index.browser.js.map +1 -0
- package/dist/react/auth/index.d.ts +100 -0
- package/dist/react/auth/index.d.ts.map +1 -0
- package/dist/react/auth/index.js +145 -0
- package/dist/react/auth/index.js.map +1 -0
- package/dist/react/core/index.d.ts +469 -0
- package/dist/react/core/index.d.ts.map +1 -0
- package/dist/react/core/index.js +464 -0
- package/dist/react/core/index.js.map +1 -0
- package/dist/react/form/index.d.ts +232 -0
- package/dist/react/form/index.d.ts.map +1 -0
- package/dist/react/form/index.js +432 -0
- package/dist/react/form/index.js.map +1 -0
- package/dist/react/head/index.browser.js +423 -0
- package/dist/react/head/index.browser.js.map +1 -0
- package/dist/react/head/index.d.ts +288 -0
- package/dist/react/head/index.d.ts.map +1 -0
- package/dist/react/head/index.js +465 -0
- package/dist/react/head/index.js.map +1 -0
- package/dist/react/i18n/index.d.ts +175 -0
- package/dist/react/i18n/index.d.ts.map +1 -0
- package/dist/react/i18n/index.js +224 -0
- package/dist/react/i18n/index.js.map +1 -0
- package/dist/react/router/index.browser.js +1980 -0
- package/dist/react/router/index.browser.js.map +1 -0
- package/dist/react/router/index.d.ts +2068 -0
- package/dist/react/router/index.d.ts.map +1 -0
- package/dist/react/router/index.js +4932 -0
- package/dist/react/router/index.js.map +1 -0
- package/dist/react/websocket/index.d.ts +117 -0
- package/dist/react/websocket/index.d.ts.map +1 -0
- package/dist/react/websocket/index.js +107 -0
- package/dist/react/websocket/index.js.map +1 -0
- package/dist/redis/index.bun.js +4 -0
- package/dist/redis/index.bun.js.map +1 -1
- package/dist/redis/index.d.ts +127 -130
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +16 -25
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.d.ts +80 -71
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/retry/index.js +11 -2
- package/dist/retry/index.js.map +1 -1
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts +119 -28
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +404 -3
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +642 -228
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1579 -37
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +1141 -111
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +1261 -25
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.d.ts +63 -78
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/cache/index.js +7 -22
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/compress/index.d.ts +13 -5
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/compress/index.js +10 -2
- package/dist/server/compress/index.js.map +1 -1
- package/dist/server/cookies/index.d.ts +46 -22
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js +7 -5
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.d.ts +307 -196
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +271 -38
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +24 -34
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/cors/index.js +7 -21
- package/dist/server/cors/index.js.map +1 -1
- package/dist/server/health/index.d.ts +25 -19
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/health/index.js +8 -2
- package/dist/server/health/index.js.map +1 -1
- package/dist/server/helmet/index.d.ts +13 -5
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/helmet/index.js +11 -3
- package/dist/server/helmet/index.js.map +1 -1
- package/dist/server/links/index.browser.js +9 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +133 -128
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +24 -11
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +524 -4
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js +4472 -7
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/multipart/index.d.ts +15 -9
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/multipart/index.js +9 -3
- package/dist/server/multipart/index.js.map +1 -1
- package/dist/server/proxy/index.d.ts +110 -104
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/proxy/index.js +8 -2
- package/dist/server/proxy/index.js.map +1 -1
- package/dist/server/rate-limit/index.d.ts +46 -51
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.js +18 -55
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/static/index.d.ts +181 -48
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/static/index.js +1848 -5
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +348 -53
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js +1849 -6
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +312 -18
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +1854 -10
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js +496 -0
- package/dist/system/index.browser.js.map +1 -0
- package/dist/system/index.d.ts +1158 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/{file → system}/index.js +412 -20
- package/dist/system/index.js.map +1 -0
- package/dist/thread/index.d.ts +82 -73
- package/dist/thread/index.d.ts.map +1 -1
- package/dist/thread/index.js +13 -4
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/core/index.d.ts +330 -323
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/core/index.js +12 -5
- package/dist/topic/core/index.js.map +1 -1
- package/dist/topic/redis/index.d.ts +6 -6
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/vite/index.d.ts +163 -5825
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +130 -477
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +3 -3
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +287 -283
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +15 -11
- package/dist/websocket/index.js.map +1 -1
- package/package.json +86 -17
- package/src/api/audits/index.ts +10 -33
- package/src/api/files/__tests__/$bucket.spec.ts +1 -1
- package/src/api/files/controllers/AdminFileStatsController.spec.ts +1 -1
- package/src/api/files/controllers/FileController.spec.ts +1 -1
- package/src/api/files/index.ts +10 -3
- package/src/api/files/jobs/FileJobs.spec.ts +1 -1
- package/src/api/files/services/FileService.spec.ts +1 -1
- package/src/api/jobs/index.ts +10 -3
- package/src/api/keys/controllers/AdminApiKeyController.ts +75 -0
- package/src/api/keys/controllers/ApiKeyController.ts +103 -0
- package/src/api/keys/entities/apiKeyEntity.ts +41 -0
- package/src/api/keys/index.ts +49 -0
- package/src/api/keys/schemas/adminApiKeyQuerySchema.ts +7 -0
- package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +17 -0
- package/src/api/keys/schemas/createApiKeyBodySchema.ts +7 -0
- package/src/api/keys/schemas/createApiKeyResponseSchema.ts +11 -0
- package/src/api/keys/schemas/listApiKeyResponseSchema.ts +15 -0
- package/src/api/keys/schemas/revokeApiKeyParamsSchema.ts +5 -0
- package/src/api/keys/schemas/revokeApiKeyResponseSchema.ts +5 -0
- package/src/api/keys/services/ApiKeyService.spec.ts +553 -0
- package/src/api/keys/services/ApiKeyService.ts +306 -0
- package/src/api/logs/TODO.md +52 -0
- package/src/api/notifications/index.ts +10 -4
- package/src/api/parameters/index.ts +9 -30
- package/src/api/parameters/primitives/$config.ts +12 -4
- package/src/api/parameters/services/ConfigStore.ts +9 -3
- package/src/api/users/__tests__/ApiKeys-integration.spec.ts +1035 -0
- package/src/api/users/__tests__/ApiKeys.spec.ts +401 -0
- package/src/api/users/index.ts +14 -3
- package/src/api/users/primitives/$realm.ts +33 -5
- package/src/api/users/providers/RealmProvider.ts +1 -12
- package/src/api/users/services/SessionService.ts +1 -11
- package/src/api/verifications/controllers/VerificationController.ts +2 -0
- package/src/api/verifications/index.ts +10 -4
- package/src/batch/index.ts +9 -36
- package/src/batch/primitives/$batch.ts +0 -8
- package/src/batch/providers/BatchProvider.ts +29 -2
- package/src/bucket/__tests__/shared.ts +1 -1
- package/src/bucket/index.ts +13 -6
- package/src/bucket/primitives/$bucket.ts +1 -1
- package/src/bucket/providers/LocalFileStorageProvider.ts +1 -1
- package/src/bucket/providers/MemoryFileStorageProvider.ts +1 -1
- package/src/cache/core/__tests__/shared.ts +30 -0
- package/src/cache/core/index.ts +11 -6
- package/src/cache/core/primitives/$cache.spec.ts +5 -0
- package/src/cache/core/providers/CacheProvider.ts +17 -0
- package/src/cache/core/providers/MemoryCacheProvider.ts +300 -1
- package/src/cache/redis/__tests__/cache-redis.spec.ts +5 -0
- package/src/cache/redis/providers/RedisCacheProvider.ts +9 -0
- package/src/cli/apps/AlephaCli.ts +3 -16
- package/src/cli/apps/AlephaPackageBuilderCli.ts +10 -2
- package/src/cli/atoms/appEntryOptions.ts +13 -0
- package/src/cli/atoms/buildOptions.ts +1 -1
- package/src/cli/atoms/changelogOptions.ts +1 -1
- package/src/cli/commands/build.ts +64 -52
- package/src/cli/commands/db.ts +17 -11
- package/src/cli/commands/deploy.ts +1 -1
- package/src/cli/commands/dev.ts +13 -49
- package/src/cli/commands/gen/env.ts +6 -3
- package/src/cli/commands/gen/openapi.ts +5 -2
- package/src/cli/commands/init.spec.ts +544 -0
- package/src/cli/commands/init.ts +101 -58
- package/src/cli/commands/lint.ts +8 -2
- package/src/cli/commands/typecheck.ts +11 -0
- package/src/cli/defineConfig.ts +9 -0
- package/src/cli/index.ts +2 -1
- package/src/cli/providers/AppEntryProvider.ts +131 -0
- package/src/cli/providers/ViteBuildProvider.ts +40 -0
- package/src/cli/providers/ViteDevServerProvider.ts +378 -0
- package/src/cli/services/AlephaCliUtils.ts +39 -93
- package/src/cli/services/PackageManagerUtils.ts +140 -17
- package/src/cli/services/ProjectScaffolder.ts +169 -101
- package/src/cli/services/ViteUtils.ts +82 -0
- package/src/cli/{assets/claudeMd.ts → templates/agentMd.ts} +41 -28
- package/src/cli/{assets → templates}/apiHelloControllerTs.ts +2 -1
- package/src/cli/{assets → templates}/biomeJson.ts +2 -1
- package/src/cli/{assets → templates}/dummySpecTs.ts +2 -1
- package/src/cli/{assets → templates}/editorconfig.ts +2 -1
- package/src/cli/templates/gitignore.ts +39 -0
- package/src/cli/{assets → templates}/mainBrowserTs.ts +2 -1
- package/src/cli/templates/mainCss.ts +33 -0
- package/src/cli/templates/mainServerTs.ts +33 -0
- package/src/cli/{assets → templates}/tsconfigJson.ts +2 -1
- package/src/cli/templates/webAppRouterTs.ts +50 -0
- package/src/cli/templates/webHelloComponentTsx.ts +20 -0
- package/src/command/helpers/Runner.spec.ts +4 -0
- package/src/command/helpers/Runner.ts +3 -21
- package/src/command/index.ts +12 -4
- package/src/command/providers/CliProvider.spec.ts +1067 -0
- package/src/command/providers/CliProvider.ts +203 -40
- package/src/core/Alepha.ts +3 -9
- package/src/core/__tests__/Alepha-start.spec.ts +4 -4
- package/src/core/helpers/jsonSchemaToTypeBox.spec.ts +771 -0
- package/src/core/helpers/jsonSchemaToTypeBox.ts +62 -10
- package/src/core/index.shared.ts +1 -0
- package/src/core/index.ts +20 -0
- package/src/core/primitives/$module.ts +12 -0
- package/src/core/providers/EventManager.spec.ts +0 -71
- package/src/core/providers/EventManager.ts +3 -15
- package/src/core/providers/Json.ts +2 -14
- package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +257 -0
- package/src/core/providers/KeylessJsonSchemaCodec.ts +396 -14
- package/src/core/providers/SchemaValidator.spec.ts +236 -0
- package/src/datetime/index.ts +15 -0
- package/src/email/index.ts +10 -5
- package/src/email/providers/LocalEmailProvider.spec.ts +1 -1
- package/src/email/providers/LocalEmailProvider.ts +1 -1
- package/src/fake/__tests__/keyName.example.ts +1 -1
- package/src/fake/__tests__/keyName.spec.ts +5 -5
- package/src/fake/index.ts +9 -6
- package/src/fake/providers/FakeProvider.spec.ts +258 -40
- package/src/fake/providers/FakeProvider.ts +133 -19
- package/src/lock/core/index.ts +11 -4
- package/src/logger/index.ts +17 -66
- package/src/logger/providers/PrettyFormatterProvider.ts +0 -9
- package/src/mcp/errors/McpError.ts +30 -0
- package/src/mcp/index.ts +13 -27
- package/src/mcp/transports/SseMcpTransport.ts +6 -7
- package/src/orm/__tests__/PostgresProvider.spec.ts +2 -2
- package/src/orm/index.browser.ts +2 -2
- package/src/orm/index.bun.ts +4 -2
- package/src/orm/index.ts +21 -47
- package/src/orm/providers/DrizzleKitProvider.ts +3 -5
- package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -0
- package/src/orm/services/Repository.ts +18 -3
- package/src/queue/core/index.ts +14 -6
- package/src/react/auth/__tests__/$auth.spec.ts +202 -0
- package/src/react/auth/hooks/useAuth.ts +32 -0
- package/src/react/auth/index.browser.ts +13 -0
- package/src/react/auth/index.shared.ts +2 -0
- package/src/react/auth/index.ts +48 -0
- package/src/react/auth/providers/ReactAuthProvider.ts +16 -0
- package/src/react/auth/services/ReactAuth.ts +135 -0
- package/src/react/core/__tests__/Router.spec.tsx +169 -0
- package/src/react/core/components/ClientOnly.tsx +49 -0
- package/src/react/core/components/ErrorBoundary.tsx +73 -0
- package/src/react/core/contexts/AlephaContext.ts +7 -0
- package/src/react/core/contexts/AlephaProvider.tsx +42 -0
- package/src/react/core/hooks/useAction.browser.spec.tsx +569 -0
- package/src/react/core/hooks/useAction.ts +480 -0
- package/src/react/core/hooks/useAlepha.ts +26 -0
- package/src/react/core/hooks/useClient.ts +17 -0
- package/src/react/core/hooks/useEvents.ts +51 -0
- package/src/react/core/hooks/useInject.ts +12 -0
- package/src/react/core/hooks/useStore.ts +52 -0
- package/src/react/core/index.ts +90 -0
- package/src/react/form/components/FormState.tsx +17 -0
- package/src/react/form/errors/FormValidationError.ts +18 -0
- package/src/react/form/hooks/useForm.browser.spec.tsx +366 -0
- package/src/react/form/hooks/useForm.ts +47 -0
- package/src/react/form/hooks/useFormState.ts +130 -0
- package/src/react/form/index.ts +44 -0
- package/src/react/form/services/FormModel.ts +614 -0
- package/src/react/head/helpers/SeoExpander.spec.ts +203 -0
- package/src/react/head/helpers/SeoExpander.ts +142 -0
- package/src/react/head/hooks/useHead.spec.tsx +288 -0
- package/src/react/head/hooks/useHead.ts +62 -0
- package/src/react/head/index.browser.ts +26 -0
- package/src/react/head/index.ts +44 -0
- package/src/react/head/interfaces/Head.ts +105 -0
- package/src/react/head/primitives/$head.ts +25 -0
- package/src/react/head/providers/BrowserHeadProvider.browser.spec.ts +196 -0
- package/src/react/head/providers/BrowserHeadProvider.ts +212 -0
- package/src/react/head/providers/HeadProvider.ts +168 -0
- package/src/react/head/providers/ServerHeadProvider.ts +31 -0
- package/src/react/i18n/__tests__/integration.spec.tsx +239 -0
- package/src/react/i18n/components/Localize.spec.tsx +357 -0
- package/src/react/i18n/components/Localize.tsx +35 -0
- package/src/react/i18n/hooks/useI18n.browser.spec.tsx +438 -0
- package/src/react/i18n/hooks/useI18n.ts +18 -0
- package/src/react/i18n/index.ts +41 -0
- package/src/react/i18n/primitives/$dictionary.ts +69 -0
- package/src/react/i18n/providers/I18nProvider.spec.ts +389 -0
- package/src/react/i18n/providers/I18nProvider.ts +278 -0
- package/src/react/router/__tests__/page-head-browser.browser.spec.ts +95 -0
- package/src/react/router/__tests__/page-head.spec.ts +48 -0
- package/src/react/router/__tests__/seo-head.spec.ts +125 -0
- package/src/react/router/atoms/ssrManifestAtom.ts +58 -0
- package/src/react/router/components/ErrorViewer.tsx +872 -0
- package/src/react/router/components/Link.tsx +23 -0
- package/src/react/router/components/NestedView.tsx +223 -0
- package/src/react/router/components/NotFound.tsx +30 -0
- package/src/react/router/constants/PAGE_PRELOAD_KEY.ts +6 -0
- package/src/react/router/contexts/RouterLayerContext.ts +12 -0
- package/src/react/router/errors/Redirection.ts +28 -0
- package/src/react/router/hooks/useActive.ts +52 -0
- package/src/react/router/hooks/useQueryParams.ts +63 -0
- package/src/react/router/hooks/useRouter.ts +20 -0
- package/src/react/router/hooks/useRouterState.ts +11 -0
- package/src/react/router/index.browser.ts +45 -0
- package/src/react/router/index.shared.ts +19 -0
- package/src/react/router/index.ts +142 -0
- package/src/react/router/primitives/$page.browser.spec.tsx +851 -0
- package/src/react/router/primitives/$page.spec.tsx +708 -0
- package/src/react/router/primitives/$page.ts +497 -0
- package/src/react/router/providers/ReactBrowserProvider.ts +309 -0
- package/src/react/router/providers/ReactBrowserRendererProvider.ts +25 -0
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +168 -0
- package/src/react/router/providers/ReactPageProvider.ts +726 -0
- package/src/react/router/providers/ReactServerProvider.spec.tsx +316 -0
- package/src/react/router/providers/ReactServerProvider.ts +558 -0
- package/src/react/router/providers/ReactServerTemplateProvider.ts +979 -0
- package/src/react/router/providers/SSRManifestProvider.ts +334 -0
- package/src/react/router/services/ReactPageServerService.ts +48 -0
- package/src/react/router/services/ReactPageService.ts +27 -0
- package/src/react/router/services/ReactRouter.ts +262 -0
- package/src/react/websocket/hooks/useRoom.tsx +242 -0
- package/src/react/websocket/index.ts +7 -0
- package/src/redis/__tests__/redis.spec.ts +13 -0
- package/src/redis/index.ts +9 -25
- package/src/redis/providers/BunRedisProvider.ts +9 -0
- package/src/redis/providers/NodeRedisProvider.ts +8 -0
- package/src/redis/providers/RedisProvider.ts +16 -0
- package/src/retry/index.ts +11 -2
- package/src/router/index.ts +15 -0
- package/src/scheduler/index.ts +11 -2
- package/src/security/__tests__/BasicAuth.spec.ts +2 -0
- package/src/security/__tests__/ServerSecurityProvider.spec.ts +13 -5
- package/src/security/index.ts +15 -10
- package/src/security/interfaces/IssuerResolver.ts +27 -0
- package/src/security/primitives/$issuer.ts +55 -0
- package/src/security/providers/SecurityProvider.ts +179 -0
- package/src/security/providers/ServerBasicAuthProvider.ts +6 -2
- package/src/security/providers/ServerSecurityProvider.ts +36 -22
- package/src/server/auth/index.ts +12 -7
- package/src/server/cache/index.ts +7 -22
- package/src/server/compress/index.ts +10 -2
- package/src/server/cookies/index.ts +7 -5
- package/src/server/cookies/primitives/$cookie.ts +33 -11
- package/src/server/core/index.ts +17 -7
- package/src/server/core/interfaces/ServerRequest.ts +83 -1
- package/src/server/core/primitives/$action.spec.ts +1 -1
- package/src/server/core/primitives/$action.ts +8 -3
- package/src/server/core/providers/BunHttpServerProvider.ts +1 -1
- package/src/server/core/providers/NodeHttpServerProvider.spec.ts +125 -0
- package/src/server/core/providers/NodeHttpServerProvider.ts +77 -22
- package/src/server/core/providers/ServerLoggerProvider.ts +2 -2
- package/src/server/core/providers/ServerProvider.ts +9 -12
- package/src/server/core/services/ServerRequestParser.spec.ts +520 -0
- package/src/server/core/services/ServerRequestParser.ts +306 -13
- package/src/server/cors/index.ts +7 -21
- package/src/server/cors/primitives/$cors.ts +6 -2
- package/src/server/health/index.ts +8 -2
- package/src/server/helmet/index.ts +11 -3
- package/src/server/links/atoms/apiLinksAtom.ts +7 -0
- package/src/server/links/index.browser.ts +2 -0
- package/src/server/links/index.ts +13 -6
- package/src/server/metrics/index.ts +10 -3
- package/src/server/multipart/index.ts +9 -3
- package/src/server/proxy/index.ts +8 -2
- package/src/server/rate-limit/index.ts +21 -25
- package/src/server/rate-limit/primitives/$rateLimit.ts +6 -2
- package/src/server/rate-limit/providers/ServerRateLimitProvider.spec.ts +38 -14
- package/src/server/rate-limit/providers/ServerRateLimitProvider.ts +22 -56
- package/src/server/static/index.ts +8 -2
- package/src/server/static/providers/ServerStaticProvider.ts +1 -1
- package/src/server/swagger/index.ts +9 -4
- package/src/server/swagger/providers/ServerSwaggerProvider.ts +1 -1
- package/src/sms/index.ts +9 -5
- package/src/sms/providers/LocalSmsProvider.spec.ts +1 -1
- package/src/sms/providers/LocalSmsProvider.ts +1 -1
- package/src/system/index.browser.ts +11 -0
- package/src/system/index.ts +62 -0
- package/src/{file → system}/providers/FileSystemProvider.ts +16 -0
- package/src/{file → system}/providers/MemoryFileSystemProvider.ts +116 -3
- package/src/system/providers/MemoryShellProvider.ts +164 -0
- package/src/{file → system}/providers/NodeFileSystemProvider.spec.ts +2 -2
- package/src/{file → system}/providers/NodeFileSystemProvider.ts +36 -0
- package/src/system/providers/NodeShellProvider.ts +184 -0
- package/src/system/providers/ShellProvider.ts +74 -0
- package/src/{file → system}/services/FileDetector.spec.ts +2 -2
- package/src/thread/index.ts +11 -2
- package/src/topic/core/index.ts +12 -5
- package/src/vite/index.ts +3 -2
- package/src/vite/tasks/buildClient.ts +2 -8
- package/src/vite/tasks/buildServer.ts +84 -21
- package/src/vite/tasks/copyAssets.ts +5 -4
- package/src/vite/tasks/generateSitemap.ts +64 -23
- package/src/vite/tasks/index.ts +0 -2
- package/src/vite/tasks/prerenderPages.ts +49 -24
- package/src/websocket/index.ts +12 -8
- package/dist/file/index.d.ts +0 -839
- package/dist/file/index.d.ts.map +0 -1
- package/dist/file/index.js.map +0 -1
- package/src/cli/assets/indexHtml.ts +0 -15
- package/src/cli/assets/mainServerTs.ts +0 -24
- package/src/cli/assets/webAppRouterTs.ts +0 -15
- package/src/cli/assets/webHelloComponentTsx.ts +0 -16
- package/src/cli/commands/format.ts +0 -23
- package/src/file/index.ts +0 -43
- package/src/vite/helpers/boot.ts +0 -117
- package/src/vite/plugins/viteAlephaDev.ts +0 -177
- package/src/vite/tasks/devServer.ts +0 -71
- package/src/vite/tasks/runAlepha.ts +0 -270
- /package/dist/orm/{chunk-DtkW-qnP.js → chunk-DH6iiROE.js} +0 -0
- /package/src/cli/{assets → templates}/apiIndexTs.ts +0 -0
- /package/src/cli/{assets → templates}/webIndexTs.ts +0 -0
- /package/src/{file → system}/errors/FileError.ts +0 -0
- /package/src/{file → system}/services/FileDetector.ts +0 -0
|
@@ -0,0 +1,1158 @@
|
|
|
1
|
+
import * as alepha0 from "alepha";
|
|
2
|
+
import { FileLike, Json, StreamLike } from "alepha";
|
|
3
|
+
import { Readable } from "node:stream";
|
|
4
|
+
import * as alepha_logger0 from "alepha/logger";
|
|
5
|
+
|
|
6
|
+
//#region ../../src/system/errors/FileError.d.ts
|
|
7
|
+
declare class FileError extends Error {
|
|
8
|
+
constructor(message: string, cause?: Error);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region ../../src/system/providers/FileSystemProvider.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Options for creating a file from a URL
|
|
14
|
+
*/
|
|
15
|
+
interface CreateFileFromUrlOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The URL to load the file from (file://, http://, or https://)
|
|
18
|
+
*/
|
|
19
|
+
url: string;
|
|
20
|
+
/**
|
|
21
|
+
* The MIME type of the file (optional, will be detected from filename if not provided)
|
|
22
|
+
*/
|
|
23
|
+
type?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The name of the file (optional, will be extracted from URL if not provided)
|
|
26
|
+
*/
|
|
27
|
+
name?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for creating a file from a path (URL with file:// scheme)
|
|
31
|
+
*/
|
|
32
|
+
interface CreateFileFromPathOptions {
|
|
33
|
+
/**
|
|
34
|
+
* The path to the file on the local filesystem
|
|
35
|
+
*/
|
|
36
|
+
path: string;
|
|
37
|
+
/**
|
|
38
|
+
* The MIME type of the file (optional, will be detected from filename if not provided)
|
|
39
|
+
*/
|
|
40
|
+
type?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The name of the file (optional, will be extracted from URL if not provided)
|
|
43
|
+
*/
|
|
44
|
+
name?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for creating a file from a Buffer
|
|
48
|
+
*/
|
|
49
|
+
interface CreateFileFromBufferOptions {
|
|
50
|
+
/**
|
|
51
|
+
* The Buffer containing the file data
|
|
52
|
+
*/
|
|
53
|
+
buffer: Buffer;
|
|
54
|
+
/**
|
|
55
|
+
* The MIME type of the file (optional, will be detected from name if not provided)
|
|
56
|
+
*/
|
|
57
|
+
type?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The name of the file (required for proper content type detection)
|
|
60
|
+
*/
|
|
61
|
+
name?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Options for creating a file from a stream
|
|
65
|
+
*/
|
|
66
|
+
interface CreateFileFromStreamOptions {
|
|
67
|
+
/**
|
|
68
|
+
* The readable stream containing the file data
|
|
69
|
+
*/
|
|
70
|
+
stream: StreamLike;
|
|
71
|
+
/**
|
|
72
|
+
* The MIME type of the file (optional, will be detected from name if not provided)
|
|
73
|
+
*/
|
|
74
|
+
type?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The name of the file (required for proper content type detection)
|
|
77
|
+
*/
|
|
78
|
+
name?: string;
|
|
79
|
+
/**
|
|
80
|
+
* The size of the file in bytes (optional)
|
|
81
|
+
*/
|
|
82
|
+
size?: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Options for creating a file from text content
|
|
86
|
+
*/
|
|
87
|
+
interface CreateFileFromTextOptions {
|
|
88
|
+
/**
|
|
89
|
+
* The text content to create the file from
|
|
90
|
+
*/
|
|
91
|
+
text: string;
|
|
92
|
+
/**
|
|
93
|
+
* The MIME type of the file (default: text/plain)
|
|
94
|
+
*/
|
|
95
|
+
type?: string;
|
|
96
|
+
/**
|
|
97
|
+
* The name of the file (default: "file.txt")
|
|
98
|
+
*/
|
|
99
|
+
name?: string;
|
|
100
|
+
}
|
|
101
|
+
interface CreateFileFromResponseOptions {
|
|
102
|
+
/**
|
|
103
|
+
* The Response object containing the file data
|
|
104
|
+
*/
|
|
105
|
+
response: Response;
|
|
106
|
+
/**
|
|
107
|
+
* Override the name (optional, uses filename from Content-Disposition header if not provided)
|
|
108
|
+
*/
|
|
109
|
+
name?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Override the MIME type (optional, uses file.type if not provided)
|
|
112
|
+
*/
|
|
113
|
+
type?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Options for creating a file from a Web File object
|
|
117
|
+
*/
|
|
118
|
+
interface CreateFileFromWebFileOptions {
|
|
119
|
+
/**
|
|
120
|
+
* The Web File object
|
|
121
|
+
*/
|
|
122
|
+
file: File;
|
|
123
|
+
/**
|
|
124
|
+
* Override the MIME type (optional, uses file.type if not provided)
|
|
125
|
+
*/
|
|
126
|
+
type?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Override the name (optional, uses file.name if not provided)
|
|
129
|
+
*/
|
|
130
|
+
name?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Override the size (optional, uses file.size if not provided)
|
|
133
|
+
*/
|
|
134
|
+
size?: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Options for creating a file from an ArrayBuffer
|
|
138
|
+
*/
|
|
139
|
+
interface CreateFileFromArrayBufferOptions {
|
|
140
|
+
/**
|
|
141
|
+
* The ArrayBuffer containing the file data
|
|
142
|
+
*/
|
|
143
|
+
arrayBuffer: ArrayBuffer;
|
|
144
|
+
/**
|
|
145
|
+
* The MIME type of the file (optional, will be detected from name if not provided)
|
|
146
|
+
*/
|
|
147
|
+
type?: string;
|
|
148
|
+
/**
|
|
149
|
+
* The name of the file (required for proper content type detection)
|
|
150
|
+
*/
|
|
151
|
+
name?: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Union type for all createFile options
|
|
155
|
+
*/
|
|
156
|
+
type CreateFileOptions = CreateFileFromUrlOptions | CreateFileFromPathOptions | CreateFileFromBufferOptions | CreateFileFromStreamOptions | CreateFileFromTextOptions | CreateFileFromWebFileOptions | CreateFileFromResponseOptions | CreateFileFromArrayBufferOptions;
|
|
157
|
+
/**
|
|
158
|
+
* Options for rm (remove) operation
|
|
159
|
+
*/
|
|
160
|
+
interface RmOptions {
|
|
161
|
+
/**
|
|
162
|
+
* If true, removes directories and their contents recursively
|
|
163
|
+
*/
|
|
164
|
+
recursive?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* If true, no error will be thrown if the path does not exist
|
|
167
|
+
*/
|
|
168
|
+
force?: boolean;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Options for cp (copy) operation
|
|
172
|
+
*/
|
|
173
|
+
interface CpOptions {
|
|
174
|
+
/**
|
|
175
|
+
* If true, copy directories recursively
|
|
176
|
+
*/
|
|
177
|
+
recursive?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* If true, overwrite existing destination
|
|
180
|
+
*/
|
|
181
|
+
force?: boolean;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Options for mkdir operation
|
|
185
|
+
*/
|
|
186
|
+
interface MkdirOptions {
|
|
187
|
+
/**
|
|
188
|
+
* If true, creates parent directories as needed
|
|
189
|
+
*/
|
|
190
|
+
recursive?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* File mode (permission and sticky bits)
|
|
193
|
+
*/
|
|
194
|
+
mode?: number;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Options for ls (list) operation
|
|
198
|
+
*/
|
|
199
|
+
interface LsOptions {
|
|
200
|
+
/**
|
|
201
|
+
* If true, list contents of directories recursively
|
|
202
|
+
*/
|
|
203
|
+
recursive?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* If true, include hidden files (starting with .)
|
|
206
|
+
*/
|
|
207
|
+
hidden?: boolean;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* FileSystem interface providing utilities for working with files.
|
|
211
|
+
*/
|
|
212
|
+
declare abstract class FileSystemProvider {
|
|
213
|
+
/**
|
|
214
|
+
* Joins multiple path segments into a single path.
|
|
215
|
+
*
|
|
216
|
+
* @param paths - The path segments to join
|
|
217
|
+
* @returns The joined path
|
|
218
|
+
*/
|
|
219
|
+
abstract join(...paths: string[]): string;
|
|
220
|
+
/**
|
|
221
|
+
* Creates a FileLike object from various sources.
|
|
222
|
+
*
|
|
223
|
+
* @param options - Options for creating the file
|
|
224
|
+
* @returns A FileLike object
|
|
225
|
+
*/
|
|
226
|
+
abstract createFile(options: CreateFileOptions): FileLike;
|
|
227
|
+
/**
|
|
228
|
+
* Removes a file or directory.
|
|
229
|
+
*
|
|
230
|
+
* @param path - The path to remove
|
|
231
|
+
* @param options - Remove options
|
|
232
|
+
*/
|
|
233
|
+
abstract rm(path: string, options?: RmOptions): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Copies a file or directory.
|
|
236
|
+
*
|
|
237
|
+
* @param src - Source path
|
|
238
|
+
* @param dest - Destination path
|
|
239
|
+
* @param options - Copy options
|
|
240
|
+
*/
|
|
241
|
+
abstract cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Moves/renames a file or directory.
|
|
244
|
+
*
|
|
245
|
+
* @param src - Source path
|
|
246
|
+
* @param dest - Destination path
|
|
247
|
+
*/
|
|
248
|
+
abstract mv(src: string, dest: string): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Creates a directory.
|
|
251
|
+
*
|
|
252
|
+
* @param path - The directory path to create
|
|
253
|
+
* @param options - Mkdir options
|
|
254
|
+
*/
|
|
255
|
+
abstract mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
256
|
+
/**
|
|
257
|
+
* Lists files in a directory.
|
|
258
|
+
*
|
|
259
|
+
* @param path - The directory path to list
|
|
260
|
+
* @param options - List options
|
|
261
|
+
* @returns Array of filenames
|
|
262
|
+
*/
|
|
263
|
+
abstract ls(path: string, options?: LsOptions): Promise<string[]>;
|
|
264
|
+
/**
|
|
265
|
+
* Checks if a file or directory exists.
|
|
266
|
+
*
|
|
267
|
+
* @param path - The path to check
|
|
268
|
+
* @returns True if the path exists, false otherwise
|
|
269
|
+
*/
|
|
270
|
+
abstract exists(path: string): Promise<boolean>;
|
|
271
|
+
/**
|
|
272
|
+
* Reads the content of a file.
|
|
273
|
+
*
|
|
274
|
+
* @param path - The file path to read
|
|
275
|
+
* @returns The file content as a Buffer
|
|
276
|
+
*/
|
|
277
|
+
abstract readFile(path: string): Promise<Buffer>;
|
|
278
|
+
/**
|
|
279
|
+
* Writes data to a file.
|
|
280
|
+
*
|
|
281
|
+
* @param path - The file path to write to
|
|
282
|
+
* @param data - The data to write (Buffer or string)
|
|
283
|
+
*/
|
|
284
|
+
abstract writeFile(path: string, data: Uint8Array | Buffer | string | FileLike): Promise<void>;
|
|
285
|
+
/**
|
|
286
|
+
* Reads the content of a file as a string.
|
|
287
|
+
*
|
|
288
|
+
* @param path - The file path to read
|
|
289
|
+
* @returns The file content as a string
|
|
290
|
+
*/
|
|
291
|
+
abstract readTextFile(path: string): Promise<string>;
|
|
292
|
+
/**
|
|
293
|
+
* Reads the content of a file as JSON.
|
|
294
|
+
*
|
|
295
|
+
* @param path - The file path to read
|
|
296
|
+
* @returns The parsed JSON content
|
|
297
|
+
*/
|
|
298
|
+
abstract readJsonFile<T = unknown>(path: string): Promise<T>;
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region ../../src/system/providers/MemoryFileSystemProvider.d.ts
|
|
302
|
+
interface MemoryFileSystemProviderOptions {
|
|
303
|
+
/**
|
|
304
|
+
* Error to throw on mkdir operations (for testing error handling)
|
|
305
|
+
*/
|
|
306
|
+
mkdirError?: Error | null;
|
|
307
|
+
/**
|
|
308
|
+
* Error to throw on writeFile operations (for testing error handling)
|
|
309
|
+
*/
|
|
310
|
+
writeFileError?: Error | null;
|
|
311
|
+
/**
|
|
312
|
+
* Error to throw on readFile operations (for testing error handling)
|
|
313
|
+
*/
|
|
314
|
+
readFileError?: Error | null;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* In-memory implementation of FileSystemProvider for testing.
|
|
318
|
+
*
|
|
319
|
+
* This provider stores all files and directories in memory, making it ideal for
|
|
320
|
+
* unit tests that need to verify file operations without touching the real file system.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* // In tests, substitute the real FileSystemProvider with MemoryFileSystemProvider
|
|
325
|
+
* const alepha = Alepha.create().with({
|
|
326
|
+
* provide: FileSystemProvider,
|
|
327
|
+
* use: MemoryFileSystemProvider,
|
|
328
|
+
* });
|
|
329
|
+
*
|
|
330
|
+
* // Run code that uses FileSystemProvider
|
|
331
|
+
* const service = alepha.inject(MyService);
|
|
332
|
+
* await service.saveFile("test.txt", "Hello World");
|
|
333
|
+
*
|
|
334
|
+
* // Verify the file was written
|
|
335
|
+
* const memoryFs = alepha.inject(MemoryFileSystemProvider);
|
|
336
|
+
* expect(memoryFs.files.get("test.txt")?.toString()).toBe("Hello World");
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
declare class MemoryFileSystemProvider implements FileSystemProvider {
|
|
340
|
+
protected json: Json;
|
|
341
|
+
/**
|
|
342
|
+
* In-memory storage for files (path -> content)
|
|
343
|
+
*/
|
|
344
|
+
files: Map<string, Buffer<ArrayBufferLike>>;
|
|
345
|
+
/**
|
|
346
|
+
* In-memory storage for directories
|
|
347
|
+
*/
|
|
348
|
+
directories: Set<string>;
|
|
349
|
+
/**
|
|
350
|
+
* Track mkdir calls for test assertions
|
|
351
|
+
*/
|
|
352
|
+
mkdirCalls: Array<{
|
|
353
|
+
path: string;
|
|
354
|
+
options?: MkdirOptions;
|
|
355
|
+
}>;
|
|
356
|
+
/**
|
|
357
|
+
* Track writeFile calls for test assertions
|
|
358
|
+
*/
|
|
359
|
+
writeFileCalls: Array<{
|
|
360
|
+
path: string;
|
|
361
|
+
data: string;
|
|
362
|
+
}>;
|
|
363
|
+
/**
|
|
364
|
+
* Track readFile calls for test assertions
|
|
365
|
+
*/
|
|
366
|
+
readFileCalls: Array<string>;
|
|
367
|
+
/**
|
|
368
|
+
* Track rm calls for test assertions
|
|
369
|
+
*/
|
|
370
|
+
rmCalls: Array<{
|
|
371
|
+
path: string;
|
|
372
|
+
options?: RmOptions;
|
|
373
|
+
}>;
|
|
374
|
+
/**
|
|
375
|
+
* Track join calls for test assertions
|
|
376
|
+
*/
|
|
377
|
+
joinCalls: Array<string[]>;
|
|
378
|
+
/**
|
|
379
|
+
* Error to throw on mkdir (for testing error handling)
|
|
380
|
+
*/
|
|
381
|
+
mkdirError: Error | null;
|
|
382
|
+
/**
|
|
383
|
+
* Error to throw on writeFile (for testing error handling)
|
|
384
|
+
*/
|
|
385
|
+
writeFileError: Error | null;
|
|
386
|
+
/**
|
|
387
|
+
* Error to throw on readFile (for testing error handling)
|
|
388
|
+
*/
|
|
389
|
+
readFileError: Error | null;
|
|
390
|
+
constructor(options?: MemoryFileSystemProviderOptions);
|
|
391
|
+
/**
|
|
392
|
+
* Join path segments using forward slashes.
|
|
393
|
+
* Uses Node's path.join for proper normalization (handles .. and .)
|
|
394
|
+
*/
|
|
395
|
+
join(...paths: string[]): string;
|
|
396
|
+
/**
|
|
397
|
+
* Create a FileLike object from various sources.
|
|
398
|
+
*/
|
|
399
|
+
createFile(options: CreateFileOptions): FileLike;
|
|
400
|
+
/**
|
|
401
|
+
* Remove a file or directory from memory.
|
|
402
|
+
*/
|
|
403
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
404
|
+
/**
|
|
405
|
+
* Copy a file or directory in memory.
|
|
406
|
+
*/
|
|
407
|
+
cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
408
|
+
/**
|
|
409
|
+
* Move/rename a file or directory in memory.
|
|
410
|
+
*/
|
|
411
|
+
mv(src: string, dest: string): Promise<void>;
|
|
412
|
+
/**
|
|
413
|
+
* Create a directory in memory.
|
|
414
|
+
*/
|
|
415
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
416
|
+
/**
|
|
417
|
+
* List files in a directory.
|
|
418
|
+
*/
|
|
419
|
+
ls(path: string, options?: LsOptions): Promise<string[]>;
|
|
420
|
+
/**
|
|
421
|
+
* Check if a file or directory exists in memory.
|
|
422
|
+
*/
|
|
423
|
+
exists(path: string): Promise<boolean>;
|
|
424
|
+
/**
|
|
425
|
+
* Read a file from memory.
|
|
426
|
+
*/
|
|
427
|
+
readFile(path: string): Promise<Buffer>;
|
|
428
|
+
/**
|
|
429
|
+
* Read a file from memory as text.
|
|
430
|
+
*/
|
|
431
|
+
readTextFile(path: string): Promise<string>;
|
|
432
|
+
/**
|
|
433
|
+
* Read a file from memory as JSON.
|
|
434
|
+
*/
|
|
435
|
+
readJsonFile<T = unknown>(path: string): Promise<T>;
|
|
436
|
+
/**
|
|
437
|
+
* Write a file to memory.
|
|
438
|
+
*/
|
|
439
|
+
writeFile(path: string, data: Uint8Array | Buffer | string | FileLike): Promise<void>;
|
|
440
|
+
/**
|
|
441
|
+
* Reset all in-memory state (useful between tests).
|
|
442
|
+
*/
|
|
443
|
+
reset(): void;
|
|
444
|
+
/**
|
|
445
|
+
* Check if a file was written during the test.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* expect(fs.wasWritten("/project/tsconfig.json")).toBe(true);
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
wasWritten(path: string): boolean;
|
|
453
|
+
/**
|
|
454
|
+
* Check if a file was written with content matching a pattern.
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* ```typescript
|
|
458
|
+
* expect(fs.wasWrittenMatching("/project/tsconfig.json", /extends/)).toBe(true);
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
wasWrittenMatching(path: string, pattern: RegExp): boolean;
|
|
462
|
+
/**
|
|
463
|
+
* Check if a file was read during the test.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* expect(fs.wasRead("/project/package.json")).toBe(true);
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
wasRead(path: string): boolean;
|
|
471
|
+
/**
|
|
472
|
+
* Check if a file was deleted during the test.
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```typescript
|
|
476
|
+
* expect(fs.wasDeleted("/project/old-file.txt")).toBe(true);
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
wasDeleted(path: string): boolean;
|
|
480
|
+
/**
|
|
481
|
+
* Get the content of a file as a string (convenience method for testing).
|
|
482
|
+
*/
|
|
483
|
+
getFileContent(path: string): string | undefined;
|
|
484
|
+
}
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region ../../src/system/providers/ShellProvider.d.ts
|
|
487
|
+
interface ShellRunOptions {
|
|
488
|
+
/**
|
|
489
|
+
* Working directory for the command.
|
|
490
|
+
*/
|
|
491
|
+
root?: string;
|
|
492
|
+
/**
|
|
493
|
+
* Additional environment variables.
|
|
494
|
+
*/
|
|
495
|
+
env?: Record<string, string>;
|
|
496
|
+
/**
|
|
497
|
+
* Resolve the executable from node_modules/.bin.
|
|
498
|
+
* Supports local project, pnpm nested, and monorepo structures.
|
|
499
|
+
* @default false
|
|
500
|
+
*/
|
|
501
|
+
resolve?: boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Capture stdout instead of inheriting stdio.
|
|
504
|
+
* When true, returns stdout as string.
|
|
505
|
+
* When false, streams output to terminal.
|
|
506
|
+
* @default false
|
|
507
|
+
*/
|
|
508
|
+
capture?: boolean;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Abstract provider for executing shell commands and binaries.
|
|
512
|
+
*
|
|
513
|
+
* Implementations:
|
|
514
|
+
* - `NodeShellProvider` - Real shell execution using Node.js child_process
|
|
515
|
+
* - `MemoryShellProvider` - In-memory mock for testing
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```typescript
|
|
519
|
+
* class MyService {
|
|
520
|
+
* protected readonly shell = $inject(ShellProvider);
|
|
521
|
+
*
|
|
522
|
+
* async build() {
|
|
523
|
+
* // Run shell command directly
|
|
524
|
+
* await this.shell.run("yarn install");
|
|
525
|
+
*
|
|
526
|
+
* // Run local binary with resolution
|
|
527
|
+
* await this.shell.run("vite build", { resolve: true });
|
|
528
|
+
*
|
|
529
|
+
* // Capture output
|
|
530
|
+
* const output = await this.shell.run("echo hello", { capture: true });
|
|
531
|
+
* }
|
|
532
|
+
* }
|
|
533
|
+
* ```
|
|
534
|
+
*/
|
|
535
|
+
declare abstract class ShellProvider {
|
|
536
|
+
/**
|
|
537
|
+
* Run a shell command or binary.
|
|
538
|
+
*
|
|
539
|
+
* @param command - The command to run
|
|
540
|
+
* @param options - Execution options
|
|
541
|
+
* @returns stdout if capture is true, empty string otherwise
|
|
542
|
+
*/
|
|
543
|
+
abstract run(command: string, options?: ShellRunOptions): Promise<string>;
|
|
544
|
+
/**
|
|
545
|
+
* Check if a command is installed and available in the system PATH.
|
|
546
|
+
*
|
|
547
|
+
* @param command - The command name to check
|
|
548
|
+
* @returns true if the command is available
|
|
549
|
+
*/
|
|
550
|
+
abstract isInstalled(command: string): Promise<boolean>;
|
|
551
|
+
}
|
|
552
|
+
//#endregion
|
|
553
|
+
//#region ../../src/system/providers/MemoryShellProvider.d.ts
|
|
554
|
+
interface MemoryShellCall {
|
|
555
|
+
command: string;
|
|
556
|
+
options: ShellRunOptions;
|
|
557
|
+
}
|
|
558
|
+
interface MemoryShellProviderOptions {
|
|
559
|
+
/**
|
|
560
|
+
* Simulated outputs for specific commands.
|
|
561
|
+
* Key is the command string, value is the stdout to return.
|
|
562
|
+
*/
|
|
563
|
+
outputs?: Record<string, string>;
|
|
564
|
+
/**
|
|
565
|
+
* Commands that should throw an error.
|
|
566
|
+
* Key is the command string, value is the error message.
|
|
567
|
+
*/
|
|
568
|
+
errors?: Record<string, string>;
|
|
569
|
+
/**
|
|
570
|
+
* Commands that are considered "installed" in the system PATH.
|
|
571
|
+
*/
|
|
572
|
+
installedCommands?: string[];
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* In-memory implementation of ShellProvider for testing.
|
|
576
|
+
*
|
|
577
|
+
* Records all commands that would be executed without actually running them.
|
|
578
|
+
* Can be configured to return specific outputs or throw errors for testing.
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* ```typescript
|
|
582
|
+
* // In tests, substitute the real ShellProvider with MemoryShellProvider
|
|
583
|
+
* const alepha = Alepha.create().with({
|
|
584
|
+
* provide: ShellProvider,
|
|
585
|
+
* use: MemoryShellProvider,
|
|
586
|
+
* });
|
|
587
|
+
*
|
|
588
|
+
* // Configure mock behavior
|
|
589
|
+
* const shell = alepha.inject(MemoryShellProvider);
|
|
590
|
+
* shell.configure({
|
|
591
|
+
* outputs: { "echo hello": "hello\n" },
|
|
592
|
+
* errors: { "failing-cmd": "Command failed" },
|
|
593
|
+
* });
|
|
594
|
+
*
|
|
595
|
+
* // Or use the fluent API
|
|
596
|
+
* shell.outputs.set("another-cmd", "output");
|
|
597
|
+
* shell.errors.set("another-error", "Error message");
|
|
598
|
+
*
|
|
599
|
+
* // Run code that uses ShellProvider
|
|
600
|
+
* const service = alepha.inject(MyService);
|
|
601
|
+
* await service.doSomething();
|
|
602
|
+
*
|
|
603
|
+
* // Verify commands were called
|
|
604
|
+
* expect(shell.calls).toHaveLength(2);
|
|
605
|
+
* expect(shell.calls[0].command).toBe("yarn install");
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
declare class MemoryShellProvider implements ShellProvider {
|
|
609
|
+
/**
|
|
610
|
+
* All recorded shell calls.
|
|
611
|
+
*/
|
|
612
|
+
calls: MemoryShellCall[];
|
|
613
|
+
/**
|
|
614
|
+
* Simulated outputs for specific commands.
|
|
615
|
+
*/
|
|
616
|
+
outputs: Map<string, string>;
|
|
617
|
+
/**
|
|
618
|
+
* Commands that should throw an error.
|
|
619
|
+
*/
|
|
620
|
+
errors: Map<string, string>;
|
|
621
|
+
/**
|
|
622
|
+
* Commands considered installed in the system PATH.
|
|
623
|
+
*/
|
|
624
|
+
installedCommands: Set<string>;
|
|
625
|
+
/**
|
|
626
|
+
* Configure the mock with predefined outputs, errors, and installed commands.
|
|
627
|
+
*/
|
|
628
|
+
configure(options: MemoryShellProviderOptions): this;
|
|
629
|
+
/**
|
|
630
|
+
* Record command and return simulated output.
|
|
631
|
+
*/
|
|
632
|
+
run(command: string, options?: ShellRunOptions): Promise<string>;
|
|
633
|
+
/**
|
|
634
|
+
* Check if a specific command was called.
|
|
635
|
+
*/
|
|
636
|
+
wasCalled(command: string): boolean;
|
|
637
|
+
/**
|
|
638
|
+
* Check if a command matching a pattern was called.
|
|
639
|
+
*/
|
|
640
|
+
wasCalledMatching(pattern: RegExp): boolean;
|
|
641
|
+
/**
|
|
642
|
+
* Get all calls matching a pattern.
|
|
643
|
+
*/
|
|
644
|
+
getCallsMatching(pattern: RegExp): MemoryShellCall[];
|
|
645
|
+
/**
|
|
646
|
+
* Check if a command is installed.
|
|
647
|
+
*/
|
|
648
|
+
isInstalled(command: string): Promise<boolean>;
|
|
649
|
+
/**
|
|
650
|
+
* Reset all recorded state.
|
|
651
|
+
*/
|
|
652
|
+
reset(): void;
|
|
653
|
+
}
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region ../../src/system/services/FileDetector.d.ts
|
|
656
|
+
interface FileTypeResult {
|
|
657
|
+
/**
|
|
658
|
+
* The detected MIME type
|
|
659
|
+
*/
|
|
660
|
+
mimeType: string;
|
|
661
|
+
/**
|
|
662
|
+
* The detected file extension
|
|
663
|
+
*/
|
|
664
|
+
extension: string;
|
|
665
|
+
/**
|
|
666
|
+
* Whether the file type was verified by magic bytes
|
|
667
|
+
*/
|
|
668
|
+
verified: boolean;
|
|
669
|
+
/**
|
|
670
|
+
* The stream (potentially wrapped to allow re-reading)
|
|
671
|
+
*/
|
|
672
|
+
stream: Readable;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Service for detecting file types and getting content types.
|
|
676
|
+
*
|
|
677
|
+
* @example
|
|
678
|
+
* ```typescript
|
|
679
|
+
* const detector = alepha.inject(FileDetector);
|
|
680
|
+
*
|
|
681
|
+
* // Get content type from filename
|
|
682
|
+
* const mimeType = detector.getContentType("image.png"); // "image/png"
|
|
683
|
+
*
|
|
684
|
+
* // Detect file type by magic bytes
|
|
685
|
+
* const stream = createReadStream('image.png');
|
|
686
|
+
* const result = await detector.detectFileType(stream, 'image.png');
|
|
687
|
+
* console.log(result.mimeType); // 'image/png'
|
|
688
|
+
* console.log(result.verified); // true if magic bytes match
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
declare class FileDetector {
|
|
692
|
+
/**
|
|
693
|
+
* Magic byte signatures for common file formats.
|
|
694
|
+
* Each signature is represented as an array of bytes or null (wildcard).
|
|
695
|
+
*/
|
|
696
|
+
protected static readonly MAGIC_BYTES: Record<string, {
|
|
697
|
+
signature: (number | null)[];
|
|
698
|
+
mimeType: string;
|
|
699
|
+
}[]>;
|
|
700
|
+
/**
|
|
701
|
+
* All possible format signatures for checking against actual file content
|
|
702
|
+
*/
|
|
703
|
+
protected static readonly ALL_SIGNATURES: {
|
|
704
|
+
signature: (number | null)[];
|
|
705
|
+
mimeType: string;
|
|
706
|
+
ext: string;
|
|
707
|
+
}[];
|
|
708
|
+
/**
|
|
709
|
+
* MIME type map for file extensions.
|
|
710
|
+
*
|
|
711
|
+
* Can be used to get the content type of file based on its extension.
|
|
712
|
+
* Feel free to add more mime types in your project!
|
|
713
|
+
*/
|
|
714
|
+
static readonly mimeMap: Record<string, string>;
|
|
715
|
+
/**
|
|
716
|
+
* Reverse MIME type map for looking up extensions from MIME types.
|
|
717
|
+
* Prefers shorter, more common extensions when multiple exist.
|
|
718
|
+
*/
|
|
719
|
+
protected static readonly reverseMimeMap: Record<string, string>;
|
|
720
|
+
/**
|
|
721
|
+
* Returns the file extension for a given MIME type.
|
|
722
|
+
*
|
|
723
|
+
* @param mimeType - The MIME type to look up
|
|
724
|
+
* @returns The file extension (without dot), or "bin" if not found
|
|
725
|
+
*
|
|
726
|
+
* @example
|
|
727
|
+
* ```typescript
|
|
728
|
+
* const detector = alepha.inject(FileDetector);
|
|
729
|
+
* const ext = detector.getExtensionFromMimeType("image/png"); // "png"
|
|
730
|
+
* const ext2 = detector.getExtensionFromMimeType("application/octet-stream"); // "bin"
|
|
731
|
+
* ```
|
|
732
|
+
*/
|
|
733
|
+
getExtensionFromMimeType(mimeType: string): string;
|
|
734
|
+
/**
|
|
735
|
+
* Returns the content type of file based on its filename.
|
|
736
|
+
*
|
|
737
|
+
* @param filename - The filename to check
|
|
738
|
+
* @returns The MIME type
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
* ```typescript
|
|
742
|
+
* const detector = alepha.inject(FileDetector);
|
|
743
|
+
* const mimeType = detector.getContentType("image.png"); // "image/png"
|
|
744
|
+
* ```
|
|
745
|
+
*/
|
|
746
|
+
getContentType(filename: string): string;
|
|
747
|
+
/**
|
|
748
|
+
* Detects the file type by checking magic bytes against the stream content.
|
|
749
|
+
*
|
|
750
|
+
* @param stream - The readable stream to check
|
|
751
|
+
* @param filename - The filename (used to get the extension)
|
|
752
|
+
* @returns File type information including MIME type, extension, and verification status
|
|
753
|
+
*
|
|
754
|
+
* @example
|
|
755
|
+
* ```typescript
|
|
756
|
+
* const detector = alepha.inject(FileDetector);
|
|
757
|
+
* const stream = createReadStream('image.png');
|
|
758
|
+
* const result = await detector.detectFileType(stream, 'image.png');
|
|
759
|
+
* console.log(result.mimeType); // 'image/png'
|
|
760
|
+
* console.log(result.verified); // true if magic bytes match
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
detectFileType(stream: Readable, filename: string): Promise<FileTypeResult>;
|
|
764
|
+
/**
|
|
765
|
+
* Reads all bytes from a stream and returns the first N bytes along with a new stream containing all data.
|
|
766
|
+
* This approach reads the entire stream upfront to avoid complex async handling issues.
|
|
767
|
+
*
|
|
768
|
+
* @protected
|
|
769
|
+
*/
|
|
770
|
+
protected peekBytes(stream: Readable, numBytes: number): Promise<{
|
|
771
|
+
buffer: Buffer;
|
|
772
|
+
stream: Readable;
|
|
773
|
+
}>;
|
|
774
|
+
/**
|
|
775
|
+
* Checks if a buffer matches a magic byte signature.
|
|
776
|
+
*
|
|
777
|
+
* @protected
|
|
778
|
+
*/
|
|
779
|
+
protected matchesSignature(buffer: Buffer, signature: (number | null)[]): boolean;
|
|
780
|
+
}
|
|
781
|
+
//#endregion
|
|
782
|
+
//#region ../../src/system/providers/NodeFileSystemProvider.d.ts
|
|
783
|
+
/**
|
|
784
|
+
* Node.js implementation of FileSystem interface.
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```typescript
|
|
788
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
789
|
+
*
|
|
790
|
+
* // Create from URL
|
|
791
|
+
* const file1 = fs.createFile({ url: "file:///path/to/file.png" });
|
|
792
|
+
*
|
|
793
|
+
* // Create from Buffer
|
|
794
|
+
* const file2 = fs.createFile({ buffer: Buffer.from("hello"), name: "hello.txt" });
|
|
795
|
+
*
|
|
796
|
+
* // Create from text
|
|
797
|
+
* const file3 = fs.createFile({ text: "Hello, world!", name: "greeting.txt" });
|
|
798
|
+
*
|
|
799
|
+
* // File operations
|
|
800
|
+
* await fs.mkdir("/tmp/mydir", { recursive: true });
|
|
801
|
+
* await fs.cp("/src/file.txt", "/dest/file.txt");
|
|
802
|
+
* await fs.mv("/old/path.txt", "/new/path.txt");
|
|
803
|
+
* const files = await fs.ls("/tmp");
|
|
804
|
+
* await fs.rm("/tmp/file.txt");
|
|
805
|
+
* ```
|
|
806
|
+
*/
|
|
807
|
+
declare class NodeFileSystemProvider implements FileSystemProvider {
|
|
808
|
+
protected detector: FileDetector;
|
|
809
|
+
protected json: Json;
|
|
810
|
+
join(...paths: string[]): string;
|
|
811
|
+
/**
|
|
812
|
+
* Creates a FileLike object from various sources.
|
|
813
|
+
*
|
|
814
|
+
* @param options - Options for creating the file
|
|
815
|
+
* @returns A FileLike object
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* ```typescript
|
|
819
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
820
|
+
*
|
|
821
|
+
* // From URL
|
|
822
|
+
* const file1 = fs.createFile({ url: "https://example.com/image.png" });
|
|
823
|
+
*
|
|
824
|
+
* // From Buffer
|
|
825
|
+
* const file2 = fs.createFile({
|
|
826
|
+
* buffer: Buffer.from("hello"),
|
|
827
|
+
* name: "hello.txt",
|
|
828
|
+
* type: "text/plain"
|
|
829
|
+
* });
|
|
830
|
+
*
|
|
831
|
+
* // From text
|
|
832
|
+
* const file3 = fs.createFile({ text: "Hello!", name: "greeting.txt" });
|
|
833
|
+
*
|
|
834
|
+
* // From stream with detection
|
|
835
|
+
* const stream = createReadStream("/path/to/file.png");
|
|
836
|
+
* const file4 = fs.createFile({ stream, name: "image.png" });
|
|
837
|
+
* ```
|
|
838
|
+
*/
|
|
839
|
+
createFile(options: CreateFileOptions): FileLike;
|
|
840
|
+
/**
|
|
841
|
+
* Removes a file or directory.
|
|
842
|
+
*
|
|
843
|
+
* @param path - The path to remove
|
|
844
|
+
* @param options - Remove options
|
|
845
|
+
*
|
|
846
|
+
* @example
|
|
847
|
+
* ```typescript
|
|
848
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
849
|
+
*
|
|
850
|
+
* // Remove a file
|
|
851
|
+
* await fs.rm("/tmp/file.txt");
|
|
852
|
+
*
|
|
853
|
+
* // Remove a directory recursively
|
|
854
|
+
* await fs.rm("/tmp/mydir", { recursive: true });
|
|
855
|
+
*
|
|
856
|
+
* // Remove with force (no error if doesn't exist)
|
|
857
|
+
* await fs.rm("/tmp/maybe-exists.txt", { force: true });
|
|
858
|
+
* ```
|
|
859
|
+
*/
|
|
860
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
861
|
+
/**
|
|
862
|
+
* Copies a file or directory.
|
|
863
|
+
*
|
|
864
|
+
* @param src - Source path
|
|
865
|
+
* @param dest - Destination path
|
|
866
|
+
* @param options - Copy options
|
|
867
|
+
*
|
|
868
|
+
* @example
|
|
869
|
+
* ```typescript
|
|
870
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
871
|
+
*
|
|
872
|
+
* // Copy a file
|
|
873
|
+
* await fs.cp("/src/file.txt", "/dest/file.txt");
|
|
874
|
+
*
|
|
875
|
+
* // Copy a directory recursively
|
|
876
|
+
* await fs.cp("/src/dir", "/dest/dir", { recursive: true });
|
|
877
|
+
*
|
|
878
|
+
* // Copy with force (overwrite existing)
|
|
879
|
+
* await fs.cp("/src/file.txt", "/dest/file.txt", { force: true });
|
|
880
|
+
* ```
|
|
881
|
+
*/
|
|
882
|
+
cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
883
|
+
/**
|
|
884
|
+
* Moves/renames a file or directory.
|
|
885
|
+
*
|
|
886
|
+
* @param src - Source path
|
|
887
|
+
* @param dest - Destination path
|
|
888
|
+
*
|
|
889
|
+
* @example
|
|
890
|
+
* ```typescript
|
|
891
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
892
|
+
*
|
|
893
|
+
* // Move/rename a file
|
|
894
|
+
* await fs.mv("/old/path.txt", "/new/path.txt");
|
|
895
|
+
*
|
|
896
|
+
* // Move a directory
|
|
897
|
+
* await fs.mv("/old/dir", "/new/dir");
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
mv(src: string, dest: string): Promise<void>;
|
|
901
|
+
/**
|
|
902
|
+
* Creates a directory.
|
|
903
|
+
*
|
|
904
|
+
* @param path - The directory path to create
|
|
905
|
+
* @param options - Mkdir options
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* ```typescript
|
|
909
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
910
|
+
*
|
|
911
|
+
* // Create a directory
|
|
912
|
+
* await fs.mkdir("/tmp/mydir");
|
|
913
|
+
*
|
|
914
|
+
* // Create nested directories
|
|
915
|
+
* await fs.mkdir("/tmp/path/to/dir", { recursive: true });
|
|
916
|
+
*
|
|
917
|
+
* // Create with specific permissions
|
|
918
|
+
* await fs.mkdir("/tmp/mydir", { mode: 0o755 });
|
|
919
|
+
* ```
|
|
920
|
+
*/
|
|
921
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
922
|
+
/**
|
|
923
|
+
* Lists files in a directory.
|
|
924
|
+
*
|
|
925
|
+
* @param path - The directory path to list
|
|
926
|
+
* @param options - List options
|
|
927
|
+
* @returns Array of filenames
|
|
928
|
+
*
|
|
929
|
+
* @example
|
|
930
|
+
* ```typescript
|
|
931
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
932
|
+
*
|
|
933
|
+
* // List files in a directory
|
|
934
|
+
* const files = await fs.ls("/tmp");
|
|
935
|
+
* console.log(files); // ["file1.txt", "file2.txt", "subdir"]
|
|
936
|
+
*
|
|
937
|
+
* // List with hidden files
|
|
938
|
+
* const allFiles = await fs.ls("/tmp", { hidden: true });
|
|
939
|
+
*
|
|
940
|
+
* // List recursively
|
|
941
|
+
* const allFilesRecursive = await fs.ls("/tmp", { recursive: true });
|
|
942
|
+
* ```
|
|
943
|
+
*/
|
|
944
|
+
ls(path: string, options?: LsOptions): Promise<string[]>;
|
|
945
|
+
/**
|
|
946
|
+
* Checks if a file or directory exists.
|
|
947
|
+
*
|
|
948
|
+
* @param path - The path to check
|
|
949
|
+
* @returns True if the path exists, false otherwise
|
|
950
|
+
*
|
|
951
|
+
* @example
|
|
952
|
+
* ```typescript
|
|
953
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
954
|
+
*
|
|
955
|
+
* if (await fs.exists("/tmp/file.txt")) {
|
|
956
|
+
* console.log("File exists");
|
|
957
|
+
* }
|
|
958
|
+
* ```
|
|
959
|
+
*/
|
|
960
|
+
exists(path: string): Promise<boolean>;
|
|
961
|
+
/**
|
|
962
|
+
* Reads the content of a file.
|
|
963
|
+
*
|
|
964
|
+
* @param path - The file path to read
|
|
965
|
+
* @returns The file content as a Buffer
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```typescript
|
|
969
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
970
|
+
*
|
|
971
|
+
* const buffer = await fs.readFile("/tmp/file.txt");
|
|
972
|
+
* console.log(buffer.toString("utf-8"));
|
|
973
|
+
* ```
|
|
974
|
+
*/
|
|
975
|
+
readFile(path: string): Promise<Buffer>;
|
|
976
|
+
/**
|
|
977
|
+
* Writes data to a file.
|
|
978
|
+
*
|
|
979
|
+
* @param path - The file path to write to
|
|
980
|
+
* @param data - The data to write (Buffer or string)
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* ```typescript
|
|
984
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
985
|
+
*
|
|
986
|
+
* // Write string
|
|
987
|
+
* await fs.writeFile("/tmp/file.txt", "Hello, world!");
|
|
988
|
+
*
|
|
989
|
+
* // Write Buffer
|
|
990
|
+
* await fs.writeFile("/tmp/file.bin", Buffer.from([0x01, 0x02, 0x03]));
|
|
991
|
+
* ```
|
|
992
|
+
*/
|
|
993
|
+
writeFile(path: string, data: Uint8Array | Buffer | string | FileLike): Promise<void>;
|
|
994
|
+
/**
|
|
995
|
+
* Reads the content of a file as a string.
|
|
996
|
+
*
|
|
997
|
+
* @param path - The file path to read
|
|
998
|
+
* @returns The file content as a string
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
* ```typescript
|
|
1002
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
1003
|
+
* const content = await fs.readTextFile("/tmp/file.txt");
|
|
1004
|
+
* ```
|
|
1005
|
+
*/
|
|
1006
|
+
readTextFile(path: string): Promise<string>;
|
|
1007
|
+
/**
|
|
1008
|
+
* Reads the content of a file as JSON.
|
|
1009
|
+
*
|
|
1010
|
+
* @param path - The file path to read
|
|
1011
|
+
* @returns The parsed JSON content
|
|
1012
|
+
*
|
|
1013
|
+
* @example
|
|
1014
|
+
* ```typescript
|
|
1015
|
+
* const fs = alepha.inject(NodeFileSystemProvider);
|
|
1016
|
+
* const config = await fs.readJsonFile<{ name: string }>("/tmp/config.json");
|
|
1017
|
+
* ```
|
|
1018
|
+
*/
|
|
1019
|
+
readJsonFile<T = unknown>(path: string): Promise<T>;
|
|
1020
|
+
/**
|
|
1021
|
+
* Creates a FileLike object from a Web File.
|
|
1022
|
+
*
|
|
1023
|
+
* @protected
|
|
1024
|
+
*/
|
|
1025
|
+
protected createFileFromWebFile(source: File, options?: {
|
|
1026
|
+
type?: string;
|
|
1027
|
+
name?: string;
|
|
1028
|
+
size?: number;
|
|
1029
|
+
}): FileLike;
|
|
1030
|
+
/**
|
|
1031
|
+
* Creates a FileLike object from a Buffer.
|
|
1032
|
+
*
|
|
1033
|
+
* @protected
|
|
1034
|
+
*/
|
|
1035
|
+
protected createFileFromBuffer(source: Buffer, options?: {
|
|
1036
|
+
type?: string;
|
|
1037
|
+
name?: string;
|
|
1038
|
+
}): FileLike;
|
|
1039
|
+
/**
|
|
1040
|
+
* Creates a FileLike object from a stream.
|
|
1041
|
+
*
|
|
1042
|
+
* @protected
|
|
1043
|
+
*/
|
|
1044
|
+
protected createFileFromStream(source: StreamLike, options?: {
|
|
1045
|
+
type?: string;
|
|
1046
|
+
name?: string;
|
|
1047
|
+
size?: number;
|
|
1048
|
+
}): FileLike & {
|
|
1049
|
+
_buffer: null | Buffer;
|
|
1050
|
+
};
|
|
1051
|
+
/**
|
|
1052
|
+
* Creates a FileLike object from a URL.
|
|
1053
|
+
*
|
|
1054
|
+
* @protected
|
|
1055
|
+
*/
|
|
1056
|
+
protected createFileFromUrl(url: string, options?: {
|
|
1057
|
+
type?: string;
|
|
1058
|
+
name?: string;
|
|
1059
|
+
}): FileLike;
|
|
1060
|
+
/**
|
|
1061
|
+
* Gets a streaming response from a URL.
|
|
1062
|
+
*
|
|
1063
|
+
* @protected
|
|
1064
|
+
*/
|
|
1065
|
+
protected getStreamingResponse(url: string): Readable;
|
|
1066
|
+
/**
|
|
1067
|
+
* Loads data from a URL.
|
|
1068
|
+
*
|
|
1069
|
+
* @protected
|
|
1070
|
+
*/
|
|
1071
|
+
protected loadFromUrl(url: string): Promise<Buffer>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Creates a stream from a URL.
|
|
1074
|
+
*
|
|
1075
|
+
* @protected
|
|
1076
|
+
*/
|
|
1077
|
+
protected createStreamFromUrl(url: string): Readable;
|
|
1078
|
+
/**
|
|
1079
|
+
* Converts a stream-like object to a Buffer.
|
|
1080
|
+
*
|
|
1081
|
+
* @protected
|
|
1082
|
+
*/
|
|
1083
|
+
protected streamToBuffer(streamLike: StreamLike): Promise<Buffer>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Converts a Node.js Buffer to an ArrayBuffer.
|
|
1086
|
+
*
|
|
1087
|
+
* @protected
|
|
1088
|
+
*/
|
|
1089
|
+
protected bufferToArrayBuffer(buffer: Buffer): ArrayBuffer;
|
|
1090
|
+
}
|
|
1091
|
+
//#endregion
|
|
1092
|
+
//#region ../../src/system/providers/NodeShellProvider.d.ts
|
|
1093
|
+
/**
|
|
1094
|
+
* Node.js implementation of ShellProvider.
|
|
1095
|
+
*
|
|
1096
|
+
* Executes shell commands using Node.js child_process module.
|
|
1097
|
+
* Supports binary resolution from node_modules/.bin for local packages.
|
|
1098
|
+
*/
|
|
1099
|
+
declare class NodeShellProvider implements ShellProvider {
|
|
1100
|
+
protected readonly log: alepha_logger0.Logger;
|
|
1101
|
+
protected readonly fs: FileSystemProvider;
|
|
1102
|
+
/**
|
|
1103
|
+
* Run a shell command or binary.
|
|
1104
|
+
*/
|
|
1105
|
+
run(command: string, options?: ShellRunOptions): Promise<string>;
|
|
1106
|
+
/**
|
|
1107
|
+
* Execute command with inherited stdio (streams to terminal).
|
|
1108
|
+
*/
|
|
1109
|
+
protected execInherit(executable: string, args: string[], options: {
|
|
1110
|
+
cwd: string;
|
|
1111
|
+
env?: Record<string, string>;
|
|
1112
|
+
}): Promise<string>;
|
|
1113
|
+
/**
|
|
1114
|
+
* Execute command and capture stdout.
|
|
1115
|
+
*/
|
|
1116
|
+
protected execCapture(command: string, options: {
|
|
1117
|
+
cwd: string;
|
|
1118
|
+
env?: Record<string, string>;
|
|
1119
|
+
}): Promise<string>;
|
|
1120
|
+
/**
|
|
1121
|
+
* Resolve executable path from node_modules/.bin.
|
|
1122
|
+
*
|
|
1123
|
+
* Search order:
|
|
1124
|
+
* 1. Local: node_modules/.bin/
|
|
1125
|
+
* 2. Pnpm nested: node_modules/alepha/node_modules/.bin/
|
|
1126
|
+
* 3. Monorepo: Walk up to 3 parent directories
|
|
1127
|
+
*/
|
|
1128
|
+
protected resolveExecutable(name: string, root: string): Promise<string>;
|
|
1129
|
+
/**
|
|
1130
|
+
* Check if executable exists at path.
|
|
1131
|
+
*/
|
|
1132
|
+
protected findExecutable(root: string, relativePath: string): Promise<string | undefined>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Check if a command is installed and available in the system PATH.
|
|
1135
|
+
*/
|
|
1136
|
+
isInstalled(command: string): Promise<boolean>;
|
|
1137
|
+
}
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region ../../src/system/index.d.ts
|
|
1140
|
+
/**
|
|
1141
|
+
* | type | quality | stability |
|
|
1142
|
+
* |------|---------|-----------|
|
|
1143
|
+
* | tooling | standard | stable |
|
|
1144
|
+
*
|
|
1145
|
+
* System-level abstractions for portable code across runtimes.
|
|
1146
|
+
*
|
|
1147
|
+
* **Features:**
|
|
1148
|
+
* - File system operations (read, write, exists, etc.)
|
|
1149
|
+
* - Shell command execution
|
|
1150
|
+
* - File type detection and MIME utilities
|
|
1151
|
+
* - Memory implementations for testing
|
|
1152
|
+
*
|
|
1153
|
+
* @module alepha.system
|
|
1154
|
+
*/
|
|
1155
|
+
declare const AlephaSystem: alepha0.Service<alepha0.Module>;
|
|
1156
|
+
//#endregion
|
|
1157
|
+
export { AlephaSystem, CpOptions, CreateFileFromArrayBufferOptions, CreateFileFromBufferOptions, CreateFileFromPathOptions, CreateFileFromResponseOptions, CreateFileFromStreamOptions, CreateFileFromTextOptions, CreateFileFromUrlOptions, CreateFileFromWebFileOptions, CreateFileOptions, FileDetector, FileError, FileSystemProvider, FileTypeResult, LsOptions, MemoryFileSystemProvider, MemoryFileSystemProviderOptions, MemoryShellCall, MemoryShellProvider, MemoryShellProviderOptions, MkdirOptions, NodeFileSystemProvider, NodeShellProvider, RmOptions, ShellProvider, ShellRunOptions };
|
|
1158
|
+
//# sourceMappingURL=index.d.ts.map
|