effect 4.0.0-beta.85 → 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/Cron.d.ts.map +1 -1
- package/dist/Cron.js +4 -0
- package/dist/Cron.js.map +1 -1
- package/dist/Schema.d.ts +745 -393
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +90 -64
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +20 -29
- 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 +6 -7
- 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/representation.js +1 -5
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.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.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/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.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/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/Cron.ts +4 -0
- package/src/Schema.ts +963 -688
- package/src/SchemaAST.ts +25 -35
- package/src/SchemaParser.ts +85 -77
- package/src/internal/effect.ts +6 -22
- package/src/internal/matcher.ts +0 -5
- package/src/internal/schema/arbitrary.ts +1 -1
- package/src/internal/schema/representation.ts +1 -5
- package/src/internal/schema/schema.ts +1 -1
- 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 +49 -47
- 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 +2 -2
- 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 +3 -3
- 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 +2 -2
- 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
|
@@ -60,7 +60,7 @@ type SuccessType<S> = S extends HttpApiSchema.StreamSse<
|
|
|
60
60
|
infer _Value
|
|
61
61
|
> ? Stream.Stream<_Value, _Error["Type"], never>
|
|
62
62
|
: S extends HttpApiSchema.StreamUint8Array ? Stream.Stream<Uint8Array, unknown, never>
|
|
63
|
-
: S extends Schema.
|
|
63
|
+
: S extends Schema.Constraint ? S["Type"]
|
|
64
64
|
: never
|
|
65
65
|
|
|
66
66
|
type SuccessEncodingServices<S> = S extends HttpApiSchema.StreamSse<
|
|
@@ -69,7 +69,7 @@ type SuccessEncodingServices<S> = S extends HttpApiSchema.StreamSse<
|
|
|
69
69
|
infer _Value
|
|
70
70
|
> ? _Events["EncodingServices"] | _Error["EncodingServices"]
|
|
71
71
|
: S extends HttpApiSchema.StreamUint8Array ? never
|
|
72
|
-
: S extends Schema.
|
|
72
|
+
: S extends Schema.Constraint ? S["EncodingServices"]
|
|
73
73
|
: never
|
|
74
74
|
|
|
75
75
|
type SuccessDecodingServices<S> = S extends HttpApiSchema.StreamSse<
|
|
@@ -78,10 +78,10 @@ type SuccessDecodingServices<S> = S extends HttpApiSchema.StreamSse<
|
|
|
78
78
|
infer _Value
|
|
79
79
|
> ? _Events["DecodingServices"] | _Error["DecodingServices"]
|
|
80
80
|
: S extends HttpApiSchema.StreamUint8Array ? never
|
|
81
|
-
: S extends Schema.
|
|
81
|
+
: S extends Schema.Constraint ? S["DecodingServices"]
|
|
82
82
|
: never
|
|
83
83
|
|
|
84
|
-
type ExtractSuccessOrArray<S extends SuccessConstraint> = S extends ReadonlyArray<Schema.
|
|
84
|
+
type ExtractSuccessOrArray<S extends SuccessConstraint> = S extends ReadonlyArray<Schema.Constraint> ? S[number] : S
|
|
85
85
|
|
|
86
86
|
type ExtractBufferedSuccess<S extends SuccessConstraint> = Exclude<
|
|
87
87
|
Extract<ExtractSuccessOrArray<S>, Schema.Top>,
|
|
@@ -262,8 +262,18 @@ export interface Any extends Pipeable {
|
|
|
262
262
|
* @category models
|
|
263
263
|
* @since 4.0.0
|
|
264
264
|
*/
|
|
265
|
-
export interface AnyWithProps
|
|
266
|
-
|
|
265
|
+
export interface AnyWithProps extends
|
|
266
|
+
HttpApiEndpoint<
|
|
267
|
+
string,
|
|
268
|
+
HttpMethod,
|
|
269
|
+
string,
|
|
270
|
+
Schema.Top,
|
|
271
|
+
Schema.Top,
|
|
272
|
+
Schema.Top,
|
|
273
|
+
Schema.Top,
|
|
274
|
+
any,
|
|
275
|
+
any
|
|
276
|
+
>
|
|
267
277
|
{}
|
|
268
278
|
|
|
269
279
|
/**
|
|
@@ -578,10 +588,10 @@ export type RequestRaw<Endpoint extends Any> = Endpoint extends HttpApiEndpoint<
|
|
|
578
588
|
* @since 4.0.0
|
|
579
589
|
*/
|
|
580
590
|
export type ClientRequest<
|
|
581
|
-
Params extends Schema.
|
|
582
|
-
Query extends Schema.
|
|
583
|
-
Payload extends Schema.
|
|
584
|
-
Headers extends Schema.
|
|
591
|
+
Params extends Schema.Constraint,
|
|
592
|
+
Query extends Schema.Constraint,
|
|
593
|
+
Payload extends Schema.Constraint,
|
|
594
|
+
Headers extends Schema.Constraint,
|
|
585
595
|
ResponseMode extends ClientResponseMode
|
|
586
596
|
> = (
|
|
587
597
|
& ([Params["Type"]] extends [never] ? {} : { readonly params: Params["Type"] })
|
|
@@ -1027,8 +1037,8 @@ function makeProto<
|
|
|
1027
1037
|
* @since 4.0.0
|
|
1028
1038
|
*/
|
|
1029
1039
|
export type ParamsConstraint =
|
|
1030
|
-
| Record<string, Schema.
|
|
1031
|
-
| Schema.
|
|
1040
|
+
| Record<string, Schema.Codec<unknown, string | undefined, unknown, unknown>>
|
|
1041
|
+
| Schema.Codec<unknown, Record<string, string | undefined>, unknown, unknown>
|
|
1032
1042
|
|
|
1033
1043
|
/**
|
|
1034
1044
|
* Constraint for header schemas: each header must encode to `string | undefined`,
|
|
@@ -1038,8 +1048,8 @@ export type ParamsConstraint =
|
|
|
1038
1048
|
* @since 4.0.0
|
|
1039
1049
|
*/
|
|
1040
1050
|
export type HeadersConstraint =
|
|
1041
|
-
| Record<string, Schema.
|
|
1042
|
-
| Schema.
|
|
1051
|
+
| Record<string, Schema.Codec<unknown, string | undefined, unknown, unknown>>
|
|
1052
|
+
| Schema.Codec<unknown, Record<string, string | undefined>, unknown, unknown>
|
|
1043
1053
|
|
|
1044
1054
|
/**
|
|
1045
1055
|
* Constraint for query schemas: each field must encode to `string`, an array of
|
|
@@ -1049,8 +1059,8 @@ export type HeadersConstraint =
|
|
|
1049
1059
|
* @since 4.0.0
|
|
1050
1060
|
*/
|
|
1051
1061
|
export type QueryConstraint =
|
|
1052
|
-
| Record<string, Schema.
|
|
1053
|
-
| Schema.
|
|
1062
|
+
| Record<string, Schema.Codec<unknown, string | ReadonlyArray<string> | undefined, unknown, unknown>>
|
|
1063
|
+
| Schema.Codec<unknown, string | ReadonlyArray<string> | undefined, unknown, unknown>
|
|
1054
1064
|
|
|
1055
1065
|
/**
|
|
1056
1066
|
* Payload schema depends on the HTTP method:
|
|
@@ -1065,7 +1075,7 @@ export type QueryConstraint =
|
|
|
1065
1075
|
*/
|
|
1066
1076
|
export type PayloadConstraint<Method extends HttpMethod> = Method extends HttpMethod.NoBody ? Record<
|
|
1067
1077
|
string,
|
|
1068
|
-
Schema.
|
|
1078
|
+
Schema.Codec<unknown, string | ReadonlyArray<string> | undefined, unknown, unknown>
|
|
1069
1079
|
> :
|
|
1070
1080
|
Schema.Top | ReadonlyArray<Schema.Top>
|
|
1071
1081
|
|
|
@@ -1101,7 +1111,7 @@ export type ErrorConstraint = Schema.Top | ReadonlyArray<Schema.Top>
|
|
|
1101
1111
|
|
|
1102
1112
|
type ErrorNoStream<S extends ErrorConstraint> = [
|
|
1103
1113
|
Extract<
|
|
1104
|
-
S extends ReadonlyArray<Schema.
|
|
1114
|
+
S extends ReadonlyArray<Schema.Constraint> ? S[number] : S,
|
|
1105
1115
|
HttpApiSchema.StreamSchema
|
|
1106
1116
|
>
|
|
1107
1117
|
] extends [never] ? S : never
|
|
@@ -1147,7 +1157,7 @@ export const make = <Method extends HttpMethod>(method: Method): {
|
|
|
1147
1157
|
: StringTree<ExtractSchemaOrArray<Payload>>,
|
|
1148
1158
|
StringTree<Headers extends Schema.Struct.Fields ? Schema.Struct<Headers> : Headers>,
|
|
1149
1159
|
JsonSuccessOrArray<Success>,
|
|
1150
|
-
Json<Error extends ReadonlyArray<Schema.
|
|
1160
|
+
Json<Error extends ReadonlyArray<Schema.Constraint> ? Error[number] : Error>
|
|
1151
1161
|
>
|
|
1152
1162
|
<
|
|
1153
1163
|
const Name extends string,
|
|
@@ -1179,7 +1189,7 @@ export const make = <Method extends HttpMethod>(method: Method): {
|
|
|
1179
1189
|
ExtractSchemaOrArray<Payload>,
|
|
1180
1190
|
ExtractSchemaOrArray<Headers>,
|
|
1181
1191
|
ExtractSuccessOrArray<Success>,
|
|
1182
|
-
Error extends ReadonlyArray<Schema.
|
|
1192
|
+
Error extends ReadonlyArray<Schema.Constraint> ? Error[number] : Error
|
|
1183
1193
|
>
|
|
1184
1194
|
} =>
|
|
1185
1195
|
<
|
|
@@ -1210,11 +1220,11 @@ export const make = <Method extends HttpMethod>(method: Method): {
|
|
|
1210
1220
|
Params extends Schema.Struct.Fields ? Schema.Struct<Params> : Params,
|
|
1211
1221
|
Query extends Schema.Struct.Fields ? Schema.Struct<Query> : Query,
|
|
1212
1222
|
Payload extends Schema.Struct.Fields ? Schema.Struct<Payload>
|
|
1213
|
-
: Payload extends ReadonlyArray<Schema.
|
|
1223
|
+
: Payload extends ReadonlyArray<Schema.Constraint> ? Payload[number]
|
|
1214
1224
|
: Payload,
|
|
1215
1225
|
Headers extends Schema.Struct.Fields ? Schema.Struct<Headers> : Headers,
|
|
1216
1226
|
ExtractSuccessOrArray<Success>,
|
|
1217
|
-
Error extends ReadonlyArray<Schema.
|
|
1227
|
+
Error extends ReadonlyArray<Schema.Constraint> ? Error[number] : Error
|
|
1218
1228
|
> => {
|
|
1219
1229
|
const disableCodecs = options?.disableCodecs ?? false
|
|
1220
1230
|
const transformStringTree = disableCodecs ? identity : Schema.toCodecStringTree
|
|
@@ -1233,10 +1243,10 @@ export const make = <Method extends HttpMethod>(method: Method): {
|
|
|
1233
1243
|
})
|
|
1234
1244
|
}
|
|
1235
1245
|
|
|
1236
|
-
type ExtractSchemaOrArray<S extends Schema.Struct.Fields | Schema.
|
|
1237
|
-
Schema.Struct.Fields ? Schema.Struct<S>
|
|
1238
|
-
|
|
1239
|
-
|
|
1246
|
+
type ExtractSchemaOrArray<S extends Schema.Struct.Fields | Schema.Constraint | ReadonlyArray<Schema.Constraint>> =
|
|
1247
|
+
S extends Schema.Struct.Fields ? Schema.Struct<S>
|
|
1248
|
+
: S extends ReadonlyArray<Schema.Constraint> ? S[number]
|
|
1249
|
+
: S
|
|
1240
1250
|
|
|
1241
1251
|
/**
|
|
1242
1252
|
* A schema codec that decodes and encodes the schema's value type through JSON
|
|
@@ -1245,7 +1255,7 @@ type ExtractSchemaOrArray<S extends Schema.Struct.Fields | Schema.Top | Readonly
|
|
|
1245
1255
|
* @category Codecs
|
|
1246
1256
|
* @since 4.0.0
|
|
1247
1257
|
*/
|
|
1248
|
-
export interface Json<S extends Schema.
|
|
1258
|
+
export interface Json<S extends Schema.Constraint>
|
|
1249
1259
|
extends Schema.Codec<S["Type"], Schema.Json, S["DecodingServices"], S["EncodingServices"]>
|
|
1250
1260
|
{}
|
|
1251
1261
|
|
|
@@ -1256,7 +1266,7 @@ export interface Json<S extends Schema.Top>
|
|
|
1256
1266
|
* @category Codecs
|
|
1257
1267
|
* @since 4.0.0
|
|
1258
1268
|
*/
|
|
1259
|
-
export interface StringTree<S extends Schema.
|
|
1269
|
+
export interface StringTree<S extends Schema.Constraint> extends
|
|
1260
1270
|
Schema.Codec<
|
|
1261
1271
|
S["Type"],
|
|
1262
1272
|
Schema.StringTree,
|
|
@@ -1267,7 +1277,7 @@ export interface StringTree<S extends Schema.Top> extends
|
|
|
1267
1277
|
|
|
1268
1278
|
function ensureStruct(
|
|
1269
1279
|
params: Schema.Struct.Fields | Schema.Top | undefined,
|
|
1270
|
-
transform:
|
|
1280
|
+
transform: (schema: Schema.Top) => Schema.Top
|
|
1271
1281
|
): Schema.Top | undefined {
|
|
1272
1282
|
if (params === undefined) return undefined
|
|
1273
1283
|
if (Schema.isSchema(params)) return transform(params)
|
|
@@ -1275,12 +1285,14 @@ function ensureStruct(
|
|
|
1275
1285
|
}
|
|
1276
1286
|
|
|
1277
1287
|
function getPayload(
|
|
1278
|
-
payload: Schema.
|
|
1288
|
+
payload: Schema.Constraint | ReadonlyArray<Schema.Constraint> | Schema.Struct.Fields | undefined,
|
|
1279
1289
|
method: HttpMethod,
|
|
1280
1290
|
disableCodecs: boolean
|
|
1281
1291
|
): PayloadMap {
|
|
1282
|
-
const result: Map<
|
|
1283
|
-
|
|
1292
|
+
const result: Map<
|
|
1293
|
+
string,
|
|
1294
|
+
{ encoding: HttpApiSchema.PayloadEncoding; schemas: [Schema.Top, ...Array<Schema.Top>] }
|
|
1295
|
+
> = new Map()
|
|
1284
1296
|
if (payload === undefined) return result
|
|
1285
1297
|
const schemas: Array<Schema.Top> = Array.isArray(payload)
|
|
1286
1298
|
? payload
|
|
@@ -1338,7 +1350,7 @@ function getErrorResponse(
|
|
|
1338
1350
|
return new Set(disableCodecs ? schemas : schemas.map(transformResponse))
|
|
1339
1351
|
}
|
|
1340
1352
|
|
|
1341
|
-
function validateSuccessResponse(schemas: ReadonlyArray<Schema.
|
|
1353
|
+
function validateSuccessResponse(schemas: ReadonlyArray<Schema.Constraint>, method: HttpMethod) {
|
|
1342
1354
|
const statuses = new Map<number, {
|
|
1343
1355
|
readonly stream?: HttpApiSchema.StreamSchema | undefined
|
|
1344
1356
|
bufferedContentTypes: Set<string>
|
|
@@ -45,8 +45,8 @@ export const isSecurity = (u: AnyService): u is AnyServiceSecurity => hasPropert
|
|
|
45
45
|
|
|
46
46
|
type ErrorConstraint = Schema.Top | ReadonlyArray<Schema.Top>
|
|
47
47
|
|
|
48
|
-
type ErrorSchemaFromConstraint<E> = E extends ReadonlyArray<Schema.
|
|
49
|
-
: E extends Schema.
|
|
48
|
+
type ErrorSchemaFromConstraint<E> = E extends ReadonlyArray<Schema.Constraint> ? E[number]
|
|
49
|
+
: E extends Schema.Constraint ? E
|
|
50
50
|
: never
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -233,7 +233,7 @@ export const Accepted: Accepted = Empty(202)
|
|
|
233
233
|
* @category schemas
|
|
234
234
|
* @since 4.0.0
|
|
235
235
|
*/
|
|
236
|
-
export interface asNoContent<S extends Schema.
|
|
236
|
+
export interface asNoContent<S extends Schema.Constraint> extends Schema.decodeTo<Schema.toType<S>, Schema.Void> {}
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
239
|
* Marks a schema as a no-content response while preserving a decoded client value.
|
|
@@ -249,7 +249,7 @@ export interface asNoContent<S extends Schema.Top> extends Schema.decodeTo<Schem
|
|
|
249
249
|
* @category encoding
|
|
250
250
|
* @since 4.0.0
|
|
251
251
|
*/
|
|
252
|
-
export function asNoContent<S extends Schema.
|
|
252
|
+
export function asNoContent<S extends Schema.Constraint>(options: {
|
|
253
253
|
readonly decode: LazyArg<S["Type"]>
|
|
254
254
|
}) {
|
|
255
255
|
return (self: S): asNoContent<S> => {
|
|
@@ -292,19 +292,22 @@ export type StreamSseMode = "events" | "data"
|
|
|
292
292
|
*/
|
|
293
293
|
export interface StreamSse<
|
|
294
294
|
Events extends Sse.EventCodec,
|
|
295
|
-
Error extends Schema.
|
|
295
|
+
Error extends Schema.Constraint,
|
|
296
296
|
Value = Events["Type"]
|
|
297
297
|
> extends
|
|
298
|
-
Schema.
|
|
299
|
-
Stream.Stream<Value, Error["Type"], never>,
|
|
300
|
-
Stream.Stream<Value, Error["Type"], never>,
|
|
301
|
-
Events["DecodingServices"] | Error["DecodingServices"],
|
|
302
|
-
Events["EncodingServices"] | Error["EncodingServices"],
|
|
298
|
+
Schema.BottomLazy<
|
|
303
299
|
SchemaAST.Declaration,
|
|
304
300
|
StreamSse<Events, Error, Value>
|
|
305
301
|
>
|
|
306
302
|
{
|
|
303
|
+
readonly "Type": Stream.Stream<Value, Error["Type"], never>
|
|
304
|
+
readonly "Encoded": Stream.Stream<Value, Error["Type"], never>
|
|
305
|
+
readonly "DecodingServices": Events["DecodingServices"] | Error["DecodingServices"]
|
|
306
|
+
readonly "EncodingServices": Events["EncodingServices"] | Error["EncodingServices"]
|
|
307
307
|
readonly "Rebuild": StreamSse<Events, Error, Value>
|
|
308
|
+
readonly "~type.make.in": Stream.Stream<Value, Error["Type"], never>
|
|
309
|
+
readonly "~type.make": Stream.Stream<Value, Error["Type"], never>
|
|
310
|
+
readonly "Iso": Stream.Stream<Value, Error["Type"], never>
|
|
308
311
|
readonly [StreamSchemaTypeId]: typeof StreamSchemaTypeId
|
|
309
312
|
readonly _tag: "StreamSse"
|
|
310
313
|
readonly mode: "sse"
|
|
@@ -321,7 +324,7 @@ export interface StreamSse<
|
|
|
321
324
|
* @category models
|
|
322
325
|
* @since 4.0.0
|
|
323
326
|
*/
|
|
324
|
-
export interface SseEventFromData<Data extends Schema.
|
|
327
|
+
export interface SseEventFromData<Data extends Schema.Constraint> extends
|
|
325
328
|
Schema.Codec<
|
|
326
329
|
{
|
|
327
330
|
readonly id: string | undefined
|
|
@@ -375,20 +378,6 @@ export interface StreamUint8Array extends
|
|
|
375
378
|
*/
|
|
376
379
|
export type StreamSchema = StreamSse<Sse.EventCodec, Schema.Top, unknown> | StreamUint8Array
|
|
377
380
|
|
|
378
|
-
/** @internal */
|
|
379
|
-
export type StreamMetadata =
|
|
380
|
-
| {
|
|
381
|
-
readonly mode: "sse"
|
|
382
|
-
readonly sseMode: StreamSseMode
|
|
383
|
-
readonly contentType: string
|
|
384
|
-
readonly events: Sse.EventCodec
|
|
385
|
-
readonly error: Schema.Top
|
|
386
|
-
}
|
|
387
|
-
| {
|
|
388
|
-
readonly mode: "uint8array"
|
|
389
|
-
readonly contentType: string
|
|
390
|
-
}
|
|
391
|
-
|
|
392
381
|
const streamSchema = Schema.declare(Stream.isStream)
|
|
393
382
|
|
|
394
383
|
/**
|
|
@@ -404,7 +393,7 @@ export const StreamSse: {
|
|
|
404
393
|
* @category constructors
|
|
405
394
|
* @since 4.0.0
|
|
406
395
|
*/
|
|
407
|
-
<Events extends Sse.EventCodec, Error extends Schema.
|
|
396
|
+
<Events extends Sse.EventCodec, Error extends Schema.Constraint = Schema.Never>(
|
|
408
397
|
options: {
|
|
409
398
|
readonly contentType?: string | undefined
|
|
410
399
|
readonly events: Events
|
|
@@ -417,7 +406,7 @@ export const StreamSse: {
|
|
|
417
406
|
* @category constructors
|
|
418
407
|
* @since 4.0.0
|
|
419
408
|
*/
|
|
420
|
-
<Data extends Schema.
|
|
409
|
+
<Data extends Schema.Constraint, Error extends Schema.Constraint = Schema.Never>(
|
|
421
410
|
options: {
|
|
422
411
|
readonly contentType?: string | undefined
|
|
423
412
|
readonly data: Data
|
|
@@ -427,8 +416,8 @@ export const StreamSse: {
|
|
|
427
416
|
} = (options: {
|
|
428
417
|
readonly contentType?: string | undefined
|
|
429
418
|
readonly events?: Sse.EventCodec | undefined
|
|
430
|
-
readonly data?: Schema.
|
|
431
|
-
readonly error?: Schema.
|
|
419
|
+
readonly data?: Schema.Constraint | undefined
|
|
420
|
+
readonly error?: Schema.Constraint | undefined
|
|
432
421
|
}): StreamSse<Sse.EventCodec, Schema.Top, unknown> => {
|
|
433
422
|
const events = options.events ?? (options.data === undefined ? undefined : Schema.Struct({
|
|
434
423
|
id: Schema.UndefinedOr(Schema.String),
|
|
@@ -477,22 +466,6 @@ export const isStreamSse = (u: unknown): u is StreamSse<Sse.EventCodec, Schema.T
|
|
|
477
466
|
export const isStreamUint8Array = (u: unknown): u is StreamUint8Array =>
|
|
478
467
|
isStreamSchema(u) && u._tag === "StreamUint8Array"
|
|
479
468
|
|
|
480
|
-
/** @internal */
|
|
481
|
-
export function getStreamMetadata(self: StreamSchema): StreamMetadata {
|
|
482
|
-
return self._tag === "StreamSse" ?
|
|
483
|
-
{
|
|
484
|
-
mode: self.mode,
|
|
485
|
-
sseMode: self.sseMode,
|
|
486
|
-
contentType: self.contentType,
|
|
487
|
-
events: self.events,
|
|
488
|
-
error: self.error
|
|
489
|
-
} :
|
|
490
|
-
{
|
|
491
|
-
mode: self.mode,
|
|
492
|
-
contentType: self.contentType
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
469
|
function defaultStreamContentType(mode: StreamMode): string {
|
|
497
470
|
switch (mode) {
|
|
498
471
|
case "sse":
|
|
@@ -454,7 +454,7 @@ export function fromApi<Id extends string, Groups extends HttpApiGroup.Any>(
|
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
function processParameters(schema: Schema.
|
|
457
|
+
function processParameters(schema: Schema.Constraint | undefined, i: OpenAPISpecParameter["in"]) {
|
|
458
458
|
if (schema) {
|
|
459
459
|
const ast = SchemaAST.getLastEncoding(schema.ast)
|
|
460
460
|
if (SchemaAST.isObjects(ast)) {
|
|
@@ -636,7 +636,7 @@ function extractSuccessResponseBodies(endpoint: HttpApiEndpoint.AnyWithProps): R
|
|
|
636
636
|
}
|
|
637
637
|
|
|
638
638
|
function extractResponseBodies(
|
|
639
|
-
schemas: Array<Schema.
|
|
639
|
+
schemas: Array<Schema.Constraint>,
|
|
640
640
|
getStatus: (ast: SchemaAST.AST) => number,
|
|
641
641
|
getDescription: (ast: SchemaAST.AST) => string | undefined
|
|
642
642
|
): ResponseBodies {
|
|
@@ -650,7 +650,7 @@ function extractResponseBodies(
|
|
|
650
650
|
|
|
651
651
|
return map
|
|
652
652
|
|
|
653
|
-
function process(schema: Schema.
|
|
653
|
+
function process(schema: Schema.Constraint) {
|
|
654
654
|
if (HttpApiSchema.isStreamSchema(schema)) {
|
|
655
655
|
addStreamContent(schema)
|
|
656
656
|
return
|
|
@@ -679,7 +679,7 @@ function extractResponseBodies(
|
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
681
|
|
|
682
|
-
function addContent(schema: Schema.
|
|
682
|
+
function addContent(schema: Schema.Constraint, status: number, encoding: HttpApiSchema.Encoding) {
|
|
683
683
|
const description = getDescription(schema.ast)
|
|
684
684
|
const statusMap = map.get(status)
|
|
685
685
|
const { _tag, contentType } = encoding
|
|
@@ -738,7 +738,7 @@ type Content = Map<
|
|
|
738
738
|
HttpApiSchema.Encoding["_tag"],
|
|
739
739
|
Map<
|
|
740
740
|
string, // contentType
|
|
741
|
-
Set<Schema.
|
|
741
|
+
Set<Schema.Constraint>
|
|
742
742
|
>
|
|
743
743
|
>
|
|
744
744
|
|
|
@@ -138,33 +138,6 @@ export const encodeResource = (resource: Resource): Uint8Array =>
|
|
|
138
138
|
: new Uint8Array(0)
|
|
139
139
|
)
|
|
140
140
|
|
|
141
|
-
// Trace types (opentelemetry.proto.trace.v1)
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Status code enum
|
|
145
|
-
*
|
|
146
|
-
* @internal
|
|
147
|
-
*/
|
|
148
|
-
export const StatusCode = {
|
|
149
|
-
Unset: 0,
|
|
150
|
-
Ok: 1,
|
|
151
|
-
Error: 2
|
|
152
|
-
} as const
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* SpanKind enum
|
|
156
|
-
*
|
|
157
|
-
* @internal
|
|
158
|
-
*/
|
|
159
|
-
export const SpanKind = {
|
|
160
|
-
Unspecified: 0,
|
|
161
|
-
Internal: 1,
|
|
162
|
-
Server: 2,
|
|
163
|
-
Client: 3,
|
|
164
|
-
Producer: 4,
|
|
165
|
-
Consumer: 5
|
|
166
|
-
} as const
|
|
167
|
-
|
|
168
141
|
/**
|
|
169
142
|
* Encodes a Status message.
|
|
170
143
|
*
|
|
@@ -376,19 +349,6 @@ export const encodeResourceSpans = (resourceSpans: ResourceSpan): Uint8Array =>
|
|
|
376
349
|
export const encodeTracesData = (tracesData: TraceData): Uint8Array =>
|
|
377
350
|
Proto.repeatedField(1, tracesData.resourceSpans, encodeResourceSpans)
|
|
378
351
|
|
|
379
|
-
// Metrics types (opentelemetry.proto.metrics.v1)
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* AggregationTemporality enum
|
|
383
|
-
*
|
|
384
|
-
* @internal
|
|
385
|
-
*/
|
|
386
|
-
export const AggregationTemporality = {
|
|
387
|
-
Unspecified: 0,
|
|
388
|
-
Delta: 1,
|
|
389
|
-
Cumulative: 2
|
|
390
|
-
} as const
|
|
391
|
-
|
|
392
352
|
/**
|
|
393
353
|
* Encodes a NumberDataPoint message.
|
|
394
354
|
*
|
|
@@ -631,41 +591,6 @@ export const encodeMetricsData = (metricsData: {
|
|
|
631
591
|
readonly resourceMetrics: ReadonlyArray<Parameters<typeof encodeResourceMetrics>[0]>
|
|
632
592
|
}): Uint8Array => Proto.repeatedField(1, metricsData.resourceMetrics, encodeResourceMetrics)
|
|
633
593
|
|
|
634
|
-
// Logs types (opentelemetry.proto.logs.v1)
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* SeverityNumber enum
|
|
638
|
-
*
|
|
639
|
-
* @internal
|
|
640
|
-
*/
|
|
641
|
-
export const SeverityNumber = {
|
|
642
|
-
Unspecified: 0,
|
|
643
|
-
Trace: 1,
|
|
644
|
-
Trace2: 2,
|
|
645
|
-
Trace3: 3,
|
|
646
|
-
Trace4: 4,
|
|
647
|
-
Debug: 5,
|
|
648
|
-
Debug2: 6,
|
|
649
|
-
Debug3: 7,
|
|
650
|
-
Debug4: 8,
|
|
651
|
-
Info: 9,
|
|
652
|
-
Info2: 10,
|
|
653
|
-
Info3: 11,
|
|
654
|
-
Info4: 12,
|
|
655
|
-
Warn: 13,
|
|
656
|
-
Warn2: 14,
|
|
657
|
-
Warn3: 15,
|
|
658
|
-
Warn4: 16,
|
|
659
|
-
Error: 17,
|
|
660
|
-
Error2: 18,
|
|
661
|
-
Error3: 19,
|
|
662
|
-
Error4: 20,
|
|
663
|
-
Fatal: 21,
|
|
664
|
-
Fatal2: 22,
|
|
665
|
-
Fatal3: 23,
|
|
666
|
-
Fatal4: 24
|
|
667
|
-
} as const
|
|
668
|
-
|
|
669
594
|
/**
|
|
670
595
|
* Encodes a LogRecord message.
|
|
671
596
|
*
|
|
@@ -37,17 +37,6 @@ export const encodeVarint = (value: number | bigint): Uint8Array => {
|
|
|
37
37
|
return new Uint8Array(bytes)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* Encodes a signed varint using ZigZag encoding
|
|
42
|
-
*
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
export const encodeSint = (value: number | bigint): Uint8Array => {
|
|
46
|
-
const n = typeof value === "bigint" ? value : BigInt(value)
|
|
47
|
-
const zigzag = (n << BigInt(1)) ^ (n >> BigInt(63))
|
|
48
|
-
return encodeVarint(zigzag)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
40
|
/**
|
|
52
41
|
* Encodes a 64-bit fixed value (little-endian)
|
|
53
42
|
*
|
|
@@ -133,17 +122,6 @@ export const varintField = (fieldNumber: number, value: number | bigint): Uint8A
|
|
|
133
122
|
encodeVarint(value)
|
|
134
123
|
)
|
|
135
124
|
|
|
136
|
-
/**
|
|
137
|
-
* Encodes a sint field (ZigZag encoded)
|
|
138
|
-
*
|
|
139
|
-
* @internal
|
|
140
|
-
*/
|
|
141
|
-
export const sintField = (fieldNumber: number, value: number | bigint): Uint8Array =>
|
|
142
|
-
concat(
|
|
143
|
-
encodeVarint(encodeTag(fieldNumber, WireType.Varint)),
|
|
144
|
-
encodeSint(value)
|
|
145
|
-
)
|
|
146
|
-
|
|
147
125
|
/**
|
|
148
126
|
* Encodes a bool field
|
|
149
127
|
*
|
|
@@ -231,26 +209,6 @@ export const repeatedField = <T>(
|
|
|
231
209
|
encode: (value: T) => Uint8Array
|
|
232
210
|
): Uint8Array => concat(...values.map((v) => messageField(fieldNumber, encode(v))))
|
|
233
211
|
|
|
234
|
-
/**
|
|
235
|
-
* Encodes repeated varint fields (not packed)
|
|
236
|
-
*
|
|
237
|
-
* @internal
|
|
238
|
-
*/
|
|
239
|
-
export const repeatedVarintField = (
|
|
240
|
-
fieldNumber: number,
|
|
241
|
-
values: ReadonlyArray<number | bigint>
|
|
242
|
-
): Uint8Array => concat(...values.map((v) => varintField(fieldNumber, v)))
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Helper to conditionally encode an optional field
|
|
246
|
-
*
|
|
247
|
-
* @internal
|
|
248
|
-
*/
|
|
249
|
-
export const optionalField = <T>(
|
|
250
|
-
value: T | undefined,
|
|
251
|
-
encode: (v: T) => Uint8Array
|
|
252
|
-
): Uint8Array => value !== undefined ? encode(value) : new Uint8Array(0)
|
|
253
|
-
|
|
254
212
|
/**
|
|
255
213
|
* Helper to conditionally encode a string field if non-empty
|
|
256
214
|
*
|
|
@@ -695,7 +695,7 @@ const SchemaStoreTypeId = "~effect/persistence/KeyValueStore/SchemaStore" as con
|
|
|
695
695
|
* @category SchemaStore
|
|
696
696
|
* @since 4.0.0
|
|
697
697
|
*/
|
|
698
|
-
export interface SchemaStore<S extends Schema.
|
|
698
|
+
export interface SchemaStore<S extends Schema.Constraint> {
|
|
699
699
|
readonly [SchemaStoreTypeId]: typeof SchemaStoreTypeId
|
|
700
700
|
/**
|
|
701
701
|
* Returns the value of the specified key if it exists.
|
|
@@ -756,7 +756,7 @@ export interface SchemaStore<S extends Schema.Top> {
|
|
|
756
756
|
* @category SchemaStore
|
|
757
757
|
* @since 4.0.0
|
|
758
758
|
*/
|
|
759
|
-
export const toSchemaStore = <S extends Schema.
|
|
759
|
+
export const toSchemaStore = <S extends Schema.Constraint>(self: KeyValueStore, schema: S): SchemaStore<S> => {
|
|
760
760
|
const serializer = Schema.toCodecJson(schema)
|
|
761
761
|
const jsonSchema = Schema.fromJsonString(serializer)
|
|
762
762
|
const decode = Schema.decodeEffect(jsonSchema)
|
|
@@ -37,7 +37,7 @@ export const symbol = "~effect/persistence/Persistable" as const
|
|
|
37
37
|
* @category models
|
|
38
38
|
* @since 4.0.0
|
|
39
39
|
*/
|
|
40
|
-
export interface Persistable<A extends Schema.
|
|
40
|
+
export interface Persistable<A extends Schema.Constraint, E extends Schema.Constraint> extends PrimaryKey.PrimaryKey {
|
|
41
41
|
readonly [symbol]: {
|
|
42
42
|
readonly success: A
|
|
43
43
|
readonly error: E
|
|
@@ -50,7 +50,7 @@ export interface Persistable<A extends Schema.Top, E extends Schema.Top> extends
|
|
|
50
50
|
* @category models
|
|
51
51
|
* @since 4.0.0
|
|
52
52
|
*/
|
|
53
|
-
export type Any = Persistable<Schema.
|
|
53
|
+
export type Any = Persistable<Schema.Constraint, Schema.Constraint>
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Extracts the success schema from a persistable request.
|
|
@@ -147,8 +147,8 @@ export const Class = <
|
|
|
147
147
|
>() =>
|
|
148
148
|
<
|
|
149
149
|
const Tag extends string,
|
|
150
|
-
A extends Schema.
|
|
151
|
-
E extends Schema.
|
|
150
|
+
A extends Schema.Constraint = Schema.Void,
|
|
151
|
+
E extends Schema.Constraint = Schema.Never
|
|
152
152
|
>(tag: Tag, options: {
|
|
153
153
|
readonly primaryKey: (payload: Config["payload"]) => string
|
|
154
154
|
readonly success?: A | undefined
|
|
@@ -205,7 +205,7 @@ export const Class = <
|
|
|
205
205
|
* @category accessors
|
|
206
206
|
* @since 4.0.0
|
|
207
207
|
*/
|
|
208
|
-
export const exitSchema = <A extends Schema.
|
|
208
|
+
export const exitSchema = <A extends Schema.Constraint, E extends Schema.Constraint>(
|
|
209
209
|
self: Persistable<A, E>
|
|
210
210
|
): Schema.Exit<A, E, Schema.Defect> => {
|
|
211
211
|
let schema = exitSchemaCache.get(self)
|
|
@@ -224,7 +224,7 @@ const exitSchemaCache = new WeakMap<Persistable<any, any>, Schema.Exit<any, any,
|
|
|
224
224
|
* @category serialization
|
|
225
225
|
* @since 4.0.0
|
|
226
226
|
*/
|
|
227
|
-
export const serializeExit = <A extends Schema.
|
|
227
|
+
export const serializeExit = <A extends Schema.Constraint, E extends Schema.Constraint>(
|
|
228
228
|
self: Persistable<A, E>,
|
|
229
229
|
exit: Exit.Exit<A["Type"], E["Type"]>
|
|
230
230
|
): Effect.Effect<unknown, Schema.SchemaError, A["EncodingServices"] | E["EncodingServices"]> => {
|
|
@@ -239,7 +239,7 @@ export const serializeExit = <A extends Schema.Top, E extends Schema.Top>(
|
|
|
239
239
|
* @category serialization
|
|
240
240
|
* @since 4.0.0
|
|
241
241
|
*/
|
|
242
|
-
export const deserializeExit = <A extends Schema.
|
|
242
|
+
export const deserializeExit = <A extends Schema.Constraint, E extends Schema.Constraint>(
|
|
243
243
|
self: Persistable<A, E>,
|
|
244
244
|
encoded: unknown
|
|
245
245
|
): Effect.Effect<
|
|
@@ -104,7 +104,7 @@ export interface PersistedQueue<in out A, out R = never> {
|
|
|
104
104
|
export class PersistedQueueFactory extends Context.Service<
|
|
105
105
|
PersistedQueueFactory,
|
|
106
106
|
{
|
|
107
|
-
readonly make: <S extends Schema.
|
|
107
|
+
readonly make: <S extends Schema.Constraint>(options: {
|
|
108
108
|
readonly name: string
|
|
109
109
|
readonly schema: S
|
|
110
110
|
}) => Effect.Effect<PersistedQueue<S["Type"], S["EncodingServices"] | S["DecodingServices"]>>
|
|
@@ -118,7 +118,7 @@ export class PersistedQueueFactory extends Context.Service<
|
|
|
118
118
|
* @category accessors
|
|
119
119
|
* @since 4.0.0
|
|
120
120
|
*/
|
|
121
|
-
export const make = <S extends Schema.
|
|
121
|
+
export const make = <S extends Schema.Constraint>(options: {
|
|
122
122
|
readonly name: string
|
|
123
123
|
readonly schema: S
|
|
124
124
|
}): Effect.Effect<
|
|
@@ -143,7 +143,7 @@ export const makeFactory = Effect.gen(function*() {
|
|
|
143
143
|
const store = yield* PersistedQueueStore
|
|
144
144
|
|
|
145
145
|
return PersistedQueueFactory.of({
|
|
146
|
-
make<S extends Schema.
|
|
146
|
+
make<S extends Schema.Constraint>(options: {
|
|
147
147
|
readonly name: string
|
|
148
148
|
readonly schema: S
|
|
149
149
|
}) {
|