effect 4.0.0-beta.84 → 4.0.0-beta.86
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/ChannelSchema.d.ts +8 -8
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/Config.d.ts +2 -2
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +10 -3
- package/dist/Config.js.map +1 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +4 -3
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +4 -0
- package/dist/Cron.js.map +1 -1
- package/dist/Layer.js +4 -3
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +4 -3
- package/dist/LayerMap.js.map +1 -1
- package/dist/Random.d.ts +31 -0
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +32 -0
- package/dist/Random.js.map +1 -1
- package/dist/Schema.d.ts +793 -399
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +121 -75
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +8 -7
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +207 -157
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.d.ts +24 -24
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +43 -39
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +300 -300
- package/dist/internal/effect.js +16 -17
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/matcher.js +0 -2
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/schema/arbitrary.js +17 -1
- package/dist/internal/schema/arbitrary.js.map +1 -1
- package/dist/internal/schema/representation.js +1 -5
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/stackTraceLimit.d.ts +2 -0
- package/dist/internal/stackTraceLimit.d.ts.map +1 -0
- package/dist/internal/stackTraceLimit.js +40 -0
- package/dist/internal/stackTraceLimit.js.map +1 -0
- package/dist/internal/tracer.d.ts.map +1 -1
- package/dist/internal/tracer.js +4 -3
- package/dist/internal/tracer.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +9 -9
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +3 -2
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +2 -2
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js.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/LanguageModel.d.ts +4 -4
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +13 -6
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +2 -2
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +2 -2
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +26 -26
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +4 -5
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +8 -7
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +8 -7
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +1806 -168
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +0 -70
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +3 -4
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.d.ts.map +1 -1
- package/dist/unstable/cli/internal/ansi.js +0 -22
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/config.d.ts +48 -0
- package/dist/unstable/cli/internal/config.d.ts.map +1 -1
- package/dist/unstable/cli/internal/config.js +0 -6
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -3
- package/dist/unstable/cluster/Reply.d.ts +2 -2
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts +6 -6
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +8 -8
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +1 -1
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +22 -22
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
- package/dist/unstable/http/HttpBody.d.ts +1 -1
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +12 -3
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +32 -32
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +4 -3
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +13 -6
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +0 -13
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/internal/otlpProtobuf.js +0 -68
- package/dist/unstable/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +0 -28
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +2 -2
- 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 +6 -6
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +3 -3
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +1 -1
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +5 -5
- package/dist/unstable/persistence/Persistence.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 +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +3 -4
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +25 -4
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +7 -0
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +20 -0
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +2 -2
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +4 -3
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +10 -3
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +3 -3
- package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
- package/dist/unstable/schema/Model.d.ts +2 -2
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +16 -2
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +1 -0
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts +4 -4
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +5 -5
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +1 -0
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +3 -0
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +2 -2
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +18 -18
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +3 -3
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +3 -3
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ChannelSchema.ts +9 -9
- package/src/Config.ts +12 -5
- package/src/Context.ts +4 -5
- package/src/Cron.ts +4 -0
- package/src/Layer.ts +4 -4
- package/src/LayerMap.ts +4 -3
- package/src/Random.ts +42 -0
- package/src/Schema.ts +1038 -710
- package/src/SchemaAST.ts +239 -169
- package/src/SchemaParser.ts +85 -77
- package/src/internal/effect.ts +17 -33
- package/src/internal/matcher.ts +0 -5
- package/src/internal/schema/arbitrary.ts +24 -3
- package/src/internal/schema/representation.ts +1 -5
- package/src/internal/schema/schema.ts +1 -1
- package/src/internal/stackTraceLimit.ts +63 -0
- package/src/internal/tracer.ts +4 -3
- package/src/testing/TestSchema.ts +14 -13
- package/src/unstable/ai/AnthropicStructuredOutput.ts +2 -2
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/ai/LanguageModel.ts +7 -7
- package/src/unstable/ai/McpSchema.ts +16 -14
- package/src/unstable/ai/McpServer.ts +7 -7
- package/src/unstable/ai/OpenAiStructuredOutput.ts +2 -2
- package/src/unstable/ai/Response.ts +9 -5
- package/src/unstable/ai/Tool.ts +53 -50
- package/src/unstable/cli/Argument.ts +9 -8
- package/src/unstable/cli/Flag.ts +9 -8
- package/src/unstable/cli/Param.ts +6 -146
- package/src/unstable/cli/Primitive.ts +5 -6
- package/src/unstable/cli/internal/ansi.ts +0 -33
- package/src/unstable/cli/internal/config.ts +0 -8
- package/src/unstable/cli/internal/parser.ts +2 -2
- package/src/unstable/cluster/MessageStorage.ts +1 -1
- package/src/unstable/cluster/Reply.ts +6 -2
- package/src/unstable/devtools/DevToolsSchema.ts +1 -1
- package/src/unstable/encoding/Msgpack.ts +9 -7
- package/src/unstable/encoding/Ndjson.ts +10 -10
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/eventlog/Event.ts +3 -3
- package/src/unstable/http/HttpBody.ts +1 -1
- package/src/unstable/http/HttpClientRequest.ts +1 -1
- package/src/unstable/http/HttpIncomingMessage.ts +1 -1
- package/src/unstable/http/HttpMiddleware.ts +12 -3
- package/src/unstable/httpapi/HttpApi.ts +1 -1
- package/src/unstable/httpapi/HttpApiBuilder.ts +9 -5
- package/src/unstable/httpapi/HttpApiClient.ts +10 -10
- package/src/unstable/httpapi/HttpApiEndpoint.ts +45 -33
- package/src/unstable/httpapi/HttpApiMiddleware.ts +6 -5
- package/src/unstable/httpapi/HttpApiSchema.ts +16 -43
- package/src/unstable/httpapi/OpenApi.ts +5 -5
- package/src/unstable/observability/internal/otlpProtobuf.ts +0 -75
- package/src/unstable/observability/internal/protobuf.ts +0 -42
- package/src/unstable/persistence/KeyValueStore.ts +2 -2
- package/src/unstable/persistence/Persistable.ts +7 -7
- package/src/unstable/persistence/PersistedQueue.ts +4 -4
- package/src/unstable/persistence/Persistence.ts +5 -5
- package/src/unstable/reactivity/AsyncResult.ts +4 -4
- package/src/unstable/reactivity/Atom.ts +1 -1
- package/src/unstable/reactivity/AtomHttpApi.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +7 -8
- package/src/unstable/rpc/RpcClient.ts +26 -4
- package/src/unstable/rpc/RpcMessage.ts +19 -0
- package/src/unstable/rpc/RpcMiddleware.ts +6 -5
- package/src/unstable/rpc/RpcSchema.ts +12 -9
- package/src/unstable/rpc/RpcWorker.ts +3 -3
- package/src/unstable/schema/Model.ts +2 -2
- package/src/unstable/schema/VariantSchema.ts +19 -17
- package/src/unstable/sql/SqlConnection.ts +5 -0
- package/src/unstable/sql/SqlModel.ts +2 -2
- package/src/unstable/sql/SqlResolver.ts +6 -6
- package/src/unstable/sql/SqlSchema.ts +5 -5
- package/src/unstable/sql/Statement.ts +11 -0
- package/src/unstable/workflow/Activity.ts +6 -6
- package/src/unstable/workflow/DurableDeferred.ts +33 -33
- package/src/unstable/workflow/Workflow.ts +5 -5
- package/src/unstable/workflow/WorkflowEngine.ts +10 -10
- package/dist/internal/concurrency.d.ts +0 -2
- package/dist/internal/concurrency.d.ts.map +0 -1
- package/dist/internal/concurrency.js +0 -29
- package/dist/internal/concurrency.js.map +0 -1
- package/src/internal/concurrency.ts +0 -52
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import * as assert from "node:assert"
|
|
13
13
|
import type * as Context from "../Context.ts"
|
|
14
14
|
import * as Effect from "../Effect.ts"
|
|
15
|
+
import { pipe } from "../Function.ts"
|
|
15
16
|
import * as Record from "../Record.ts"
|
|
16
17
|
import * as Result from "../Result.ts"
|
|
17
18
|
import * as Schema from "../Schema.ts"
|
|
@@ -48,7 +49,7 @@ import * as FastCheck from "../testing/FastCheck.ts"
|
|
|
48
49
|
* @category testing
|
|
49
50
|
* @since 4.0.0
|
|
50
51
|
*/
|
|
51
|
-
export class Asserts<S extends Schema.
|
|
52
|
+
export class Asserts<S extends Schema.Constraint> {
|
|
52
53
|
/**
|
|
53
54
|
* Static helpers for comparing schema AST structures.
|
|
54
55
|
*
|
|
@@ -313,7 +314,7 @@ export class Asserts<S extends Schema.Top> {
|
|
|
313
314
|
* @category testing
|
|
314
315
|
* @since 4.0.0
|
|
315
316
|
*/
|
|
316
|
-
export class Decoding<S extends Schema.
|
|
317
|
+
export class Decoding<S extends Schema.Constraint> {
|
|
317
318
|
readonly schema: S
|
|
318
319
|
readonly decodeUnknownEffect: (
|
|
319
320
|
input: unknown,
|
|
@@ -350,16 +351,16 @@ export class Decoding<S extends Schema.Top> {
|
|
|
350
351
|
*
|
|
351
352
|
* @see {@link fail} for asserting decoding failures
|
|
352
353
|
*/
|
|
353
|
-
async succeed<S extends Schema.
|
|
354
|
+
async succeed<S extends Schema.ConstraintDecoder<unknown, never>>(
|
|
354
355
|
this: Decoding<S>,
|
|
355
356
|
input: unknown
|
|
356
357
|
): Promise<void>
|
|
357
|
-
async succeed<S extends Schema.
|
|
358
|
+
async succeed<S extends Schema.ConstraintDecoder<unknown, never>>(
|
|
358
359
|
this: Decoding<S>,
|
|
359
360
|
input: unknown,
|
|
360
361
|
expected: S["Type"]
|
|
361
362
|
): Promise<void>
|
|
362
|
-
async succeed<S extends Schema.
|
|
363
|
+
async succeed<S extends Schema.ConstraintDecoder<unknown, never>>(
|
|
363
364
|
this: Decoding<S>,
|
|
364
365
|
input: unknown,
|
|
365
366
|
expected?: S["Type"]
|
|
@@ -393,7 +394,7 @@ export class Decoding<S extends Schema.Top> {
|
|
|
393
394
|
*
|
|
394
395
|
* @see {@link succeed} for asserting successful decoding
|
|
395
396
|
*/
|
|
396
|
-
async fail<S extends Schema.
|
|
397
|
+
async fail<S extends Schema.ConstraintDecoder<unknown, never>>(
|
|
397
398
|
this: Decoding<S>,
|
|
398
399
|
input: unknown,
|
|
399
400
|
message: string
|
|
@@ -420,7 +421,7 @@ export class Decoding<S extends Schema.Top> {
|
|
|
420
421
|
implementation: Service
|
|
421
422
|
): Decoding<Schema.middlewareDecoding<S, Exclude<S["DecodingServices"], Id>>> {
|
|
422
423
|
return new Decoding(
|
|
423
|
-
this.schema
|
|
424
|
+
pipe(this.schema, Schema.middlewareDecoding(Effect.provideService(service, implementation))),
|
|
424
425
|
this.options
|
|
425
426
|
)
|
|
426
427
|
}
|
|
@@ -453,7 +454,7 @@ export class Decoding<S extends Schema.Top> {
|
|
|
453
454
|
* @category testing
|
|
454
455
|
* @since 4.0.0
|
|
455
456
|
*/
|
|
456
|
-
export class Encoding<S extends Schema.
|
|
457
|
+
export class Encoding<S extends Schema.Constraint> {
|
|
457
458
|
readonly schema: S
|
|
458
459
|
readonly encodeUnknownEffect: (
|
|
459
460
|
input: unknown,
|
|
@@ -490,16 +491,16 @@ export class Encoding<S extends Schema.Top> {
|
|
|
490
491
|
*
|
|
491
492
|
* @see {@link fail} for asserting encoding failures
|
|
492
493
|
*/
|
|
493
|
-
async succeed<S extends Schema.
|
|
494
|
+
async succeed<S extends Schema.ConstraintEncoder<unknown, never>>(
|
|
494
495
|
this: Encoding<S>,
|
|
495
496
|
input: unknown
|
|
496
497
|
): Promise<void>
|
|
497
|
-
async succeed<S extends Schema.
|
|
498
|
+
async succeed<S extends Schema.ConstraintEncoder<unknown, never>>(
|
|
498
499
|
this: Encoding<S>,
|
|
499
500
|
input: unknown,
|
|
500
501
|
expected: S["Encoded"]
|
|
501
502
|
): Promise<void>
|
|
502
|
-
async succeed<S extends Schema.
|
|
503
|
+
async succeed<S extends Schema.ConstraintEncoder<unknown, never>>(
|
|
503
504
|
this: Encoding<S>,
|
|
504
505
|
input: unknown,
|
|
505
506
|
expected?: S["Encoded"]
|
|
@@ -533,7 +534,7 @@ export class Encoding<S extends Schema.Top> {
|
|
|
533
534
|
*
|
|
534
535
|
* @see {@link succeed} for asserting successful encoding
|
|
535
536
|
*/
|
|
536
|
-
async fail<S extends Schema.
|
|
537
|
+
async fail<S extends Schema.ConstraintEncoder<unknown, never>>(
|
|
537
538
|
this: Encoding<S>,
|
|
538
539
|
input: unknown,
|
|
539
540
|
message: string
|
|
@@ -560,7 +561,7 @@ export class Encoding<S extends Schema.Top> {
|
|
|
560
561
|
implementation: Service
|
|
561
562
|
): Encoding<Schema.middlewareEncoding<S, Exclude<S["EncodingServices"], Id>>> {
|
|
562
563
|
return new Encoding(
|
|
563
|
-
this.schema
|
|
564
|
+
pipe(this.schema, Schema.middlewareEncoding(Effect.provideService(service, implementation))),
|
|
564
565
|
this.options
|
|
565
566
|
)
|
|
566
567
|
}
|
|
@@ -54,9 +54,9 @@ import * as Tool from "./Tool.ts"
|
|
|
54
54
|
* @since 4.0.0
|
|
55
55
|
*/
|
|
56
56
|
export function toCodecAnthropic<T, E, RD, RE>(
|
|
57
|
-
schema: Schema.
|
|
57
|
+
schema: Schema.ConstraintCodec<T, E, RD, RE>
|
|
58
58
|
): {
|
|
59
|
-
readonly codec: Schema.
|
|
59
|
+
readonly codec: Schema.ConstraintCodec<T, unknown, RD, RE>
|
|
60
60
|
readonly jsonSchema: JsonSchema.JsonSchema
|
|
61
61
|
} {
|
|
62
62
|
const to = schema.ast
|
package/src/unstable/ai/Chat.ts
CHANGED
|
@@ -336,7 +336,7 @@ export interface Service {
|
|
|
336
336
|
*/
|
|
337
337
|
readonly generateObject: <
|
|
338
338
|
ObjectEncoded extends Record<string, any>,
|
|
339
|
-
ObjectSchema extends Schema.
|
|
339
|
+
ObjectSchema extends Schema.Codec<unknown, ObjectEncoded, unknown, unknown>,
|
|
340
340
|
Options extends NoExcessProperties<LanguageModel.GenerateObjectOptions<any, ObjectSchema>, Options>
|
|
341
341
|
>(
|
|
342
342
|
options: Options & LanguageModel.GenerateObjectOptions<LanguageModel.ExtractTools<Options>, ObjectSchema>
|
|
@@ -124,7 +124,7 @@ export interface Service {
|
|
|
124
124
|
*/
|
|
125
125
|
readonly generateObject: <
|
|
126
126
|
ObjectEncoded extends Record<string, any>,
|
|
127
|
-
StructuredOutputSchema extends Schema.
|
|
127
|
+
StructuredOutputSchema extends Schema.Codec<unknown, ObjectEncoded, unknown, unknown>,
|
|
128
128
|
Options extends NoExcessProperties<
|
|
129
129
|
GenerateObjectOptions<any, StructuredOutputSchema>,
|
|
130
130
|
Options
|
|
@@ -191,8 +191,8 @@ export interface Service {
|
|
|
191
191
|
* @category models
|
|
192
192
|
* @since 4.0.0
|
|
193
193
|
*/
|
|
194
|
-
export type CodecTransformer = <T, E, RD, RE>(schema: Schema.
|
|
195
|
-
readonly codec: Schema.
|
|
194
|
+
export type CodecTransformer = <T, E, RD, RE>(schema: Schema.ConstraintCodec<T, E, RD, RE>) => {
|
|
195
|
+
readonly codec: Schema.ConstraintCodec<T, unknown, RD, RE>
|
|
196
196
|
readonly jsonSchema: JsonSchema.JsonSchema
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -835,7 +835,7 @@ export const make: (params: {
|
|
|
835
835
|
|
|
836
836
|
const generateObject = <
|
|
837
837
|
ObjectEncoded extends Record<string, any>,
|
|
838
|
-
StructuredOutputSchema extends Schema.
|
|
838
|
+
StructuredOutputSchema extends Schema.Codec<unknown, ObjectEncoded, unknown, unknown>,
|
|
839
839
|
Options extends NoExcessProperties<
|
|
840
840
|
GenerateObjectOptions<any, StructuredOutputSchema>,
|
|
841
841
|
Options
|
|
@@ -1691,7 +1691,7 @@ export const generateText: {
|
|
|
1691
1691
|
*/
|
|
1692
1692
|
export const generateObject = <
|
|
1693
1693
|
ObjectEncoded extends Record<string, any>,
|
|
1694
|
-
StructuredOutputSchema extends Schema.
|
|
1694
|
+
StructuredOutputSchema extends Schema.Codec<unknown, ObjectEncoded, unknown, unknown>,
|
|
1695
1695
|
Options extends NoExcessProperties<
|
|
1696
1696
|
GenerateObjectOptions<any, StructuredOutputSchema>,
|
|
1697
1697
|
Options
|
|
@@ -2161,7 +2161,7 @@ const resolveToolkit = <Tools extends Record<string, Tool.Any>, E, R>(
|
|
|
2161
2161
|
: Effect.succeed(toolkit as unknown as Toolkit.WithHandler<Tools>)) as any
|
|
2162
2162
|
|
|
2163
2163
|
/** @internal */
|
|
2164
|
-
export const getObjectName = <StructuredOutputSchema extends Schema.
|
|
2164
|
+
export const getObjectName = <StructuredOutputSchema extends Schema.Constraint>(
|
|
2165
2165
|
objectName: string | undefined,
|
|
2166
2166
|
schema: StructuredOutputSchema
|
|
2167
2167
|
): string => {
|
|
@@ -2179,7 +2179,7 @@ export const getObjectName = <StructuredOutputSchema extends Schema.Top>(
|
|
|
2179
2179
|
}
|
|
2180
2180
|
|
|
2181
2181
|
const resolveStructuredOutput = Effect.fnUntraced(function*<
|
|
2182
|
-
StructuredOutputSchema extends Schema.
|
|
2182
|
+
StructuredOutputSchema extends Schema.Constraint
|
|
2183
2183
|
>(response: ReadonlyArray<Response.AllParts<any>>, schema: StructuredOutputSchema) {
|
|
2184
2184
|
const texts: Array<string> = []
|
|
2185
2185
|
for (const part of response) {
|
|
@@ -35,7 +35,7 @@ import * as RpcMiddleware from "../rpc/RpcMiddleware.ts"
|
|
|
35
35
|
* @category models
|
|
36
36
|
* @since 4.0.0
|
|
37
37
|
*/
|
|
38
|
-
export interface optionalWithDefault<S extends Schema.
|
|
38
|
+
export interface optionalWithDefault<S extends Schema.Constraint & Schema.WithoutConstructorDefault>
|
|
39
39
|
extends Schema.withConstructorDefault<Schema.decodeTo<Schema.toType<Schema.optionalKey<S>>, Schema.optionalKey<S>>>
|
|
40
40
|
{}
|
|
41
41
|
|
|
@@ -51,7 +51,7 @@ export interface optionalWithDefault<S extends Schema.Top & Schema.WithoutConstr
|
|
|
51
51
|
* @category schemas
|
|
52
52
|
* @since 4.0.0
|
|
53
53
|
*/
|
|
54
|
-
export const optionalWithDefault = <S extends Schema.
|
|
54
|
+
export const optionalWithDefault = <S extends Schema.Constraint & Schema.WithoutConstructorDefault>(
|
|
55
55
|
schema: S,
|
|
56
56
|
defaultValue: () => Schema.optionalKey<S>["Type"]
|
|
57
57
|
): optionalWithDefault<S> => {
|
|
@@ -78,7 +78,9 @@ export const optionalWithDefault = <S extends Schema.Top & Schema.WithoutConstru
|
|
|
78
78
|
* @category schemas
|
|
79
79
|
* @since 4.0.0
|
|
80
80
|
*/
|
|
81
|
-
export const optional = <S extends Schema.
|
|
81
|
+
export const optional = <S extends Schema.Constraint>(
|
|
82
|
+
schema: S
|
|
83
|
+
): Schema.decodeTo<Schema.optional<S>, Schema.optionalKey<S>> =>
|
|
82
84
|
Schema.optionalKey(schema).pipe(
|
|
83
85
|
Schema.decodeTo(Schema.optional(schema), {
|
|
84
86
|
decode: SchemaGetter.passthrough() as any,
|
|
@@ -2460,7 +2462,7 @@ const ParamSchemaTypeId = "~effect/ai/McpSchema/ParamSchema"
|
|
|
2460
2462
|
* @category parameters
|
|
2461
2463
|
* @since 4.0.0
|
|
2462
2464
|
*/
|
|
2463
|
-
export function isParam(schema: Schema.
|
|
2465
|
+
export function isParam(schema: Schema.Constraint): schema is Param<string, Schema.Top> {
|
|
2464
2466
|
return Predicate.hasProperty(schema, ParamSchemaTypeId)
|
|
2465
2467
|
}
|
|
2466
2468
|
|
|
@@ -2475,18 +2477,11 @@ export function isParam(schema: Schema.Top): schema is Param<string, Schema.Top>
|
|
|
2475
2477
|
* @category parameters
|
|
2476
2478
|
* @since 4.0.0
|
|
2477
2479
|
*/
|
|
2478
|
-
export interface Param<Name extends string, S extends Schema.
|
|
2479
|
-
Schema.
|
|
2480
|
-
S["Type"],
|
|
2481
|
-
S["Encoded"],
|
|
2482
|
-
S["DecodingServices"],
|
|
2483
|
-
S["EncodingServices"],
|
|
2480
|
+
export interface Param<Name extends string, S extends Schema.Constraint> extends
|
|
2481
|
+
Schema.BottomLazy<
|
|
2484
2482
|
S["ast"],
|
|
2485
2483
|
Param<Name, S>,
|
|
2486
|
-
S["~type.make.in"],
|
|
2487
|
-
S["Iso"],
|
|
2488
2484
|
S["~type.parameters"],
|
|
2489
|
-
S["~type.make"],
|
|
2490
2485
|
S["~type.mutability"],
|
|
2491
2486
|
S["~type.optionality"],
|
|
2492
2487
|
S["~type.constructor.default"],
|
|
@@ -2494,7 +2489,14 @@ export interface Param<Name extends string, S extends Schema.Top> extends
|
|
|
2494
2489
|
S["~encoded.optionality"]
|
|
2495
2490
|
>
|
|
2496
2491
|
{
|
|
2492
|
+
readonly "Type": S["Type"]
|
|
2493
|
+
readonly "Encoded": S["Encoded"]
|
|
2494
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
2495
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
2497
2496
|
readonly "Rebuild": Param<Name, S>
|
|
2497
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
2498
|
+
readonly "~type.make": S["~type.make"]
|
|
2499
|
+
readonly "Iso": S["Iso"]
|
|
2498
2500
|
readonly [ParamSchemaTypeId]: typeof ParamSchemaTypeId
|
|
2499
2501
|
readonly name: Name
|
|
2500
2502
|
readonly schema: S
|
|
@@ -2506,7 +2508,7 @@ export interface Param<Name extends string, S extends Schema.Top> extends
|
|
|
2506
2508
|
* @category parameters
|
|
2507
2509
|
* @since 4.0.0
|
|
2508
2510
|
*/
|
|
2509
|
-
export function param<const Name extends string, S extends Schema.
|
|
2511
|
+
export function param<const Name extends string, S extends Schema.Constraint>(
|
|
2510
2512
|
name: Name,
|
|
2511
2513
|
schema: S
|
|
2512
2514
|
): Param<Name, S> {
|
|
@@ -782,7 +782,7 @@ export type ValidateCompletions<Completions, Keys extends string> =
|
|
|
782
782
|
* @category models
|
|
783
783
|
* @since 4.0.0
|
|
784
784
|
*/
|
|
785
|
-
export type ResourceCompletions<Schemas extends ReadonlyArray<Schema.
|
|
785
|
+
export type ResourceCompletions<Schemas extends ReadonlyArray<Schema.Constraint>> = {
|
|
786
786
|
readonly [
|
|
787
787
|
K in Extract<keyof Schemas, `${number}`> as Schemas[K] extends Param<infer Id, infer _S> ? Id
|
|
788
788
|
: `param${K}`
|
|
@@ -848,7 +848,7 @@ export const registerResource: {
|
|
|
848
848
|
* @category resources
|
|
849
849
|
* @since 4.0.0
|
|
850
850
|
*/
|
|
851
|
-
<const Schemas extends ReadonlyArray<Schema.
|
|
851
|
+
<const Schemas extends ReadonlyArray<Schema.Constraint>>(segments: TemplateStringsArray, ...schemas: Schemas): <
|
|
852
852
|
E,
|
|
853
853
|
R,
|
|
854
854
|
const Completions extends Partial<ResourceCompletions<Schemas>> = {}
|
|
@@ -1035,7 +1035,7 @@ export const resource: {
|
|
|
1035
1035
|
* @category resources
|
|
1036
1036
|
* @since 4.0.0
|
|
1037
1037
|
*/
|
|
1038
|
-
<const Schemas extends ReadonlyArray<Schema.
|
|
1038
|
+
<const Schemas extends ReadonlyArray<Schema.Constraint>>(segments: TemplateStringsArray, ...schemas: Schemas): <
|
|
1039
1039
|
E,
|
|
1040
1040
|
R,
|
|
1041
1041
|
const Completions extends Partial<ResourceCompletions<Schemas>> = {}
|
|
@@ -1112,7 +1112,7 @@ export const registerPrompt = <
|
|
|
1112
1112
|
}
|
|
1113
1113
|
): Effect.Effect<void, never, Exclude<Schema.Struct.DecodingServices<Params> | R, McpServerClient> | McpServer> => {
|
|
1114
1114
|
const args = Arr.empty<typeof PromptArgument.Type>()
|
|
1115
|
-
const props: Record<string, Schema.
|
|
1115
|
+
const props: Record<string, Schema.Constraint> = options.parameters ?? {}
|
|
1116
1116
|
for (const [name, prop] of Object.entries(props)) {
|
|
1117
1117
|
args.push({
|
|
1118
1118
|
name,
|
|
@@ -1236,14 +1236,14 @@ export const prompt = <
|
|
|
1236
1236
|
* @category elicitation
|
|
1237
1237
|
* @since 4.0.0
|
|
1238
1238
|
*/
|
|
1239
|
-
export const elicit: <S extends Schema.
|
|
1239
|
+
export const elicit: <S extends Schema.ConstraintEncoder<Record<string, unknown>, unknown>>(options: {
|
|
1240
1240
|
readonly message: string
|
|
1241
1241
|
readonly schema: S
|
|
1242
1242
|
}) => Effect.Effect<
|
|
1243
1243
|
S["Type"],
|
|
1244
1244
|
ElicitationDeclined,
|
|
1245
1245
|
McpServerClient | S["DecodingServices"]
|
|
1246
|
-
> = Effect.fnUntraced(function*<S extends Schema.
|
|
1246
|
+
> = Effect.fnUntraced(function*<S extends Schema.ConstraintEncoder<Record<string, unknown>, unknown>>(options: {
|
|
1247
1247
|
readonly message: string
|
|
1248
1248
|
readonly schema: S
|
|
1249
1249
|
}) {
|
|
@@ -1297,7 +1297,7 @@ const makeUriMatcher = <A>() => {
|
|
|
1297
1297
|
return { add, find } as const
|
|
1298
1298
|
}
|
|
1299
1299
|
|
|
1300
|
-
const compileUriTemplate = (segments: TemplateStringsArray, ...schemas: ReadonlyArray<Schema.
|
|
1300
|
+
const compileUriTemplate = (segments: TemplateStringsArray, ...schemas: ReadonlyArray<Schema.Constraint>) => {
|
|
1301
1301
|
let routerPath = segments[0].replace(":", "::")
|
|
1302
1302
|
let uriPath = segments[0]
|
|
1303
1303
|
const params: Record<string, Schema.Top> = {}
|
|
@@ -51,9 +51,9 @@ import * as Tool from "./Tool.ts"
|
|
|
51
51
|
* @since 4.0.0
|
|
52
52
|
*/
|
|
53
53
|
export function toCodecOpenAI<T, E, RD, RE>(
|
|
54
|
-
schema: Schema.
|
|
54
|
+
schema: Schema.ConstraintCodec<T, E, RD, RE>
|
|
55
55
|
): {
|
|
56
|
-
codec: Schema.
|
|
56
|
+
codec: Schema.ConstraintCodec<T, unknown, RD, RE>
|
|
57
57
|
jsonSchema: JsonSchema.JsonSchema
|
|
58
58
|
} {
|
|
59
59
|
const to = schema.ast
|
|
@@ -1382,7 +1382,7 @@ export interface ToolCallPartMetadata extends ProviderMetadata {}
|
|
|
1382
1382
|
* @category schemas
|
|
1383
1383
|
* @since 4.0.0
|
|
1384
1384
|
*/
|
|
1385
|
-
export const ToolCallPart: <const Name extends string, Params extends Schema.
|
|
1385
|
+
export const ToolCallPart: <const Name extends string, Params extends Schema.Constraint>(
|
|
1386
1386
|
name: Name,
|
|
1387
1387
|
params: Params
|
|
1388
1388
|
) => Schema.Struct<
|
|
@@ -1397,7 +1397,7 @@ export const ToolCallPart: <const Name extends string, Params extends Schema.Top
|
|
|
1397
1397
|
Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>
|
|
1398
1398
|
>
|
|
1399
1399
|
}
|
|
1400
|
-
> = <const Name extends string, Params extends Schema.
|
|
1400
|
+
> = <const Name extends string, Params extends Schema.Constraint>(
|
|
1401
1401
|
name: Name,
|
|
1402
1402
|
params: Params
|
|
1403
1403
|
) =>
|
|
@@ -1595,7 +1595,11 @@ export interface ToolResultPartMetadata extends ProviderMetadata {}
|
|
|
1595
1595
|
* @category schemas
|
|
1596
1596
|
* @since 4.0.0
|
|
1597
1597
|
*/
|
|
1598
|
-
export const ToolResultPart: <
|
|
1598
|
+
export const ToolResultPart: <
|
|
1599
|
+
const Name extends string,
|
|
1600
|
+
Success extends Schema.Constraint,
|
|
1601
|
+
Failure extends Schema.Constraint
|
|
1602
|
+
>(
|
|
1599
1603
|
name: Name,
|
|
1600
1604
|
success: Success,
|
|
1601
1605
|
failure: Failure
|
|
@@ -1633,8 +1637,8 @@ export const ToolResultPart: <const Name extends string, Success extends Schema.
|
|
|
1633
1637
|
>
|
|
1634
1638
|
> = <
|
|
1635
1639
|
const Name extends string,
|
|
1636
|
-
Success extends Schema.
|
|
1637
|
-
Failure extends Schema.
|
|
1640
|
+
Success extends Schema.Constraint,
|
|
1641
|
+
Failure extends Schema.Constraint
|
|
1638
1642
|
>(
|
|
1639
1643
|
name: Name,
|
|
1640
1644
|
success: Success,
|
package/src/unstable/ai/Tool.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import * as Context from "../../Context.ts"
|
|
15
15
|
import type * as Effect from "../../Effect.ts"
|
|
16
16
|
import { constFalse, constTrue, identity } from "../../Function.ts"
|
|
17
|
+
import * as StackTraceLimit from "../../internal/stackTraceLimit.ts"
|
|
17
18
|
import type * as JsonSchema from "../../JsonSchema.ts"
|
|
18
19
|
import { pipeArguments } from "../../Pipeable.ts"
|
|
19
20
|
import * as Predicate from "../../Predicate.ts"
|
|
@@ -138,7 +139,7 @@ export interface NeedsApprovalContext {
|
|
|
138
139
|
* @category models
|
|
139
140
|
* @since 4.0.0
|
|
140
141
|
*/
|
|
141
|
-
export type NeedsApprovalFunction<Params extends Schema.
|
|
142
|
+
export type NeedsApprovalFunction<Params extends Schema.Constraint> = (
|
|
142
143
|
params: Params["Type"],
|
|
143
144
|
context: NeedsApprovalContext
|
|
144
145
|
) => boolean | Effect.Effect<boolean>
|
|
@@ -155,7 +156,7 @@ export type NeedsApprovalFunction<Params extends Schema.Top> = (
|
|
|
155
156
|
* @category models
|
|
156
157
|
* @since 4.0.0
|
|
157
158
|
*/
|
|
158
|
-
export type NeedsApproval<Params extends Schema.
|
|
159
|
+
export type NeedsApproval<Params extends Schema.Constraint> =
|
|
159
160
|
| boolean
|
|
160
161
|
| NeedsApprovalFunction<Params>
|
|
161
162
|
|
|
@@ -195,9 +196,9 @@ export type NeedsApproval<Params extends Schema.Top> =
|
|
|
195
196
|
export interface Tool<
|
|
196
197
|
out Name extends string,
|
|
197
198
|
out Config extends {
|
|
198
|
-
readonly parameters: Schema.
|
|
199
|
-
readonly success: Schema.
|
|
200
|
-
readonly failure: Schema.
|
|
199
|
+
readonly parameters: Schema.Constraint
|
|
200
|
+
readonly success: Schema.Constraint
|
|
201
|
+
readonly failure: Schema.Constraint
|
|
201
202
|
readonly failureMode: FailureMode
|
|
202
203
|
},
|
|
203
204
|
out Requirements = never
|
|
@@ -289,7 +290,7 @@ export interface Tool<
|
|
|
289
290
|
/**
|
|
290
291
|
* Set the schema to use to validate the result of a tool call when successful.
|
|
291
292
|
*/
|
|
292
|
-
setSuccess<SuccessSchema extends Schema.
|
|
293
|
+
setSuccess<SuccessSchema extends Schema.Constraint>(
|
|
293
294
|
schema: SuccessSchema
|
|
294
295
|
): Tool<
|
|
295
296
|
Name,
|
|
@@ -305,7 +306,7 @@ export interface Tool<
|
|
|
305
306
|
/**
|
|
306
307
|
* Set the schema to use to validate the result of a tool call when it fails.
|
|
307
308
|
*/
|
|
308
|
-
setFailure<FailureSchema extends Schema.
|
|
309
|
+
setFailure<FailureSchema extends Schema.Constraint>(
|
|
309
310
|
schema: FailureSchema
|
|
310
311
|
): Tool<
|
|
311
312
|
Name,
|
|
@@ -321,7 +322,7 @@ export interface Tool<
|
|
|
321
322
|
/**
|
|
322
323
|
* Set the schema to use to validate the parameters of a tool call.
|
|
323
324
|
*/
|
|
324
|
-
setParameters<ParametersSchema extends Schema.
|
|
325
|
+
setParameters<ParametersSchema extends Schema.Constraint>(
|
|
325
326
|
schema: ParametersSchema
|
|
326
327
|
): Tool<
|
|
327
328
|
Name,
|
|
@@ -386,10 +387,10 @@ export interface ProviderDefined<
|
|
|
386
387
|
out Identifier extends `${string}.${string}`,
|
|
387
388
|
out Name extends string,
|
|
388
389
|
out Config extends {
|
|
389
|
-
readonly args: Schema.
|
|
390
|
-
readonly parameters: Schema.
|
|
391
|
-
readonly success: Schema.
|
|
392
|
-
readonly failure: Schema.
|
|
390
|
+
readonly args: Schema.Constraint
|
|
391
|
+
readonly parameters: Schema.Constraint
|
|
392
|
+
readonly success: Schema.Constraint
|
|
393
|
+
readonly failure: Schema.Constraint
|
|
393
394
|
readonly failureMode: FailureMode
|
|
394
395
|
},
|
|
395
396
|
out RequiresHandler extends boolean = false
|
|
@@ -480,9 +481,9 @@ export interface ProviderDefined<
|
|
|
480
481
|
export interface Dynamic<
|
|
481
482
|
out Name extends string,
|
|
482
483
|
out Config extends {
|
|
483
|
-
readonly parameters: Schema.
|
|
484
|
-
readonly success: Schema.
|
|
485
|
-
readonly failure: Schema.
|
|
484
|
+
readonly parameters: Schema.Constraint | JsonSchema.JsonSchema
|
|
485
|
+
readonly success: Schema.Constraint
|
|
486
|
+
readonly failure: Schema.Constraint
|
|
486
487
|
readonly failureMode: FailureMode
|
|
487
488
|
},
|
|
488
489
|
out Requirements = never
|
|
@@ -490,7 +491,7 @@ export interface Dynamic<
|
|
|
490
491
|
Tool<
|
|
491
492
|
Name,
|
|
492
493
|
{
|
|
493
|
-
readonly parameters: Config["parameters"] extends Schema.
|
|
494
|
+
readonly parameters: Config["parameters"] extends Schema.Constraint ? Config["parameters"] : typeof Schema.Unknown
|
|
494
495
|
readonly success: Config["success"]
|
|
495
496
|
readonly failure: Config["failure"]
|
|
496
497
|
readonly failureMode: Config["failureMode"]
|
|
@@ -504,7 +505,7 @@ export interface Dynamic<
|
|
|
504
505
|
* The raw JSON Schema for parameters. Present when `parameters` was provided
|
|
505
506
|
* as a JSON Schema, `undefined` when an Effect Schema was used.
|
|
506
507
|
*/
|
|
507
|
-
readonly jsonSchema: Config["parameters"] extends Schema.
|
|
508
|
+
readonly jsonSchema: Config["parameters"] extends Schema.Constraint ? undefined : JsonSchema.JsonSchema
|
|
508
509
|
}
|
|
509
510
|
|
|
510
511
|
// =============================================================================
|
|
@@ -1035,16 +1036,16 @@ const Proto = {
|
|
|
1035
1036
|
addDependency(this: Any) {
|
|
1036
1037
|
return userDefinedProto({ ...this })
|
|
1037
1038
|
},
|
|
1038
|
-
setParameters(this: Any, parametersSchema: Schema.
|
|
1039
|
+
setParameters(this: Any, parametersSchema: Schema.Constraint) {
|
|
1039
1040
|
return userDefinedProto({
|
|
1040
1041
|
...this,
|
|
1041
1042
|
parametersSchema
|
|
1042
1043
|
})
|
|
1043
1044
|
},
|
|
1044
|
-
setSuccess(this: Any, successSchema: Schema.
|
|
1045
|
+
setSuccess(this: Any, successSchema: Schema.Constraint) {
|
|
1045
1046
|
return userDefinedProto({ ...this, successSchema })
|
|
1046
1047
|
},
|
|
1047
|
-
setFailure(this: Any, failureSchema: Schema.
|
|
1048
|
+
setFailure(this: Any, failureSchema: Schema.Constraint) {
|
|
1048
1049
|
return userDefinedProto({ ...this, failureSchema })
|
|
1049
1050
|
},
|
|
1050
1051
|
annotate<I, S>(this: Any, tag: Context.Key<I, S>, value: S) {
|
|
@@ -1073,9 +1074,9 @@ const DynamicProto = {
|
|
|
1073
1074
|
|
|
1074
1075
|
const userDefinedProto = <
|
|
1075
1076
|
const Name extends string,
|
|
1076
|
-
Parameters extends Schema.
|
|
1077
|
-
Success extends Schema.
|
|
1078
|
-
Failure extends Schema.
|
|
1077
|
+
Parameters extends Schema.Constraint,
|
|
1078
|
+
Success extends Schema.Constraint,
|
|
1079
|
+
Failure extends Schema.Constraint,
|
|
1079
1080
|
Mode extends FailureMode
|
|
1080
1081
|
>(options: {
|
|
1081
1082
|
readonly name: Name
|
|
@@ -1103,10 +1104,10 @@ const userDefinedProto = <
|
|
|
1103
1104
|
const providerDefinedProto = <
|
|
1104
1105
|
const Identifier extends `${string}.${string}`,
|
|
1105
1106
|
const Name extends string,
|
|
1106
|
-
Args extends Schema.
|
|
1107
|
-
Parameters extends Schema.
|
|
1108
|
-
Success extends Schema.
|
|
1109
|
-
Failure extends Schema.
|
|
1107
|
+
Args extends Schema.Constraint,
|
|
1108
|
+
Parameters extends Schema.Constraint,
|
|
1109
|
+
Success extends Schema.Constraint,
|
|
1110
|
+
Failure extends Schema.Constraint,
|
|
1110
1111
|
RequiresHandler extends boolean,
|
|
1111
1112
|
Mode extends FailureMode
|
|
1112
1113
|
>(options: {
|
|
@@ -1135,9 +1136,9 @@ const providerDefinedProto = <
|
|
|
1135
1136
|
|
|
1136
1137
|
const dynamicProto = <
|
|
1137
1138
|
const Name extends string,
|
|
1138
|
-
Parameters extends Schema.
|
|
1139
|
-
Success extends Schema.
|
|
1140
|
-
Failure extends Schema.
|
|
1139
|
+
Parameters extends Schema.Constraint | JsonSchema.JsonSchema,
|
|
1140
|
+
Success extends Schema.Constraint,
|
|
1141
|
+
Failure extends Schema.Constraint,
|
|
1141
1142
|
Mode extends FailureMode
|
|
1142
1143
|
>(options: {
|
|
1143
1144
|
readonly name: Name
|
|
@@ -1193,9 +1194,9 @@ const dynamicProto = <
|
|
|
1193
1194
|
*/
|
|
1194
1195
|
export const make = <
|
|
1195
1196
|
const Name extends string,
|
|
1196
|
-
Parameters extends Schema.
|
|
1197
|
-
Success extends Schema.
|
|
1198
|
-
Failure extends Schema.
|
|
1197
|
+
Parameters extends Schema.Constraint = typeof EmptyParams,
|
|
1198
|
+
Success extends Schema.Constraint = typeof Schema.Void,
|
|
1199
|
+
Failure extends Schema.Constraint = typeof Schema.Never,
|
|
1199
1200
|
Mode extends FailureMode | undefined = undefined,
|
|
1200
1201
|
Dependencies extends Array<Context.Key<any, any> | Context.Key<never, any>> = []
|
|
1201
1202
|
>(name: Name, options?: {
|
|
@@ -1360,21 +1361,23 @@ export const dynamic: {
|
|
|
1360
1361
|
const Name extends string,
|
|
1361
1362
|
const Options extends {
|
|
1362
1363
|
readonly description?: string | undefined
|
|
1363
|
-
readonly parameters?: Schema.
|
|
1364
|
-
readonly success?: Schema.
|
|
1365
|
-
readonly failure?: Schema.
|
|
1364
|
+
readonly parameters?: Schema.Constraint | JsonSchema.JsonSchema | undefined
|
|
1365
|
+
readonly success?: Schema.Constraint | undefined
|
|
1366
|
+
readonly failure?: Schema.Constraint | undefined
|
|
1366
1367
|
readonly failureMode?: FailureMode | undefined
|
|
1367
1368
|
readonly needsApproval?: NeedsApproval<any> | undefined
|
|
1368
1369
|
}
|
|
1369
1370
|
>(name: Name, options?: Options): Dynamic<
|
|
1370
1371
|
Name,
|
|
1371
1372
|
{
|
|
1372
|
-
readonly parameters: Options extends { readonly parameters: infer P } ? P extends Schema.
|
|
1373
|
+
readonly parameters: Options extends { readonly parameters: infer P } ? P extends Schema.Constraint ? P
|
|
1373
1374
|
: P extends JsonSchema.JsonSchema ? P
|
|
1374
1375
|
: typeof Schema.Unknown
|
|
1375
1376
|
: typeof Schema.Unknown
|
|
1376
|
-
readonly success: Options extends { readonly success: infer S extends Schema.
|
|
1377
|
-
|
|
1377
|
+
readonly success: Options extends { readonly success: infer S extends Schema.Constraint } ? S
|
|
1378
|
+
: typeof Schema.Unknown
|
|
1379
|
+
readonly failure: Options extends { readonly failure: infer F extends Schema.Constraint } ? F
|
|
1380
|
+
: typeof Schema.Never
|
|
1378
1381
|
readonly failureMode: Options extends { readonly failureMode: infer M extends FailureMode } ? M : "error"
|
|
1379
1382
|
}
|
|
1380
1383
|
>
|
|
@@ -1382,9 +1385,9 @@ export const dynamic: {
|
|
|
1382
1385
|
const Name extends string,
|
|
1383
1386
|
const Options extends {
|
|
1384
1387
|
readonly description?: string | undefined
|
|
1385
|
-
readonly parameters?: Schema.
|
|
1386
|
-
readonly success?: Schema.
|
|
1387
|
-
readonly failure?: Schema.
|
|
1388
|
+
readonly parameters?: Schema.Constraint | JsonSchema.JsonSchema | undefined
|
|
1389
|
+
readonly success?: Schema.Constraint | undefined
|
|
1390
|
+
readonly failure?: Schema.Constraint | undefined
|
|
1388
1391
|
readonly failureMode?: FailureMode | undefined
|
|
1389
1392
|
readonly needsApproval?: NeedsApproval<any> | undefined
|
|
1390
1393
|
}
|
|
@@ -1448,10 +1451,10 @@ export const dynamic: {
|
|
|
1448
1451
|
export const providerDefined = <
|
|
1449
1452
|
const Identifier extends `${string}.${string}`,
|
|
1450
1453
|
const Name extends string,
|
|
1451
|
-
Args extends Schema.
|
|
1452
|
-
Parameters extends Schema.
|
|
1453
|
-
Success extends Schema.
|
|
1454
|
-
Failure extends Schema.
|
|
1454
|
+
Args extends Schema.Constraint = typeof Schema.Void,
|
|
1455
|
+
Parameters extends Schema.Constraint = typeof Schema.Void,
|
|
1456
|
+
Success extends Schema.Constraint = typeof Schema.Void,
|
|
1457
|
+
Failure extends Schema.Constraint = typeof Schema.Never,
|
|
1455
1458
|
RequiresHandler extends boolean = false
|
|
1456
1459
|
>(options: {
|
|
1457
1460
|
/**
|
|
@@ -1704,7 +1707,7 @@ export const getJsonSchema = <Tool extends Any>(tool: Tool, options?: {
|
|
|
1704
1707
|
* @category converting
|
|
1705
1708
|
* @since 4.0.0
|
|
1706
1709
|
*/
|
|
1707
|
-
export const getJsonSchemaFromSchema = <S extends Schema.
|
|
1710
|
+
export const getJsonSchemaFromSchema = <S extends Schema.Constraint>(schema: S, options?: {
|
|
1708
1711
|
readonly transformer?: CodecTransformer
|
|
1709
1712
|
}): JsonSchema.JsonSchema => {
|
|
1710
1713
|
if (Predicate.isNotUndefined(options?.transformer)) {
|
|
@@ -1997,12 +2000,12 @@ function filter(obj: any) {
|
|
|
1997
2000
|
*/
|
|
1998
2001
|
export const unsafeSecureJsonParse = (text: string): unknown => {
|
|
1999
2002
|
// Performance optimization, see https://github.com/fastify/secure-json-parse/pull/90
|
|
2000
|
-
const
|
|
2001
|
-
|
|
2003
|
+
const prevLimit = StackTraceLimit.getStackTraceLimit()
|
|
2004
|
+
StackTraceLimit.setStackTraceLimit(0)
|
|
2002
2005
|
try {
|
|
2003
2006
|
return _parse(text)
|
|
2004
2007
|
} finally {
|
|
2005
|
-
|
|
2008
|
+
StackTraceLimit.setStackTraceLimit(prevLimit)
|
|
2006
2009
|
}
|
|
2007
2010
|
}
|
|
2008
2011
|
|