effect 4.0.0-beta.94 → 4.0.0-beta.98
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/dist/Array.d.ts.map +1 -1
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/Boolean.d.ts.map +1 -1
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +44 -6
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +63 -24
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts.map +1 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Cron.d.ts +4 -1
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +98 -53
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Data.d.ts.map +1 -1
- package/dist/DateTime.d.ts +12 -12
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effectable.d.ts.map +1 -1
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ExecutionPlan.d.ts +2 -2
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/FiberHandle.d.ts +8 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberMap.d.ts +8 -8
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberSet.d.ts +4 -4
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Function.d.ts.map +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js.map +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/Inspectable.d.ts.map +1 -1
- package/dist/Inspectable.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Layer.d.ts.map +1 -1
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerRef.d.ts +5 -7
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +4 -6
- package/dist/LayerRef.js.map +1 -1
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/Logger.d.ts.map +1 -1
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/Metric.d.ts.map +1 -1
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/NonEmptyIterable.d.ts.map +1 -1
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +28 -10
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Order.d.ts.map +1 -1
- package/dist/Ordering.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/PrimaryKey.d.ts.map +1 -1
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/Record.d.ts.map +1 -1
- package/dist/Redactable.d.ts.map +1 -1
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/RegExp.d.ts.map +1 -1
- package/dist/Request.d.ts +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Schedule.d.ts +1206 -4013
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +244 -1348
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +71 -22
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +76 -33
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +25 -10
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.d.ts +53 -0
- package/dist/SchemaError.d.ts.map +1 -0
- package/dist/SchemaError.js +61 -0
- package/dist/SchemaError.js.map +1 -0
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +17 -12
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaRepresentation.d.ts +106 -106
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +186 -224
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +38 -2
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +38 -2
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedRef.d.ts.map +1 -1
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stream.d.ts +2 -2
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +1 -1
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/Take.d.ts.map +1 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/Types.d.ts +1 -1
- package/dist/Types.d.ts.map +1 -1
- package/dist/UndefinedOr.d.ts.map +1 -1
- package/dist/Utils.d.ts.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +26 -8
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/equivalence.js +1 -2
- package/dist/internal/schema/equivalence.js.map +1 -1
- package/dist/internal/schema/representation.js +1 -3
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.d.ts +0 -13
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +4 -29
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestConsole.d.ts.map +1 -1
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +1 -1
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +1 -1
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +278 -278
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
- package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +8 -16
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +8 -16
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/Command.d.ts +4 -3
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +3 -3
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +6 -8
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/unstable/cli/GlobalFlag.js +6 -6
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.d.ts.map +1 -1
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts.map +1 -1
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityId.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxy.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js +2 -4
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/EntityType.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/MachineId.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +25 -29
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +8 -8
- package/dist/unstable/cluster/ShardId.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +3 -4
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingRegistrationEvent.d.ts +6 -8
- package/dist/unstable/cluster/ShardingRegistrationEvent.d.ts.map +1 -1
- package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/Singleton.d.ts.map +1 -1
- package/dist/unstable/cluster/SingletonAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/Snowflake.d.ts +1 -1
- package/dist/unstable/cluster/Snowflake.d.ts.map +1 -1
- package/dist/unstable/cluster/Snowflake.js +1 -1
- package/dist/unstable/cluster/Snowflake.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +26 -24
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/devtools/DevTools.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventGroup.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +2 -2
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +21 -21
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +3 -4
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +1 -1
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +1 -1
- package/dist/unstable/http/HttpClientError.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +1 -1
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +2 -2
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +2 -1
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Url.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.d.ts +36 -15
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +19 -20
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +51 -62
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +68 -58
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +53 -53
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +40 -30
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +171 -170
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +31 -19
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +23 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +31 -0
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +55 -30
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js +22 -29
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +8 -8
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js +4 -3
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +8 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.d.ts +4 -4
- package/dist/unstable/httpapi/HttpApiTest.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js +9 -8
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +77 -37
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/httpapi/internal/html.js +6 -2
- package/dist/unstable/httpapi/internal/html.js.map +1 -1
- package/dist/unstable/httpapi/internal/mediaType.d.ts +2 -0
- package/dist/unstable/httpapi/internal/mediaType.d.ts.map +1 -0
- package/dist/unstable/httpapi/internal/mediaType.js +7 -0
- package/dist/unstable/httpapi/internal/mediaType.js.map +1 -0
- package/dist/unstable/observability/Otlp.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +3 -1
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +16 -12
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +2 -2
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -1
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +7 -7
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +3 -2
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRef.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +2 -2
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +28 -37
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -1
- package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +2 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +5 -5
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +7 -7
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +2 -2
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +8 -8
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +5 -3
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +11 -8
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/schema/Model.d.ts +24 -38
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
- package/dist/unstable/sql/Migrator.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +2 -2
- package/dist/unstable/sql/SqlError.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/SqlStream.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +1 -1
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +1 -1
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +1 -1
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +1 -1
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.d.ts +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js +1 -2
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/package.json +11 -12
- package/src/ConfigProvider.ts +79 -27
- package/src/Cron.ts +109 -57
- package/src/LayerRef.ts +4 -6
- package/src/Number.ts +29 -10
- package/src/Schedule.ts +1437 -4445
- package/src/Schema.ts +95 -34
- package/src/SchemaAST.ts +25 -13
- package/src/SchemaError.ts +64 -0
- package/src/SchemaGetter.ts +22 -16
- package/src/SchemaRepresentation.ts +165 -202
- package/src/SchemaTransformation.ts +42 -2
- package/src/Stream.ts +1 -1
- package/src/index.ts +10 -0
- package/src/internal/effect.ts +39 -22
- package/src/internal/schema/equivalence.ts +1 -2
- package/src/internal/schema/representation.ts +4 -4
- package/src/internal/schema/schema.ts +4 -37
- package/src/unstable/cli/CliError.ts +24 -16
- package/src/unstable/cli/Command.ts +8 -8
- package/src/unstable/cli/GlobalFlag.ts +22 -33
- package/src/unstable/cluster/ClusterCron.ts +4 -3
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +4 -3
- package/src/unstable/cluster/EntityProxyServer.ts +15 -17
- package/src/unstable/cluster/Sharding.ts +4 -4
- package/src/unstable/cluster/Snowflake.ts +2 -2
- package/src/unstable/cluster/internal/entityManager.ts +61 -47
- package/src/unstable/eventlog/EventLog.ts +4 -3
- package/src/unstable/httpapi/HttpApi.ts +72 -47
- package/src/unstable/httpapi/HttpApiBuilder.ts +320 -217
- package/src/unstable/httpapi/HttpApiClient.ts +196 -151
- package/src/unstable/httpapi/HttpApiEndpoint.ts +251 -447
- package/src/unstable/httpapi/HttpApiError.ts +33 -0
- package/src/unstable/httpapi/HttpApiGroup.ts +95 -74
- package/src/unstable/httpapi/HttpApiMiddleware.ts +10 -7
- package/src/unstable/httpapi/HttpApiScalar.ts +15 -12
- package/src/unstable/httpapi/HttpApiSchema.ts +8 -0
- package/src/unstable/httpapi/HttpApiSwagger.ts +2 -2
- package/src/unstable/httpapi/HttpApiTest.ts +15 -14
- package/src/unstable/httpapi/OpenApi.ts +74 -36
- package/src/unstable/httpapi/internal/html.ts +9 -2
- package/src/unstable/httpapi/internal/mediaType.ts +6 -0
- package/src/unstable/observability/OtlpExporter.ts +1 -1
- package/src/unstable/persistence/PersistedQueue.ts +16 -14
- package/src/unstable/reactivity/Atom.ts +1 -1
- package/src/unstable/reactivity/AtomHttpApi.ts +164 -162
- package/src/unstable/reactivity/AtomRegistry.ts +35 -44
- package/src/unstable/rpc/RpcClient.ts +10 -9
- package/src/unstable/rpc/RpcMessage.ts +8 -9
- package/src/unstable/rpc/RpcSerialization.ts +16 -16
- package/src/unstable/rpc/RpcServer.ts +15 -9
- package/src/unstable/workflow/Activity.ts +6 -5
- package/src/unstable/workflow/DurableDeferred.ts +1 -1
- package/src/unstable/workflow/DurableQueue.ts +4 -3
- package/src/unstable/workflow/WorkflowEngine.ts +4 -3
- package/src/unstable/workflow/WorkflowProxyServer.ts +11 -12
|
@@ -30,7 +30,7 @@ import * as SchemaIssue from "../../SchemaIssue.ts"
|
|
|
30
30
|
import * as SchemaTransformation from "../../SchemaTransformation.ts"
|
|
31
31
|
import * as Scope from "../../Scope.ts"
|
|
32
32
|
import * as Stream from "../../Stream.ts"
|
|
33
|
-
import type {
|
|
33
|
+
import type { NoInfer } from "../../Types.ts"
|
|
34
34
|
import * as UndefinedOr from "../../UndefinedOr.ts"
|
|
35
35
|
import * as Sse from "../encoding/Sse.ts"
|
|
36
36
|
import type { Cookie } from "../http/Cookies.ts"
|
|
@@ -52,6 +52,7 @@ import type * as HttpApiGroup from "./HttpApiGroup.ts"
|
|
|
52
52
|
import * as HttpApiMiddleware from "./HttpApiMiddleware.ts"
|
|
53
53
|
import * as HttpApiSchema from "./HttpApiSchema.ts"
|
|
54
54
|
import type * as HttpApiSecurity from "./HttpApiSecurity.ts"
|
|
55
|
+
import * as MediaType from "./internal/mediaType.ts"
|
|
55
56
|
import * as OpenApi from "./OpenApi.ts"
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -60,7 +61,7 @@ import * as OpenApi from "./OpenApi.ts"
|
|
|
60
61
|
* @category constructors
|
|
61
62
|
* @since 4.0.0
|
|
62
63
|
*/
|
|
63
|
-
export const layer = <Id extends string, Groups extends HttpApiGroup.
|
|
64
|
+
export const layer = <Id extends string, Groups extends HttpApiGroup.Constraint>(
|
|
64
65
|
api: HttpApi.HttpApi<Id, Groups>,
|
|
65
66
|
options?: {
|
|
66
67
|
readonly openapiPath?: `/${string}` | undefined
|
|
@@ -87,7 +88,8 @@ export const layer = <Id extends string, Groups extends HttpApiGroup.Any>(
|
|
|
87
88
|
const availableGroups = Array.from(services.mapUnsafe.keys()).filter((key) =>
|
|
88
89
|
key.startsWith("effect/httpapi/HttpApiGroup/")
|
|
89
90
|
)
|
|
90
|
-
|
|
91
|
+
const groups = Object.values(api.groups) as ReadonlyArray<HttpApiGroup.Top>
|
|
92
|
+
for (const group of groups) {
|
|
91
93
|
const groupRoutes = services.mapUnsafe.get(group.key)?.routes as Array<HttpRouter.Route<any, any>>
|
|
92
94
|
if (groupRoutes === undefined) {
|
|
93
95
|
const available = availableGroups.length === 0 ? "none" : availableGroups.join(", ")
|
|
@@ -118,17 +120,17 @@ export const layer = <Id extends string, Groups extends HttpApiGroup.Any>(
|
|
|
118
120
|
*/
|
|
119
121
|
export const group = <
|
|
120
122
|
ApiId extends string,
|
|
121
|
-
Groups extends HttpApiGroup.
|
|
122
|
-
const
|
|
123
|
+
Groups extends HttpApiGroup.Constraint,
|
|
124
|
+
const Identifier extends HttpApiGroup.Identifier<Groups>,
|
|
123
125
|
Return
|
|
124
126
|
>(
|
|
125
127
|
api: HttpApi.HttpApi<ApiId, Groups>,
|
|
126
|
-
|
|
128
|
+
groupIdentifier: Identifier,
|
|
127
129
|
build: (
|
|
128
|
-
handlers: Handlers.FromGroup<HttpApiGroup.
|
|
130
|
+
handlers: Handlers.FromGroup<HttpApiGroup.WithIdentifier<Groups, Identifier>>
|
|
129
131
|
) => Handlers.ValidateReturn<Return>
|
|
130
132
|
): Layer.Layer<
|
|
131
|
-
HttpApiGroup.
|
|
133
|
+
HttpApiGroup.Service<ApiId, Identifier>,
|
|
132
134
|
Handlers.Error<Return>,
|
|
133
135
|
Exclude<Handlers.Context<Return>, Scope.Scope>
|
|
134
136
|
> =>
|
|
@@ -136,9 +138,9 @@ export const group = <
|
|
|
136
138
|
const services = (yield* Effect.context<any>()).pipe(
|
|
137
139
|
Context.omit(Scope.Scope)
|
|
138
140
|
)
|
|
139
|
-
const group = api.groups[
|
|
141
|
+
const group = api.groups[groupIdentifier] as HttpApiGroup.Constraint
|
|
140
142
|
const result = build(makeHandlers(group))
|
|
141
|
-
const handlers: Handlers<any, any> = Effect.isEffect(result)
|
|
143
|
+
const handlers: Handlers<any, any, any> = Effect.isEffect(result)
|
|
142
144
|
? (yield* result as Effect.Effect<any, any, any>)
|
|
143
145
|
: result
|
|
144
146
|
const routes: Array<HttpRouter.Route<any, any>> = []
|
|
@@ -153,21 +155,96 @@ export const group = <
|
|
|
153
155
|
)
|
|
154
156
|
})) as any
|
|
155
157
|
|
|
156
|
-
|
|
157
|
-
* Type identifier symbol used to brand `Handlers` values.
|
|
158
|
-
*
|
|
159
|
-
* @category type IDs
|
|
160
|
-
* @since 4.0.0
|
|
161
|
-
*/
|
|
162
|
-
export const HandlersTypeId: unique symbol = Symbol.for("@effect/platform/HttpApiBuilder/Handlers")
|
|
158
|
+
const HandlersTypeId = "~effect/httpapi/HttpApiBuilder/Handlers"
|
|
163
159
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
160
|
+
type EndpointMap<Endpoints extends HttpApiEndpoint.Constraint> = {
|
|
161
|
+
readonly [Endpoint in Endpoints as HttpApiEndpoint.Identifier<Endpoint>]: Endpoint
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type HandlerRequirements<
|
|
165
|
+
Endpoint extends HttpApiEndpoint.Constraint,
|
|
166
|
+
R1,
|
|
167
|
+
R = HttpApiEndpoint.ExcludeProvided<
|
|
168
|
+
Endpoint,
|
|
169
|
+
R1 | HttpApiEndpoint.ServerServices<Endpoint>
|
|
170
|
+
>
|
|
171
|
+
> =
|
|
172
|
+
| HttpApiEndpoint.Middleware<Endpoint>
|
|
173
|
+
| HttpApiEndpoint.MiddlewareServices<Endpoint>
|
|
174
|
+
| ([R] extends [never] ? never : HttpRouter.Request<"Requires", R>)
|
|
175
|
+
|
|
176
|
+
interface HandlerOptions {
|
|
177
|
+
readonly uninterruptible?: boolean | undefined
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** @internal */
|
|
181
|
+
export interface HandlerRuntime {
|
|
182
|
+
readonly endpoint: HttpApiEndpoint.Top
|
|
183
|
+
readonly handler: HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, unknown, unknown>
|
|
184
|
+
readonly isRaw: boolean
|
|
185
|
+
readonly uninterruptible: boolean
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type HandleAllEntry<Endpoint extends HttpApiEndpoint.Constraint> =
|
|
189
|
+
| HttpApiEndpoint.Handler<
|
|
190
|
+
Endpoint,
|
|
191
|
+
HttpApiEndpoint.MiddlewareError<Endpoint>,
|
|
192
|
+
unknown
|
|
193
|
+
>
|
|
194
|
+
| {
|
|
195
|
+
readonly handler: HttpApiEndpoint.Handler<
|
|
196
|
+
Endpoint,
|
|
197
|
+
HttpApiEndpoint.MiddlewareError<Endpoint>,
|
|
198
|
+
unknown
|
|
199
|
+
>
|
|
200
|
+
readonly options?: HandlerOptions | undefined
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
type HandleAllHandlers<EndpointsByIdentifier extends Record<string, HttpApiEndpoint.Constraint>> = {
|
|
204
|
+
readonly [Identifier in keyof EndpointsByIdentifier]?: HandleAllEntry<EndpointsByIdentifier[Identifier]>
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
type HandleAllExtraKeys<
|
|
208
|
+
EndpointsByIdentifier extends Record<string, HttpApiEndpoint.Constraint>,
|
|
209
|
+
HandlersByIdentifier
|
|
210
|
+
> = {
|
|
211
|
+
readonly [Identifier in Exclude<keyof HandlersByIdentifier, keyof EndpointsByIdentifier>]: never
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
type NotHandledIdentifier<Identifier extends PropertyKey, HandledIdentifiers extends PropertyKey> = Identifier extends
|
|
215
|
+
HandledIdentifiers ? never :
|
|
216
|
+
unknown
|
|
217
|
+
|
|
218
|
+
type HandleAllEntryHandler<Entry> = Entry extends { readonly handler: infer Handler } ? Handler : Entry
|
|
219
|
+
|
|
220
|
+
type HandleAllRequirements<
|
|
221
|
+
EndpointsByIdentifier extends Record<string, HttpApiEndpoint.Constraint>,
|
|
222
|
+
HandlersByIdentifier extends HandleAllHandlers<EndpointsByIdentifier>
|
|
223
|
+
> = {
|
|
224
|
+
readonly [Identifier in keyof HandlersByIdentifier & keyof EndpointsByIdentifier]: HandleAllEntryHandler<
|
|
225
|
+
HandlersByIdentifier[Identifier]
|
|
226
|
+
> extends HttpApiEndpoint.Handler<
|
|
227
|
+
EndpointsByIdentifier[Identifier],
|
|
228
|
+
HttpApiEndpoint.MiddlewareError<EndpointsByIdentifier[Identifier]>,
|
|
229
|
+
infer R1
|
|
230
|
+
> ? HandlerRequirements<EndpointsByIdentifier[Identifier], R1> :
|
|
231
|
+
never
|
|
232
|
+
}[keyof HandlersByIdentifier & keyof EndpointsByIdentifier]
|
|
233
|
+
|
|
234
|
+
type HandlersResult<A> = A extends Effect.Effect<infer H, any, any> ? H : A
|
|
235
|
+
|
|
236
|
+
type MissingHandlerNames<H extends Handlers<any, any, any>> = Exclude<
|
|
237
|
+
keyof H["~EndpointsByIdentifier"],
|
|
238
|
+
H["~HandledIdentifiers"]
|
|
239
|
+
>
|
|
240
|
+
|
|
241
|
+
type ValidateHandlersReturn<
|
|
242
|
+
A,
|
|
243
|
+
H = HandlersResult<A>,
|
|
244
|
+
Missing = H extends Handlers<any, any, any> ? MissingHandlerNames<H> : never
|
|
245
|
+
> = H extends Handlers<any, any, any> ? [Missing] extends [never] ? A
|
|
246
|
+
: `Endpoint not handled: ${Missing & string}`
|
|
247
|
+
: `Must return the implemented handlers`
|
|
171
248
|
|
|
172
249
|
/**
|
|
173
250
|
* Mutable handler collection for one `HttpApi` group.
|
|
@@ -175,59 +252,77 @@ export type HandlersTypeId = typeof HandlersTypeId
|
|
|
175
252
|
* **Details**
|
|
176
253
|
*
|
|
177
254
|
* Each call to `handle` or `handleRaw` registers an endpoint implementation and
|
|
178
|
-
*
|
|
179
|
-
*
|
|
255
|
+
* adds that endpoint identifier to the type-level set of implemented endpoints.
|
|
256
|
+
* Endpoint identifiers that were already handled are rejected at the type level.
|
|
180
257
|
*
|
|
181
258
|
* @category handlers
|
|
182
259
|
* @since 4.0.0
|
|
183
260
|
*/
|
|
184
261
|
export interface Handlers<
|
|
185
262
|
R,
|
|
186
|
-
|
|
263
|
+
EndpointsByIdentifier extends Record<string, HttpApiEndpoint.Constraint> = {},
|
|
264
|
+
HandledIdentifiers extends keyof EndpointsByIdentifier = never
|
|
187
265
|
> extends Pipeable {
|
|
188
|
-
readonly [HandlersTypeId]:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
readonly
|
|
266
|
+
readonly [HandlersTypeId]: typeof HandlersTypeId
|
|
267
|
+
readonly "~EndpointsByIdentifier": EndpointsByIdentifier
|
|
268
|
+
readonly "~HandledIdentifiers": HandledIdentifiers
|
|
269
|
+
/** @internal */
|
|
270
|
+
readonly group: HttpApiGroup.Top
|
|
271
|
+
/** @internal */
|
|
272
|
+
readonly handlers: Map<string, HandlerRuntime>
|
|
193
273
|
|
|
194
274
|
/**
|
|
195
|
-
* Add the implementation for an `HttpApiEndpoint` to a `Handlers` group.
|
|
275
|
+
* Add the implementation for an unhandled `HttpApiEndpoint` to a `Handlers` group.
|
|
196
276
|
*/
|
|
197
|
-
handle<
|
|
198
|
-
|
|
199
|
-
|
|
277
|
+
handle<
|
|
278
|
+
Identifier extends keyof EndpointsByIdentifier,
|
|
279
|
+
R1
|
|
280
|
+
>(
|
|
281
|
+
identifier: Identifier & NotHandledIdentifier<Identifier, HandledIdentifiers>,
|
|
282
|
+
handler: HttpApiEndpoint.Handler<
|
|
283
|
+
EndpointsByIdentifier[Identifier],
|
|
284
|
+
HttpApiEndpoint.MiddlewareError<EndpointsByIdentifier[Identifier]>,
|
|
285
|
+
R1
|
|
286
|
+
>,
|
|
200
287
|
options?: { readonly uninterruptible?: boolean | undefined } | undefined
|
|
201
288
|
): Handlers<
|
|
202
|
-
|
|
|
203
|
-
|
|
204
|
-
|
|
|
205
|
-
| (HttpApiEndpoint.ExcludeProvidedWithName<
|
|
206
|
-
Endpoints,
|
|
207
|
-
Name,
|
|
208
|
-
R1 | HttpApiEndpoint.ServerServicesWithName<Endpoints, Name>
|
|
209
|
-
> extends infer _R ? _R extends never ? never : HttpRouter.Request<"Requires", _R> : never),
|
|
210
|
-
HttpApiEndpoint.ExcludeName<Endpoints, Name>
|
|
289
|
+
R | HandlerRequirements<EndpointsByIdentifier[Identifier], R1>,
|
|
290
|
+
EndpointsByIdentifier,
|
|
291
|
+
HandledIdentifiers | Identifier
|
|
211
292
|
>
|
|
212
293
|
|
|
213
294
|
/**
|
|
214
|
-
* Add
|
|
295
|
+
* Add implementations for unhandled `HttpApiEndpoint`s in a `Handlers` group.
|
|
296
|
+
*/
|
|
297
|
+
handleAll<const HandlersByIdentifier extends HandleAllHandlers<Omit<EndpointsByIdentifier, HandledIdentifiers>>>(
|
|
298
|
+
handlers:
|
|
299
|
+
& HandlersByIdentifier
|
|
300
|
+
& HandleAllExtraKeys<Omit<EndpointsByIdentifier, HandledIdentifiers>, HandlersByIdentifier>
|
|
301
|
+
): Handlers<
|
|
302
|
+
R | HandleAllRequirements<EndpointsByIdentifier, HandlersByIdentifier>,
|
|
303
|
+
EndpointsByIdentifier,
|
|
304
|
+
HandledIdentifiers | keyof HandlersByIdentifier & keyof EndpointsByIdentifier
|
|
305
|
+
>
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Add the implementation for an unhandled `HttpApiEndpoint` to a `Handlers` group.
|
|
215
309
|
* This version opts out of automatic payload decoding and provides the raw request.
|
|
216
310
|
*/
|
|
217
|
-
handleRaw<
|
|
218
|
-
|
|
219
|
-
|
|
311
|
+
handleRaw<
|
|
312
|
+
Identifier extends keyof EndpointsByIdentifier,
|
|
313
|
+
R1
|
|
314
|
+
>(
|
|
315
|
+
identifier: Identifier & NotHandledIdentifier<Identifier, HandledIdentifiers>,
|
|
316
|
+
handler: HttpApiEndpoint.HandlerRaw<
|
|
317
|
+
EndpointsByIdentifier[Identifier],
|
|
318
|
+
HttpApiEndpoint.MiddlewareError<EndpointsByIdentifier[Identifier]>,
|
|
319
|
+
R1
|
|
320
|
+
>,
|
|
220
321
|
options?: { readonly uninterruptible?: boolean | undefined } | undefined
|
|
221
322
|
): Handlers<
|
|
222
|
-
|
|
|
223
|
-
|
|
224
|
-
|
|
|
225
|
-
| (HttpApiEndpoint.ExcludeProvidedWithName<
|
|
226
|
-
Endpoints,
|
|
227
|
-
Name,
|
|
228
|
-
R1 | HttpApiEndpoint.ServerServicesWithName<Endpoints, Name>
|
|
229
|
-
> extends infer _R ? _R extends never ? never : HttpRouter.Request<"Requires", _R> : never),
|
|
230
|
-
HttpApiEndpoint.ExcludeName<Endpoints, Name>
|
|
323
|
+
R | HandlerRequirements<EndpointsByIdentifier[Identifier], R1>,
|
|
324
|
+
EndpointsByIdentifier,
|
|
325
|
+
HandledIdentifiers | Identifier
|
|
231
326
|
>
|
|
232
327
|
}
|
|
233
328
|
|
|
@@ -237,34 +332,6 @@ export interface Handlers<
|
|
|
237
332
|
* @since 4.0.0
|
|
238
333
|
*/
|
|
239
334
|
export declare namespace Handlers {
|
|
240
|
-
/**
|
|
241
|
-
* A `Handlers` value with its context and endpoint types erased.
|
|
242
|
-
*
|
|
243
|
-
* @category handlers
|
|
244
|
-
* @since 4.0.0
|
|
245
|
-
*/
|
|
246
|
-
export interface Any {
|
|
247
|
-
readonly [HandlersTypeId]: any
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Record stored for a registered endpoint handler.
|
|
252
|
-
*
|
|
253
|
-
* **Details**
|
|
254
|
-
*
|
|
255
|
-
* It keeps the endpoint metadata, handler function, whether raw request handling
|
|
256
|
-
* is used, and whether the handler should run uninterruptibly.
|
|
257
|
-
*
|
|
258
|
-
* @category handlers
|
|
259
|
-
* @since 4.0.0
|
|
260
|
-
*/
|
|
261
|
-
export type Item<R> = {
|
|
262
|
-
readonly endpoint: HttpApiEndpoint.AnyWithProps
|
|
263
|
-
readonly handler: HttpApiEndpoint.Handler<any, any, R>
|
|
264
|
-
readonly isRaw: boolean
|
|
265
|
-
readonly uninterruptible: boolean
|
|
266
|
-
}
|
|
267
|
-
|
|
268
335
|
/**
|
|
269
336
|
* Creates a handler collection for a group where every endpoint in the group is
|
|
270
337
|
* still awaiting an implementation.
|
|
@@ -272,9 +339,9 @@ export declare namespace Handlers {
|
|
|
272
339
|
* @category handlers
|
|
273
340
|
* @since 4.0.0
|
|
274
341
|
*/
|
|
275
|
-
export type FromGroup<Group extends HttpApiGroup.
|
|
342
|
+
export type FromGroup<Group extends HttpApiGroup.Constraint> = Handlers<
|
|
276
343
|
never,
|
|
277
|
-
|
|
344
|
+
Group["endpoints"]
|
|
278
345
|
>
|
|
279
346
|
|
|
280
347
|
/**
|
|
@@ -285,22 +352,7 @@ export declare namespace Handlers {
|
|
|
285
352
|
* @category handlers
|
|
286
353
|
* @since 4.0.0
|
|
287
354
|
*/
|
|
288
|
-
export type ValidateReturn<A> = A
|
|
289
|
-
| Handlers<
|
|
290
|
-
infer _R,
|
|
291
|
-
infer _Endpoints
|
|
292
|
-
>
|
|
293
|
-
| Effect.Effect<
|
|
294
|
-
Handlers<
|
|
295
|
-
infer _R,
|
|
296
|
-
infer _Endpoints
|
|
297
|
-
>,
|
|
298
|
-
infer _EX,
|
|
299
|
-
infer _RX
|
|
300
|
-
>
|
|
301
|
-
) ? [_Endpoints] extends [never] ? A
|
|
302
|
-
: `Endpoint not handled: ${HttpApiEndpoint.Name<_Endpoints>}` :
|
|
303
|
-
`Must return the implemented handlers`
|
|
355
|
+
export type ValidateReturn<A> = ValidateHandlersReturn<A>
|
|
304
356
|
|
|
305
357
|
/**
|
|
306
358
|
* Extracts the error channel from an effect that produces a `Handlers`
|
|
@@ -312,7 +364,8 @@ export declare namespace Handlers {
|
|
|
312
364
|
export type Error<A> = A extends Effect.Effect<
|
|
313
365
|
Handlers<
|
|
314
366
|
infer _R,
|
|
315
|
-
infer
|
|
367
|
+
infer _EndpointsByIdentifier,
|
|
368
|
+
infer _HandledIdentifiers
|
|
316
369
|
>,
|
|
317
370
|
infer _EX,
|
|
318
371
|
infer _RX
|
|
@@ -328,12 +381,14 @@ export declare namespace Handlers {
|
|
|
328
381
|
*/
|
|
329
382
|
export type Context<A> = A extends Handlers<
|
|
330
383
|
infer _R,
|
|
331
|
-
infer
|
|
384
|
+
infer _EndpointsByIdentifier,
|
|
385
|
+
infer _HandledIdentifiers
|
|
332
386
|
> ? _R :
|
|
333
387
|
A extends Effect.Effect<
|
|
334
388
|
Handlers<
|
|
335
389
|
infer _R,
|
|
336
|
-
infer
|
|
390
|
+
infer _EndpointsByIdentifier,
|
|
391
|
+
infer _HandledIdentifiers
|
|
337
392
|
>,
|
|
338
393
|
infer _EX,
|
|
339
394
|
infer _RX
|
|
@@ -341,34 +396,18 @@ export declare namespace Handlers {
|
|
|
341
396
|
never
|
|
342
397
|
}
|
|
343
398
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
*/
|
|
351
|
-
export const endpoint = <
|
|
352
|
-
ApiId extends string,
|
|
353
|
-
Groups extends HttpApiGroup.Any,
|
|
354
|
-
const GroupName extends HttpApiGroup.Name<Groups>,
|
|
355
|
-
const EndpointName extends HttpApiEndpoint.Name<HttpApiGroup.Endpoints<HttpApiGroup.WithName<Groups, GroupName>>>,
|
|
399
|
+
type EndpointReturn<
|
|
400
|
+
Groups extends HttpApiGroup.Constraint,
|
|
401
|
+
GroupIdentifier extends HttpApiGroup.Identifier<Groups>,
|
|
402
|
+
EndpointIdentifier extends HttpApiGroup.Endpoints<
|
|
403
|
+
HttpApiGroup.WithIdentifier<Groups, GroupIdentifier>
|
|
404
|
+
>["identifier"],
|
|
356
405
|
R,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
api: HttpApi.HttpApi<ApiId, Groups>,
|
|
361
|
-
groupName: GroupName,
|
|
362
|
-
endpointName: EndpointName,
|
|
363
|
-
handler: NoInfer<
|
|
364
|
-
HttpApiEndpoint.HandlerWithName<
|
|
365
|
-
HttpApiGroup.Endpoints<HttpApiGroup.WithName<Groups, GroupName>>,
|
|
366
|
-
EndpointName,
|
|
367
|
-
never,
|
|
368
|
-
R
|
|
369
|
-
>
|
|
406
|
+
Endpoint extends HttpApiEndpoint.Constraint = HttpApiEndpoint.WithIdentifier<
|
|
407
|
+
HttpApiGroup.Endpoints<HttpApiGroup.WithIdentifier<Groups, GroupIdentifier>>,
|
|
408
|
+
EndpointIdentifier
|
|
370
409
|
>
|
|
371
|
-
|
|
410
|
+
> = Effect.Effect<
|
|
372
411
|
Effect.Effect<
|
|
373
412
|
HttpServerResponse,
|
|
374
413
|
never,
|
|
@@ -385,10 +424,39 @@ export const endpoint = <
|
|
|
385
424
|
| FileSystem
|
|
386
425
|
| HttpPlatform
|
|
387
426
|
| Path
|
|
388
|
-
>
|
|
427
|
+
>
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Builds the server-side HTTP effect for a single endpoint in an API group using
|
|
431
|
+
* the endpoint metadata, middleware, codecs, and supplied handler.
|
|
432
|
+
*
|
|
433
|
+
* @category handlers
|
|
434
|
+
* @since 4.0.0
|
|
435
|
+
*/
|
|
436
|
+
export const endpoint = <
|
|
437
|
+
ApiId extends string,
|
|
438
|
+
Groups extends HttpApiGroup.Constraint,
|
|
439
|
+
const GroupIdentifier extends HttpApiGroup.Identifier<Groups>,
|
|
440
|
+
const EndpointIdentifier extends HttpApiGroup.Endpoints<
|
|
441
|
+
HttpApiGroup.WithIdentifier<Groups, GroupIdentifier>
|
|
442
|
+
>["identifier"],
|
|
443
|
+
R
|
|
444
|
+
>(
|
|
445
|
+
api: HttpApi.HttpApi<ApiId, Groups>,
|
|
446
|
+
groupIdentifier: GroupIdentifier,
|
|
447
|
+
endpointIdentifier: EndpointIdentifier,
|
|
448
|
+
handler: NoInfer<
|
|
449
|
+
HttpApiEndpoint.HandlerWithIdentifier<
|
|
450
|
+
HttpApiGroup.Endpoints<HttpApiGroup.WithIdentifier<Groups, GroupIdentifier>>,
|
|
451
|
+
EndpointIdentifier,
|
|
452
|
+
never,
|
|
453
|
+
R
|
|
454
|
+
>
|
|
455
|
+
>
|
|
456
|
+
): EndpointReturn<Groups, GroupIdentifier, EndpointIdentifier, R> =>
|
|
389
457
|
Effect.contextWith((context: Context.Context<any>) => {
|
|
390
|
-
const group = api.groups[
|
|
391
|
-
const endpoint = group.endpoints[
|
|
458
|
+
const group = api.groups[groupIdentifier] as unknown as HttpApiGroup.Top
|
|
459
|
+
const endpoint = group.endpoints[endpointIdentifier]
|
|
392
460
|
return Effect.succeed(handlerToHttpEffect(
|
|
393
461
|
group,
|
|
394
462
|
endpoint,
|
|
@@ -416,8 +484,10 @@ export const securityDecode = <Security extends HttpApiSecurity.HttpApiSecurity>
|
|
|
416
484
|
case "Http": {
|
|
417
485
|
return Effect.map(
|
|
418
486
|
HttpServerRequest,
|
|
419
|
-
|
|
420
|
-
|
|
487
|
+
(request) =>
|
|
488
|
+
Redacted.make(
|
|
489
|
+
getAuthorizationCredential(request.headers.authorization, self.scheme) ?? ""
|
|
490
|
+
) as any
|
|
421
491
|
)
|
|
422
492
|
}
|
|
423
493
|
case "ApiKey": {
|
|
@@ -444,24 +514,20 @@ export const securityDecode = <Security extends HttpApiSecurity.HttpApiSecurity>
|
|
|
444
514
|
username: "",
|
|
445
515
|
password: Redacted.make("")
|
|
446
516
|
} as any
|
|
447
|
-
return
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
)
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
} as any
|
|
462
|
-
}
|
|
463
|
-
})
|
|
464
|
-
)
|
|
517
|
+
return Effect.map(HttpServerRequest, (request) => {
|
|
518
|
+
const encoded = getAuthorizationCredential(request.headers.authorization, basicScheme)
|
|
519
|
+
if (encoded === undefined) return empty
|
|
520
|
+
const decoded = Result.getOrUndefined(Encoding.decodeBase64String(encoded))
|
|
521
|
+
if (decoded === undefined) return empty
|
|
522
|
+
// RFC 7617, Section 2: only the first colon separates the user-id from the password.
|
|
523
|
+
// https://www.rfc-editor.org/rfc/rfc7617.html#section-2
|
|
524
|
+
const separator = decoded.indexOf(":")
|
|
525
|
+
if (separator === -1) return empty
|
|
526
|
+
return {
|
|
527
|
+
username: decoded.slice(0, separator),
|
|
528
|
+
password: Redacted.make(decoded.slice(separator + 1))
|
|
529
|
+
} as any
|
|
530
|
+
})
|
|
465
531
|
}
|
|
466
532
|
}
|
|
467
533
|
}
|
|
@@ -492,53 +558,101 @@ export const securitySetCookie = (
|
|
|
492
558
|
// Internal
|
|
493
559
|
// -----------------------------------------------------------------------------
|
|
494
560
|
|
|
495
|
-
const
|
|
561
|
+
const basicScheme = "Basic"
|
|
562
|
+
|
|
563
|
+
function getAuthorizationCredential(
|
|
564
|
+
authorization: string | undefined,
|
|
565
|
+
scheme: string
|
|
566
|
+
): string | undefined {
|
|
567
|
+
const schemeLength = scheme.length
|
|
568
|
+
// RFC 9110, Section 11.1: schemes are case-insensitive and credentials follow 1*SP.
|
|
569
|
+
// https://www.rfc-editor.org/rfc/rfc9110.html#section-11.1
|
|
570
|
+
if (
|
|
571
|
+
authorization === undefined ||
|
|
572
|
+
authorization.length <= schemeLength ||
|
|
573
|
+
authorization.charCodeAt(schemeLength) !== 32 ||
|
|
574
|
+
authorization.slice(0, schemeLength).toLowerCase() !== scheme.toLowerCase()
|
|
575
|
+
) {
|
|
576
|
+
return undefined
|
|
577
|
+
}
|
|
578
|
+
let credentialStart = schemeLength + 1
|
|
579
|
+
while (authorization.charCodeAt(credentialStart) === 32) {
|
|
580
|
+
credentialStart++
|
|
581
|
+
}
|
|
582
|
+
return credentialStart === authorization.length ? undefined : authorization.slice(credentialStart)
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const registerHandler = (
|
|
586
|
+
self: Handlers<any, any, any>,
|
|
587
|
+
identifier: string,
|
|
588
|
+
handler: HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, any, any>,
|
|
589
|
+
isRaw: boolean,
|
|
590
|
+
options?: HandlerOptions | undefined
|
|
591
|
+
) => {
|
|
592
|
+
if (!Object.hasOwn(self.group.endpoints, identifier)) {
|
|
593
|
+
throw new Error(`HttpApiEndpoint "${identifier}" not found in HttpApiGroup "${self.group.identifier}"`)
|
|
594
|
+
}
|
|
595
|
+
if (self.handlers.has(identifier)) {
|
|
596
|
+
throw new Error(
|
|
597
|
+
`Handler for HttpApiEndpoint "${identifier}" is already registered in HttpApiGroup "${self.group.identifier}"`
|
|
598
|
+
)
|
|
599
|
+
}
|
|
600
|
+
const endpoint = self.group.endpoints[identifier]
|
|
601
|
+
self.handlers.set(identifier, {
|
|
602
|
+
endpoint,
|
|
603
|
+
handler,
|
|
604
|
+
isRaw,
|
|
605
|
+
uninterruptible: options?.uninterruptible ?? false
|
|
606
|
+
})
|
|
607
|
+
return self
|
|
608
|
+
}
|
|
496
609
|
|
|
497
610
|
const HandlersProto = {
|
|
498
|
-
[HandlersTypeId]:
|
|
499
|
-
_Endpoints: identity
|
|
500
|
-
},
|
|
611
|
+
[HandlersTypeId]: HandlersTypeId,
|
|
501
612
|
pipe() {
|
|
502
613
|
return pipeArguments(this, arguments)
|
|
503
614
|
},
|
|
504
615
|
handle(
|
|
505
|
-
this: Handlers<any,
|
|
506
|
-
|
|
507
|
-
handler: HttpApiEndpoint.Handler<
|
|
616
|
+
this: Handlers<any, any, any>,
|
|
617
|
+
identifier: string,
|
|
618
|
+
handler: HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, any, any>,
|
|
508
619
|
options?: { readonly uninterruptible?: boolean | undefined } | undefined
|
|
509
620
|
) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
621
|
+
return registerHandler(this, identifier, handler, false, options)
|
|
622
|
+
},
|
|
623
|
+
handleAll(
|
|
624
|
+
this: Handlers<any, any, any>,
|
|
625
|
+
handlers: Record<
|
|
626
|
+
string,
|
|
627
|
+
HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, any, any> | {
|
|
628
|
+
readonly handler: HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, any, any>
|
|
629
|
+
readonly options?: HandlerOptions | undefined
|
|
630
|
+
}
|
|
631
|
+
>
|
|
632
|
+
) {
|
|
633
|
+
for (const [identifier, entry] of Object.entries(handlers)) {
|
|
634
|
+
const handler = typeof entry === "function" ? entry : entry.handler
|
|
635
|
+
const options = typeof entry === "function" ? undefined : entry.options
|
|
636
|
+
registerHandler(this, identifier, handler, false, options)
|
|
637
|
+
}
|
|
517
638
|
return this
|
|
518
639
|
},
|
|
519
640
|
handleRaw(
|
|
520
|
-
this: Handlers<any,
|
|
521
|
-
|
|
522
|
-
handler: HttpApiEndpoint.Handler<
|
|
641
|
+
this: Handlers<any, any, any>,
|
|
642
|
+
identifier: string,
|
|
643
|
+
handler: HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, any, any>,
|
|
523
644
|
options?: { readonly uninterruptible?: boolean | undefined } | undefined
|
|
524
645
|
) {
|
|
525
|
-
|
|
526
|
-
this.handlers.set(name, {
|
|
527
|
-
endpoint,
|
|
528
|
-
handler,
|
|
529
|
-
isRaw: true,
|
|
530
|
-
uninterruptible: options?.uninterruptible ?? false
|
|
531
|
-
})
|
|
532
|
-
return this
|
|
646
|
+
return registerHandler(this, identifier, handler, true, options)
|
|
533
647
|
}
|
|
534
648
|
}
|
|
535
649
|
|
|
536
|
-
const makeHandlers = <R,
|
|
537
|
-
group:
|
|
538
|
-
): Handlers<R, Endpoints
|
|
650
|
+
const makeHandlers = <R, Group extends HttpApiGroup.Constraint>(
|
|
651
|
+
group: Group
|
|
652
|
+
): Handlers<R, EndpointMap<HttpApiGroup.Endpoints<Group>>> => {
|
|
539
653
|
const self = Object.create(HandlersProto)
|
|
540
654
|
self.group = group
|
|
541
|
-
self.handlers = new Map<string,
|
|
655
|
+
self.handlers = new Map<string, HandlerRuntime>()
|
|
542
656
|
return self
|
|
543
657
|
}
|
|
544
658
|
|
|
@@ -581,7 +695,7 @@ function decodePayload(
|
|
|
581
695
|
): Effect.Effect<unknown, Schema.SchemaError, unknown> | HttpServerResponse | undefined {
|
|
582
696
|
const hasBody = HttpMethod.hasBody(httpRequest.method)
|
|
583
697
|
const contentType = hasBody
|
|
584
|
-
?
|
|
698
|
+
? MediaType.normalize(httpRequest.headers["content-type"] ?? "application/json")
|
|
585
699
|
: "application/x-www-form-urlencoded"
|
|
586
700
|
const existing = payloadBy.get(contentType)
|
|
587
701
|
if (!existing) {
|
|
@@ -635,10 +749,10 @@ function decodePayload(
|
|
|
635
749
|
}
|
|
636
750
|
|
|
637
751
|
function handlerToHttpEffect(
|
|
638
|
-
group: HttpApiGroup.
|
|
639
|
-
endpoint: HttpApiEndpoint.
|
|
752
|
+
group: HttpApiGroup.Top,
|
|
753
|
+
endpoint: HttpApiEndpoint.Top,
|
|
640
754
|
context: Context.Context<any>,
|
|
641
|
-
handler: HttpApiEndpoint.Handler<
|
|
755
|
+
handler: HttpApiEndpoint.Handler<HttpApiEndpoint.Constraint, any, any>,
|
|
642
756
|
isRaw: boolean
|
|
643
757
|
) {
|
|
644
758
|
const encodeSuccess = Schema.encodeUnknownEffect(makeSuccessSchema(endpoint))
|
|
@@ -706,8 +820,8 @@ function handlerToHttpEffect(
|
|
|
706
820
|
|
|
707
821
|
/** @internal */
|
|
708
822
|
export function handlerToRoute(
|
|
709
|
-
group: HttpApiGroup.
|
|
710
|
-
handler:
|
|
823
|
+
group: HttpApiGroup.Top,
|
|
824
|
+
handler: HandlerRuntime,
|
|
711
825
|
context: Context.Context<any>
|
|
712
826
|
): HttpRouter.Route<any, any> {
|
|
713
827
|
const endpoint = handler.endpoint
|
|
@@ -719,31 +833,20 @@ export function handlerToRoute(
|
|
|
719
833
|
)
|
|
720
834
|
}
|
|
721
835
|
|
|
722
|
-
const
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
: "application/json"
|
|
726
|
-
|
|
727
|
-
const getRequestMediaType = (request: HttpServerRequest): string => {
|
|
728
|
-
const contentType = getRequestContentType(request)
|
|
729
|
-
const index = contentType.indexOf(";")
|
|
730
|
-
return index === -1 ? contentType : contentType.slice(0, index).trim()
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
const applyMiddleware = <A extends Effect.Effect<any, any, any>>(
|
|
734
|
-
group: HttpApiGroup.AnyWithProps,
|
|
735
|
-
endpoint: HttpApiEndpoint.AnyWithProps,
|
|
836
|
+
const applyMiddleware = <Group extends HttpApiGroup.Constraint, A extends Effect.Effect<any, any, any>>(
|
|
837
|
+
group: Group,
|
|
838
|
+
endpoint: HttpApiEndpoint.Top,
|
|
736
839
|
context: Context.Context<any>,
|
|
737
840
|
handler: A
|
|
738
841
|
) => {
|
|
739
842
|
const options = { group, endpoint }
|
|
740
843
|
for (const key_ of endpoint.middlewares) {
|
|
741
|
-
const key = key_ as
|
|
742
|
-
const service = Context.getUnsafe(context, key
|
|
844
|
+
const key = key_ as HttpApiMiddleware.AnyService
|
|
845
|
+
const service = Context.getUnsafe(context, key)
|
|
743
846
|
const apply = HttpApiMiddleware.isSecurity(key)
|
|
744
|
-
? makeSecurityMiddleware(key, service
|
|
847
|
+
? makeSecurityMiddleware(key, service)
|
|
745
848
|
: service
|
|
746
|
-
handler = apply(handler, options)
|
|
849
|
+
handler = apply(handler, options)
|
|
747
850
|
}
|
|
748
851
|
return handler
|
|
749
852
|
}
|
|
@@ -771,8 +874,8 @@ const makeSecurityMiddleware = (
|
|
|
771
874
|
}
|
|
772
875
|
|
|
773
876
|
const middleware = Effect.fnUntraced(function*(handler: Effect.Effect<any, any, any>, options: {
|
|
774
|
-
readonly group: HttpApiGroup.
|
|
775
|
-
readonly endpoint: HttpApiEndpoint.
|
|
877
|
+
readonly group: HttpApiGroup.Top
|
|
878
|
+
readonly endpoint: HttpApiEndpoint.Top
|
|
776
879
|
}) {
|
|
777
880
|
handler = Effect.mapError(handler, (error) => new HandlerError(error))
|
|
778
881
|
let lastResult: Result.Result<any, any> | undefined
|
|
@@ -816,7 +919,7 @@ type StreamEncoder = (response: unknown, context: Context.Context<never>) =>
|
|
|
816
919
|
| Effect.Effect<HttpServerResponse, Schema.SchemaError, unknown>
|
|
817
920
|
| undefined
|
|
818
921
|
|
|
819
|
-
function makeStreamEncoder(endpoint: HttpApiEndpoint.
|
|
922
|
+
function makeStreamEncoder(endpoint: HttpApiEndpoint.Top): StreamEncoder | undefined {
|
|
820
923
|
const streamSchema = getStreamSuccessSchema(endpoint)
|
|
821
924
|
if (streamSchema === undefined) {
|
|
822
925
|
return undefined
|
|
@@ -863,7 +966,7 @@ function makeStreamEncoder(endpoint: HttpApiEndpoint.AnyWithProps): StreamEncode
|
|
|
863
966
|
}
|
|
864
967
|
}
|
|
865
968
|
|
|
866
|
-
function getStreamSuccessSchema(endpoint: HttpApiEndpoint.
|
|
969
|
+
function getStreamSuccessSchema(endpoint: HttpApiEndpoint.Top) {
|
|
867
970
|
for (const schema of endpoint.success) {
|
|
868
971
|
if (HttpApiSchema.isStreamSchema(schema)) {
|
|
869
972
|
return schema
|
|
@@ -871,7 +974,7 @@ function getStreamSuccessSchema(endpoint: HttpApiEndpoint.AnyWithProps) {
|
|
|
871
974
|
}
|
|
872
975
|
}
|
|
873
976
|
|
|
874
|
-
function hasBufferedSuccess(endpoint: HttpApiEndpoint.
|
|
977
|
+
function hasBufferedSuccess(endpoint: HttpApiEndpoint.Top): boolean {
|
|
875
978
|
for (const schema of endpoint.success) {
|
|
876
979
|
if (Schema.isSchema(schema) && !HttpApiSchema.isStreamSchema(schema)) return true
|
|
877
980
|
}
|
|
@@ -942,14 +1045,14 @@ const toResponseSuccessSchema = toResponseSchema(HttpApiSchema.getStatusSuccess)
|
|
|
942
1045
|
const toResponseErrorSchema = toResponseSchema(HttpApiSchema.getStatusError)
|
|
943
1046
|
|
|
944
1047
|
function makeSuccessSchema(
|
|
945
|
-
endpoint: HttpApiEndpoint.
|
|
1048
|
+
endpoint: HttpApiEndpoint.Top
|
|
946
1049
|
): Schema.ConstraintEncoder<HttpServerResponse, unknown> {
|
|
947
1050
|
const schemas = HttpApiEndpoint.getSuccessSchemas(endpoint).map(toResponseSuccessSchema)
|
|
948
1051
|
return schemas.length === 1 ? schemas[0] : Schema.Union(schemas)
|
|
949
1052
|
}
|
|
950
1053
|
|
|
951
1054
|
function makeErrorSchema(
|
|
952
|
-
endpoint: HttpApiEndpoint.
|
|
1055
|
+
endpoint: HttpApiEndpoint.Top
|
|
953
1056
|
): Schema.ConstraintEncoder<HttpServerResponse, unknown> {
|
|
954
1057
|
const schemas = HttpApiEndpoint.getErrorSchemas(endpoint).map(toResponseErrorSchema)
|
|
955
1058
|
if (schemas.length === 0) return Schema.Never
|
|
@@ -967,7 +1070,7 @@ function toResponseSchema(getStatus: (ast: SchemaAST.AST) => number) {
|
|
|
967
1070
|
const responseSchema = $HttpServerResponse.pipe(
|
|
968
1071
|
Schema.decodeTo(schema, getResponseTransformation(getStatus, schema))
|
|
969
1072
|
)
|
|
970
|
-
cache.set(
|
|
1073
|
+
cache.set(schema.ast, responseSchema)
|
|
971
1074
|
return responseSchema
|
|
972
1075
|
}
|
|
973
1076
|
}
|