effect 4.0.0-beta.100 → 4.0.0-beta.102
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/Array.js +81 -5
- package/dist/Array.js.map +1 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +27 -9
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +6 -5
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.js +7 -7
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +2 -1
- package/dist/Data.js.map +1 -1
- package/dist/Effect.d.ts +61 -100
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +66 -39
- package/dist/Effect.js.map +1 -1
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +3 -2
- package/dist/FiberHandle.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +2 -1
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.d.ts.map +1 -1
- package/dist/JsonPatch.js +4 -3
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +9 -11
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +3 -2
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +9 -0
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +3 -0
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +4 -3
- package/dist/Metric.js.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +4 -0
- package/dist/MutableList.js.map +1 -1
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +5 -4
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +2 -1
- package/dist/Option.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -4
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Record.d.ts +93 -1
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +57 -19
- package/dist/Record.js.map +1 -1
- package/dist/References.d.ts +0 -45
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +0 -45
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +9 -6
- package/dist/Request.js.map +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +2 -1
- package/dist/Result.js.map +1 -1
- package/dist/Schema.d.ts +1269 -496
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2308 -614
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +2 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +189 -130
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.js +1 -1
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +13 -11
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +34 -24
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.js +1 -1
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +1 -12
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +403 -1504
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +294 -2852
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +2 -2
- package/dist/SchemaTransformation.js +3 -3
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +5 -3
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js.map +1 -1
- package/dist/Stream.d.ts +15 -9
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +46 -16
- package/dist/Stream.js.map +1 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +5 -4
- package/dist/Struct.js.map +1 -1
- package/dist/Types.d.ts +1 -3
- package/dist/Types.d.ts.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +3 -2
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/effect.js +119 -53
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/record.d.ts +0 -3
- package/dist/internal/record.d.ts.map +1 -1
- package/dist/internal/record.js +10 -5
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/references.js +0 -4
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/schema/annotations.js +12 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +743 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/fromRepresentation.d.ts +2 -0
- package/dist/internal/schema/fromRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/fromRepresentation.js +252 -0
- package/dist/internal/schema/fromRepresentation.js.map +1 -0
- package/dist/internal/schema/schema.js +28 -40
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/{arbitrary.d.ts → toArbitrary.d.ts} +1 -1
- package/dist/internal/schema/toArbitrary.d.ts.map +1 -0
- package/dist/internal/schema/{arbitrary.js → toArbitrary.js} +8 -9
- package/dist/internal/schema/toArbitrary.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.d.ts +2 -0
- package/dist/internal/schema/toCodeDocument.d.ts.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +438 -0
- package/dist/internal/schema/toCodeDocument.js.map +1 -0
- package/dist/internal/schema/toEquivalence.d.ts +2 -0
- package/dist/internal/schema/toEquivalence.d.ts.map +1 -0
- package/dist/internal/schema/{equivalence.js → toEquivalence.js} +15 -13
- package/dist/internal/schema/toEquivalence.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +466 -0
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/toRepresentation.d.ts +2 -0
- package/dist/internal/schema/toRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/toRepresentation.js +369 -0
- package/dist/internal/schema/toRepresentation.js.map +1 -0
- package/dist/internal/stackTraceLimit.js +3 -6
- package/dist/internal/stackTraceLimit.js.map +1 -1
- package/dist/testing/TestClock.js +4 -1
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +26 -26
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +5 -4
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +21 -6
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +86 -316
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +1 -1
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +4 -1
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +19 -17
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +197 -197
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +13 -13
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +4 -4
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +116 -49
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +32 -10
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +193 -377
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +19 -19
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +14 -14
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +4 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +11 -3
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +9 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +14 -10
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +15 -12
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/structured-output.d.ts +2 -0
- package/dist/unstable/ai/internal/structured-output.d.ts.map +1 -0
- package/dist/unstable/ai/internal/structured-output.js +316 -0
- package/dist/unstable/ai/internal/structured-output.js.map +1 -0
- package/dist/unstable/cli/CliError.d.ts +40 -2
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +45 -6
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/Command.js +14 -5
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Param.js +3 -3
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +3 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +11 -4
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/config.d.ts +0 -48
- package/dist/unstable/cli/internal/config.d.ts.map +1 -1
- package/dist/unstable/cli/internal/config.js +8 -10
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.js +1 -1
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +2 -1
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/Reply.js +1 -1
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +1 -1
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +125 -24
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +10 -2
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SingleRunner.d.ts +4 -2
- package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SingleRunner.js +2 -1
- package/dist/unstable/cluster/SingleRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts +7 -4
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +55 -24
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +109 -62
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +19 -7
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/shardLock.d.ts +2 -0
- package/dist/unstable/cluster/internal/shardLock.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/shardLock.js +4 -0
- package/dist/unstable/cluster/internal/shardLock.js.map +1 -0
- package/dist/unstable/devtools/DevToolsSchema.d.ts +20 -20
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +8 -5
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
- package/dist/unstable/eventlog/EventJournal.js +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 +15 -11
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +26 -26
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +8 -3
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +2 -2
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +3 -3
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +24 -22
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Headers.js +8 -8
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +44 -0
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +14 -0
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -2
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +5 -4
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +17 -15
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/Template.js +1 -1
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +17 -14
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +3 -3
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +5 -5
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +37 -24
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +72 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +69 -4
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -3
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +2 -2
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +7 -3
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +5 -2
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -3
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +2 -2
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +2 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +2 -2
- package/dist/unstable/persistence/RateLimiter.js +2 -2
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.js +2 -2
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +3 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +4 -3
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +83 -0
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +31 -0
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +2 -1
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +1 -2
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +13 -10
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +1 -1
- package/dist/unstable/socket/Socket.js +1 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +2 -2
- package/dist/unstable/sql/SqlError.js +2 -2
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +7 -6
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +86 -25
- package/src/Channel.ts +32 -14
- package/src/Config.ts +6 -5
- package/src/ConfigProvider.ts +7 -7
- package/src/Data.ts +3 -2
- package/src/Effect.ts +70 -116
- package/src/FiberHandle.ts +3 -2
- package/src/Iterable.ts +2 -1
- package/src/JsonPatch.ts +4 -3
- package/src/JsonSchema.ts +9 -11
- package/src/Logger.ts +3 -2
- package/src/ManagedRuntime.ts +13 -0
- package/src/Metric.ts +4 -3
- package/src/MutableList.ts +4 -0
- package/src/Optic.ts +5 -4
- package/src/Option.ts +2 -1
- package/src/PartitionedSemaphore.ts +1 -4
- package/src/Record.ts +119 -22
- package/src/References.ts +0 -46
- package/src/Request.ts +5 -7
- package/src/Result.ts +2 -1
- package/src/Schema.ts +2538 -987
- package/src/SchemaAST.ts +228 -149
- package/src/SchemaError.ts +1 -1
- package/src/SchemaGetter.ts +36 -29
- package/src/SchemaIssue.ts +1 -1
- package/src/SchemaParser.ts +1 -25
- package/src/SchemaRepresentation.ts +697 -3398
- package/src/SchemaTransformation.ts +3 -3
- package/src/Semaphore.ts +5 -3
- package/src/Stream.ts +63 -19
- package/src/Struct.ts +5 -4
- package/src/Types.ts +1 -3
- package/src/index.ts +0 -5
- package/src/internal/core.ts +4 -3
- package/src/internal/effect.ts +132 -70
- package/src/internal/matcher.ts +1 -1
- package/src/internal/record.ts +11 -7
- package/src/internal/references.ts +0 -5
- package/src/internal/schema/annotations.ts +44 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +957 -0
- package/src/internal/schema/fromRepresentation.ts +345 -0
- package/src/internal/schema/schema.ts +45 -46
- package/src/internal/schema/{arbitrary.ts → toArbitrary.ts} +8 -10
- package/src/internal/schema/toCodeDocument.ts +572 -0
- package/src/internal/schema/{equivalence.ts → toEquivalence.ts} +12 -7
- package/src/internal/schema/toJsonSchemaDocument.ts +475 -0
- package/src/internal/schema/toRepresentation.ts +401 -0
- package/src/internal/stackTraceLimit.ts +3 -7
- package/src/testing/TestClock.ts +1 -1
- package/src/unstable/ai/AiError.ts +5 -4
- package/src/unstable/ai/AnthropicStructuredOutput.ts +102 -333
- package/src/unstable/ai/EmbeddingModel.ts +1 -1
- package/src/unstable/ai/LanguageModel.ts +30 -28
- package/src/unstable/ai/McpSchema.ts +15 -15
- package/src/unstable/ai/McpServer.ts +172 -56
- package/src/unstable/ai/OpenAiStructuredOutput.ts +230 -395
- package/src/unstable/ai/Response.ts +24 -24
- package/src/unstable/ai/Tool.ts +22 -4
- package/src/unstable/ai/Toolkit.ts +19 -7
- package/src/unstable/ai/internal/codec-transformer.ts +13 -7
- package/src/unstable/ai/internal/structured-output.ts +458 -0
- package/src/unstable/cli/CliError.ts +51 -5
- package/src/unstable/cli/Command.ts +4 -4
- package/src/unstable/cli/Param.ts +3 -3
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/internal/command.ts +13 -5
- package/src/unstable/cli/internal/config.ts +8 -10
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +3 -3
- package/src/unstable/cluster/Entity.ts +1 -1
- package/src/unstable/cluster/Envelope.ts +2 -1
- package/src/unstable/cluster/Reply.ts +1 -1
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/ShardId.ts +1 -1
- package/src/unstable/cluster/Sharding.ts +161 -34
- package/src/unstable/cluster/ShardingConfig.ts +5 -1
- package/src/unstable/cluster/SingleRunner.ts +4 -2
- package/src/unstable/cluster/SqlMessageStorage.ts +83 -35
- package/src/unstable/cluster/SqlRunnerStorage.ts +186 -116
- package/src/unstable/cluster/internal/entityManager.ts +31 -10
- package/src/unstable/cluster/internal/shardLock.ts +9 -0
- package/src/unstable/devtools/DevToolsSchema.ts +10 -5
- package/src/unstable/eventlog/EventJournal.ts +1 -1
- package/src/unstable/eventlog/EventLog.ts +21 -11
- package/src/unstable/eventlog/EventLogEncryption.ts +1 -1
- package/src/unstable/eventlog/EventLogMessage.ts +10 -3
- package/src/unstable/eventlog/SqlEventJournal.ts +2 -2
- package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +1 -1
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +6 -3
- package/src/unstable/http/Cookies.ts +29 -24
- package/src/unstable/http/Headers.ts +8 -8
- package/src/unstable/http/HttpClientRequest.ts +57 -0
- package/src/unstable/http/HttpRouter.ts +6 -3
- package/src/unstable/http/HttpServerRequest.ts +5 -4
- package/src/unstable/http/Multipart.ts +16 -13
- package/src/unstable/http/Template.ts +1 -1
- package/src/unstable/http/UrlParams.ts +17 -14
- package/src/unstable/httpapi/HttpApi.ts +3 -3
- package/src/unstable/httpapi/HttpApiClient.ts +5 -5
- package/src/unstable/httpapi/HttpApiGroup.ts +1 -1
- package/src/unstable/httpapi/OpenApi.ts +52 -28
- package/src/unstable/observability/OtlpExporter.ts +109 -5
- package/src/unstable/observability/OtlpLogger.ts +5 -5
- package/src/unstable/observability/OtlpMetrics.ts +8 -4
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/persistence/Persistable.ts +3 -2
- package/src/unstable/persistence/RateLimiter.ts +2 -2
- package/src/unstable/persistence/Redis.ts +2 -2
- package/src/unstable/process/ChildProcessSpawner.ts +1 -1
- package/src/unstable/reactivity/AsyncResult.ts +4 -3
- package/src/unstable/reactivity/Atom.ts +92 -0
- package/src/unstable/reactivity/AtomRegistry.ts +1 -1
- package/src/unstable/rpc/RpcClient.ts +2 -1
- package/src/unstable/schema/VariantSchema.ts +14 -24
- package/src/unstable/socket/Socket.ts +1 -1
- package/src/unstable/sql/SqlError.ts +2 -2
- package/src/unstable/sql/Statement.ts +7 -6
- package/dist/SchemaUtils.d.ts +0 -28
- package/dist/SchemaUtils.d.ts.map +0 -1
- package/dist/SchemaUtils.js +0 -45
- package/dist/SchemaUtils.js.map +0 -1
- package/dist/internal/schema/arbitrary.d.ts.map +0 -1
- package/dist/internal/schema/arbitrary.js.map +0 -1
- package/dist/internal/schema/equivalence.d.ts +0 -2
- package/dist/internal/schema/equivalence.d.ts.map +0 -1
- package/dist/internal/schema/equivalence.js.map +0 -1
- package/dist/internal/schema/representation.d.ts +0 -2
- package/dist/internal/schema/representation.d.ts.map +0 -1
- package/dist/internal/schema/representation.js +0 -865
- package/dist/internal/schema/representation.js.map +0 -1
- package/src/SchemaUtils.ts +0 -51
- package/src/internal/schema/representation.ts +0 -795
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import * as Arr from "../../Array.ts"
|
|
2
|
+
import type * as Schema from "../../Schema.ts"
|
|
3
|
+
import * as SchemaAST from "../../SchemaAST.ts"
|
|
4
|
+
import type * as SchemaRepresentation from "../../SchemaRepresentation.ts"
|
|
5
|
+
import * as InternalRecord from "../record.ts"
|
|
6
|
+
import * as InternalAnnotations from "./annotations.ts"
|
|
7
|
+
|
|
8
|
+
/** @internal */
|
|
9
|
+
export function toRepresentation(
|
|
10
|
+
ast: SchemaAST.AST
|
|
11
|
+
): SchemaRepresentation.Document {
|
|
12
|
+
const { references, representations } = toRepresentations([ast])
|
|
13
|
+
return { representation: representations[0], references }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export function toRepresentations(
|
|
18
|
+
asts: readonly [SchemaAST.AST, ...Array<SchemaAST.AST>]
|
|
19
|
+
): SchemaRepresentation.MultiDocument {
|
|
20
|
+
return lowerASTs(asts, [])
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type CheckRepresentationAnnotation = SchemaRepresentation.CheckRepresentationAnnotation<
|
|
24
|
+
SchemaRepresentation.Representation
|
|
25
|
+
>
|
|
26
|
+
|
|
27
|
+
function annotationsField<A>(annotations: A | undefined): { readonly annotations: A } | undefined {
|
|
28
|
+
return annotations === undefined ? undefined : { annotations }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @internal */
|
|
32
|
+
export function fromSchemaMultiDocument(
|
|
33
|
+
document: SchemaRepresentation.SchemaMultiDocument
|
|
34
|
+
): SchemaRepresentation.MultiDocument {
|
|
35
|
+
const definitions = Object.entries(document.definitions).map(([key, schema]) => {
|
|
36
|
+
const original = schema.ast
|
|
37
|
+
const encoded = SchemaAST.getLastEncoding(original)
|
|
38
|
+
const body = SchemaAST.isSuspend(encoded) ? encoded.thunk() : encoded
|
|
39
|
+
return { key, original, encoded, body }
|
|
40
|
+
})
|
|
41
|
+
const asts = Arr.map(document.schemas, (schema) => schema.ast)
|
|
42
|
+
return lowerASTs(asts, definitions)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface ExternalDefinition {
|
|
46
|
+
readonly key: string
|
|
47
|
+
readonly original: SchemaAST.AST
|
|
48
|
+
readonly encoded: SchemaAST.AST
|
|
49
|
+
readonly body: SchemaAST.AST
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Preserve repeated structural nodes as references without adding noise for leaf nodes.
|
|
53
|
+
function isShareable(ast: SchemaAST.AST): boolean {
|
|
54
|
+
return SchemaAST.isArrays(ast) ||
|
|
55
|
+
SchemaAST.isObjects(ast) ||
|
|
56
|
+
(SchemaAST.isUnion(ast) && ast.types.some(isShareable))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface ReferenceIdentifier {
|
|
60
|
+
readonly identifier: string
|
|
61
|
+
readonly isFallback: boolean
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function resolveReferenceIdentifier(ast: SchemaAST.AST): ReferenceIdentifier | undefined {
|
|
65
|
+
const identifier = InternalAnnotations.resolveIdentifier(ast)
|
|
66
|
+
if (identifier !== undefined) return { identifier, isFallback: false }
|
|
67
|
+
const fallback = InternalAnnotations.resolveIdentifierFallback(ast)
|
|
68
|
+
return fallback === undefined ? undefined : { identifier: `${fallback}JsonEncoding`, isFallback: true }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function hasSameReferenceOwner(self: SchemaAST.AST, that: SchemaAST.AST): boolean {
|
|
72
|
+
if (self === that) return true
|
|
73
|
+
const selfKeys = Reflect.ownKeys(self)
|
|
74
|
+
const thatKeys = Reflect.ownKeys(that)
|
|
75
|
+
if (selfKeys.length !== thatKeys.length) return false
|
|
76
|
+
for (const key of selfKeys) {
|
|
77
|
+
if (key !== "context" && (self as any)[key] !== (that as any)[key]) return false
|
|
78
|
+
}
|
|
79
|
+
return true
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function lowerASTs(
|
|
83
|
+
asts: readonly [SchemaAST.AST, ...Array<SchemaAST.AST>],
|
|
84
|
+
externalDefinitions: ReadonlyArray<ExternalDefinition>
|
|
85
|
+
): SchemaRepresentation.MultiDocument {
|
|
86
|
+
const references: Record<string, SchemaRepresentation.Representation> = {}
|
|
87
|
+
const referenceMap = new Map<SchemaAST.AST, string>()
|
|
88
|
+
const fallbackReferences: Array<readonly [SchemaAST.AST, string]> = []
|
|
89
|
+
const referenceOwners = new Map<string, SchemaAST.AST>()
|
|
90
|
+
const externalReferences = new Set(externalDefinitions.map((definition) => definition.key))
|
|
91
|
+
const visiting = new Set<SchemaAST.AST>()
|
|
92
|
+
const visited = new Set<SchemaAST.AST>()
|
|
93
|
+
const shared = new Set<SchemaAST.AST>()
|
|
94
|
+
|
|
95
|
+
for (const definition of externalDefinitions) {
|
|
96
|
+
referenceOwners.set(definition.key, definition.body)
|
|
97
|
+
referenceMap.set(definition.original, definition.key)
|
|
98
|
+
referenceMap.set(definition.encoded, definition.key)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
for (const ast of asts) visit(ast)
|
|
102
|
+
for (const definition of externalDefinitions) visit(definition.body)
|
|
103
|
+
|
|
104
|
+
const representations = Arr.map(asts, (ast) => recur(ast))
|
|
105
|
+
|
|
106
|
+
for (const definition of externalDefinitions) {
|
|
107
|
+
InternalRecord.assignProperty(references, definition.key, recur(definition.body, definition.key))
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { representations, references }
|
|
111
|
+
|
|
112
|
+
function generateReference(prefix: string, owner: SchemaAST.AST): string {
|
|
113
|
+
let candidate = prefix
|
|
114
|
+
let suffix = 0
|
|
115
|
+
while (referenceOwners.has(candidate)) {
|
|
116
|
+
candidate = `${prefix}${++suffix}`
|
|
117
|
+
}
|
|
118
|
+
referenceOwners.set(candidate, owner)
|
|
119
|
+
return candidate
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function visit(input: SchemaAST.AST): void {
|
|
123
|
+
const ast = SchemaAST.getLastEncoding(input)
|
|
124
|
+
if (visited.has(ast)) {
|
|
125
|
+
if (isShareable(ast)) shared.add(ast)
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
visited.add(ast)
|
|
129
|
+
const referenceIdentifier = resolveReferenceIdentifier(ast)
|
|
130
|
+
if (referenceIdentifier !== undefined && !referenceIdentifier.isFallback) {
|
|
131
|
+
const owner = referenceOwners.get(referenceIdentifier.identifier)
|
|
132
|
+
if (owner === undefined) {
|
|
133
|
+
referenceOwners.set(referenceIdentifier.identifier, ast)
|
|
134
|
+
} else if (
|
|
135
|
+
referenceMap.get(ast) !== referenceIdentifier.identifier &&
|
|
136
|
+
!hasSameReferenceOwner(owner, ast)
|
|
137
|
+
) {
|
|
138
|
+
throw new Error(`Duplicate identifier: ${JSON.stringify(referenceIdentifier.identifier)}`)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
visitChecks(ast.checks)
|
|
142
|
+
switch (ast._tag) {
|
|
143
|
+
case "Declaration":
|
|
144
|
+
case "Arrays":
|
|
145
|
+
case "Objects":
|
|
146
|
+
case "Union":
|
|
147
|
+
ast.recur((child) => {
|
|
148
|
+
visit(child)
|
|
149
|
+
return child
|
|
150
|
+
})
|
|
151
|
+
break
|
|
152
|
+
case "TemplateLiteral":
|
|
153
|
+
ast.parts.forEach(visit)
|
|
154
|
+
break
|
|
155
|
+
case "Suspend":
|
|
156
|
+
visit(ast.thunk())
|
|
157
|
+
break
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function visitChecks(checks: SchemaAST.Checks | undefined): void {
|
|
162
|
+
checks?.forEach((check) => {
|
|
163
|
+
check.annotations?.representation?.schemas?.forEach((schema) => visit(SchemaAST.toType(schema)))
|
|
164
|
+
if (check._tag === "FilterGroup") visitChecks(check.checks)
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function recur(
|
|
169
|
+
ast: SchemaAST.AST,
|
|
170
|
+
ownedReference?: string
|
|
171
|
+
): SchemaRepresentation.Representation {
|
|
172
|
+
const found = referenceMap.get(ast)
|
|
173
|
+
if (found !== undefined && found !== ownedReference) {
|
|
174
|
+
return { _tag: "Reference", $ref: found }
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const projected = SchemaAST.getLastEncoding(ast)
|
|
178
|
+
if (projected !== ast) {
|
|
179
|
+
return recur(projected, ownedReference)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const referenceIdentifier = ownedReference === undefined ? resolveReferenceIdentifier(ast) : undefined
|
|
183
|
+
if (referenceIdentifier !== undefined) {
|
|
184
|
+
const reference = getReference(referenceIdentifier, ast)
|
|
185
|
+
referenceMap.set(ast, reference)
|
|
186
|
+
if (!Object.hasOwn(references, reference) && !externalReferences.has(reference)) {
|
|
187
|
+
InternalRecord.assignProperty(references, reference, on(ast))
|
|
188
|
+
}
|
|
189
|
+
return { _tag: "Reference", $ref: reference }
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (ownedReference === undefined && shared.has(ast)) {
|
|
193
|
+
const reference = generateReference(`${ast._tag}_`, ast)
|
|
194
|
+
referenceMap.set(ast, reference)
|
|
195
|
+
InternalRecord.assignProperty(references, reference, on(ast))
|
|
196
|
+
return { _tag: "Reference", $ref: reference }
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (visiting.has(ast)) {
|
|
200
|
+
const reference = generateReference(`${ast._tag}_`, ast)
|
|
201
|
+
referenceMap.set(ast, reference)
|
|
202
|
+
return { _tag: "Reference", $ref: reference }
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
visiting.add(ast)
|
|
206
|
+
const representation = on(ast)
|
|
207
|
+
visiting.delete(ast)
|
|
208
|
+
|
|
209
|
+
const reference = referenceMap.get(ast)
|
|
210
|
+
if (reference !== undefined && reference !== ownedReference) {
|
|
211
|
+
InternalRecord.assignProperty(references, reference, representation)
|
|
212
|
+
return { _tag: "Reference", $ref: reference }
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return representation
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function getReference(referenceIdentifier: ReferenceIdentifier, ast: SchemaAST.AST): string {
|
|
219
|
+
if (!referenceIdentifier.isFallback) {
|
|
220
|
+
return referenceIdentifier.identifier
|
|
221
|
+
}
|
|
222
|
+
for (const [owner, reference] of fallbackReferences) {
|
|
223
|
+
if (hasSameReferenceOwner(owner, ast)) return reference
|
|
224
|
+
}
|
|
225
|
+
const reference = generateReference(referenceIdentifier.identifier, ast)
|
|
226
|
+
fallbackReferences.push([ast, reference])
|
|
227
|
+
return reference
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function on(ast: SchemaAST.AST): SchemaRepresentation.Representation {
|
|
231
|
+
const checks = fromChecks(ast.checks)
|
|
232
|
+
switch (ast._tag) {
|
|
233
|
+
case "Declaration":
|
|
234
|
+
return {
|
|
235
|
+
_tag: "Declaration",
|
|
236
|
+
typeParameters: ast.typeParameters.map((ast) => recur(ast)),
|
|
237
|
+
checks,
|
|
238
|
+
...fromDeclarationAnnotations(ast.annotations)
|
|
239
|
+
}
|
|
240
|
+
case "Null":
|
|
241
|
+
case "Undefined":
|
|
242
|
+
case "Void":
|
|
243
|
+
case "Never":
|
|
244
|
+
case "Unknown":
|
|
245
|
+
case "Any":
|
|
246
|
+
case "String":
|
|
247
|
+
case "Boolean":
|
|
248
|
+
case "Number":
|
|
249
|
+
case "BigInt":
|
|
250
|
+
case "Symbol":
|
|
251
|
+
case "ObjectKeyword":
|
|
252
|
+
return {
|
|
253
|
+
_tag: ast._tag,
|
|
254
|
+
checks,
|
|
255
|
+
...annotationsField(ast.annotations)
|
|
256
|
+
}
|
|
257
|
+
case "Literal":
|
|
258
|
+
return {
|
|
259
|
+
_tag: "Literal",
|
|
260
|
+
literal: ast.literal,
|
|
261
|
+
checks,
|
|
262
|
+
...annotationsField(ast.annotations)
|
|
263
|
+
}
|
|
264
|
+
case "UniqueSymbol":
|
|
265
|
+
return {
|
|
266
|
+
_tag: "UniqueSymbol",
|
|
267
|
+
symbol: ast.symbol,
|
|
268
|
+
checks,
|
|
269
|
+
...annotationsField(ast.annotations)
|
|
270
|
+
}
|
|
271
|
+
case "Enum":
|
|
272
|
+
return {
|
|
273
|
+
_tag: "Enum",
|
|
274
|
+
enums: ast.enums,
|
|
275
|
+
checks,
|
|
276
|
+
...annotationsField(ast.annotations)
|
|
277
|
+
}
|
|
278
|
+
case "TemplateLiteral":
|
|
279
|
+
return {
|
|
280
|
+
_tag: "TemplateLiteral",
|
|
281
|
+
parts: ast.parts.map((ast) => recur(ast)),
|
|
282
|
+
checks,
|
|
283
|
+
...annotationsField(ast.annotations)
|
|
284
|
+
}
|
|
285
|
+
case "Arrays":
|
|
286
|
+
return {
|
|
287
|
+
_tag: "Arrays",
|
|
288
|
+
elements: ast.elements.map((element) => {
|
|
289
|
+
const projected = SchemaAST.getLastEncoding(element)
|
|
290
|
+
const annotations = projected.context?.annotations
|
|
291
|
+
return {
|
|
292
|
+
isOptional: SchemaAST.isOptional(projected),
|
|
293
|
+
type: recur(element),
|
|
294
|
+
...annotationsField(annotations)
|
|
295
|
+
}
|
|
296
|
+
}),
|
|
297
|
+
rest: ast.rest.map((ast) => recur(ast)),
|
|
298
|
+
checks,
|
|
299
|
+
...annotationsField(ast.annotations)
|
|
300
|
+
}
|
|
301
|
+
case "Objects":
|
|
302
|
+
return {
|
|
303
|
+
_tag: "Objects",
|
|
304
|
+
propertySignatures: ast.propertySignatures.map((property) => {
|
|
305
|
+
const projected = SchemaAST.getLastEncoding(property.type)
|
|
306
|
+
const annotations = projected.context?.annotations
|
|
307
|
+
return {
|
|
308
|
+
name: property.name,
|
|
309
|
+
type: recur(property.type),
|
|
310
|
+
isOptional: SchemaAST.isOptional(projected),
|
|
311
|
+
isMutable: SchemaAST.isMutable(projected),
|
|
312
|
+
...annotationsField(annotations)
|
|
313
|
+
}
|
|
314
|
+
}),
|
|
315
|
+
indexSignatures: ast.indexSignatures.map((index) => ({
|
|
316
|
+
parameter: recur(index.parameter),
|
|
317
|
+
type: recur(index.type)
|
|
318
|
+
})),
|
|
319
|
+
checks,
|
|
320
|
+
...annotationsField(ast.annotations)
|
|
321
|
+
}
|
|
322
|
+
case "Union":
|
|
323
|
+
return {
|
|
324
|
+
_tag: "Union",
|
|
325
|
+
types: ast.types.map((ast) => recur(ast)),
|
|
326
|
+
mode: ast.mode,
|
|
327
|
+
checks,
|
|
328
|
+
...annotationsField(ast.annotations)
|
|
329
|
+
}
|
|
330
|
+
case "Suspend":
|
|
331
|
+
return {
|
|
332
|
+
_tag: "Suspend",
|
|
333
|
+
checks: [],
|
|
334
|
+
thunk: recur(ast.thunk()),
|
|
335
|
+
...annotationsField(ast.annotations)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function fromChecks(
|
|
341
|
+
checks: readonly [SchemaAST.Check<any>, ...Array<SchemaAST.Check<any>>] | undefined
|
|
342
|
+
): Array<SchemaRepresentation.Check> {
|
|
343
|
+
return checks?.map(fromCheck) ?? []
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function fromCheck(
|
|
347
|
+
check: SchemaAST.Check<any>
|
|
348
|
+
): SchemaRepresentation.Check {
|
|
349
|
+
switch (check._tag) {
|
|
350
|
+
case "Filter":
|
|
351
|
+
return {
|
|
352
|
+
_tag: "Filter",
|
|
353
|
+
aborted: check.aborted,
|
|
354
|
+
...fromCheckAnnotations(check.annotations)
|
|
355
|
+
}
|
|
356
|
+
case "FilterGroup":
|
|
357
|
+
return {
|
|
358
|
+
_tag: "FilterGroup",
|
|
359
|
+
checks: Arr.map(check.checks, fromCheck),
|
|
360
|
+
...fromCheckAnnotations(check.annotations)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function fromDeclarationAnnotations<
|
|
366
|
+
A extends Schema.Annotations.Annotations & {
|
|
367
|
+
readonly representation?: SchemaRepresentation.RepresentationAnnotation | undefined
|
|
368
|
+
}
|
|
369
|
+
>(annotations: A | undefined): {
|
|
370
|
+
readonly representation?: SchemaRepresentation.RepresentationAnnotation | undefined
|
|
371
|
+
readonly annotations?: Omit<A, "representation"> | undefined
|
|
372
|
+
} | undefined {
|
|
373
|
+
if (annotations === undefined) return undefined
|
|
374
|
+
const { representation, ...ordinary } = annotations
|
|
375
|
+
return {
|
|
376
|
+
...(representation === undefined ? undefined : { representation }),
|
|
377
|
+
...(Object.keys(ordinary).length === 0 ? undefined : { annotations: ordinary })
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function fromCheckAnnotations<
|
|
382
|
+
A extends Schema.Annotations.Annotations & {
|
|
383
|
+
readonly representation?: SchemaRepresentation.CheckRepresentationAnnotation<SchemaAST.AST> | undefined
|
|
384
|
+
}
|
|
385
|
+
>(annotations: A | undefined): {
|
|
386
|
+
readonly representation?: CheckRepresentationAnnotation | undefined
|
|
387
|
+
readonly annotations?: Omit<A, "representation"> | undefined
|
|
388
|
+
} | undefined {
|
|
389
|
+
if (annotations === undefined) return undefined
|
|
390
|
+
const { representation, ...ordinary } = annotations
|
|
391
|
+
const projected = representation === undefined
|
|
392
|
+
? undefined
|
|
393
|
+
: representation.schemas === undefined
|
|
394
|
+
? representation as CheckRepresentationAnnotation
|
|
395
|
+
: { ...representation, schemas: representation.schemas.map((schema) => recur(SchemaAST.toType(schema))) }
|
|
396
|
+
return {
|
|
397
|
+
...(projected === undefined ? undefined : { representation: projected }),
|
|
398
|
+
...(Object.keys(ordinary).length === 0 ? undefined : { annotations: ordinary })
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { ErrorWithStackTraceLimit } from "./tracer.ts"
|
|
18
18
|
|
|
19
|
-
const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor
|
|
20
|
-
const ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty
|
|
21
|
-
const ObjectIsExtensible = Object.isExtensible
|
|
22
|
-
|
|
23
19
|
/**
|
|
24
20
|
* Check if `Error.stackTraceLimit` is writable.
|
|
25
21
|
* Returns `false` if the property is frozen, non-writable, or `Error` is non-extensible.
|
|
@@ -27,12 +23,12 @@ const ObjectIsExtensible = Object.isExtensible
|
|
|
27
23
|
* @internal
|
|
28
24
|
*/
|
|
29
25
|
export const isStackTraceLimitWritable = (): boolean => {
|
|
30
|
-
const desc =
|
|
26
|
+
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit")
|
|
31
27
|
if (desc === undefined) {
|
|
32
|
-
return
|
|
28
|
+
return Object.isExtensible(Error)
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
return
|
|
31
|
+
return Object.hasOwn(desc, "writable")
|
|
36
32
|
? desc.writable === true
|
|
37
33
|
: desc.set !== undefined
|
|
38
34
|
}
|
package/src/testing/TestClock.ts
CHANGED
|
@@ -225,7 +225,7 @@ const SleepOrder = Order.flip(Order.Struct({
|
|
|
225
225
|
export const make = Effect.fnUntraced(function*(
|
|
226
226
|
options?: TestClock.Options
|
|
227
227
|
) {
|
|
228
|
-
const config =
|
|
228
|
+
const config = { ...defaultOptions, ...options }
|
|
229
229
|
let sequence = 0
|
|
230
230
|
const sleeps: Array<{
|
|
231
231
|
readonly sequence: number
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import * as Duration from "../../Duration.ts"
|
|
15
15
|
import * as Effect from "../../Effect.ts"
|
|
16
|
+
import * as InternalRecord from "../../internal/record.ts"
|
|
16
17
|
import * as Option from "../../Option.ts"
|
|
17
18
|
import * as Predicate from "../../Predicate.ts"
|
|
18
19
|
import { redact } from "../../Redactable.ts"
|
|
@@ -34,7 +35,7 @@ const redactHeaders = (headers: Record<string, string>): Record<string, string>
|
|
|
34
35
|
const result: Record<string, string> = {}
|
|
35
36
|
for (const key in redacted) {
|
|
36
37
|
const value = redacted[key]
|
|
37
|
-
result
|
|
38
|
+
InternalRecord.assignProperty(result, key, Redacted.isRedacted(value) ? value.toString() : value)
|
|
38
39
|
}
|
|
39
40
|
return result
|
|
40
41
|
}
|
|
@@ -306,9 +307,9 @@ export interface UnknownErrorMetadata extends ProviderMetadata {}
|
|
|
306
307
|
* @since 4.0.0
|
|
307
308
|
*/
|
|
308
309
|
export const UsageInfo = Schema.Struct({
|
|
309
|
-
promptTokens: Schema.optional(Schema.
|
|
310
|
-
completionTokens: Schema.optional(Schema.
|
|
311
|
-
totalTokens: Schema.optional(Schema.
|
|
310
|
+
promptTokens: Schema.optional(Schema.Int),
|
|
311
|
+
completionTokens: Schema.optional(Schema.Int),
|
|
312
|
+
totalTokens: Schema.optional(Schema.Int)
|
|
312
313
|
}).annotate({ identifier: "UsageInfo" })
|
|
313
314
|
|
|
314
315
|
/**
|