effect 4.0.0-beta.36 → 4.0.0-beta.38

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.
Files changed (125) hide show
  1. package/dist/Cause.d.ts +31 -0
  2. package/dist/Cause.d.ts.map +1 -1
  3. package/dist/Cause.js +19 -0
  4. package/dist/Cause.js.map +1 -1
  5. package/dist/Channel.d.ts +2 -2
  6. package/dist/Channel.d.ts.map +1 -1
  7. package/dist/Effect.d.ts +1 -16
  8. package/dist/Effect.d.ts.map +1 -1
  9. package/dist/Effect.js.map +1 -1
  10. package/dist/Schedule.d.ts.map +1 -1
  11. package/dist/Schedule.js +19 -1
  12. package/dist/Schedule.js.map +1 -1
  13. package/dist/Schema.d.ts +20 -48
  14. package/dist/Schema.d.ts.map +1 -1
  15. package/dist/Schema.js +9 -13
  16. package/dist/Schema.js.map +1 -1
  17. package/dist/SchemaAST.d.ts +5 -0
  18. package/dist/SchemaAST.d.ts.map +1 -1
  19. package/dist/SchemaAST.js.map +1 -1
  20. package/dist/SchemaParser.d.ts +22 -66
  21. package/dist/SchemaParser.d.ts.map +1 -1
  22. package/dist/SchemaParser.js +7 -2
  23. package/dist/SchemaParser.js.map +1 -1
  24. package/dist/Sink.d.ts +5 -2
  25. package/dist/Sink.d.ts.map +1 -1
  26. package/dist/Sink.js.map +1 -1
  27. package/dist/Stream.d.ts +1 -1
  28. package/dist/Stream.d.ts.map +1 -1
  29. package/dist/internal/effect.js +15 -1
  30. package/dist/internal/effect.js.map +1 -1
  31. package/dist/unstable/cli/Prompt.js +16 -6
  32. package/dist/unstable/cli/Prompt.js.map +1 -1
  33. package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
  34. package/dist/unstable/cluster/EntityAddress.js +1 -1
  35. package/dist/unstable/cluster/EntityAddress.js.map +1 -1
  36. package/dist/unstable/cluster/Runner.d.ts.map +1 -1
  37. package/dist/unstable/cluster/Runner.js +1 -1
  38. package/dist/unstable/cluster/Runner.js.map +1 -1
  39. package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
  40. package/dist/unstable/cluster/RunnerAddress.js +1 -1
  41. package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
  42. package/dist/unstable/cluster/ShardId.js +3 -3
  43. package/dist/unstable/cluster/ShardId.js.map +1 -1
  44. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  45. package/dist/unstable/devtools/DevToolsClient.js +4 -3
  46. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  47. package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -3
  48. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  49. package/dist/unstable/devtools/DevToolsSchema.js +11 -1
  50. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  51. package/dist/unstable/eventlog/EventJournal.js +2 -2
  52. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  53. package/dist/unstable/eventlog/EventLog.js +1 -1
  54. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  55. package/dist/unstable/eventlog/SqlEventLogJournal.js +2 -2
  56. package/dist/unstable/eventlog/SqlEventLogJournal.js.map +1 -1
  57. package/dist/unstable/http/HttpClientRequest.d.ts +24 -2
  58. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  59. package/dist/unstable/http/HttpClientRequest.js +97 -0
  60. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  61. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  62. package/dist/unstable/http/HttpServerResponse.js +2 -1
  63. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  64. package/dist/unstable/httpapi/HttpApiBuilder.js +9 -8
  65. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  66. package/dist/unstable/httpapi/HttpApiClient.d.ts +36 -20
  67. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  68. package/dist/unstable/httpapi/HttpApiClient.js +49 -18
  69. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  70. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +186 -67
  71. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  72. package/dist/unstable/httpapi/HttpApiEndpoint.js +44 -29
  73. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  74. package/dist/unstable/httpapi/HttpApiSchema.d.ts +5 -0
  75. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  76. package/dist/unstable/httpapi/HttpApiSchema.js +20 -2
  77. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  78. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  79. package/dist/unstable/httpapi/OpenApi.js +2 -5
  80. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  81. package/dist/unstable/reactivity/AtomHttpApi.d.ts +11 -7
  82. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  83. package/dist/unstable/reactivity/AtomHttpApi.js +6 -6
  84. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  85. package/dist/unstable/schema/VariantSchema.d.ts +1 -1
  86. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  87. package/dist/unstable/sql/Migrator.d.ts.map +1 -1
  88. package/dist/unstable/sql/Migrator.js +2 -2
  89. package/dist/unstable/sql/Migrator.js.map +1 -1
  90. package/dist/unstable/sql/SqlError.d.ts +229 -9
  91. package/dist/unstable/sql/SqlError.d.ts.map +1 -1
  92. package/dist/unstable/sql/SqlError.js +256 -6
  93. package/dist/unstable/sql/SqlError.js.map +1 -1
  94. package/package.json +1 -1
  95. package/src/Cause.ts +35 -0
  96. package/src/Channel.ts +2 -2
  97. package/src/Effect.ts +1 -16
  98. package/src/Schedule.ts +20 -8
  99. package/src/Schema.ts +14 -22
  100. package/src/SchemaAST.ts +6 -0
  101. package/src/SchemaParser.ts +32 -31
  102. package/src/Sink.ts +5 -2
  103. package/src/Stream.ts +1 -1
  104. package/src/internal/effect.ts +27 -2
  105. package/src/unstable/cli/Prompt.ts +15 -6
  106. package/src/unstable/cluster/EntityAddress.ts +1 -1
  107. package/src/unstable/cluster/Runner.ts +1 -1
  108. package/src/unstable/cluster/RunnerAddress.ts +1 -1
  109. package/src/unstable/cluster/ShardId.ts +2 -2
  110. package/src/unstable/devtools/DevToolsClient.ts +23 -18
  111. package/src/unstable/devtools/DevToolsSchema.ts +13 -1
  112. package/src/unstable/eventlog/EventJournal.ts +2 -2
  113. package/src/unstable/eventlog/EventLog.ts +1 -1
  114. package/src/unstable/eventlog/SqlEventLogJournal.ts +2 -2
  115. package/src/unstable/http/HttpClientRequest.ts +104 -2
  116. package/src/unstable/http/HttpServerResponse.ts +8 -4
  117. package/src/unstable/httpapi/HttpApiBuilder.ts +15 -9
  118. package/src/unstable/httpapi/HttpApiClient.ts +118 -55
  119. package/src/unstable/httpapi/HttpApiEndpoint.ts +164 -36
  120. package/src/unstable/httpapi/HttpApiSchema.ts +20 -2
  121. package/src/unstable/httpapi/OpenApi.ts +2 -6
  122. package/src/unstable/reactivity/AtomHttpApi.ts +22 -17
  123. package/src/unstable/schema/VariantSchema.ts +1 -1
  124. package/src/unstable/sql/Migrator.ts +7 -5
  125. package/src/unstable/sql/SqlError.ts +360 -8
package/src/Schedule.ts CHANGED
@@ -4053,14 +4053,26 @@ export const fibonacci = (one: Duration.Input): Schedule<Duration.Duration> => {
4053
4053
  */
4054
4054
  export const fixed = (interval: Duration.Input): Schedule<number> => {
4055
4055
  const window = Duration.toMillis(Duration.fromInputUnsafe(interval))
4056
- return fromStepWithMetadata(effect.succeed((meta) =>
4057
- effect.succeed([
4058
- meta.attempt - 1,
4059
- window === 0
4060
- ? Duration.zero
4061
- : Duration.millis(window - (meta.elapsed % window))
4062
- ])
4063
- ))
4056
+ return fromStepWithMetadata(effect.sync(() => {
4057
+ let start = 0
4058
+ let lastRun = 0
4059
+ return (meta) =>
4060
+ effect.sync(() => {
4061
+ if (window === 0) {
4062
+ return [meta.attempt - 1, Duration.zero] as const
4063
+ }
4064
+ if (meta.attempt === 1) {
4065
+ start = meta.now
4066
+ lastRun = meta.now + window
4067
+ return [0, Duration.millis(window)] as const
4068
+ }
4069
+ const runningBehind = meta.now > (lastRun + window)
4070
+ const boundary = window - ((meta.now - start) % window)
4071
+ const delay = runningBehind ? 0 : boundary === 0 ? window : boundary
4072
+ lastRun = runningBehind ? meta.now : meta.now + delay
4073
+ return [meta.attempt - 1, Duration.millis(delay)] as const
4074
+ })
4075
+ }))
4064
4076
  }
4065
4077
 
4066
4078
  /**
package/src/Schema.ts CHANGED
@@ -172,7 +172,7 @@ export type ConstructorDefault = "no-default" | "with-default"
172
172
  * Options for `makeUnsafe` and Class constructors.
173
173
  *
174
174
  * When to use:
175
- * - Pass `disableValidation: true` to skip validation when you trust the data.
175
+ * - Pass `disableChecks: true` to skip validation when you trust the data.
176
176
  * - Pass `parseOptions` to control error reporting behavior.
177
177
  *
178
178
  * @see {@link Bottom.makeUnsafe}
@@ -187,7 +187,7 @@ export interface MakeOptions {
187
187
  /**
188
188
  * Whether to disable validation for the schema.
189
189
  */
190
- readonly disableValidation?: boolean | undefined
190
+ readonly disableChecks?: boolean | undefined
191
191
  }
192
192
 
193
193
  /**
@@ -669,9 +669,7 @@ export declare namespace Codec {
669
669
  *
670
670
  * @since 4.0.0
671
671
  */
672
- export type ToAsserts<S extends Top & { readonly DecodingServices: never }> = <I>(
673
- input: I
674
- ) => asserts input is I & S["Type"]
672
+ export type ToAsserts<S extends Top> = <I>(input: I) => asserts input is I & S["Type"]
675
673
  }
676
674
 
677
675
  /**
@@ -943,9 +941,7 @@ function makeStandardResult<A>(exit: Exit_.Exit<StandardSchemaV1.Result<A>>): St
943
941
  * @category Standard Schema
944
942
  * @since 4.0.0
945
943
  */
946
- export function toStandardSchemaV1<
947
- S extends Top & { readonly DecodingServices: never }
948
- >(
944
+ export function toStandardSchemaV1<S extends Decoder<unknown>>(
949
945
  self: S,
950
946
  options?: {
951
947
  readonly leafHook?: Issue.LeafHook | undefined
@@ -1157,7 +1153,7 @@ export const decodeEffect: <S extends Top>(
1157
1153
  * @category Decoding
1158
1154
  * @since 4.0.0
1159
1155
  */
1160
- export function decodeUnknownExit<S extends Top & { readonly DecodingServices: never }>(schema: S) {
1156
+ export function decodeUnknownExit<S extends Decoder<unknown>>(schema: S) {
1161
1157
  const parser = Parser.decodeUnknownExit(schema)
1162
1158
  return (input: unknown, options?: AST.ParseOptions): Exit_.Exit<S["Type"], SchemaError> => {
1163
1159
  return Exit_.mapError(parser(input, options), (issue) => new SchemaError(issue))
@@ -1174,7 +1170,7 @@ export function decodeUnknownExit<S extends Top & { readonly DecodingServices: n
1174
1170
  * @category Decoding
1175
1171
  * @since 4.0.0
1176
1172
  */
1177
- export const decodeExit: <S extends Top & { readonly DecodingServices: never }>(
1173
+ export const decodeExit: <S extends Decoder<unknown>>(
1178
1174
  schema: S
1179
1175
  ) => (input: S["Encoded"], options?: AST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError> = decodeUnknownExit
1180
1176
 
@@ -1327,7 +1323,7 @@ export const encodeEffect: <S extends Top>(
1327
1323
  * @category Encoding
1328
1324
  * @since 4.0.0
1329
1325
  */
1330
- export function encodeUnknownExit<S extends Top & { readonly EncodingServices: never }>(schema: S) {
1326
+ export function encodeUnknownExit<S extends Encoder<unknown>>(schema: S) {
1331
1327
  const parser = Parser.encodeUnknownExit(schema)
1332
1328
  return (input: unknown, options?: AST.ParseOptions): Exit_.Exit<S["Encoded"], SchemaError> => {
1333
1329
  return Exit_.mapError(parser(input, options), (issue) => new SchemaError(issue))
@@ -1344,7 +1340,7 @@ export function encodeUnknownExit<S extends Top & { readonly EncodingServices: n
1344
1340
  * @category Encoding
1345
1341
  * @since 4.0.0
1346
1342
  */
1347
- export const encodeExit: <S extends Top & { readonly EncodingServices: never }>(
1343
+ export const encodeExit: <S extends Encoder<unknown>>(
1348
1344
  schema: S
1349
1345
  ) => (input: S["Type"], options?: AST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError> = encodeUnknownExit
1350
1346
 
@@ -9857,12 +9853,8 @@ function makeClass<
9857
9853
  return class extends Inherited {
9858
9854
  constructor(...[input, options]: ReadonlyArray<any>) {
9859
9855
  const props = input ?? {}
9860
- if (options?.disableValidation) {
9861
- super(props, options)
9862
- } else {
9863
- const validated = struct.makeUnsafe(props, options)
9864
- super({ ...props, ...validated }, { ...options, disableValidation: true })
9865
- }
9856
+ const validated = struct.makeUnsafe(props, options)
9857
+ super({ ...props, ...validated }, { ...options, disableChecks: true })
9866
9858
  }
9867
9859
 
9868
9860
  toString() {
@@ -10005,7 +9997,7 @@ function isStruct(schema: Struct.Fields | Struct<Struct.Fields>): schema is Stru
10005
9997
  /**
10006
9998
  * Creates a schema-backed class whose constructor validates input against a
10007
9999
  * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
10008
- * input (unless `disableValidation` is set in the options).
10000
+ * input (unless `disableChecks` is set in the options).
10009
10001
  *
10010
10002
  * Pass the desired class type as the first type parameter. The second optional
10011
10003
  * type parameter can be used to add nominal brands.
@@ -10050,7 +10042,7 @@ export const Class: {
10050
10042
  /**
10051
10043
  * Creates a schema-backed class whose constructor validates input against a
10052
10044
  * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
10053
- * input (unless `disableValidation` is set in the options).
10045
+ * input (unless `disableChecks` is set in the options).
10054
10046
  *
10055
10047
  * Pass the desired class type as the first type parameter. The second optional
10056
10048
  * type parameter can be used to add nominal brands.
@@ -10095,7 +10087,7 @@ export const Class: {
10095
10087
  /**
10096
10088
  * Creates a schema-backed class whose constructor validates input against a
10097
10089
  * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
10098
- * input (unless `disableValidation` is set in the options).
10090
+ * input (unless `disableChecks` is set in the options).
10099
10091
  *
10100
10092
  * Pass the desired class type as the first type parameter. The second optional
10101
10093
  * type parameter can be used to add nominal brands.
@@ -10143,7 +10135,7 @@ export const Class: {
10143
10135
  /**
10144
10136
  * Creates a schema-backed class whose constructor validates input against a
10145
10137
  * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
10146
- * input (unless `disableValidation` is set in the options).
10138
+ * input (unless `disableChecks` is set in the options).
10147
10139
  *
10148
10140
  * Pass the desired class type as the first type parameter. The second optional
10149
10141
  * type parameter can be used to add nominal brands.
package/src/SchemaAST.ts CHANGED
@@ -434,6 +434,12 @@ export interface ParseOptions {
434
434
  * default: "none"
435
435
  */
436
436
  readonly propertyOrder?: "none" | "original" | undefined
437
+
438
+ /**
439
+ * Whether to disable checks while still applying defaults and
440
+ * transformations.
441
+ */
442
+ readonly disableChecks?: boolean | undefined
437
443
  }
438
444
 
439
445
  /** @internal */
@@ -49,7 +49,12 @@ export function makeEffect<S extends Schema.Top>(schema: S) {
49
49
  const ast = recurDefaults(AST.toType(schema.ast))
50
50
  const parser = run<S["Type"], never>(ast)
51
51
  return (input: S["~type.make.in"], options?: Schema.MakeOptions): Effect.Effect<S["Type"], Issue.Issue> => {
52
- return parser(input, options?.parseOptions)
52
+ return parser(
53
+ input,
54
+ options?.disableChecks
55
+ ? options?.parseOptions ? { ...options.parseOptions, disableChecks: true } : { disableChecks: true }
56
+ : options?.parseOptions
57
+ )
53
58
  }
54
59
  }
55
60
 
@@ -84,10 +89,8 @@ export function makeUnsafe<S extends Schema.Top>(schema: S) {
84
89
  * @category Asserting
85
90
  * @since 4.0.0
86
91
  */
87
- export function is<S extends Schema.Top & { readonly DecodingServices: never }>(
88
- schema: S
89
- ): <I>(input: I) => input is I & S["Type"] {
90
- return _is<S["Type"]>(schema.ast)
92
+ export function is<T>(schema: Schema.Schema<T>): <I>(input: I) => input is I & T {
93
+ return _is<T>(schema.ast)
91
94
  }
92
95
 
93
96
  /** @internal */
@@ -113,11 +116,9 @@ export function _issue<T>(ast: AST.AST) {
113
116
  * @category Asserting
114
117
  * @since 4.0.0
115
118
  */
116
- export function asserts<S extends Schema.Top & { readonly DecodingServices: never }>(
117
- schema: S
118
- ) {
119
- const parser = asExit(run<S["Type"], never>(AST.toType(schema.ast)))
120
- return <I>(input: I): asserts input is I & S["Type"] => {
119
+ export function asserts<T>(schema: Schema.Schema<T>) {
120
+ const parser = asExit(run<T, never>(AST.toType(schema.ast)))
121
+ return <I>(input: I): asserts input is I & T => {
121
122
  const exit = parser(input, AST.defaultParseOptions)
122
123
  if (Exit.isFailure(exit)) {
123
124
  const issue = Cause.findError(exit.cause)
@@ -152,7 +153,7 @@ export const decodeEffect: <S extends Schema.Top>(
152
153
  * @category Decoding
153
154
  * @since 4.0.0
154
155
  */
155
- export function decodeUnknownPromise<S extends Schema.Top & { readonly DecodingServices: never }>(
156
+ export function decodeUnknownPromise<S extends Schema.Decoder<unknown>>(
156
157
  schema: S
157
158
  ): (input: unknown, options?: AST.ParseOptions) => Promise<S["Type"]> {
158
159
  return asPromise(decodeUnknownEffect(schema))
@@ -162,7 +163,7 @@ export function decodeUnknownPromise<S extends Schema.Top & { readonly DecodingS
162
163
  * @category Decoding
163
164
  * @since 4.0.0
164
165
  */
165
- export function decodePromise<S extends Schema.Top & { readonly DecodingServices: never }>(
166
+ export function decodePromise<S extends Schema.Decoder<unknown>>(
166
167
  schema: S
167
168
  ): (input: S["Encoded"], options?: AST.ParseOptions) => Promise<S["Type"]> {
168
169
  return asPromise(decodeEffect(schema))
@@ -172,7 +173,7 @@ export function decodePromise<S extends Schema.Top & { readonly DecodingServices
172
173
  * @category Decoding
173
174
  * @since 4.0.0
174
175
  */
175
- export function decodeUnknownExit<S extends Schema.Top & { readonly DecodingServices: never }>(
176
+ export function decodeUnknownExit<S extends Schema.Decoder<unknown>>(
176
177
  schema: S
177
178
  ): (input: unknown, options?: AST.ParseOptions) => Exit.Exit<S["Type"], Issue.Issue> {
178
179
  return asExit(decodeUnknownEffect(schema))
@@ -182,7 +183,7 @@ export function decodeUnknownExit<S extends Schema.Top & { readonly DecodingServ
182
183
  * @category Decoding
183
184
  * @since 4.0.0
184
185
  */
185
- export const decodeExit: <S extends Schema.Top & { readonly DecodingServices: never }>(
186
+ export const decodeExit: <S extends Schema.Decoder<unknown>>(
186
187
  schema: S
187
188
  ) => (input: S["Encoded"], options?: AST.ParseOptions) => Exit.Exit<S["Type"], Issue.Issue> = decodeUnknownExit
188
189
 
@@ -190,7 +191,7 @@ export const decodeExit: <S extends Schema.Top & { readonly DecodingServices: ne
190
191
  * @category Decoding
191
192
  * @since 4.0.0
192
193
  */
193
- export function decodeUnknownOption<S extends Schema.Top & { readonly DecodingServices: never }>(
194
+ export function decodeUnknownOption<S extends Schema.Decoder<unknown>>(
194
195
  schema: S
195
196
  ): (input: unknown, options?: AST.ParseOptions) => Option.Option<S["Type"]> {
196
197
  return asOption(decodeUnknownEffect(schema))
@@ -200,7 +201,7 @@ export function decodeUnknownOption<S extends Schema.Top & { readonly DecodingSe
200
201
  * @category Decoding
201
202
  * @since 4.0.0
202
203
  */
203
- export const decodeOption: <S extends Schema.Top & { readonly DecodingServices: never }>(
204
+ export const decodeOption: <S extends Schema.Decoder<unknown>>(
204
205
  schema: S
205
206
  ) => (input: S["Encoded"], options?: AST.ParseOptions) => Option.Option<S["Type"]> = decodeUnknownOption
206
207
 
@@ -208,7 +209,7 @@ export const decodeOption: <S extends Schema.Top & { readonly DecodingServices:
208
209
  * @category Decoding
209
210
  * @since 4.0.0
210
211
  */
211
- export function decodeUnknownResult<S extends Schema.Top & { readonly DecodingServices: never }>(
212
+ export function decodeUnknownResult<S extends Schema.Decoder<unknown>>(
212
213
  schema: S
213
214
  ): (input: unknown, options?: AST.ParseOptions) => Result.Result<S["Type"], Issue.Issue> {
214
215
  return asResult(decodeUnknownEffect(schema))
@@ -218,7 +219,7 @@ export function decodeUnknownResult<S extends Schema.Top & { readonly DecodingSe
218
219
  * @category Decoding
219
220
  * @since 4.0.0
220
221
  */
221
- export const decodeResult: <S extends Schema.Top & { readonly DecodingServices: never }>(
222
+ export const decodeResult: <S extends Schema.Decoder<unknown>>(
222
223
  schema: S
223
224
  ) => (input: S["Encoded"], options?: AST.ParseOptions) => Result.Result<S["Type"], Issue.Issue> = decodeUnknownResult
224
225
 
@@ -226,7 +227,7 @@ export const decodeResult: <S extends Schema.Top & { readonly DecodingServices:
226
227
  * @category Decoding
227
228
  * @since 4.0.0
228
229
  */
229
- export function decodeUnknownSync<S extends Schema.Top & { readonly DecodingServices: never }>(
230
+ export function decodeUnknownSync<S extends Schema.Decoder<unknown>>(
230
231
  schema: S
231
232
  ): (input: unknown, options?: AST.ParseOptions) => S["Type"] {
232
233
  return asSync(decodeUnknownEffect(schema))
@@ -236,7 +237,7 @@ export function decodeUnknownSync<S extends Schema.Top & { readonly DecodingServ
236
237
  * @category Decoding
237
238
  * @since 4.0.0
238
239
  */
239
- export const decodeSync: <S extends Schema.Top & { readonly DecodingServices: never }>(
240
+ export const decodeSync: <S extends Schema.Decoder<unknown>>(
240
241
  schema: S
241
242
  ) => (input: S["Encoded"], options?: AST.ParseOptions) => S["Type"] = decodeUnknownSync
242
243
 
@@ -263,7 +264,7 @@ export const encodeEffect: <S extends Schema.Top>(
263
264
  * @category Encoding
264
265
  * @since 4.0.0
265
266
  */
266
- export const encodeUnknownPromise = <S extends Schema.Top & { readonly EncodingServices: never }>(
267
+ export const encodeUnknownPromise = <S extends Schema.Encoder<unknown>>(
267
268
  schema: S
268
269
  ): (input: unknown, options?: AST.ParseOptions) => Promise<S["Encoded"]> => asPromise(encodeUnknownEffect(schema))
269
270
 
@@ -271,7 +272,7 @@ export const encodeUnknownPromise = <S extends Schema.Top & { readonly EncodingS
271
272
  * @category Encoding
272
273
  * @since 4.0.0
273
274
  */
274
- export const encodePromise: <S extends Schema.Top & { readonly EncodingServices: never }>(
275
+ export const encodePromise: <S extends Schema.Encoder<unknown>>(
275
276
  schema: S
276
277
  ) => (input: S["Type"], options?: AST.ParseOptions) => Promise<S["Encoded"]> = encodeUnknownPromise
277
278
 
@@ -279,7 +280,7 @@ export const encodePromise: <S extends Schema.Top & { readonly EncodingServices:
279
280
  * @category Encoding
280
281
  * @since 4.0.0
281
282
  */
282
- export function encodeUnknownExit<S extends Schema.Top & { readonly EncodingServices: never }>(
283
+ export function encodeUnknownExit<S extends Schema.Encoder<unknown>>(
283
284
  schema: S
284
285
  ): (input: unknown, options?: AST.ParseOptions) => Exit.Exit<S["Encoded"], Issue.Issue> {
285
286
  return asExit(encodeUnknownEffect(schema))
@@ -289,7 +290,7 @@ export function encodeUnknownExit<S extends Schema.Top & { readonly EncodingServ
289
290
  * @category Encoding
290
291
  * @since 4.0.0
291
292
  */
292
- export const encodeExit: <S extends Schema.Top & { readonly EncodingServices: never }>(
293
+ export const encodeExit: <S extends Schema.Encoder<unknown>>(
293
294
  schema: S
294
295
  ) => (input: S["Type"], options?: AST.ParseOptions) => Exit.Exit<S["Encoded"], Issue.Issue> = encodeUnknownExit
295
296
 
@@ -297,7 +298,7 @@ export const encodeExit: <S extends Schema.Top & { readonly EncodingServices: ne
297
298
  * @category Encoding
298
299
  * @since 4.0.0
299
300
  */
300
- export function encodeUnknownOption<S extends Schema.Top & { readonly EncodingServices: never }>(
301
+ export function encodeUnknownOption<S extends Schema.Encoder<unknown>>(
301
302
  schema: S
302
303
  ): (input: unknown, options?: AST.ParseOptions) => Option.Option<S["Encoded"]> {
303
304
  return asOption(encodeUnknownEffect(schema))
@@ -307,7 +308,7 @@ export function encodeUnknownOption<S extends Schema.Top & { readonly EncodingSe
307
308
  * @category Encoding
308
309
  * @since 4.0.0
309
310
  */
310
- export const encodeOption: <S extends Schema.Top & { readonly EncodingServices: never }>(
311
+ export const encodeOption: <S extends Schema.Encoder<unknown>>(
311
312
  schema: S
312
313
  ) => (input: S["Type"], options?: AST.ParseOptions) => Option.Option<S["Encoded"]> = encodeUnknownOption
313
314
 
@@ -315,7 +316,7 @@ export const encodeOption: <S extends Schema.Top & { readonly EncodingServices:
315
316
  * @category Encoding
316
317
  * @since 4.0.0
317
318
  */
318
- export function encodeUnknownResult<S extends Schema.Top & { readonly EncodingServices: never }>(
319
+ export function encodeUnknownResult<S extends Schema.Encoder<unknown>>(
319
320
  schema: S
320
321
  ): (input: unknown, options?: AST.ParseOptions) => Result.Result<S["Encoded"], Issue.Issue> {
321
322
  return asResult(encodeUnknownEffect(schema))
@@ -325,7 +326,7 @@ export function encodeUnknownResult<S extends Schema.Top & { readonly EncodingSe
325
326
  * @category Encoding
326
327
  * @since 4.0.0
327
328
  */
328
- export const encodeResult: <S extends Schema.Top & { readonly EncodingServices: never }>(
329
+ export const encodeResult: <S extends Schema.Encoder<unknown>>(
329
330
  schema: S
330
331
  ) => (input: S["Type"], options?: AST.ParseOptions) => Result.Result<S["Encoded"], Issue.Issue> = encodeUnknownResult
331
332
 
@@ -333,7 +334,7 @@ export const encodeResult: <S extends Schema.Top & { readonly EncodingServices:
333
334
  * @category Encoding
334
335
  * @since 4.0.0
335
336
  */
336
- export function encodeUnknownSync<S extends Schema.Top & { readonly EncodingServices: never }>(
337
+ export function encodeUnknownSync<S extends Schema.Encoder<unknown>>(
337
338
  schema: S
338
339
  ): (input: unknown, options?: AST.ParseOptions) => S["Encoded"] {
339
340
  return asSync(encodeUnknownEffect(schema))
@@ -343,7 +344,7 @@ export function encodeUnknownSync<S extends Schema.Top & { readonly EncodingServ
343
344
  * @category Encoding
344
345
  * @since 4.0.0
345
346
  */
346
- export const encodeSync: <S extends Schema.Top & { readonly EncodingServices: never }>(
347
+ export const encodeSync: <S extends Schema.Encoder<unknown>>(
347
348
  schema: S
348
349
  ) => (input: S["Type"], options?: AST.ParseOptions) => S["Encoded"] = encodeUnknownSync
349
350
 
@@ -449,7 +450,7 @@ const recur = memoize(
449
450
  parser ??= ast.getParser(recur)
450
451
  let sroa = srou ? Effect.flatMapEager(srou, (ou) => parser(ou, options)) : parser(ou, options)
451
452
 
452
- if (ast.checks) {
453
+ if (ast.checks && !options?.disableChecks) {
453
454
  const checks = ast.checks
454
455
  if (options?.errors === "all" && isStructural && Option.isSome(ou)) {
455
456
  sroa = Effect.catchEager(sroa, (issue) => {
package/src/Sink.ts CHANGED
@@ -63,6 +63,9 @@ export interface Sink<out A, in In = unknown, out L = never, out E = never, out
63
63
  upstream: Pull.Pull<NonEmptyReadonlyArray<In>, never, void>,
64
64
  scope: Scope.Scope
65
65
  ) => Effect.Effect<End<A, L>, E, R>
66
+ [Unify.typeSymbol]?: unknown
67
+ [Unify.unifySymbol]?: SinkUnify<this>
68
+ [Unify.ignoreSymbol]?: SinkUnifyIgnore
66
69
  }
67
70
 
68
71
  /**
@@ -122,8 +125,8 @@ export interface SinkUnify<A extends { [Unify.typeSymbol]?: any }> extends Effec
122
125
  * @category models
123
126
  * @since 2.0.0
124
127
  */
125
- export interface SinkUnifyIgnore extends Effect.EffectUnifyIgnore {
126
- Sink?: true
128
+ export interface SinkUnifyIgnore {
129
+ Effect?: true
127
130
  }
128
131
 
129
132
  /**
package/src/Stream.ts CHANGED
@@ -142,7 +142,7 @@ export interface StreamUnify<A extends { [Unify.typeSymbol]?: any }> extends Eff
142
142
  * @category Models
143
143
  * @since 2.0.0
144
144
  */
145
- export interface StreamUnifyIgnore extends Effect.EffectUnifyIgnore {
145
+ export interface StreamUnifyIgnore {
146
146
  Effect?: true
147
147
  }
148
148
 
@@ -5131,7 +5131,7 @@ export const runSyncExitWith = <R>(services: ServiceMap.ServiceMap<R>) => {
5131
5131
  const scheduler = new Scheduler.MixedScheduler("sync")
5132
5132
  const fiber = runFork(effect, { scheduler })
5133
5133
  fiber.currentDispatcher?.flush()
5134
- return (fiber as FiberImpl<A, E>)._exit ?? exitDie(fiber)
5134
+ return (fiber as FiberImpl<A, E>)._exit ?? exitDie(new AsyncFiberError(fiber))
5135
5135
  }
5136
5136
  }
5137
5137
 
@@ -5708,6 +5708,28 @@ export class ExceededCapacityError extends TaggedError("ExceededCapacityError")
5708
5708
  }
5709
5709
  }
5710
5710
 
5711
+ /** @internal */
5712
+ export const AsyncFiberErrorTypeId = "~effect/Cause/AsyncFiberError"
5713
+
5714
+ /** @internal */
5715
+ export const isAsyncFiberError = (
5716
+ u: unknown
5717
+ ): u is Cause.AsyncFiberError => hasProperty(u, AsyncFiberErrorTypeId)
5718
+
5719
+ /** @internal */
5720
+ export class AsyncFiberError extends TaggedError("AsyncFiberError")<{
5721
+ fiber: Fiber.Fiber<unknown, unknown>
5722
+ message: string
5723
+ }> {
5724
+ readonly [AsyncFiberErrorTypeId] = AsyncFiberErrorTypeId
5725
+ constructor(fiber: Fiber.Fiber<unknown, unknown>) {
5726
+ super({
5727
+ message: "An asynchronous Effect was executed with Effect.runSync",
5728
+ fiber
5729
+ })
5730
+ }
5731
+ }
5732
+
5711
5733
  /** @internal */
5712
5734
  export const UnknownErrorTypeId = "~effect/Cause/UnknownError"
5713
5735
 
@@ -5717,7 +5739,10 @@ export const isUnknownError = (
5717
5739
  ): u is Cause.UnknownError => hasProperty(u, UnknownErrorTypeId)
5718
5740
 
5719
5741
  /** @internal */
5720
- export class UnknownError extends TaggedError("UnknownError") {
5742
+ export class UnknownError extends TaggedError("UnknownError")<{
5743
+ cause: unknown
5744
+ message?: string | undefined
5745
+ }> {
5721
5746
  readonly [UnknownErrorTypeId] = UnknownErrorTypeId
5722
5747
  constructor(cause: unknown, message?: string) {
5723
5748
  super({ message, cause } as any)
@@ -2193,11 +2193,14 @@ const processSelection = Effect.fnUntraced(function*(state: FileState, options:
2193
2193
 
2194
2194
  const handleFileProcess = (options: FileOptionsReq) => {
2195
2195
  return Effect.fnUntraced(function*(input: Terminal.UserInput, state: FileState) {
2196
- if (input.key.ctrl && input.key.name === "u") {
2197
- if (showConfirmation(state.confirm)) {
2198
- return Action.Beep()
2196
+ if (input.key.ctrl) {
2197
+ if (input.key.name === "u") {
2198
+ if (showConfirmation(state.confirm)) {
2199
+ return Action.Beep()
2200
+ }
2201
+ return yield* processFileClear(state)
2199
2202
  }
2200
- return yield* processFileClear(state)
2203
+ return Action.Beep()
2201
2204
  }
2202
2205
  switch (input.key.name) {
2203
2206
  case "k":
@@ -3160,8 +3163,11 @@ const handleSelectProcess = <A>(options: SelectOptionsReq<A>) => {
3160
3163
 
3161
3164
  const handleAutoCompleteProcess = <A>(options: AutoCompleteOptionsReq<A>) => {
3162
3165
  return (input: Terminal.UserInput, state: AutoCompleteState) => {
3163
- if (input.key.ctrl && input.key.name === "u") {
3164
- return processAutoCompleteClear(state, options)
3166
+ if (input.key.ctrl) {
3167
+ if (input.key.name === "u") {
3168
+ return processAutoCompleteClear(state, options)
3169
+ }
3170
+ return Effect.succeed(Action.Beep())
3165
3171
  }
3166
3172
  switch (input.key.name) {
3167
3173
  case "k":
@@ -3423,6 +3429,9 @@ const handleTextProcess = (options: TextOptionsReq) => {
3423
3429
  case "e": {
3424
3430
  return processTextCursorEnd(state)
3425
3431
  }
3432
+ default: {
3433
+ return Effect.succeed(Action.Beep())
3434
+ }
3426
3435
  }
3427
3436
  }
3428
3437
  switch (input.key.name) {
@@ -56,4 +56,4 @@ export const make = (options: {
56
56
  readonly shardId: ShardId
57
57
  readonly entityType: EntityType
58
58
  readonly entityId: EntityId
59
- }): EntityAddress => new EntityAddress(options, { disableValidation: true })
59
+ }): EntityAddress => new EntityAddress(options, { disableChecks: true })
@@ -93,4 +93,4 @@ export const make = (props: {
93
93
  readonly address: RunnerAddress
94
94
  readonly groups: ReadonlyArray<string>
95
95
  readonly weight: number
96
- }): Runner => new Runner(props, { disableValidation: true })
96
+ }): Runner => new Runner(props, { disableChecks: true })
@@ -63,4 +63,4 @@ export class RunnerAddress extends Schema.Class<RunnerAddress>(TypeId)({
63
63
  * @category constructors
64
64
  */
65
65
  export const make = (host: string, port: number): RunnerAddress =>
66
- new RunnerAddress({ host, port }, { disableValidation: true })
66
+ new RunnerAddress({ host, port }, { disableChecks: true })
@@ -8,7 +8,7 @@ import * as S from "../../Schema.ts"
8
8
 
9
9
  const TypeId = "~effect/cluster/ShardId"
10
10
 
11
- const constDisableValidation = { disableValidation: true }
11
+ const constDisableChecks = { disableChecks: true }
12
12
 
13
13
  /**
14
14
  * @since 4.0.0
@@ -18,7 +18,7 @@ export const make = (group: string, id: number): ShardId => {
18
18
  const key = `${group}:${id}`
19
19
  let shardId = shardIdCache.get(key)
20
20
  if (!shardId) {
21
- shardId = new ShardId({ group, id }, constDisableValidation)
21
+ shardId = new ShardId({ group, id }, constDisableChecks)
22
22
  shardIdCache.set(key, shardId)
23
23
  }
24
24
  return shardId
@@ -4,6 +4,7 @@
4
4
  import * as Cause from "../../Cause.ts"
5
5
  import * as Deferred from "../../Deferred.ts"
6
6
  import * as Effect from "../../Effect.ts"
7
+ import * as Fiber from "../../Fiber.ts"
7
8
  import * as Layer from "../../Layer.ts"
8
9
  import * as Metric from "../../Metric.ts"
9
10
  import * as Queue from "../../Queue.ts"
@@ -23,9 +24,14 @@ const ResponseSchema = Schema.toCodecJson(DevToolsSchema.Response)
23
24
  * @since 4.0.0
24
25
  * @category tags
25
26
  */
26
- export class DevToolsClient extends ServiceMap.Service<DevToolsClient, {
27
- readonly sendUnsafe: (_: DevToolsSchema.Span | DevToolsSchema.SpanEvent) => void
28
- }>()("effect/devtools/DevToolsClient") {}
27
+ export class DevToolsClient extends ServiceMap.Service<
28
+ DevToolsClient,
29
+ {
30
+ readonly sendUnsafe: (
31
+ _: DevToolsSchema.Span | DevToolsSchema.SpanEvent
32
+ ) => void
33
+ }
34
+ >()("effect/devtools/DevToolsClient") {}
29
35
 
30
36
  const makeEffect = Effect.gen(function*() {
31
37
  const socket = yield* Socket.Socket
@@ -37,7 +43,9 @@ const makeEffect = Effect.gen(function*() {
37
43
  Queue.offerUnsafe(requests, toMetricsSnapshot(services))
38
44
  })
39
45
 
40
- const handleResponse = (response: DevToolsSchema.Response): Effect.Effect<void> => {
46
+ const handleResponse = (
47
+ response: DevToolsSchema.Response
48
+ ): Effect.Effect<void> => {
41
49
  switch (response._tag) {
42
50
  case "MetricsRequest": {
43
51
  return offerMetricsSnapshot
@@ -48,7 +56,7 @@ const makeEffect = Effect.gen(function*() {
48
56
  }
49
57
  }
50
58
 
51
- yield* Stream.fromQueue(requests).pipe(
59
+ const fiber = yield* Stream.fromQueue(requests).pipe(
52
60
  Stream.pipeThroughChannel(
53
61
  Ndjson.duplexSchemaString(Socket.toChannelString(socket), {
54
62
  inputSchema: RequestSchema,
@@ -57,12 +65,15 @@ const makeEffect = Effect.gen(function*() {
57
65
  ),
58
66
  Stream.onFirst(() => Deferred.completeWith(connected, Effect.void)),
59
67
  Stream.runForEach(handleResponse),
60
- Effect.forkScoped
68
+ Effect.forkDetach
61
69
  )
62
70
 
63
71
  yield* Effect.addFinalizer(() =>
64
72
  offerMetricsSnapshot.pipe(
65
- Effect.andThen(Effect.flatMap(Effect.fiberId, (id) => Queue.failCause(requests, Cause.interrupt(id))))
73
+ Effect.andThen(
74
+ Effect.flatMap(Effect.fiberId, (id) => Queue.failCause(requests, Cause.interrupt(id)))
75
+ ),
76
+ Effect.andThen(Fiber.await(fiber))
66
77
  )
67
78
  )
68
79
 
@@ -84,7 +95,9 @@ const makeEffect = Effect.gen(function*() {
84
95
  })
85
96
  })
86
97
 
87
- const toMetricsSnapshot = (services: ServiceMap.ServiceMap<never>): DevToolsSchema.MetricsSnapshot => ({
98
+ const toMetricsSnapshot = (
99
+ services: ServiceMap.ServiceMap<never>
100
+ ): DevToolsSchema.MetricsSnapshot => ({
88
101
  _tag: "MetricsSnapshot",
89
102
  metrics: Metric.snapshotUnsafe(services)
90
103
  })
@@ -108,11 +121,7 @@ export const make: Effect.Effect<
108
121
  * @since 4.0.0
109
122
  * @category layers
110
123
  */
111
- export const layer: Layer.Layer<
112
- DevToolsClient,
113
- never,
114
- Socket.Socket
115
- > = Layer.effect(DevToolsClient, make)
124
+ export const layer: Layer.Layer<DevToolsClient, never, Socket.Socket> = Layer.effect(DevToolsClient, make)
116
125
 
117
126
  const makeTracerEffect = Effect.gen(function*() {
118
127
  const client = yield* DevToolsClient
@@ -162,10 +171,6 @@ export const makeTracer: Effect.Effect<Tracer.Tracer, never, DevToolsClient> = m
162
171
  * @since 4.0.0
163
172
  * @category layers
164
173
  */
165
- export const layerTracer: Layer.Layer<
166
- never,
167
- never,
168
- Socket.Socket
169
- > = Layer.effect(Tracer.Tracer, makeTracer).pipe(
174
+ export const layerTracer: Layer.Layer<never, never, Socket.Socket> = Layer.effect(Tracer.Tracer, makeTracer).pipe(
170
175
  Layer.provide(layer)
171
176
  )