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.
Files changed (292) hide show
  1. package/dist/ChannelSchema.d.ts +8 -8
  2. package/dist/ChannelSchema.d.ts.map +1 -1
  3. package/dist/Config.d.ts +2 -2
  4. package/dist/Config.d.ts.map +1 -1
  5. package/dist/Config.js +10 -3
  6. package/dist/Config.js.map +1 -1
  7. package/dist/Context.d.ts.map +1 -1
  8. package/dist/Context.js +4 -3
  9. package/dist/Context.js.map +1 -1
  10. package/dist/Cron.d.ts.map +1 -1
  11. package/dist/Cron.js +4 -0
  12. package/dist/Cron.js.map +1 -1
  13. package/dist/Layer.js +4 -3
  14. package/dist/Layer.js.map +1 -1
  15. package/dist/LayerMap.d.ts.map +1 -1
  16. package/dist/LayerMap.js +4 -3
  17. package/dist/LayerMap.js.map +1 -1
  18. package/dist/Random.d.ts +31 -0
  19. package/dist/Random.d.ts.map +1 -1
  20. package/dist/Random.js +32 -0
  21. package/dist/Random.js.map +1 -1
  22. package/dist/Schema.d.ts +793 -399
  23. package/dist/Schema.d.ts.map +1 -1
  24. package/dist/Schema.js +121 -75
  25. package/dist/Schema.js.map +1 -1
  26. package/dist/SchemaAST.d.ts +8 -7
  27. package/dist/SchemaAST.d.ts.map +1 -1
  28. package/dist/SchemaAST.js +207 -157
  29. package/dist/SchemaAST.js.map +1 -1
  30. package/dist/SchemaParser.d.ts +24 -24
  31. package/dist/SchemaParser.d.ts.map +1 -1
  32. package/dist/SchemaParser.js +43 -39
  33. package/dist/SchemaParser.js.map +1 -1
  34. package/dist/SchemaRepresentation.d.ts +300 -300
  35. package/dist/internal/effect.js +16 -17
  36. package/dist/internal/effect.js.map +1 -1
  37. package/dist/internal/matcher.js +0 -2
  38. package/dist/internal/matcher.js.map +1 -1
  39. package/dist/internal/schema/arbitrary.js +17 -1
  40. package/dist/internal/schema/arbitrary.js.map +1 -1
  41. package/dist/internal/schema/representation.js +1 -5
  42. package/dist/internal/schema/representation.js.map +1 -1
  43. package/dist/internal/schema/schema.js.map +1 -1
  44. package/dist/internal/stackTraceLimit.d.ts +2 -0
  45. package/dist/internal/stackTraceLimit.d.ts.map +1 -0
  46. package/dist/internal/stackTraceLimit.js +40 -0
  47. package/dist/internal/stackTraceLimit.js.map +1 -0
  48. package/dist/internal/tracer.d.ts.map +1 -1
  49. package/dist/internal/tracer.js +4 -3
  50. package/dist/internal/tracer.js.map +1 -1
  51. package/dist/testing/TestSchema.d.ts +9 -9
  52. package/dist/testing/TestSchema.d.ts.map +1 -1
  53. package/dist/testing/TestSchema.js +3 -2
  54. package/dist/testing/TestSchema.js.map +1 -1
  55. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +2 -2
  56. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  57. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  58. package/dist/unstable/ai/Chat.d.ts +1 -1
  59. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  60. package/dist/unstable/ai/LanguageModel.d.ts +4 -4
  61. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  62. package/dist/unstable/ai/McpSchema.d.ts +13 -6
  63. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  64. package/dist/unstable/ai/McpSchema.js.map +1 -1
  65. package/dist/unstable/ai/McpServer.d.ts +4 -4
  66. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  67. package/dist/unstable/ai/McpServer.js.map +1 -1
  68. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +2 -2
  69. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  70. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  71. package/dist/unstable/ai/Response.d.ts +2 -2
  72. package/dist/unstable/ai/Response.d.ts.map +1 -1
  73. package/dist/unstable/ai/Response.js.map +1 -1
  74. package/dist/unstable/ai/Tool.d.ts +26 -26
  75. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  76. package/dist/unstable/ai/Tool.js +4 -5
  77. package/dist/unstable/ai/Tool.js.map +1 -1
  78. package/dist/unstable/cli/Argument.d.ts +8 -7
  79. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  80. package/dist/unstable/cli/Argument.js.map +1 -1
  81. package/dist/unstable/cli/Flag.d.ts +8 -7
  82. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  83. package/dist/unstable/cli/Flag.js.map +1 -1
  84. package/dist/unstable/cli/Param.d.ts +1806 -168
  85. package/dist/unstable/cli/Param.d.ts.map +1 -1
  86. package/dist/unstable/cli/Param.js +0 -70
  87. package/dist/unstable/cli/Param.js.map +1 -1
  88. package/dist/unstable/cli/Primitive.d.ts +3 -4
  89. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  90. package/dist/unstable/cli/Primitive.js.map +1 -1
  91. package/dist/unstable/cli/internal/ansi.d.ts.map +1 -1
  92. package/dist/unstable/cli/internal/ansi.js +0 -22
  93. package/dist/unstable/cli/internal/ansi.js.map +1 -1
  94. package/dist/unstable/cli/internal/config.d.ts +48 -0
  95. package/dist/unstable/cli/internal/config.d.ts.map +1 -1
  96. package/dist/unstable/cli/internal/config.js +0 -6
  97. package/dist/unstable/cli/internal/config.js.map +1 -1
  98. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -3
  99. package/dist/unstable/cluster/Reply.d.ts +2 -2
  100. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  101. package/dist/unstable/cluster/Reply.js.map +1 -1
  102. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  103. package/dist/unstable/encoding/Msgpack.d.ts +6 -6
  104. package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
  105. package/dist/unstable/encoding/Msgpack.js.map +1 -1
  106. package/dist/unstable/encoding/Ndjson.d.ts +8 -8
  107. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  108. package/dist/unstable/encoding/Sse.d.ts +1 -1
  109. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  110. package/dist/unstable/encoding/Sse.js.map +1 -1
  111. package/dist/unstable/eventlog/EventLogMessage.d.ts +22 -22
  112. package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
  113. package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
  114. package/dist/unstable/http/HttpBody.d.ts +1 -1
  115. package/dist/unstable/http/HttpBody.d.ts.map +1 -1
  116. package/dist/unstable/http/HttpClientRequest.d.ts +1 -1
  117. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  118. package/dist/unstable/http/HttpIncomingMessage.d.ts +1 -1
  119. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  120. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  121. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  122. package/dist/unstable/http/HttpMiddleware.js +12 -3
  123. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  124. package/dist/unstable/httpapi/HttpApi.d.ts +1 -1
  125. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  126. package/dist/unstable/httpapi/HttpApiClient.d.ts +2 -2
  127. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  128. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  129. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +32 -32
  130. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  131. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  132. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
  133. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  134. package/dist/unstable/httpapi/HttpApiMiddleware.js +4 -3
  135. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  136. package/dist/unstable/httpapi/HttpApiSchema.d.ts +13 -6
  137. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  138. package/dist/unstable/httpapi/HttpApiSchema.js +0 -13
  139. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  140. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  141. package/dist/unstable/observability/internal/otlpProtobuf.js +0 -68
  142. package/dist/unstable/observability/internal/otlpProtobuf.js.map +1 -1
  143. package/dist/unstable/observability/internal/protobuf.js +0 -28
  144. package/dist/unstable/observability/internal/protobuf.js.map +1 -1
  145. package/dist/unstable/persistence/KeyValueStore.d.ts +2 -2
  146. package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
  147. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  148. package/dist/unstable/persistence/Persistable.d.ts +6 -6
  149. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  150. package/dist/unstable/persistence/PersistedQueue.d.ts +3 -3
  151. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  152. package/dist/unstable/persistence/PersistedQueue.js +1 -1
  153. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  154. package/dist/unstable/persistence/Persistence.d.ts +5 -5
  155. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  156. package/dist/unstable/reactivity/AsyncResult.d.ts +2 -2
  157. package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
  158. package/dist/unstable/reactivity/Atom.d.ts +1 -1
  159. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  160. package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
  161. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  162. package/dist/unstable/rpc/Rpc.d.ts +3 -4
  163. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  164. package/dist/unstable/rpc/Rpc.js +1 -1
  165. package/dist/unstable/rpc/Rpc.js.map +1 -1
  166. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  167. package/dist/unstable/rpc/RpcClient.js +25 -4
  168. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  169. package/dist/unstable/rpc/RpcMessage.d.ts +7 -0
  170. package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
  171. package/dist/unstable/rpc/RpcMessage.js +20 -0
  172. package/dist/unstable/rpc/RpcMessage.js.map +1 -1
  173. package/dist/unstable/rpc/RpcMiddleware.d.ts +2 -2
  174. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  175. package/dist/unstable/rpc/RpcMiddleware.js +4 -3
  176. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  177. package/dist/unstable/rpc/RpcSchema.d.ts +10 -3
  178. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  179. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  180. package/dist/unstable/rpc/RpcWorker.d.ts +3 -3
  181. package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
  182. package/dist/unstable/schema/Model.d.ts +2 -2
  183. package/dist/unstable/schema/Model.d.ts.map +1 -1
  184. package/dist/unstable/schema/Model.js.map +1 -1
  185. package/dist/unstable/schema/VariantSchema.d.ts +16 -2
  186. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  187. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  188. package/dist/unstable/sql/SqlConnection.d.ts +1 -0
  189. package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
  190. package/dist/unstable/sql/SqlConnection.js.map +1 -1
  191. package/dist/unstable/sql/SqlModel.js.map +1 -1
  192. package/dist/unstable/sql/SqlResolver.d.ts +4 -4
  193. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  194. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  195. package/dist/unstable/sql/SqlSchema.d.ts +5 -5
  196. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  197. package/dist/unstable/sql/Statement.d.ts +1 -0
  198. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  199. package/dist/unstable/sql/Statement.js +3 -0
  200. package/dist/unstable/sql/Statement.js.map +1 -1
  201. package/dist/unstable/workflow/Activity.d.ts +2 -2
  202. package/dist/unstable/workflow/Activity.d.ts.map +1 -1
  203. package/dist/unstable/workflow/DurableDeferred.d.ts +18 -18
  204. package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
  205. package/dist/unstable/workflow/Workflow.d.ts +3 -3
  206. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  207. package/dist/unstable/workflow/Workflow.js.map +1 -1
  208. package/dist/unstable/workflow/WorkflowEngine.d.ts +3 -3
  209. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  210. package/package.json +1 -1
  211. package/src/ChannelSchema.ts +9 -9
  212. package/src/Config.ts +12 -5
  213. package/src/Context.ts +4 -5
  214. package/src/Cron.ts +4 -0
  215. package/src/Layer.ts +4 -4
  216. package/src/LayerMap.ts +4 -3
  217. package/src/Random.ts +42 -0
  218. package/src/Schema.ts +1038 -710
  219. package/src/SchemaAST.ts +239 -169
  220. package/src/SchemaParser.ts +85 -77
  221. package/src/internal/effect.ts +17 -33
  222. package/src/internal/matcher.ts +0 -5
  223. package/src/internal/schema/arbitrary.ts +24 -3
  224. package/src/internal/schema/representation.ts +1 -5
  225. package/src/internal/schema/schema.ts +1 -1
  226. package/src/internal/stackTraceLimit.ts +63 -0
  227. package/src/internal/tracer.ts +4 -3
  228. package/src/testing/TestSchema.ts +14 -13
  229. package/src/unstable/ai/AnthropicStructuredOutput.ts +2 -2
  230. package/src/unstable/ai/Chat.ts +1 -1
  231. package/src/unstable/ai/LanguageModel.ts +7 -7
  232. package/src/unstable/ai/McpSchema.ts +16 -14
  233. package/src/unstable/ai/McpServer.ts +7 -7
  234. package/src/unstable/ai/OpenAiStructuredOutput.ts +2 -2
  235. package/src/unstable/ai/Response.ts +9 -5
  236. package/src/unstable/ai/Tool.ts +53 -50
  237. package/src/unstable/cli/Argument.ts +9 -8
  238. package/src/unstable/cli/Flag.ts +9 -8
  239. package/src/unstable/cli/Param.ts +6 -146
  240. package/src/unstable/cli/Primitive.ts +5 -6
  241. package/src/unstable/cli/internal/ansi.ts +0 -33
  242. package/src/unstable/cli/internal/config.ts +0 -8
  243. package/src/unstable/cli/internal/parser.ts +2 -2
  244. package/src/unstable/cluster/MessageStorage.ts +1 -1
  245. package/src/unstable/cluster/Reply.ts +6 -2
  246. package/src/unstable/devtools/DevToolsSchema.ts +1 -1
  247. package/src/unstable/encoding/Msgpack.ts +9 -7
  248. package/src/unstable/encoding/Ndjson.ts +10 -10
  249. package/src/unstable/encoding/Sse.ts +1 -1
  250. package/src/unstable/eventlog/Event.ts +3 -3
  251. package/src/unstable/http/HttpBody.ts +1 -1
  252. package/src/unstable/http/HttpClientRequest.ts +1 -1
  253. package/src/unstable/http/HttpIncomingMessage.ts +1 -1
  254. package/src/unstable/http/HttpMiddleware.ts +12 -3
  255. package/src/unstable/httpapi/HttpApi.ts +1 -1
  256. package/src/unstable/httpapi/HttpApiBuilder.ts +9 -5
  257. package/src/unstable/httpapi/HttpApiClient.ts +10 -10
  258. package/src/unstable/httpapi/HttpApiEndpoint.ts +45 -33
  259. package/src/unstable/httpapi/HttpApiMiddleware.ts +6 -5
  260. package/src/unstable/httpapi/HttpApiSchema.ts +16 -43
  261. package/src/unstable/httpapi/OpenApi.ts +5 -5
  262. package/src/unstable/observability/internal/otlpProtobuf.ts +0 -75
  263. package/src/unstable/observability/internal/protobuf.ts +0 -42
  264. package/src/unstable/persistence/KeyValueStore.ts +2 -2
  265. package/src/unstable/persistence/Persistable.ts +7 -7
  266. package/src/unstable/persistence/PersistedQueue.ts +4 -4
  267. package/src/unstable/persistence/Persistence.ts +5 -5
  268. package/src/unstable/reactivity/AsyncResult.ts +4 -4
  269. package/src/unstable/reactivity/Atom.ts +1 -1
  270. package/src/unstable/reactivity/AtomHttpApi.ts +1 -1
  271. package/src/unstable/rpc/Rpc.ts +7 -8
  272. package/src/unstable/rpc/RpcClient.ts +26 -4
  273. package/src/unstable/rpc/RpcMessage.ts +19 -0
  274. package/src/unstable/rpc/RpcMiddleware.ts +6 -5
  275. package/src/unstable/rpc/RpcSchema.ts +12 -9
  276. package/src/unstable/rpc/RpcWorker.ts +3 -3
  277. package/src/unstable/schema/Model.ts +2 -2
  278. package/src/unstable/schema/VariantSchema.ts +19 -17
  279. package/src/unstable/sql/SqlConnection.ts +5 -0
  280. package/src/unstable/sql/SqlModel.ts +2 -2
  281. package/src/unstable/sql/SqlResolver.ts +6 -6
  282. package/src/unstable/sql/SqlSchema.ts +5 -5
  283. package/src/unstable/sql/Statement.ts +11 -0
  284. package/src/unstable/workflow/Activity.ts +6 -6
  285. package/src/unstable/workflow/DurableDeferred.ts +33 -33
  286. package/src/unstable/workflow/Workflow.ts +5 -5
  287. package/src/unstable/workflow/WorkflowEngine.ts +10 -10
  288. package/dist/internal/concurrency.d.ts +0 -2
  289. package/dist/internal/concurrency.d.ts.map +0 -1
  290. package/dist/internal/concurrency.js +0 -29
  291. package/dist/internal/concurrency.js.map +0 -1
  292. package/src/internal/concurrency.ts +0 -52
package/src/Schema.ts CHANGED
@@ -126,19 +126,13 @@ export interface MakeOptions {
126
126
 
127
127
  /**
128
128
  * The fully-parameterized base interface for all schemas. Exposes all 14 type
129
- * parameters controlling type inference, mutability, optionality, services,
130
- * and transformation behavior.
129
+ * parameters controlling type inference, mutability, optionality, services, and
130
+ * transformation behavior.
131
131
  *
132
132
  * **When to use**
133
133
  *
134
- * Use when you are writing advanced generic schema utilities or performing schema
135
- * introspection.
136
- * - In user code, prefer {@link Schema}, {@link Codec}, {@link Decoder}, or
137
- * {@link Encoder} instead.
138
- *
139
- * @see {@link Top} — the existential "any schema" type (erased type params)
140
- * @see {@link Schema} — tracks only the decoded Type
141
- * @see {@link Codec} — tracks Type + Encoded
134
+ * Use when you are writing advanced generic schema utilities or performing
135
+ * schema introspection.
142
136
  *
143
137
  * @category models
144
138
  * @since 4.0.0
@@ -152,7 +146,7 @@ export interface Bottom<
152
146
  out Rebuild extends Top,
153
147
  out TypeMakeIn = T,
154
148
  out Iso = T,
155
- in out TypeParameters extends ReadonlyArray<Top> = readonly [],
149
+ in out TypeParameters extends ReadonlyArray<Constraint> = readonly [],
156
150
  out TypeMake = TypeMakeIn,
157
151
  out TypeMutability extends Mutability = "readonly",
158
152
  out TypeOptionality extends Optionality = "required",
@@ -248,13 +242,67 @@ export interface Bottom<
248
242
  makeEffect(input: this["~type.make.in"], options?: MakeOptions): Effect.Effect<this["Type"], SchemaError>
249
243
  }
250
244
 
245
+ /**
246
+ * Lazy `Bottom` variant for schema implementations that compute their public
247
+ * views on demand.
248
+ *
249
+ * **When to use**
250
+ *
251
+ * Use as an implementation base for schema interfaces that must expose
252
+ * `Bottom` behavior without forcing TypeScript to eagerly evaluate expensive
253
+ * `Type`, `Encoded`, or service views.
254
+ *
255
+ * **Details**
256
+ *
257
+ * The laziness is purely type-level; runtime behavior is unchanged.
258
+ * `BottomLazy` keeps the structural operations inherited from `Bottom`, but
259
+ * erases the expensive schema views to `unknown`. Concrete schema interfaces can
260
+ * then redeclare the precise views they expose. This keeps wide schemas such as
261
+ * `Struct` and `Union` cheaper when generic code reads a single view, while
262
+ * preserving their exact public types.
263
+ *
264
+ * @see {@link Bottom} for the fully parameterized schema interface when every
265
+ * view must be supplied directly.
266
+ *
267
+ * @category utility types
268
+ * @since 4.0.0
269
+ */
270
+ export interface BottomLazy<
271
+ out Ast extends SchemaAST.AST,
272
+ out Rebuild extends Top,
273
+ in out TypeParameters extends ReadonlyArray<Constraint> = readonly [],
274
+ out TypeMutability extends Mutability = "readonly",
275
+ out TypeOptionality extends Optionality = "required",
276
+ out TypeConstructorDefault extends ConstructorDefault = "no-default",
277
+ out EncodedMutability extends Mutability = "readonly",
278
+ out EncodedOptionality extends Optionality = "required"
279
+ > extends
280
+ Bottom<
281
+ unknown,
282
+ unknown,
283
+ unknown,
284
+ unknown,
285
+ Ast,
286
+ Rebuild,
287
+ unknown,
288
+ unknown,
289
+ TypeParameters,
290
+ unknown,
291
+ TypeMutability,
292
+ TypeOptionality,
293
+ TypeConstructorDefault,
294
+ EncodedMutability,
295
+ EncodedOptionality
296
+ >
297
+ {}
298
+
251
299
  /**
252
300
  * Type-level representation returned by {@link declareConstructor}.
253
301
  *
254
302
  * @category constructors
255
303
  * @since 4.0.0
256
304
  */
257
- export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<Top>, Iso = T> extends
305
+ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<Constraint>, Iso = T> extends
258
306
  Bottom<
259
307
  T,
260
308
  E,
@@ -301,7 +349,7 @@ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<T
301
349
  * const isBox = (u: unknown): u is Box<unknown> =>
302
350
  * typeof u === "object" && u !== null && "value" in u
303
351
  *
304
- * const Box = <A extends Schema.Top>(item: A) =>
352
+ * const Box = <A extends Schema.Constraint>(item: A) =>
305
353
  * Schema.declareConstructor<Box<A["Type"]>, Box<A["Encoded"]>>()(
306
354
  * [item],
307
355
  * ([itemCodec]) =>
@@ -323,7 +371,7 @@ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<T
323
371
  * @since 4.0.0
324
372
  */
325
373
  export function declareConstructor<T, E = T, Iso = T>() {
326
- return <const TypeParameters extends ReadonlyArray<Top>>(
374
+ return <const TypeParameters extends ReadonlyArray<Constraint>>(
327
375
  typeParameters: TypeParameters,
328
376
  run: (
329
377
  typeParameters: {
@@ -566,8 +614,8 @@ export function annotateKey<S extends Top>(annotations: Annotations.Key<S["Type"
566
614
  * In user code prefer the narrower interfaces:
567
615
  * - {@link Schema}`<T>` — when you only care about the decoded type
568
616
  * - {@link Codec}`<T, E, RD, RE>` — when you need the encoded type and service requirements
569
- * - {@link Decoder}`<T, RD>` — for decode-only APIs
570
- * - {@link Encoder}`<E, RE>` — for encode-only APIs
617
+ * - {@link ConstraintDecoder}`<T, RD>` — for decode-only APIs
618
+ * - {@link ConstraintEncoder}`<E, RE>` — for encode-only APIs
571
619
  *
572
620
  * @category models
573
621
  * @since 4.0.0
@@ -592,6 +640,127 @@ export interface Top extends
592
640
  >
593
641
  {}
594
642
 
643
+ /**
644
+ * Lightweight structural constraint for APIs that accept schema values but only
645
+ * read their data and type-level views.
646
+ *
647
+ * **When to use**
648
+ *
649
+ * Use when you need to constrain a generic value to be a schema, but the API
650
+ * only reads properties such as `ast`, `Type`, `Encoded`, service
651
+ * requirements, constructor input views, or modifier flags.
652
+ *
653
+ * **Details**
654
+ *
655
+ * `Constraint` keeps the schema type identifier and the property surface needed
656
+ * by schema constructors, while avoiding the full `Bottom` protocol. Use
657
+ * {@link Top} when an API calls schema methods such as `annotate`, `check`,
658
+ * `rebuild`, `make`, or `makeEffect`.
659
+ *
660
+ * @see {@link Top} for the complete schema protocol.
661
+ *
662
+ * @category models
663
+ * @since 4.0.0
664
+ */
665
+ export interface Constraint {
666
+ readonly [TypeId]: typeof TypeId
667
+ readonly "ast": SchemaAST.AST
668
+
669
+ readonly "Type": unknown
670
+ readonly "Encoded": unknown
671
+ readonly "DecodingServices": unknown
672
+ readonly "EncodingServices": unknown
673
+
674
+ readonly "~type.parameters": any
675
+ readonly "~type.make.in": unknown
676
+ readonly "~type.make": unknown
677
+ readonly "Iso": unknown
678
+
679
+ readonly "~type.optionality": Optionality
680
+ readonly "~type.mutability": Mutability
681
+ readonly "~type.constructor.default": ConstructorDefault
682
+ readonly "~encoded.optionality": Optionality
683
+ readonly "~encoded.mutability": Mutability
684
+ }
685
+
686
+ /**
687
+ * Lightweight structural constraint for APIs that need codec type views but do
688
+ * not need the full schema protocol.
689
+ *
690
+ * **When to use**
691
+ *
692
+ * Use when you need to preserve decoded type, encoded type, and service
693
+ * requirements for a schema value, but the API does not call schema methods
694
+ * such as `annotate`, `check`, `rebuild`, `make`, or `makeEffect`.
695
+ *
696
+ * @see {@link Constraint} for the generic lightweight schema constraint.
697
+ * @see {@link Codec} for the full schema protocol with codec type views.
698
+ *
699
+ * @category models
700
+ * @since 4.0.0
701
+ */
702
+ export interface ConstraintCodec<out T, out E = T, out RD = never, out RE = never> extends Constraint {
703
+ readonly "Type": T
704
+ readonly "Encoded": E
705
+ readonly "DecodingServices": RD
706
+ readonly "EncodingServices": RE
707
+ }
708
+
709
+ /**
710
+ * Lightweight structural constraint for APIs that need decoder type views but
711
+ * do not need the full schema protocol.
712
+ *
713
+ * **When to use**
714
+ *
715
+ * Use when you need to preserve a schema's decoded type and decoding services,
716
+ * but the API does not constrain the encoded type, encoding services, or call
717
+ * schema methods such as `annotate`, `check`, `rebuild`, `make`, or
718
+ * `makeEffect`.
719
+ *
720
+ * @see {@link ConstraintCodec} for APIs that need both decoded and encoded codec views.
721
+ * @see {@link Codec} for the full schema protocol with codec type views.
722
+ *
723
+ * @category models
724
+ * @since 4.0.0
725
+ */
726
+ export interface ConstraintDecoder<out T, out RD = never> extends ConstraintCodec<T, unknown, RD, unknown> {}
727
+
728
+ /**
729
+ * Lightweight structural constraint for APIs that need encoder type views but
730
+ * do not need the full schema protocol.
731
+ *
732
+ * **When to use**
733
+ *
734
+ * Use when you need to preserve a schema's encoded type and encoding services,
735
+ * but the API does not constrain the decoded type, decoding services, or call
736
+ * schema methods such as `annotate`, `check`, `rebuild`, `make`, or
737
+ * `makeEffect`.
738
+ *
739
+ * @see {@link ConstraintCodec} for APIs that need both decoded and encoded codec views.
740
+ * @see {@link Codec} for the full schema protocol with codec type views.
741
+ *
742
+ * @category models
743
+ * @since 4.0.0
744
+ */
745
+ export interface ConstraintEncoder<out E, out RE = never> extends ConstraintCodec<unknown, E, unknown, RE> {}
746
+
747
+ /**
748
+ * Lightweight structural constraint for APIs that need schema views and the
749
+ * rebuilt schema type, but do not call the full schema protocol.
750
+ *
751
+ * **When to use**
752
+ *
753
+ * Use when an API needs to read `Rebuild` in addition to the schema views
754
+ * exposed by {@link Constraint}, but does not call methods such as `annotate`,
755
+ * `check`, `rebuild`, `make`, or `makeEffect`.
756
+ *
757
+ * @category models
758
+ * @since 4.0.0
759
+ */
760
+ export interface ConstraintRebuildable extends Constraint {
761
+ readonly "Rebuild": Constraint
762
+ }
763
+
595
764
  /**
596
765
  * Namespace of type-level helpers for {@link Schema}.
597
766
  *
@@ -614,7 +783,7 @@ export declare namespace Schema {
614
783
  * @category utility types
615
784
  * @since 3.10.0
616
785
  */
617
- export type Type<S> = S extends Top ? S["Type"] : never
786
+ export type Type<S> = S extends { readonly "Type": infer T } ? T : never
618
787
  }
619
788
 
620
789
  /**
@@ -674,7 +843,8 @@ export declare namespace Codec {
674
843
  * @category utility types
675
844
  * @since 3.10.0
676
845
  */
677
- export type Encoded<S> = S extends Top ? S["Encoded"] : never
846
+ export type Encoded<S> = S extends { readonly "Encoded": infer E } ? E : never
847
+
678
848
  /**
679
849
  * Extracts the Effect services required during *decoding* from a schema.
680
850
  *
@@ -691,7 +861,8 @@ export declare namespace Codec {
691
861
  * @category utility types
692
862
  * @since 4.0.0
693
863
  */
694
- export type DecodingServices<S> = S extends Top ? S["DecodingServices"] : never
864
+ export type DecodingServices<S> = S extends { readonly "DecodingServices": infer R } ? R : never
865
+
695
866
  /**
696
867
  * Extracts the Effect services required during *encoding* from a schema.
697
868
  *
@@ -708,7 +879,7 @@ export declare namespace Codec {
708
879
  * @category utility types
709
880
  * @since 4.0.0
710
881
  */
711
- export type EncodingServices<S> = S extends Top ? S["EncodingServices"] : never
882
+ export type EncodingServices<S> = S extends { readonly "EncodingServices": infer R } ? R : never
712
883
  }
713
884
 
714
885
  /**
@@ -747,8 +918,8 @@ export interface Optic<out T, out Iso> extends Schema<T> {
747
918
  * Most concrete schemas produced by this module implement `Codec`.
748
919
  *
749
920
  * For APIs that only need one direction, prefer the narrower views:
750
- * - {@link Decoder}`<T, RD>` — decode-only
751
- * - {@link Encoder}`<E, RE>` — encode-only
921
+ * - {@link ConstraintDecoder}`<T, RD>` — decode-only
922
+ * - {@link ConstraintEncoder}`<E, RE>` — encode-only
752
923
  * - {@link Schema}`<T>` — type-only (no encoded representation)
753
924
  *
754
925
  * **Example** (Accepting a codec that decodes to `number` from `string`)
@@ -776,60 +947,6 @@ export interface Codec<out T, out E = T, out RD = never, out RE = never> extends
776
947
  readonly "Rebuild": Codec<T, E, RD, RE>
777
948
  }
778
949
 
779
- /**
780
- * A {@link Codec} view for APIs that only *decode* (parse/validate) values.
781
- *
782
- * **Details**
783
- *
784
- * Use `Decoder<T, RD>` to accept "any schema that can decode to `T`" without
785
- * constraining or depending on the encoded representation (`Encoded` is
786
- * `unknown`) or encoding services.
787
- *
788
- * **Example** (Accepting schemas that only need to decode)
789
- *
790
- * ```ts
791
- * import { Schema } from "effect"
792
- *
793
- * declare function validate<T>(decoder: Schema.Decoder<T>): (input: unknown) => T
794
- *
795
- * validate(Schema.String) // ok
796
- * validate(Schema.NumberFromString) // ok
797
- * ```
798
- *
799
- * @category models
800
- * @since 4.0.0
801
- */
802
- export interface Decoder<out T, out RD = never> extends Codec<T, unknown, RD, unknown> {
803
- readonly "Rebuild": Decoder<T, RD>
804
- }
805
-
806
- /**
807
- * A {@link Codec} view for APIs that only *encode* values.
808
- *
809
- * **Details**
810
- *
811
- * Use `Encoder<E, RE>` to accept "any schema that can encode to `E`" without
812
- * constraining or depending on the decoded `Type` (`Type` is `unknown`) or
813
- * decoding services.
814
- *
815
- * **Example** (Accepting schemas that only need to encode)
816
- *
817
- * ```ts
818
- * import { Schema } from "effect"
819
- *
820
- * declare function serialize<E>(encoder: Schema.Encoder<E>): (value: unknown) => E
821
- *
822
- * serialize(Schema.String) // ok — encodes to string
823
- * serialize(Schema.NumberFromString) // ok — encodes number to string
824
- * ```
825
- *
826
- * @category models
827
- * @since 4.0.0
828
- */
829
- export interface Encoder<out E, out RE = never> extends Codec<unknown, E, unknown, RE> {
830
- readonly "Rebuild": Encoder<E, RE>
831
- }
832
-
833
950
  /**
834
951
  * Returns a codec widened to the full {@link Codec} interface, prompting
835
952
  * TypeScript to infer all four type parameters (`T`, `E`, `RD`, `RE`).
@@ -987,7 +1104,7 @@ function makeStandardResult<A>(exit: Exit_.Exit<StandardSchemaV1.Result<A>>): St
987
1104
  * @category Standard Schema
988
1105
  * @since 4.0.0
989
1106
  */
990
- export function toStandardSchemaV1<S extends Decoder<unknown>>(
1107
+ export function toStandardSchemaV1<S extends ConstraintDecoder<unknown>>(
991
1108
  self: S,
992
1109
  options?: {
993
1110
  readonly leafHook?: SchemaIssue.LeafHook | undefined
@@ -1037,7 +1154,7 @@ export function toStandardSchemaV1<S extends Decoder<unknown>>(
1037
1154
  }
1038
1155
  }
1039
1156
 
1040
- function toBaseStandardJSONSchemaV1(self: Top, target: StandardJSONSchemaV1.Target): JsonSchema.JsonSchema {
1157
+ function toBaseStandardJSONSchemaV1(self: Constraint, target: StandardJSONSchemaV1.Target): JsonSchema.JsonSchema {
1041
1158
  const doc2020_12 = toJsonSchemaDocument(self)
1042
1159
  if (target === "draft-2020-12") {
1043
1160
  const schema = doc2020_12.schema
@@ -1066,7 +1183,9 @@ function toBaseStandardJSONSchemaV1(self: Top, target: StandardJSONSchemaV1.Targ
1066
1183
  * @category Standard Schema
1067
1184
  * @since 4.0.0
1068
1185
  */
1069
- export function toStandardJSONSchemaV1<S extends Top>(self: S): StandardJSONSchemaV1<S["Encoded"], S["Type"]> & S {
1186
+ export function toStandardJSONSchemaV1<S extends Constraint>(
1187
+ self: S
1188
+ ): StandardJSONSchemaV1<S["Encoded"], S["Type"]> & S {
1070
1189
  const jsonSchema: StandardJSONSchemaV1.Props<S["Encoded"], S["Type"]>["jsonSchema"] = {
1071
1190
  input(options) {
1072
1191
  return toBaseStandardJSONSchemaV1(self, options.target)
@@ -1173,7 +1292,8 @@ export const is = SchemaParser.is
1173
1292
  * @category guards
1174
1293
  * @since 4.0.0
1175
1294
  */
1176
- export const asserts: <S extends Top, I>(schema: S, input: I) => asserts input is I & S["Type"] = SchemaParser.asserts
1295
+ export const asserts: <S extends Constraint, I>(schema: S, input: I) => asserts input is I & S["Type"] =
1296
+ SchemaParser.asserts
1177
1297
 
1178
1298
  /**
1179
1299
  * Decodes an `unknown` input against a schema, returning an `Effect` that
@@ -1196,7 +1316,7 @@ export const asserts: <S extends Top, I>(schema: S, input: I) => asserts input i
1196
1316
  * @category decoding
1197
1317
  * @since 4.0.0
1198
1318
  */
1199
- export function decodeUnknownEffect<S extends Top>(schema: S, options?: SchemaAST.ParseOptions) {
1319
+ export function decodeUnknownEffect<S extends Constraint>(schema: S, options?: SchemaAST.ParseOptions) {
1200
1320
  const parser = SchemaParser.decodeUnknownEffect(schema, options)
1201
1321
  return (
1202
1322
  input: unknown,
@@ -1227,7 +1347,7 @@ export function decodeUnknownEffect<S extends Top>(schema: S, options?: SchemaAS
1227
1347
  * @category decoding
1228
1348
  * @since 4.0.0
1229
1349
  */
1230
- export const decodeEffect: <S extends Top>(
1350
+ export const decodeEffect: <S extends Constraint>(
1231
1351
  schema: S,
1232
1352
  options?: SchemaAST.ParseOptions
1233
1353
  ) => (
@@ -1303,7 +1423,7 @@ function runSchemaErrorSync<A>(
1303
1423
  * @category decoding
1304
1424
  * @since 4.0.0
1305
1425
  */
1306
- export function decodeUnknownExit<S extends Decoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1426
+ export function decodeUnknownExit<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1307
1427
  const parser = SchemaParser.decodeUnknownExit(schema, options)
1308
1428
  return (input: unknown, options?: SchemaAST.ParseOptions): Exit_.Exit<S["Type"], SchemaError> => {
1309
1429
  return InternalSchema.mapSchemaIssueExit(parser(input, options))
@@ -1340,7 +1460,7 @@ export function decodeUnknownExit<S extends Decoder<unknown>>(schema: S, options
1340
1460
  * @category decoding
1341
1461
  * @since 4.0.0
1342
1462
  */
1343
- export const decodeExit: <S extends Decoder<unknown>>(
1463
+ export const decodeExit: <S extends ConstraintDecoder<unknown>>(
1344
1464
  schema: S,
1345
1465
  options?: SchemaAST.ParseOptions
1346
1466
  ) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError> = decodeUnknownExit
@@ -1371,7 +1491,7 @@ export const decodeExit: <S extends Decoder<unknown>>(
1371
1491
  * @category decoding
1372
1492
  * @since 3.10.0
1373
1493
  */
1374
- export const decodeUnknownOption: <S extends Decoder<unknown>>(
1494
+ export const decodeUnknownOption: <S extends ConstraintDecoder<unknown>>(
1375
1495
  schema: S,
1376
1496
  options?: SchemaAST.ParseOptions
1377
1497
  ) => (input: unknown, options?: SchemaAST.ParseOptions) => Option_.Option<S["Type"]> = SchemaParser.decodeUnknownOption
@@ -1401,10 +1521,10 @@ export const decodeUnknownOption: <S extends Decoder<unknown>>(
1401
1521
  * @category decoding
1402
1522
  * @since 3.10.0
1403
1523
  */
1404
- export const decodeOption: <S extends Decoder<unknown>>(
1524
+ export const decodeOption: <S extends ConstraintDecoder<unknown>>(
1405
1525
  schema: S,
1406
1526
  options?: SchemaAST.ParseOptions
1407
- ) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Type"]> = decodeUnknownOption
1527
+ ) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Type"]> = SchemaParser.decodeOption
1408
1528
 
1409
1529
  /**
1410
1530
  * Decodes an `unknown` input against a schema, returning a `Result` that
@@ -1435,7 +1555,7 @@ export const decodeOption: <S extends Decoder<unknown>>(
1435
1555
  * @category decoding
1436
1556
  * @since 4.0.0
1437
1557
  */
1438
- export function decodeUnknownResult<S extends Decoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1558
+ export function decodeUnknownResult<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1439
1559
  const parser = SchemaParser.decodeUnknownResult(schema, options)
1440
1560
  return (input: unknown, options?: SchemaAST.ParseOptions): Result_.Result<S["Type"], SchemaError> => {
1441
1561
  return Result_.mapError(parser(input, options), (issue) => new SchemaError(issue))
@@ -1470,7 +1590,7 @@ export function decodeUnknownResult<S extends Decoder<unknown>>(schema: S, optio
1470
1590
  * @category decoding
1471
1591
  * @since 4.0.0
1472
1592
  */
1473
- export const decodeResult: <S extends Decoder<unknown>>(
1593
+ export const decodeResult: <S extends ConstraintDecoder<unknown>>(
1474
1594
  schema: S,
1475
1595
  options?: SchemaAST.ParseOptions
1476
1596
  ) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Result_.Result<S["Type"], SchemaError> =
@@ -1503,7 +1623,10 @@ export const decodeResult: <S extends Decoder<unknown>>(
1503
1623
  * @category decoding
1504
1624
  * @since 3.10.0
1505
1625
  */
1506
- export function decodeUnknownPromise<S extends Decoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1626
+ export function decodeUnknownPromise<S extends ConstraintDecoder<unknown>>(
1627
+ schema: S,
1628
+ options?: SchemaAST.ParseOptions
1629
+ ) {
1507
1630
  const parser = decodeUnknownEffect(schema, options)
1508
1631
  return (input: unknown, options?: SchemaAST.ParseOptions): Promise<S["Type"]> => {
1509
1632
  return runSchemaErrorPromise(parser(input, options))
@@ -1537,7 +1660,7 @@ export function decodeUnknownPromise<S extends Decoder<unknown>>(schema: S, opti
1537
1660
  * @category decoding
1538
1661
  * @since 3.10.0
1539
1662
  */
1540
- export const decodePromise: <S extends Decoder<unknown>>(
1663
+ export const decodePromise: <S extends ConstraintDecoder<unknown>>(
1541
1664
  schema: S,
1542
1665
  options?: SchemaAST.ParseOptions
1543
1666
  ) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Promise<S["Type"]> = decodeUnknownPromise
@@ -1586,7 +1709,7 @@ export const decodePromise: <S extends Decoder<unknown>>(
1586
1709
  * @category decoding
1587
1710
  * @since 4.0.0
1588
1711
  */
1589
- export function decodeUnknownSync<S extends Decoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1712
+ export function decodeUnknownSync<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1590
1713
  const parser = decodeUnknownEffect(schema, options)
1591
1714
  return (input: unknown, options?: SchemaAST.ParseOptions): S["Type"] => {
1592
1715
  return runSchemaErrorSync(parser(input, options))
@@ -1619,7 +1742,7 @@ export function decodeUnknownSync<S extends Decoder<unknown>>(schema: S, options
1619
1742
  * @category decoding
1620
1743
  * @since 4.0.0
1621
1744
  */
1622
- export const decodeSync: <S extends Decoder<unknown>>(
1745
+ export const decodeSync: <S extends ConstraintDecoder<unknown>>(
1623
1746
  schema: S,
1624
1747
  options?: SchemaAST.ParseOptions
1625
1748
  ) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => S["Type"] = decodeUnknownSync
@@ -1656,7 +1779,7 @@ export const decodeSync: <S extends Decoder<unknown>>(
1656
1779
  * @category encoding
1657
1780
  * @since 4.0.0
1658
1781
  */
1659
- export function encodeUnknownEffect<S extends Top>(schema: S, options?: SchemaAST.ParseOptions) {
1782
+ export function encodeUnknownEffect<S extends Constraint>(schema: S, options?: SchemaAST.ParseOptions) {
1660
1783
  const parser = SchemaParser.encodeUnknownEffect(schema, options)
1661
1784
  return (
1662
1785
  input: unknown,
@@ -1687,7 +1810,7 @@ export function encodeUnknownEffect<S extends Top>(schema: S, options?: SchemaAS
1687
1810
  * @category encoding
1688
1811
  * @since 4.0.0
1689
1812
  */
1690
- export const encodeEffect: <S extends Top>(
1813
+ export const encodeEffect: <S extends Constraint>(
1691
1814
  schema: S,
1692
1815
  options?: SchemaAST.ParseOptions
1693
1816
  ) => (
@@ -1724,7 +1847,7 @@ export const encodeEffect: <S extends Top>(
1724
1847
  * @category encoding
1725
1848
  * @since 4.0.0
1726
1849
  */
1727
- export function encodeUnknownExit<S extends Encoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1850
+ export function encodeUnknownExit<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1728
1851
  const parser = SchemaParser.encodeUnknownExit(schema, options)
1729
1852
  return (input: unknown, options?: SchemaAST.ParseOptions): Exit_.Exit<S["Encoded"], SchemaError> => {
1730
1853
  return InternalSchema.mapSchemaIssueExit(parser(input, options))
@@ -1761,7 +1884,7 @@ export function encodeUnknownExit<S extends Encoder<unknown>>(schema: S, options
1761
1884
  * @category encoding
1762
1885
  * @since 4.0.0
1763
1886
  */
1764
- export const encodeExit: <S extends Encoder<unknown>>(
1887
+ export const encodeExit: <S extends ConstraintEncoder<unknown>>(
1765
1888
  schema: S,
1766
1889
  options?: SchemaAST.ParseOptions
1767
1890
  ) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError> = encodeUnknownExit
@@ -1792,7 +1915,7 @@ export const encodeExit: <S extends Encoder<unknown>>(
1792
1915
  * @category encoding
1793
1916
  * @since 3.10.0
1794
1917
  */
1795
- export const encodeUnknownOption: <S extends Encoder<unknown>>(
1918
+ export const encodeUnknownOption: <S extends ConstraintEncoder<unknown>>(
1796
1919
  schema: S,
1797
1920
  options?: SchemaAST.ParseOptions
1798
1921
  ) => (input: unknown, options?: SchemaAST.ParseOptions) => Option_.Option<S["Encoded"]> =
@@ -1823,10 +1946,10 @@ export const encodeUnknownOption: <S extends Encoder<unknown>>(
1823
1946
  * @category encoding
1824
1947
  * @since 3.10.0
1825
1948
  */
1826
- export const encodeOption: <S extends Encoder<unknown>>(
1949
+ export const encodeOption: <S extends ConstraintEncoder<unknown>>(
1827
1950
  schema: S,
1828
1951
  options?: SchemaAST.ParseOptions
1829
- ) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Encoded"]> = encodeUnknownOption
1952
+ ) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Encoded"]> = SchemaParser.encodeOption
1830
1953
 
1831
1954
  /**
1832
1955
  * Encodes an `unknown` input against a schema, returning a `Result` that
@@ -1856,7 +1979,7 @@ export const encodeOption: <S extends Encoder<unknown>>(
1856
1979
  * @category encoding
1857
1980
  * @since 4.0.0
1858
1981
  */
1859
- export function encodeUnknownResult<S extends Encoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1982
+ export function encodeUnknownResult<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1860
1983
  const parser = SchemaParser.encodeUnknownResult(schema, options)
1861
1984
  return (input: unknown, options?: SchemaAST.ParseOptions): Result_.Result<S["Encoded"], SchemaError> => {
1862
1985
  return Result_.mapError(parser(input, options), (issue) => new SchemaError(issue))
@@ -1891,7 +2014,7 @@ export function encodeUnknownResult<S extends Encoder<unknown>>(schema: S, optio
1891
2014
  * @category encoding
1892
2015
  * @since 4.0.0
1893
2016
  */
1894
- export const encodeResult: <S extends Encoder<unknown>>(
2017
+ export const encodeResult: <S extends ConstraintEncoder<unknown>>(
1895
2018
  schema: S,
1896
2019
  options?: SchemaAST.ParseOptions
1897
2020
  ) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Result_.Result<S["Encoded"], SchemaError> =
@@ -1923,7 +2046,10 @@ export const encodeResult: <S extends Encoder<unknown>>(
1923
2046
  * @category encoding
1924
2047
  * @since 3.10.0
1925
2048
  */
1926
- export function encodeUnknownPromise<S extends Encoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
2049
+ export function encodeUnknownPromise<S extends ConstraintEncoder<unknown>>(
2050
+ schema: S,
2051
+ options?: SchemaAST.ParseOptions
2052
+ ) {
1927
2053
  const parser = encodeUnknownEffect(schema, options)
1928
2054
  return (input: unknown, options?: SchemaAST.ParseOptions): Promise<S["Encoded"]> => {
1929
2055
  return runSchemaErrorPromise(parser(input, options))
@@ -1957,7 +2083,7 @@ export function encodeUnknownPromise<S extends Encoder<unknown>>(schema: S, opti
1957
2083
  * @category encoding
1958
2084
  * @since 3.10.0
1959
2085
  */
1960
- export const encodePromise: <S extends Encoder<unknown>>(
2086
+ export const encodePromise: <S extends ConstraintEncoder<unknown>>(
1961
2087
  schema: S,
1962
2088
  options?: SchemaAST.ParseOptions
1963
2089
  ) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Promise<S["Encoded"]> = encodeUnknownPromise
@@ -1988,7 +2114,7 @@ export const encodePromise: <S extends Encoder<unknown>>(
1988
2114
  * @category encoding
1989
2115
  * @since 4.0.0
1990
2116
  */
1991
- export function encodeUnknownSync<S extends Encoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
2117
+ export function encodeUnknownSync<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
1992
2118
  const parser = encodeUnknownEffect(schema, options)
1993
2119
  return (input: unknown, options?: SchemaAST.ParseOptions): S["Encoded"] => {
1994
2120
  return runSchemaErrorSync(parser(input, options) as Effect.Effect<S["Encoded"], SchemaError>)
@@ -2019,7 +2145,7 @@ export function encodeUnknownSync<S extends Encoder<unknown>>(schema: S, options
2019
2145
  * @category encoding
2020
2146
  * @since 4.0.0
2021
2147
  */
2022
- export const encodeSync: <S extends Encoder<unknown>>(
2148
+ export const encodeSync: <S extends ConstraintEncoder<unknown>>(
2023
2149
  schema: S,
2024
2150
  options?: SchemaAST.ParseOptions
2025
2151
  ) => (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"] = encodeUnknownSync
@@ -2041,7 +2167,7 @@ export const encodeSync: <S extends Encoder<unknown>>(
2041
2167
  * @category constructors
2042
2168
  * @since 3.10.0
2043
2169
  */
2044
- export const make: <S extends Top>(ast: S["ast"], options?: object) => S = InternalSchema.make
2170
+ export const make: <S extends Constraint>(ast: S["ast"], options?: object) => S = InternalSchema.make
2045
2171
 
2046
2172
  /**
2047
2173
  * Transforms a schema into a class that can be extended with `extends`. The
@@ -2086,18 +2212,11 @@ export function isSchema(u: unknown): u is Top {
2086
2212
  * @category models
2087
2213
  * @since 4.0.0
2088
2214
  */
2089
- export interface optionalKey<S extends Top> extends
2090
- Bottom<
2091
- S["Type"],
2092
- S["Encoded"],
2093
- S["DecodingServices"],
2094
- S["EncodingServices"],
2215
+ export interface optionalKey<S extends Constraint> extends
2216
+ BottomLazy<
2095
2217
  S["ast"],
2096
2218
  optionalKey<S>,
2097
- S["~type.make.in"],
2098
- S["Iso"],
2099
2219
  S["~type.parameters"],
2100
- S["~type.make"],
2101
2220
  S["~type.mutability"],
2102
2221
  "optional",
2103
2222
  S["~type.constructor.default"],
@@ -2105,12 +2224,19 @@ export interface optionalKey<S extends Top> extends
2105
2224
  "optional"
2106
2225
  >
2107
2226
  {
2227
+ readonly "Type": S["Type"]
2228
+ readonly "Encoded": S["Encoded"]
2229
+ readonly "DecodingServices": S["DecodingServices"]
2230
+ readonly "EncodingServices": S["EncodingServices"]
2231
+ readonly "~type.make.in": S["~type.make.in"]
2232
+ readonly "~type.make": S["~type.make"]
2233
+ readonly "Iso": S["Iso"]
2108
2234
  readonly schema: S
2109
2235
  }
2110
2236
 
2111
2237
  interface optionalKeyLambda extends Lambda {
2112
- <S extends Top>(self: S): optionalKey<S>
2113
- readonly "~lambda.out": this["~lambda.in"] extends Top ? optionalKey<this["~lambda.in"]> : never
2238
+ <S extends Constraint>(self: S): optionalKey<S>
2239
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? optionalKey<this["~lambda.in"]> : never
2114
2240
  }
2115
2241
 
2116
2242
  /**
@@ -2140,8 +2266,8 @@ export const optionalKey = Struct_.lambda<optionalKeyLambda>((schema) =>
2140
2266
  )
2141
2267
 
2142
2268
  interface requiredKeyLambda extends Lambda {
2143
- <S extends Top>(self: optionalKey<S>): S
2144
- readonly "~lambda.out": this["~lambda.in"] extends optionalKey<Top> ? this["~lambda.in"]["schema"]
2269
+ <S extends Constraint>(self: optionalKey<S>): S
2270
+ readonly "~lambda.out": this["~lambda.in"] extends optionalKey<Constraint> ? this["~lambda.in"]["schema"]
2145
2271
  : "Error: schema not eligible for requiredKey"
2146
2272
  }
2147
2273
 
@@ -2164,13 +2290,13 @@ export const requiredKey = Struct_.lambda<requiredKeyLambda>((self) => self.sche
2164
2290
  * @category models
2165
2291
  * @since 3.10.0
2166
2292
  */
2167
- export interface optional<S extends Top> extends optionalKey<UndefinedOr<S>> {
2293
+ export interface optional<S extends Constraint> extends optionalKey<UndefinedOr<S>> {
2168
2294
  readonly "Rebuild": optional<S>
2169
2295
  }
2170
2296
 
2171
2297
  interface optionalLambda extends Lambda {
2172
- <S extends Top>(self: S): optional<S>
2173
- readonly "~lambda.out": this["~lambda.in"] extends Top ? optional<this["~lambda.in"]> : never
2298
+ <S extends Constraint>(self: S): optional<S>
2299
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? optional<this["~lambda.in"]> : never
2174
2300
  }
2175
2301
 
2176
2302
  /**
@@ -2205,8 +2331,8 @@ interface optionalLambda extends Lambda {
2205
2331
  export const optional = Struct_.lambda<optionalLambda>((self) => optionalKey(UndefinedOr(self)))
2206
2332
 
2207
2333
  interface requiredLambda extends Lambda {
2208
- <S extends Top>(self: optional<S>): S
2209
- readonly "~lambda.out": this["~lambda.in"] extends optional<Top> ? this["~lambda.in"]["schema"]["members"][0]
2334
+ <S extends Constraint>(self: optional<S>): S
2335
+ readonly "~lambda.out": this["~lambda.in"] extends optional<Constraint> ? this["~lambda.in"]["schema"]["members"][0]
2210
2336
  : "Error: schema not eligible for required"
2211
2337
  }
2212
2338
 
@@ -2233,18 +2359,11 @@ export const required = Struct_.lambda<requiredLambda>((self) => self.schema.mem
2233
2359
  * @category models
2234
2360
  * @since 4.0.0
2235
2361
  */
2236
- export interface mutableKey<S extends Top> extends
2237
- Bottom<
2238
- S["Type"],
2239
- S["Encoded"],
2240
- S["DecodingServices"],
2241
- S["EncodingServices"],
2362
+ export interface mutableKey<S extends Constraint> extends
2363
+ BottomLazy<
2242
2364
  S["ast"],
2243
2365
  mutableKey<S>,
2244
- S["~type.make.in"],
2245
- S["Iso"],
2246
2366
  S["~type.parameters"],
2247
- S["~type.make"],
2248
2367
  "mutable",
2249
2368
  S["~type.optionality"],
2250
2369
  S["~type.constructor.default"],
@@ -2252,12 +2371,19 @@ export interface mutableKey<S extends Top> extends
2252
2371
  S["~encoded.optionality"]
2253
2372
  >
2254
2373
  {
2374
+ readonly "Type": S["Type"]
2375
+ readonly "Encoded": S["Encoded"]
2376
+ readonly "DecodingServices": S["DecodingServices"]
2377
+ readonly "EncodingServices": S["EncodingServices"]
2378
+ readonly "~type.make.in": S["~type.make.in"]
2379
+ readonly "~type.make": S["~type.make"]
2380
+ readonly "Iso": S["Iso"]
2255
2381
  readonly schema: S
2256
2382
  }
2257
2383
 
2258
2384
  interface mutableKeyLambda extends Lambda {
2259
- <S extends Top>(self: S): mutableKey<S>
2260
- readonly "~lambda.out": this["~lambda.in"] extends Top ? mutableKey<this["~lambda.in"]> : never
2385
+ <S extends Constraint>(self: S): mutableKey<S>
2386
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? mutableKey<this["~lambda.in"]> : never
2261
2387
  }
2262
2388
 
2263
2389
  /**
@@ -2272,8 +2398,8 @@ export const mutableKey = Struct_.lambda<mutableKeyLambda>((schema) =>
2272
2398
  )
2273
2399
 
2274
2400
  interface readonlyKeyLambda extends Lambda {
2275
- <S extends Top>(self: mutableKey<S>): S
2276
- readonly "~lambda.out": this["~lambda.in"] extends mutableKey<Top> ? this["~lambda.in"]["schema"]
2401
+ <S extends Constraint>(self: mutableKey<S>): S
2402
+ readonly "~lambda.out": this["~lambda.in"] extends mutableKey<Constraint> ? this["~lambda.in"]["schema"]
2277
2403
  : "Error: schema not eligible for readonlyKey"
2278
2404
  }
2279
2405
 
@@ -2296,29 +2422,30 @@ export const readonlyKey = Struct_.lambda<readonlyKeyLambda>((self) => self.sche
2296
2422
  * @category transforming
2297
2423
  * @since 4.0.0
2298
2424
  */
2299
- export interface toType<S extends Top> extends
2300
- Bottom<
2301
- S["Type"],
2302
- S["Type"],
2303
- never,
2304
- never,
2425
+ export interface toType<S extends Constraint> extends
2426
+ BottomLazy<
2305
2427
  S["ast"],
2306
2428
  toType<S>,
2307
- S["~type.make.in"],
2308
- S["Iso"],
2309
2429
  S["~type.parameters"],
2310
- S["~type.make"],
2311
2430
  S["~type.mutability"],
2312
2431
  S["~type.optionality"],
2313
2432
  S["~type.constructor.default"],
2314
2433
  S["~encoded.mutability"],
2315
2434
  S["~encoded.optionality"]
2316
2435
  >
2317
- {}
2436
+ {
2437
+ readonly "Type": S["Type"]
2438
+ readonly "Encoded": S["Type"]
2439
+ readonly "DecodingServices": never
2440
+ readonly "EncodingServices": never
2441
+ readonly "~type.make.in": S["~type.make.in"]
2442
+ readonly "~type.make": S["~type.make"]
2443
+ readonly "Iso": S["Iso"]
2444
+ }
2318
2445
 
2319
2446
  interface toTypeLambda extends Lambda {
2320
- <S extends Top>(self: S): toType<S>
2321
- readonly "~lambda.out": this["~lambda.in"] extends Top ? toType<this["~lambda.in"]> : never
2447
+ <S extends Constraint>(self: S): toType<S>
2448
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? toType<this["~lambda.in"]> : never
2322
2449
  }
2323
2450
 
2324
2451
  /**
@@ -2336,29 +2463,30 @@ export const toType = Struct_.lambda<toTypeLambda>((schema) => make(SchemaAST.to
2336
2463
  * @category transforming
2337
2464
  * @since 4.0.0
2338
2465
  */
2339
- export interface toEncoded<S extends Top> extends
2340
- Bottom<
2341
- S["Encoded"],
2342
- S["Encoded"],
2343
- never,
2344
- never,
2466
+ export interface toEncoded<S extends Constraint> extends
2467
+ BottomLazy<
2345
2468
  SchemaAST.AST,
2346
2469
  toEncoded<S>,
2347
- S["Encoded"],
2348
- S["Encoded"],
2349
- ReadonlyArray<Top>,
2350
- S["Encoded"],
2470
+ ReadonlyArray<Constraint>,
2351
2471
  S["~type.mutability"],
2352
2472
  S["~type.optionality"],
2353
2473
  S["~type.constructor.default"],
2354
2474
  S["~encoded.mutability"],
2355
2475
  S["~encoded.optionality"]
2356
2476
  >
2357
- {}
2477
+ {
2478
+ readonly "Type": S["Encoded"]
2479
+ readonly "Encoded": S["Encoded"]
2480
+ readonly "DecodingServices": never
2481
+ readonly "EncodingServices": never
2482
+ readonly "~type.make.in": S["Encoded"]
2483
+ readonly "~type.make": S["Encoded"]
2484
+ readonly "Iso": S["Encoded"]
2485
+ }
2358
2486
 
2359
2487
  interface toEncodedLambda extends Lambda {
2360
- <S extends Top>(self: S): toEncoded<S>
2361
- readonly "~lambda.out": this["~lambda.in"] extends Top ? toEncoded<this["~lambda.in"]> : never
2488
+ <S extends Constraint>(self: S): toEncoded<S>
2489
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? toEncoded<this["~lambda.in"]> : never
2362
2490
  }
2363
2491
 
2364
2492
  /**
@@ -2379,17 +2507,10 @@ const FlipTypeId = "~effect/Schema/flip"
2379
2507
  * @since 4.0.0
2380
2508
  */
2381
2509
  export interface flip<S extends Top> extends
2382
- Bottom<
2383
- S["Encoded"],
2384
- S["Type"],
2385
- S["EncodingServices"],
2386
- S["DecodingServices"],
2510
+ BottomLazy<
2387
2511
  SchemaAST.AST,
2388
2512
  flip<S>,
2389
- S["Encoded"],
2390
- S["Encoded"],
2391
- ReadonlyArray<Top>,
2392
- S["Encoded"],
2513
+ ReadonlyArray<Constraint>,
2393
2514
  S["~encoded.mutability"],
2394
2515
  S["~encoded.optionality"],
2395
2516
  ConstructorDefault,
@@ -2397,6 +2518,13 @@ export interface flip<S extends Top> extends
2397
2518
  S["~type.optionality"]
2398
2519
  >
2399
2520
  {
2521
+ readonly "Type": S["Encoded"]
2522
+ readonly "Encoded": S["Type"]
2523
+ readonly "DecodingServices": S["EncodingServices"]
2524
+ readonly "EncodingServices": S["DecodingServices"]
2525
+ readonly "~type.make.in": S["Encoded"]
2526
+ readonly "~type.make": S["Encoded"]
2527
+ readonly "Iso": S["Encoded"]
2400
2528
  readonly [FlipTypeId]: typeof FlipTypeId
2401
2529
  readonly schema: S
2402
2530
  }
@@ -2498,7 +2626,7 @@ export declare namespace TemplateLiteral {
2498
2626
  * @category utility types
2499
2627
  * @since 4.0.0
2500
2628
  */
2501
- export interface SchemaPart extends Top {
2629
+ export interface SchemaPart extends Constraint {
2502
2630
  readonly Encoded: string | number | bigint
2503
2631
  }
2504
2632
 
@@ -2531,7 +2659,7 @@ export declare namespace TemplateLiteral {
2531
2659
  Template extends string,
2532
2660
  Next
2533
2661
  > = Next extends LiteralPart ? `${Template}${Next}`
2534
- : Next extends Codec<unknown, infer E extends LiteralPart, unknown, unknown> ? `${Template}${E}`
2662
+ : Next extends { readonly Encoded: infer E extends LiteralPart } ? `${Template}${E}`
2535
2663
  : never
2536
2664
 
2537
2665
  /**
@@ -2565,18 +2693,26 @@ export interface TemplateLiteral<Parts extends TemplateLiteral.Parts> extends
2565
2693
  }
2566
2694
 
2567
2695
  function templateLiteralFromParts<Parts extends TemplateLiteral.Parts>(parts: Parts) {
2568
- return new SchemaAST.TemplateLiteral(parts.map((part) => isSchema(part) ? part.ast : new SchemaAST.Literal(part)))
2696
+ return new SchemaAST.TemplateLiteral(
2697
+ parts.map((part) => isSchema(part) ? part.ast : new SchemaAST.Literal(part as TemplateLiteral.LiteralPart))
2698
+ )
2569
2699
  }
2570
2700
 
2571
2701
  /**
2572
- * Creates a schema that validates strings matching a template literal pattern. Each part can be
2573
- * a literal string/number/bigint or a schema whose encoded type is a string, number, or bigint.
2702
+ * Creates a schema that validates strings by matching ordered template literal
2703
+ * parts.
2574
2704
  *
2575
2705
  * **When to use**
2576
2706
  *
2577
2707
  * Use when the decoded value should remain the matched string and you do not
2578
2708
  * need the individual template parts parsed into a tuple.
2579
2709
  *
2710
+ * **Details**
2711
+ *
2712
+ * Each part can be a literal `string`, `number`, or `bigint`, or a schema whose
2713
+ * encoded type is `string`, `number`, or `bigint`. Checks on string, number,
2714
+ * and bigint schema parts are applied while matching each segment.
2715
+ *
2580
2716
  * **Example** (Defining a URL path pattern)
2581
2717
  *
2582
2718
  * ```ts
@@ -2627,20 +2763,23 @@ export declare namespace TemplateLiteralParser {
2627
2763
  * @since 3.10.0
2628
2764
  */
2629
2765
  export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> extends
2630
- Bottom<
2631
- TemplateLiteralParser.Type<Parts>,
2632
- TemplateLiteral.Encoded<Parts>,
2633
- never,
2634
- never,
2766
+ BottomLazy<
2635
2767
  SchemaAST.Arrays,
2636
2768
  TemplateLiteralParser<Parts>
2637
2769
  >
2638
2770
  {
2771
+ readonly "Type": TemplateLiteralParser.Type<Parts>
2772
+ readonly "Encoded": TemplateLiteral.Encoded<Parts>
2773
+ readonly "DecodingServices": never
2774
+ readonly "EncodingServices": never
2775
+ readonly "~type.make.in": TemplateLiteralParser.Type<Parts>
2776
+ readonly "~type.make": TemplateLiteralParser.Type<Parts>
2777
+ readonly "Iso": TemplateLiteralParser.Type<Parts>
2639
2778
  readonly parts: Parts
2640
2779
  }
2641
2780
 
2642
2781
  /**
2643
- * Schema for parsing template literal matches into typed tuple parts.
2782
+ * Schema for parsing matched template literal strings into typed tuple parts.
2644
2783
  *
2645
2784
  * **When to use**
2646
2785
  *
@@ -2650,7 +2789,8 @@ export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> exte
2650
2789
  * **Details**
2651
2790
  *
2652
2791
  * Unlike {@link TemplateLiteral}, this schema decodes the matched string into a
2653
- * readonly tuple with one element per schema part.
2792
+ * readonly tuple with one element per schema part. Checks on string, number,
2793
+ * and bigint schema parts are applied while matching each segment.
2654
2794
  *
2655
2795
  * **Example** (Parsing path parameters)
2656
2796
  *
@@ -2992,7 +3132,7 @@ export declare namespace Struct {
2992
3132
  * @category utility types
2993
3133
  * @since 3.10.0
2994
3134
  */
2995
- export type Fields = { readonly [x: PropertyKey]: Top }
3135
+ export type Fields = { readonly [x: PropertyKey]: Constraint }
2996
3136
 
2997
3137
  type TypeOptionalKeys<Fields extends Struct.Fields> = {
2998
3138
  [K in keyof Fields]: Fields[K] extends { readonly "~type.optionality": "optional" } ? K
@@ -3004,15 +3144,46 @@ export declare namespace Struct {
3004
3144
  : never
3005
3145
  }[keyof Fields]
3006
3146
 
3007
- type Type_<
3147
+ type SetOptional<A, K extends keyof A> = Omit<A, K> & Partial<Pick<A, K>>
3148
+
3149
+ type Mutable<A> = { -readonly [K in keyof A]: A[K] }
3150
+
3151
+ type SetMutable<A, K extends keyof A> = Omit<A, K> & Mutable<Pick<A, K>>
3152
+
3153
+ type Side = "Type" | "Iso" | "Encoded"
3154
+
3155
+ type EncodedOptionalKeys<Fields extends Struct.Fields> = {
3156
+ [K in keyof Fields]: Fields[K] extends { readonly "~encoded.optionality": "optional" } ? K
3157
+ : never
3158
+ }[keyof Fields]
3159
+
3160
+ type EncodedMutableKeys<Fields extends Struct.Fields> = {
3161
+ [K in keyof Fields]: Fields[K] extends { readonly "~encoded.mutability": "mutable" } ? K
3162
+ : never
3163
+ }[keyof Fields]
3164
+
3165
+ type SideOptionalKeys<F extends Fields, S extends Side> = S extends "Encoded" ? EncodedOptionalKeys<F>
3166
+ : TypeOptionalKeys<F>
3167
+
3168
+ type SideMutableKeys<F extends Fields, S extends Side> = S extends "Encoded" ? EncodedMutableKeys<F>
3169
+ : TypeMutableKeys<F>
3170
+
3171
+ type ReadonlySide<F extends Fields, S extends Side> = { readonly [K in keyof F]: F[K][S] }
3172
+
3173
+ type View<
3008
3174
  F extends Fields,
3009
- O extends keyof F = TypeOptionalKeys<F>,
3010
- M extends keyof F = TypeMutableKeys<F>
3011
- > =
3012
- & { readonly [K in keyof F as K extends M | O ? never : K]: F[K]["Type"] }
3013
- & { readonly [K in keyof F as K extends O ? K extends M ? never : K : never]?: F[K]["Type"] }
3014
- & { -readonly [K in keyof F as K extends M ? K extends O ? never : K : never]: F[K]["Type"] }
3015
- & { -readonly [K in keyof F as K extends M & O ? K : never]?: F[K]["Type"] }
3175
+ S extends Side,
3176
+ O extends keyof F = SideOptionalKeys<F, S>,
3177
+ M extends keyof F = SideMutableKeys<F, S>
3178
+ > = [O | M] extends [never] ? ReadonlySide<F, S>
3179
+ : [M] extends [never] ? Simplify<SetOptional<ReadonlySide<F, S>, O>>
3180
+ : [O] extends [never] ? Simplify<SetMutable<ReadonlySide<F, S>, M>>
3181
+ : Simplify<
3182
+ SetMutable<
3183
+ SetOptional<ReadonlySide<F, S>, O>,
3184
+ Extract<keyof SetOptional<ReadonlySide<F, S>, O>, M>
3185
+ >
3186
+ >
3016
3187
 
3017
3188
  /**
3018
3189
  * Computes the decoded object type for a struct field map.
@@ -3025,17 +3196,7 @@ export declare namespace Struct {
3025
3196
  * @category utility types
3026
3197
  * @since 3.10.0
3027
3198
  */
3028
- export type Type<F extends Fields> = Simplify<Type_<F>>
3029
-
3030
- type Iso_<
3031
- F extends Fields,
3032
- O extends keyof F = TypeOptionalKeys<F>,
3033
- M extends keyof F = TypeMutableKeys<F>
3034
- > =
3035
- & { readonly [K in keyof F as K extends M | O ? never : K]: F[K]["Iso"] }
3036
- & { readonly [K in keyof F as K extends O ? K extends M ? never : K : never]?: F[K]["Iso"] }
3037
- & { -readonly [K in keyof F as K extends M ? K extends O ? never : K : never]: F[K]["Iso"] }
3038
- & { -readonly [K in keyof F as K extends M & O ? K : never]?: F[K]["Iso"] }
3199
+ export type Type<F extends Fields> = View<F, "Type">
3039
3200
 
3040
3201
  /**
3041
3202
  * Computes the iso object type for a struct field map from each field schema's
@@ -3049,27 +3210,7 @@ export declare namespace Struct {
3049
3210
  * @category utility types
3050
3211
  * @since 4.0.0
3051
3212
  */
3052
- export type Iso<F extends Fields> = Simplify<Iso_<F>>
3053
-
3054
- type EncodedOptionalKeys<Fields extends Struct.Fields> = {
3055
- [K in keyof Fields]: Fields[K] extends { readonly "~encoded.optionality": "optional" } ? K
3056
- : never
3057
- }[keyof Fields]
3058
-
3059
- type EncodedMutableKeys<Fields extends Struct.Fields> = {
3060
- [K in keyof Fields]: Fields[K] extends { readonly "~encoded.mutability": "mutable" } ? K
3061
- : never
3062
- }[keyof Fields]
3063
-
3064
- type Encoded_<
3065
- F extends Fields,
3066
- O extends keyof F = EncodedOptionalKeys<F>,
3067
- M extends keyof F = EncodedMutableKeys<F>
3068
- > =
3069
- & { readonly [K in keyof F as K extends M | O ? never : K]: F[K]["Encoded"] }
3070
- & { readonly [K in keyof F as K extends O ? K extends M ? never : K : never]?: F[K]["Encoded"] }
3071
- & { -readonly [K in keyof F as K extends M ? K extends O ? never : K : never]: F[K]["Encoded"] }
3072
- & { -readonly [K in keyof F as K extends M & O ? K : never]?: F[K]["Encoded"] }
3213
+ export type Iso<F extends Fields> = View<F, "Iso">
3073
3214
 
3074
3215
  /**
3075
3216
  * Computes the encoded object type for a struct field map.
@@ -3083,7 +3224,7 @@ export declare namespace Struct {
3083
3224
  * @category utility types
3084
3225
  * @since 3.10.0
3085
3226
  */
3086
- export type Encoded<F extends Fields> = Simplify<Encoded_<F>>
3227
+ export type Encoded<F extends Fields> = View<F, "Encoded">
3087
3228
 
3088
3229
  /**
3089
3230
  * Union of all decoding service requirements needed by the schemas in a struct
@@ -3108,12 +3249,12 @@ export declare namespace Struct {
3108
3249
  : never
3109
3250
  }[keyof Fields]
3110
3251
 
3111
- type MakeIn_<
3252
+ type ReadonlyMakeIn<F extends Fields> = { readonly [K in keyof F]: F[K]["~type.make"] }
3253
+
3254
+ type MakeInView<
3112
3255
  F extends Fields,
3113
- O = TypeOptionalKeys<F> | TypeConstructorDefaultedKeys<F>
3114
- > =
3115
- & { readonly [K in keyof F as K extends O ? never : K]: F[K]["~type.make"] }
3116
- & { readonly [K in keyof F as K extends O ? K : never]?: F[K]["~type.make"] }
3256
+ O extends keyof F = TypeOptionalKeys<F> | TypeConstructorDefaultedKeys<F>
3257
+ > = [O] extends [never] ? ReadonlyMakeIn<F> : Simplify<SetOptional<ReadonlyMakeIn<F>, O>>
3117
3258
 
3118
3259
  /**
3119
3260
  * Computes the input object type accepted when constructing a struct value.
@@ -3126,7 +3267,7 @@ export declare namespace Struct {
3126
3267
  * @category utility types
3127
3268
  * @since 4.0.0
3128
3269
  */
3129
- export type MakeIn<F extends Fields> = Simplify<MakeIn_<F>>
3270
+ export type MakeIn<F extends Fields> = MakeInView<F>
3130
3271
  }
3131
3272
 
3132
3273
  /**
@@ -3135,18 +3276,14 @@ export declare namespace Struct {
3135
3276
  * @category models
3136
3277
  * @since 3.10.0
3137
3278
  */
3138
- export interface Struct<Fields extends Struct.Fields> extends
3139
- Bottom<
3140
- Struct.Type<Fields>,
3141
- Struct.Encoded<Fields>,
3142
- Struct.DecodingServices<Fields>,
3143
- Struct.EncodingServices<Fields>,
3144
- SchemaAST.Objects,
3145
- Struct<Fields>,
3146
- Struct.MakeIn<Fields>,
3147
- Struct.Iso<Fields>
3148
- >
3149
- {
3279
+ export interface Struct<Fields extends Struct.Fields> extends BottomLazy<SchemaAST.Objects, Struct<Fields>> {
3280
+ readonly "Type": Struct.Type<Fields>
3281
+ readonly "Encoded": Struct.Encoded<Fields>
3282
+ readonly "DecodingServices": Struct.DecodingServices<Fields>
3283
+ readonly "EncodingServices": Struct.EncodingServices<Fields>
3284
+ readonly "~type.make.in": Struct.MakeIn<Fields>
3285
+ readonly "~type.make": Struct.MakeIn<Fields>
3286
+ readonly "Iso": Struct.Iso<Fields>
3150
3287
  /**
3151
3288
  * The field definitions of this struct. Spread them into a new struct to
3152
3289
  * reuse fields across schemas.
@@ -3293,7 +3430,7 @@ export function fieldsAssign<const NewFields extends Struct.Fields>(fields: NewF
3293
3430
  * @since 4.0.0
3294
3431
  */
3295
3432
  export interface encodeKeys<
3296
- S extends Top & { readonly fields: Struct.Fields },
3433
+ S extends Constraint & { readonly fields: Struct.Fields },
3297
3434
  M extends { readonly [K in keyof S["fields"]]?: PropertyKey }
3298
3435
  > extends
3299
3436
  decodeTo<
@@ -3340,7 +3477,7 @@ const canonicalPropertyKey = (key: PropertyKey): string | symbol =>
3340
3477
  * @since 4.0.0
3341
3478
  */
3342
3479
  export function encodeKeys<
3343
- S extends Top & { readonly fields: Struct.Fields },
3480
+ S extends Constraint & { readonly fields: Struct.Fields },
3344
3481
  const M extends { readonly [K in keyof S["fields"]]?: PropertyKey }
3345
3482
  >(mapping: M) {
3346
3483
  return function(self: S): encodeKeys<S, M> {
@@ -3482,7 +3619,7 @@ export declare namespace Record {
3482
3619
  * @category utility types
3483
3620
  * @since 3.10.0
3484
3621
  */
3485
- export type Type<Key extends Record.Key, Value extends Top> = Value extends
3622
+ export type Type<Key extends Record.Key, Value extends Constraint> = Value extends
3486
3623
  { readonly "~type.optionality": "optional" } ?
3487
3624
  Value extends { readonly "~type.mutability": "mutable" } ? { [P in Key["Type"]]?: Value["Type"] }
3488
3625
  : { readonly [P in Key["Type"]]?: Value["Type"] }
@@ -3496,7 +3633,7 @@ export declare namespace Record {
3496
3633
  * @category utility types
3497
3634
  * @since 4.0.0
3498
3635
  */
3499
- export type Iso<Key extends Record.Key, Value extends Top> = Value extends
3636
+ export type Iso<Key extends Record.Key, Value extends Constraint> = Value extends
3500
3637
  { readonly "~type.optionality": "optional" } ?
3501
3638
  Value extends { readonly "~type.mutability": "mutable" } ? { [P in Key["Iso"]]?: Value["Iso"] }
3502
3639
  : { readonly [P in Key["Iso"]]?: Value["Iso"] }
@@ -3515,7 +3652,7 @@ export declare namespace Record {
3515
3652
  * @category utility types
3516
3653
  * @since 3.10.0
3517
3654
  */
3518
- export type Encoded<Key extends Record.Key, Value extends Top> = Value extends
3655
+ export type Encoded<Key extends Record.Key, Value extends Constraint> = Value extends
3519
3656
  { readonly "~encoded.optionality": "optional" } ?
3520
3657
  Value extends { readonly "~encoded.mutability": "mutable" } ? { [P in Key["Encoded"]]?: Value["Encoded"] }
3521
3658
  : { readonly [P in Key["Encoded"]]?: Value["Encoded"] }
@@ -3529,7 +3666,7 @@ export declare namespace Record {
3529
3666
  * @category utility types
3530
3667
  * @since 4.0.0
3531
3668
  */
3532
- export type DecodingServices<Key extends Record.Key, Value extends Top> =
3669
+ export type DecodingServices<Key extends Record.Key, Value extends Constraint> =
3533
3670
  | Key["DecodingServices"]
3534
3671
  | Value["DecodingServices"]
3535
3672
 
@@ -3540,7 +3677,7 @@ export declare namespace Record {
3540
3677
  * @category utility types
3541
3678
  * @since 4.0.0
3542
3679
  */
3543
- export type EncodingServices<Key extends Record.Key, Value extends Top> =
3680
+ export type EncodingServices<Key extends Record.Key, Value extends Constraint> =
3544
3681
  | Key["EncodingServices"]
3545
3682
  | Value["EncodingServices"]
3546
3683
 
@@ -3556,7 +3693,7 @@ export declare namespace Record {
3556
3693
  * @category utility types
3557
3694
  * @since 4.0.0
3558
3695
  */
3559
- export type MakeIn<Key extends Record.Key, Value extends Top> = Value extends
3696
+ export type MakeIn<Key extends Record.Key, Value extends Constraint> = Value extends
3560
3697
  { readonly "~encoded.optionality": "optional" } ?
3561
3698
  Value extends { readonly "~encoded.mutability": "mutable" } ? { [P in Key["~type.make"]]?: Value["~type.make"] }
3562
3699
  : { readonly [P in Key["~type.make"]]?: Value["~type.make"] }
@@ -3570,24 +3707,36 @@ export declare namespace Record {
3570
3707
  * @category models
3571
3708
  * @since 4.0.0
3572
3709
  */
3573
- export interface $Record<Key extends Record.Key, Value extends Top> extends
3574
- Bottom<
3575
- Record.Type<Key, Value>,
3576
- Record.Encoded<Key, Value>,
3577
- Record.DecodingServices<Key, Value>,
3578
- Record.EncodingServices<Key, Value>,
3710
+ export interface $Record<Key extends Record.Key, Value extends Constraint> extends
3711
+ BottomLazy<
3579
3712
  SchemaAST.Objects,
3580
- $Record<Key, Value>,
3581
- Simplify<Record.MakeIn<Key, Value>>,
3582
- Record.Iso<Key, Value>
3713
+ $Record<Key, Value>
3583
3714
  >
3584
3715
  {
3716
+ readonly "Type": Record.Type<Key, Value>
3717
+ readonly "Encoded": Record.Encoded<Key, Value>
3718
+ readonly "DecodingServices": Record.DecodingServices<Key, Value>
3719
+ readonly "EncodingServices": Record.EncodingServices<Key, Value>
3720
+ readonly "~type.make.in": Simplify<Record.MakeIn<Key, Value>>
3721
+ readonly "~type.make": Simplify<Record.MakeIn<Key, Value>>
3722
+ readonly "Iso": Record.Iso<Key, Value>
3585
3723
  readonly key: Key
3586
3724
  readonly value: Value
3587
3725
  }
3588
3726
 
3589
3727
  /**
3590
- * Defines a record (dictionary) schema with typed keys and values.
3728
+ * Defines a record schema whose dynamic properties are selected by a key schema
3729
+ * and decoded with a value schema.
3730
+ *
3731
+ * **Details**
3732
+ *
3733
+ * For dynamic keys, the key schema selects matching own properties and the
3734
+ * value schema decodes or encodes only those selected properties. Checks on
3735
+ * string, number, symbol, and template literal key schemas narrow which
3736
+ * properties are selected.
3737
+ *
3738
+ * For transformed key schemas, property selection is based on encoded property
3739
+ * names before the selected key is decoded.
3591
3740
  *
3592
3741
  * **Example** (Defining a string-keyed record of numbers)
3593
3742
  *
@@ -3607,7 +3756,7 @@ export interface $Record<Key extends Record.Key, Value extends Top> extends
3607
3756
  * @category constructors
3608
3757
  * @since 3.10.0
3609
3758
  */
3610
- export function Record<Key extends Record.Key, Value extends Top>(
3759
+ export function Record<Key extends Record.Key, Value extends Constraint>(
3611
3760
  key: Key,
3612
3761
  value: Value,
3613
3762
  options?: {
@@ -3641,7 +3790,7 @@ export declare namespace StructWithRest {
3641
3790
  * @category utility types
3642
3791
  * @since 4.0.0
3643
3792
  */
3644
- export type Objects = Top & { readonly ast: SchemaAST.Objects }
3793
+ export type Objects = Constraint & { readonly ast: SchemaAST.Objects }
3645
3794
 
3646
3795
  /**
3647
3796
  * Readonly list of record schemas that provide the additional index signatures
@@ -3650,7 +3799,7 @@ export declare namespace StructWithRest {
3650
3799
  * @category utility types
3651
3800
  * @since 3.10.0
3652
3801
  */
3653
- export type Records = ReadonlyArray<$Record<Record.Key, Top>>
3802
+ export type Records = ReadonlyArray<$Record<Record.Key, Constraint>>
3654
3803
 
3655
3804
  type MergeTuple<T extends ReadonlyArray<unknown>> = T extends readonly [infer Head, ...infer Tail] ?
3656
3805
  Head & MergeTuple<Tail>
@@ -3747,24 +3896,52 @@ export declare namespace StructWithRest {
3747
3896
  [I in keyof Records]: Records[I][Side] extends object ? IncompatibleKeys<S[Side], Records[I][Side]> : never
3748
3897
  }[number]
3749
3898
 
3899
+ type IncompatibleRecords<S extends Objects, Records extends StructWithRest.Records> =
3900
+ | IncompatibleSideKeys<S, Records, "Type">
3901
+ | IncompatibleSideKeys<S, Records, "Encoded">
3902
+ | IncompatibleSideKeys<S, Records, "Iso">
3903
+ | IncompatibleSideKeys<S, Records, "~type.make">
3904
+
3750
3905
  /**
3751
- * Validates that the records are compatible with the struct.
3906
+ * Checks whether fixed fields are compatible with the rest record schemas.
3907
+ *
3908
+ * **Details**
3909
+ *
3910
+ * Returns `true` when all fixed fields can also satisfy the matching rest
3911
+ * index signatures. Returns a diagnostic object when TypeScript would make
3912
+ * the resulting intersection too narrow for one or more fixed keys.
3913
+ *
3914
+ * **Example** (Checking record compatibility)
3915
+ *
3916
+ * ```ts
3917
+ * import { Schema } from "effect"
3918
+ *
3919
+ * const user = Schema.Struct({ id: Schema.String })
3920
+ * const stringExtras = [Schema.Record(Schema.String, Schema.String)] as const
3921
+ *
3922
+ * type UserCheck = Schema.StructWithRest.ValidateRecords<typeof user, typeof stringExtras>
3923
+ *
3924
+ * const userCheck: UserCheck = true
3925
+ * void userCheck
3926
+ *
3927
+ * const counter = Schema.Struct({ count: Schema.NumberFromString })
3928
+ *
3929
+ * type CounterCheck = Schema.StructWithRest.ValidateRecords<typeof counter, typeof stringExtras>
3930
+ * // ^? { "incompatible index signatures": "count" }
3931
+ *
3932
+ * const counterCheck = null as unknown as CounterCheck
3933
+ * void counterCheck
3934
+ * ```
3752
3935
  *
3753
3936
  * @category utility types
3754
3937
  * @since 4.0.0
3755
3938
  */
3756
- export type ValidateRecords<S extends Objects, Records extends StructWithRest.Records> = [
3757
- | IncompatibleSideKeys<S, Records, "Type">
3758
- | IncompatibleSideKeys<S, Records, "Encoded">
3759
- | IncompatibleSideKeys<S, Records, "Iso">
3760
- | IncompatibleSideKeys<S, Records, "~type.make">
3761
- ] extends [never] ? unknown
3939
+ export type ValidateRecords<
3940
+ S extends Objects,
3941
+ Records extends StructWithRest.Records
3942
+ > = [IncompatibleRecords<S, Records>] extends [never] ? true
3762
3943
  : {
3763
- "incompatible index signatures":
3764
- | IncompatibleSideKeys<S, Records, "Type">
3765
- | IncompatibleSideKeys<S, Records, "Encoded">
3766
- | IncompatibleSideKeys<S, Records, "Iso">
3767
- | IncompatibleSideKeys<S, Records, "~type.make">
3944
+ "incompatible index signatures": IncompatibleRecords<S, Records>
3768
3945
  }
3769
3946
  }
3770
3947
 
@@ -3778,17 +3955,18 @@ export interface StructWithRest<
3778
3955
  S extends StructWithRest.Objects,
3779
3956
  Records extends StructWithRest.Records
3780
3957
  > extends
3781
- Bottom<
3782
- Simplify<StructWithRest.Type<S, Records>>,
3783
- Simplify<StructWithRest.Encoded<S, Records>>,
3784
- StructWithRest.DecodingServices<S, Records>,
3785
- StructWithRest.EncodingServices<S, Records>,
3958
+ BottomLazy<
3786
3959
  SchemaAST.Objects,
3787
- StructWithRest<S, Records>,
3788
- Simplify<StructWithRest.MakeIn<S, Records>>,
3789
- Simplify<StructWithRest.Iso<S, Records>>
3960
+ StructWithRest<S, Records>
3790
3961
  >
3791
3962
  {
3963
+ readonly "Type": Simplify<StructWithRest.Type<S, Records>>
3964
+ readonly "Encoded": Simplify<StructWithRest.Encoded<S, Records>>
3965
+ readonly "DecodingServices": StructWithRest.DecodingServices<S, Records>
3966
+ readonly "EncodingServices": StructWithRest.EncodingServices<S, Records>
3967
+ readonly "~type.make.in": Simplify<StructWithRest.MakeIn<S, Records>>
3968
+ readonly "~type.make": Simplify<StructWithRest.MakeIn<S, Records>>
3969
+ readonly "Iso": Simplify<StructWithRest.Iso<S, Records>>
3792
3970
  readonly schema: S
3793
3971
  readonly records: Records
3794
3972
  }
@@ -3797,6 +3975,13 @@ export interface StructWithRest<
3797
3975
  * Extends a struct schema with one or more record (index-signature) schemas,
3798
3976
  * producing a schema whose decoded type intersects the struct and all records.
3799
3977
  *
3978
+ * **Gotchas**
3979
+ *
3980
+ * TypeScript index signatures also apply to fixed keys. `StructWithRest` does
3981
+ * not reject incompatible fixed fields at the call site; use
3982
+ * `StructWithRest.ValidateRecords` when you want an explicit type-level
3983
+ * compatibility check.
3984
+ *
3800
3985
  * **Example** (Defining structs with string-indexed extra keys)
3801
3986
  *
3802
3987
  * ```ts
@@ -3819,7 +4004,7 @@ export function StructWithRest<
3819
4004
  const Records extends StructWithRest.Records
3820
4005
  >(
3821
4006
  schema: S,
3822
- records: Records & StructWithRest.ValidateRecords<S, Records>
4007
+ records: Records
3823
4008
  ): StructWithRest<S, Records> {
3824
4009
  return make(SchemaAST.structWithRest(schema.ast, records.map(SchemaAST.getAST)), { schema, records })
3825
4010
  }
@@ -3844,7 +4029,7 @@ export declare namespace Tuple {
3844
4029
  * @category utility types
3845
4030
  * @since 3.10.0
3846
4031
  */
3847
- export type Elements = ReadonlyArray<Top>
4032
+ export type Elements = ReadonlyArray<Constraint>
3848
4033
 
3849
4034
  type Type_<
3850
4035
  Elements,
@@ -3962,17 +4147,18 @@ export declare namespace Tuple {
3962
4147
  * @since 3.10.0
3963
4148
  */
3964
4149
  export interface Tuple<Elements extends Tuple.Elements> extends
3965
- Bottom<
3966
- Tuple.Type<Elements>,
3967
- Tuple.Encoded<Elements>,
3968
- Tuple.DecodingServices<Elements>,
3969
- Tuple.EncodingServices<Elements>,
4150
+ BottomLazy<
3970
4151
  SchemaAST.Arrays,
3971
- Tuple<Elements>,
3972
- Tuple.MakeIn<Elements>,
3973
- Tuple.Iso<Elements>
4152
+ Tuple<Elements>
3974
4153
  >
3975
4154
  {
4155
+ readonly "Type": Tuple.Type<Elements>
4156
+ readonly "Encoded": Tuple.Encoded<Elements>
4157
+ readonly "DecodingServices": Tuple.DecodingServices<Elements>
4158
+ readonly "EncodingServices": Tuple.EncodingServices<Elements>
4159
+ readonly "~type.make.in": Tuple.MakeIn<Elements>
4160
+ readonly "~type.make": Tuple.MakeIn<Elements>
4161
+ readonly "Iso": Tuple.Iso<Elements>
3976
4162
  readonly elements: Elements
3977
4163
  /**
3978
4164
  * Returns a new tuple with the elements modified by the provided function.
@@ -4032,7 +4218,7 @@ function makeTuple<Elements extends Tuple.Elements>(ast: SchemaAST.Arrays, eleme
4032
4218
  * @category constructors
4033
4219
  * @since 3.10.0
4034
4220
  */
4035
- export function Tuple<const Elements extends ReadonlyArray<Top>>(elements: Elements): Tuple<Elements> {
4221
+ export function Tuple<const Elements extends ReadonlyArray<Constraint>>(elements: Elements): Tuple<Elements> {
4036
4222
  return makeTuple(SchemaAST.tuple(elements), elements)
4037
4223
  }
4038
4224
 
@@ -4056,7 +4242,7 @@ export declare namespace TupleWithRest {
4056
4242
  * @category utility types
4057
4243
  * @since 3.10.0
4058
4244
  */
4059
- export type TupleType = Top & {
4245
+ export type TupleType = Constraint & {
4060
4246
  readonly Type: ReadonlyArray<unknown>
4061
4247
  readonly Encoded: ReadonlyArray<unknown>
4062
4248
  readonly ast: SchemaAST.Arrays
@@ -4075,7 +4261,7 @@ export declare namespace TupleWithRest {
4075
4261
  * @category utility types
4076
4262
  * @since 3.10.0
4077
4263
  */
4078
- export type Rest = readonly [Top, ...Array<Top>]
4264
+ export type Rest = readonly [Constraint, ...Array<Constraint>]
4079
4265
 
4080
4266
  /**
4081
4267
  * Computes the decoded tuple type for a `TupleWithRest`.
@@ -4090,7 +4276,7 @@ export declare namespace TupleWithRest {
4090
4276
  * @since 3.10.0
4091
4277
  */
4092
4278
  export type Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends
4093
- readonly [infer Head extends Top, ...infer Tail extends ReadonlyArray<Top>] ? Readonly<[
4279
+ readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? Readonly<[
4094
4280
  ...T,
4095
4281
  ...Array<Head["Type"]>,
4096
4282
  ...{ readonly [K in keyof Tail]: Tail[K]["Type"] }
@@ -4110,7 +4296,7 @@ export declare namespace TupleWithRest {
4110
4296
  * @since 4.0.0
4111
4297
  */
4112
4298
  export type Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends
4113
- readonly [infer Head extends Top, ...infer Tail extends ReadonlyArray<Top>] ? Readonly<[
4299
+ readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? Readonly<[
4114
4300
  ...T,
4115
4301
  ...Array<Head["Iso"]>,
4116
4302
  ...{ readonly [K in keyof Tail]: Tail[K]["Iso"] }
@@ -4130,7 +4316,7 @@ export declare namespace TupleWithRest {
4130
4316
  * @since 3.10.0
4131
4317
  */
4132
4318
  export type Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends
4133
- readonly [infer Head extends Top, ...infer Tail extends ReadonlyArray<Top>] ? readonly [
4319
+ readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? readonly [
4134
4320
  ...E,
4135
4321
  ...Array<Head["Encoded"]>,
4136
4322
  ...{ readonly [K in keyof Tail]: Tail[K]["Encoded"] }
@@ -4150,7 +4336,7 @@ export declare namespace TupleWithRest {
4150
4336
  * @since 4.0.0
4151
4337
  */
4152
4338
  export type MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends
4153
- readonly [infer Head extends Top, ...infer Tail extends ReadonlyArray<Top>] ? readonly [
4339
+ readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? readonly [
4154
4340
  ...M,
4155
4341
  ...Array<Head["~type.make"]>,
4156
4342
  ...{ readonly [K in keyof Tail]: Tail[K]["~type.make"] }
@@ -4168,17 +4354,18 @@ export interface TupleWithRest<
4168
4354
  S extends TupleWithRest.TupleType,
4169
4355
  Rest extends TupleWithRest.Rest
4170
4356
  > extends
4171
- Bottom<
4172
- TupleWithRest.Type<S["Type"], Rest>,
4173
- TupleWithRest.Encoded<S["Encoded"], Rest>,
4174
- S["DecodingServices"] | Rest[number]["DecodingServices"],
4175
- S["EncodingServices"] | Rest[number]["EncodingServices"],
4357
+ BottomLazy<
4176
4358
  SchemaAST.Arrays,
4177
- TupleWithRest<S, Rest>,
4178
- TupleWithRest.MakeIn<S["~type.make"], Rest>,
4179
- TupleWithRest.Iso<S["Iso"], Rest>
4359
+ TupleWithRest<S, Rest>
4180
4360
  >
4181
4361
  {
4362
+ readonly "Type": TupleWithRest.Type<S["Type"], Rest>
4363
+ readonly "Encoded": TupleWithRest.Encoded<S["Encoded"], Rest>
4364
+ readonly "DecodingServices": S["DecodingServices"] | Rest[number]["DecodingServices"]
4365
+ readonly "EncodingServices": S["EncodingServices"] | Rest[number]["EncodingServices"]
4366
+ readonly "~type.make.in": TupleWithRest.MakeIn<S["~type.make"], Rest>
4367
+ readonly "~type.make": TupleWithRest.MakeIn<S["~type.make"], Rest>
4368
+ readonly "Iso": TupleWithRest.Iso<S["Iso"], Rest>
4182
4369
  readonly schema: S
4183
4370
  readonly rest: Rest
4184
4371
  }
@@ -4226,24 +4413,25 @@ export function TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extend
4226
4413
  * @category models
4227
4414
  * @since 4.0.0
4228
4415
  */
4229
- export interface $Array<S extends Top> extends
4230
- Bottom<
4231
- ReadonlyArray<S["Type"]>,
4232
- ReadonlyArray<S["Encoded"]>,
4233
- S["DecodingServices"],
4234
- S["EncodingServices"],
4416
+ export interface $Array<S extends Constraint> extends
4417
+ BottomLazy<
4235
4418
  SchemaAST.Arrays,
4236
- $Array<S>,
4237
- ReadonlyArray<S["~type.make"]>,
4238
- ReadonlyArray<S["Iso"]>
4419
+ $Array<S>
4239
4420
  >
4240
4421
  {
4422
+ readonly "Type": ReadonlyArray<S["Type"]>
4423
+ readonly "Encoded": ReadonlyArray<S["Encoded"]>
4424
+ readonly "DecodingServices": S["DecodingServices"]
4425
+ readonly "EncodingServices": S["EncodingServices"]
4426
+ readonly "~type.make.in": ReadonlyArray<S["~type.make"]>
4427
+ readonly "~type.make": ReadonlyArray<S["~type.make"]>
4428
+ readonly "Iso": ReadonlyArray<S["Iso"]>
4241
4429
  readonly value: S
4242
4430
  }
4243
4431
 
4244
4432
  interface ArrayLambda extends Lambda {
4245
- <S extends Top>(self: S): $Array<S>
4246
- readonly "~lambda.out": this["~lambda.in"] extends Top ? $Array<this["~lambda.in"]> : never
4433
+ <S extends Constraint>(self: S): $Array<S>
4434
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? $Array<this["~lambda.in"]> : never
4247
4435
  }
4248
4436
 
4249
4437
  /**
@@ -4282,24 +4470,25 @@ export {
4282
4470
  * @category models
4283
4471
  * @since 3.10.0
4284
4472
  */
4285
- export interface NonEmptyArray<S extends Top> extends
4286
- Bottom<
4287
- readonly [S["Type"], ...Array<S["Type"]>],
4288
- readonly [S["Encoded"], ...Array<S["Encoded"]>],
4289
- S["DecodingServices"],
4290
- S["EncodingServices"],
4473
+ export interface NonEmptyArray<S extends Constraint> extends
4474
+ BottomLazy<
4291
4475
  SchemaAST.Arrays,
4292
- NonEmptyArray<S>,
4293
- readonly [S["~type.make"], ...Array<S["~type.make"]>],
4294
- readonly [S["Iso"], ...Array<S["Iso"]>]
4476
+ NonEmptyArray<S>
4295
4477
  >
4296
4478
  {
4479
+ readonly "Type": readonly [S["Type"], ...Array<S["Type"]>]
4480
+ readonly "Encoded": readonly [S["Encoded"], ...Array<S["Encoded"]>]
4481
+ readonly "DecodingServices": S["DecodingServices"]
4482
+ readonly "EncodingServices": S["EncodingServices"]
4483
+ readonly "~type.make.in": readonly [S["~type.make"], ...Array<S["~type.make"]>]
4484
+ readonly "~type.make": readonly [S["~type.make"], ...Array<S["~type.make"]>]
4485
+ readonly "Iso": readonly [S["Iso"], ...Array<S["Iso"]>]
4297
4486
  readonly value: S
4298
4487
  }
4299
4488
 
4300
4489
  interface NonEmptyArrayLambda extends Lambda {
4301
- <S extends Top>(self: S): NonEmptyArray<S>
4302
- readonly "~lambda.out": this["~lambda.in"] extends Top ? NonEmptyArray<this["~lambda.in"]> : never
4490
+ <S extends Constraint>(self: S): NonEmptyArray<S>
4491
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? NonEmptyArray<this["~lambda.in"]> : never
4303
4492
  }
4304
4493
 
4305
4494
  /**
@@ -4330,7 +4519,7 @@ export const NonEmptyArray = Struct_.lambda<NonEmptyArrayLambda>((schema) =>
4330
4519
  * @category constructors
4331
4520
  * @since 3.10.0
4332
4521
  */
4333
- export interface ArrayEnsure<S extends Top> extends decodeTo<$Array<toType<S>>, Union<readonly [S, $Array<S>]>> {
4522
+ export interface ArrayEnsure<S extends Constraint> extends decodeTo<$Array<toType<S>>, Union<readonly [S, $Array<S>]>> {
4334
4523
  readonly "Rebuild": ArrayEnsure<S>
4335
4524
  }
4336
4525
 
@@ -4360,7 +4549,7 @@ export interface ArrayEnsure<S extends Top> extends decodeTo<$Array<toType<S>>,
4360
4549
  * @category constructors
4361
4550
  * @since 3.10.0
4362
4551
  */
4363
- export function ArrayEnsure<S extends Top>(schema: S): ArrayEnsure<S> {
4552
+ export function ArrayEnsure<S extends Constraint>(schema: S): ArrayEnsure<S> {
4364
4553
  return Union([schema, ArraySchema(schema)]).pipe(decodeTo(
4365
4554
  ArraySchema(toType(schema)),
4366
4555
  SchemaTransformation.transform({
@@ -4376,7 +4565,7 @@ export function ArrayEnsure<S extends Top>(schema: S): ArrayEnsure<S> {
4376
4565
  * @category models
4377
4566
  * @since 4.0.0
4378
4567
  */
4379
- export interface UniqueArray<S extends Top> extends $Array<S> {
4568
+ export interface UniqueArray<S extends Constraint> extends $Array<S> {
4380
4569
  readonly "Rebuild": UniqueArray<S>
4381
4570
  }
4382
4571
 
@@ -4391,7 +4580,7 @@ export interface UniqueArray<S extends Top> extends $Array<S> {
4391
4580
  * @category constructors
4392
4581
  * @since 4.0.0
4393
4582
  */
4394
- export function UniqueArray<S extends Top>(item: S): UniqueArray<S> {
4583
+ export function UniqueArray<S extends Constraint>(item: S): UniqueArray<S> {
4395
4584
  return ArraySchema(item).check(isUnique())
4396
4585
  }
4397
4586
 
@@ -4401,19 +4590,11 @@ export function UniqueArray<S extends Top>(item: S): UniqueArray<S> {
4401
4590
  * @category transforming
4402
4591
  * @since 3.10.0
4403
4592
  */
4404
- export interface mutable<S extends Top & { readonly "ast": SchemaAST.Arrays }> extends
4405
- Bottom<
4406
- Mutable<S["Type"]>,
4407
- Mutable<S["Encoded"]>,
4408
- S["DecodingServices"],
4409
- S["EncodingServices"],
4593
+ export interface mutable<S extends Constraint & { readonly "ast": SchemaAST.Arrays }> extends
4594
+ BottomLazy<
4410
4595
  S["ast"],
4411
4596
  mutable<S>,
4412
- // "~type.make" and "~type.make.in" as they are because they are contravariant
4413
- S["~type.make.in"],
4414
- S["Iso"],
4415
4597
  S["~type.parameters"],
4416
- S["~type.make"],
4417
4598
  S["~type.mutability"],
4418
4599
  S["~type.optionality"],
4419
4600
  S["~type.constructor.default"],
@@ -4421,12 +4602,20 @@ export interface mutable<S extends Top & { readonly "ast": SchemaAST.Arrays }> e
4421
4602
  S["~encoded.optionality"]
4422
4603
  >
4423
4604
  {
4605
+ readonly "Type": Mutable<S["Type"]>
4606
+ readonly "Encoded": Mutable<S["Encoded"]>
4607
+ readonly "DecodingServices": S["DecodingServices"]
4608
+ readonly "EncodingServices": S["EncodingServices"]
4609
+ // "~type.make" and "~type.make.in" as they are because they are contravariant
4610
+ readonly "~type.make.in": S["~type.make.in"]
4611
+ readonly "~type.make": S["~type.make"]
4612
+ readonly "Iso": S["Iso"]
4424
4613
  readonly schema: S
4425
4614
  }
4426
4615
 
4427
4616
  interface mutableLambda extends Lambda {
4428
- <S extends Top & { readonly "ast": SchemaAST.Arrays }>(self: S): mutable<S>
4429
- readonly "~lambda.out": this["~lambda.in"] extends Top & { readonly "ast": SchemaAST.Arrays } ?
4617
+ <S extends Constraint & { readonly "ast": SchemaAST.Arrays }>(self: S): mutable<S>
4618
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint & { readonly "ast": SchemaAST.Arrays } ?
4430
4619
  mutable<this["~lambda.in"]>
4431
4620
  : "Error: schema not eligible for mutable"
4432
4621
  }
@@ -4458,18 +4647,19 @@ export const mutable = Struct_.lambda<mutableLambda>((schema) => {
4458
4647
  * @category models
4459
4648
  * @since 3.10.0
4460
4649
  */
4461
- export interface Union<Members extends ReadonlyArray<Top>> extends
4462
- Bottom<
4463
- { [K in keyof Members]: Members[K]["Type"] }[number],
4464
- { [K in keyof Members]: Members[K]["Encoded"] }[number],
4465
- { [K in keyof Members]: Members[K]["DecodingServices"] }[number],
4466
- { [K in keyof Members]: Members[K]["EncodingServices"] }[number],
4650
+ export interface Union<Members extends ReadonlyArray<Constraint>> extends
4651
+ BottomLazy<
4467
4652
  SchemaAST.Union<{ [K in keyof Members]: Members[K]["ast"] }[number]>,
4468
- Union<Members>,
4469
- { [K in keyof Members]: Members[K]["~type.make"] }[number],
4470
- { [K in keyof Members]: Members[K]["Iso"] }[number]
4653
+ Union<Members>
4471
4654
  >
4472
4655
  {
4656
+ readonly "Type": { [K in keyof Members]: Members[K]["Type"] }[number]
4657
+ readonly "Encoded": { [K in keyof Members]: Members[K]["Encoded"] }[number]
4658
+ readonly "DecodingServices": { [K in keyof Members]: Members[K]["DecodingServices"] }[number]
4659
+ readonly "EncodingServices": { [K in keyof Members]: Members[K]["EncodingServices"] }[number]
4660
+ readonly "~type.make.in": { [K in keyof Members]: Members[K]["~type.make"] }[number]
4661
+ readonly "~type.make": { [K in keyof Members]: Members[K]["~type.make"] }[number]
4662
+ readonly "Iso": { [K in keyof Members]: Members[K]["Iso"] }[number]
4473
4663
  readonly members: Members
4474
4664
  /**
4475
4665
  * Returns a new union with the members modified by the provided function.
@@ -4487,7 +4677,7 @@ export interface Union<Members extends ReadonlyArray<Top>> extends
4487
4677
  * use this option if you have verified that your refinements remain correct
4488
4678
  * after the transformation.
4489
4679
  */
4490
- mapMembers<To extends ReadonlyArray<Top>>(
4680
+ mapMembers<To extends ReadonlyArray<Constraint>>(
4491
4681
  f: (members: Members) => To,
4492
4682
  options?: {
4493
4683
  readonly unsafePreserveChecks?: boolean | undefined
@@ -4495,13 +4685,13 @@ export interface Union<Members extends ReadonlyArray<Top>> extends
4495
4685
  ): Union<Simplify<Readonly<To>>>
4496
4686
  }
4497
4687
 
4498
- function makeUnion<Members extends ReadonlyArray<Top>>(
4688
+ function makeUnion<Members extends ReadonlyArray<Constraint>>(
4499
4689
  ast: SchemaAST.Union<Members[number]["ast"]>,
4500
4690
  members: Members
4501
4691
  ): Union<Members> {
4502
4692
  return make(ast, {
4503
4693
  members,
4504
- mapMembers<To extends ReadonlyArray<Top>>(
4694
+ mapMembers<To extends ReadonlyArray<Constraint>>(
4505
4695
  this: Union<Members>,
4506
4696
  f: (members: Members) => To,
4507
4697
  options?: {
@@ -4541,7 +4731,7 @@ function makeUnion<Members extends ReadonlyArray<Top>>(
4541
4731
  * @category constructors
4542
4732
  * @since 3.10.0
4543
4733
  */
4544
- export function Union<const Members extends ReadonlyArray<Top>>(
4734
+ export function Union<const Members extends ReadonlyArray<Constraint>>(
4545
4735
  members: Members,
4546
4736
  options?: { mode?: "anyOf" | "oneOf" }
4547
4737
  ): Union<Members> {
@@ -4562,7 +4752,7 @@ export interface Literals<L extends ReadonlyArray<SchemaAST.LiteralValue>>
4562
4752
  /**
4563
4753
  * Map over the members of the union.
4564
4754
  */
4565
- mapMembers<To extends ReadonlyArray<Top>>(f: (members: this["members"]) => To): Union<Simplify<Readonly<To>>>
4755
+ mapMembers<To extends ReadonlyArray<Constraint>>(f: (members: this["members"]) => To): Union<Simplify<Readonly<To>>>
4566
4756
 
4567
4757
  pick<const L2 extends ReadonlyArray<L[number]>>(literals: L2): Literals<L2>
4568
4758
 
@@ -4592,7 +4782,7 @@ export function Literals<const L extends ReadonlyArray<SchemaAST.LiteralValue>>(
4592
4782
  return make(SchemaAST.union(members, "anyOf", undefined), {
4593
4783
  literals,
4594
4784
  members,
4595
- mapMembers<To extends ReadonlyArray<Top>>(
4785
+ mapMembers<To extends ReadonlyArray<Constraint>>(
4596
4786
  this: Literals<L>,
4597
4787
  f: (members: Literals<L>["members"]) => To
4598
4788
  ): Union<Simplify<Readonly<To>>> {
@@ -4615,13 +4805,13 @@ export function Literals<const L extends ReadonlyArray<SchemaAST.LiteralValue>>(
4615
4805
  * @category models
4616
4806
  * @since 3.10.0
4617
4807
  */
4618
- export interface NullOr<S extends Top> extends Union<readonly [S, Null]> {
4808
+ export interface NullOr<S extends Constraint> extends Union<readonly [S, Null]> {
4619
4809
  readonly "Rebuild": NullOr<S>
4620
4810
  }
4621
4811
 
4622
4812
  interface NullOrLambda extends Lambda {
4623
- <S extends Top>(self: S): NullOr<S>
4624
- readonly "~lambda.out": this["~lambda.in"] extends Top ? NullOr<this["~lambda.in"]> : never
4813
+ <S extends Constraint>(self: S): NullOr<S>
4814
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? NullOr<this["~lambda.in"]> : never
4625
4815
  }
4626
4816
 
4627
4817
  /**
@@ -4638,13 +4828,13 @@ export const NullOr = Struct_.lambda<NullOrLambda>((self) => Union([self, Null])
4638
4828
  * @category models
4639
4829
  * @since 3.10.0
4640
4830
  */
4641
- export interface UndefinedOr<S extends Top> extends Union<readonly [S, Undefined]> {
4831
+ export interface UndefinedOr<S extends Constraint> extends Union<readonly [S, Undefined]> {
4642
4832
  readonly "Rebuild": UndefinedOr<S>
4643
4833
  }
4644
4834
 
4645
4835
  interface UndefinedOrLambda extends Lambda {
4646
- <S extends Top>(self: S): UndefinedOr<S>
4647
- readonly "~lambda.out": this["~lambda.in"] extends Top ? UndefinedOr<this["~lambda.in"]> : never
4836
+ <S extends Constraint>(self: S): UndefinedOr<S>
4837
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? UndefinedOr<this["~lambda.in"]> : never
4648
4838
  }
4649
4839
 
4650
4840
  /**
@@ -4661,13 +4851,13 @@ export const UndefinedOr = Struct_.lambda<UndefinedOrLambda>((self) => Union([se
4661
4851
  * @category models
4662
4852
  * @since 3.10.0
4663
4853
  */
4664
- export interface NullishOr<S extends Top> extends Union<readonly [S, Null, Undefined]> {
4854
+ export interface NullishOr<S extends Constraint> extends Union<readonly [S, Null, Undefined]> {
4665
4855
  readonly "Rebuild": NullishOr<S>
4666
4856
  }
4667
4857
 
4668
4858
  interface NullishOrLambda extends Lambda {
4669
- <S extends Top>(self: S): NullishOr<S>
4670
- readonly "~lambda.out": this["~lambda.in"] extends Top ? NullishOr<this["~lambda.in"]> : never
4859
+ <S extends Constraint>(self: S): NullishOr<S>
4860
+ readonly "~lambda.out": this["~lambda.in"] extends Constraint ? NullishOr<this["~lambda.in"]> : never
4671
4861
  }
4672
4862
 
4673
4863
  /**
@@ -4684,25 +4874,26 @@ export const NullishOr = Struct_.lambda<NullishOrLambda>((self) => Union([self,
4684
4874
  * @category models
4685
4875
  * @since 3.10.0
4686
4876
  */
4687
- export interface suspend<S extends Top> extends
4688
- Bottom<
4689
- S["Type"],
4690
- S["Encoded"],
4691
- S["DecodingServices"],
4692
- S["EncodingServices"],
4877
+ export interface suspend<S extends Constraint> extends
4878
+ BottomLazy<
4693
4879
  SchemaAST.Suspend,
4694
4880
  suspend<S>,
4695
- S["~type.make.in"],
4696
- S["Iso"],
4697
4881
  S["~type.parameters"],
4698
- S["~type.make"],
4699
4882
  S["~type.mutability"],
4700
4883
  S["~type.optionality"],
4701
4884
  S["~type.constructor.default"],
4702
4885
  S["~encoded.mutability"],
4703
4886
  S["~encoded.optionality"]
4704
4887
  >
4705
- {}
4888
+ {
4889
+ readonly "Type": S["Type"]
4890
+ readonly "Encoded": S["Encoded"]
4891
+ readonly "DecodingServices": S["DecodingServices"]
4892
+ readonly "EncodingServices": S["EncodingServices"]
4893
+ readonly "~type.make.in": S["~type.make.in"]
4894
+ readonly "~type.make": S["~type.make"]
4895
+ readonly "Iso": S["Iso"]
4896
+ }
4706
4897
 
4707
4898
  /**
4708
4899
  * Creates a suspended schema that defers evaluation until needed. This is
@@ -4728,7 +4919,7 @@ export interface suspend<S extends Top> extends
4728
4919
  * @category constructors
4729
4920
  * @since 3.10.0
4730
4921
  */
4731
- export function suspend<S extends Top>(f: () => S): suspend<S> {
4922
+ export function suspend<S extends Constraint>(f: () => S): suspend<S> {
4732
4923
  return make(new SchemaAST.Suspend(() => f().ast))
4733
4924
  }
4734
4925
 
@@ -4761,18 +4952,11 @@ export function check<S extends Top>(
4761
4952
  * @category filtering
4762
4953
  * @since 3.10.0
4763
4954
  */
4764
- export interface refine<T extends S["Type"], S extends Top> extends
4765
- Bottom<
4766
- T,
4767
- S["Encoded"],
4768
- S["DecodingServices"],
4769
- S["EncodingServices"],
4955
+ export interface refine<T extends S["Type"], S extends Constraint> extends
4956
+ BottomLazy<
4770
4957
  S["ast"],
4771
4958
  refine<T, S>,
4772
- S["~type.make.in"],
4773
- T,
4774
4959
  S["~type.parameters"],
4775
- T,
4776
4960
  S["~type.mutability"],
4777
4961
  S["~type.optionality"],
4778
4962
  S["~type.constructor.default"],
@@ -4780,6 +4964,13 @@ export interface refine<T extends S["Type"], S extends Top> extends
4780
4964
  S["~encoded.optionality"]
4781
4965
  >
4782
4966
  {
4967
+ readonly "Type": T
4968
+ readonly "Encoded": S["Encoded"]
4969
+ readonly "DecodingServices": S["DecodingServices"]
4970
+ readonly "EncodingServices": S["EncodingServices"]
4971
+ readonly "~type.make.in": S["~type.make.in"]
4972
+ readonly "~type.make": T
4973
+ readonly "Iso": T
4783
4974
  readonly schema: S
4784
4975
  }
4785
4976
 
@@ -4798,7 +4989,7 @@ export interface refine<T extends S["Type"], S extends Top> extends
4798
4989
  * @category filtering
4799
4990
  * @since 3.10.0
4800
4991
  */
4801
- export function refine<S extends Top, T extends S["Type"]>(
4992
+ export function refine<S extends Constraint, T extends S["Type"]>(
4802
4993
  refinement: (value: S["Type"]) => value is T,
4803
4994
  annotations?: Annotations.Filter
4804
4995
  ) {
@@ -4814,18 +5005,11 @@ type DistributeBrands<B> = UnionToIntersection<B extends infer U extends string
4814
5005
  * @category branding
4815
5006
  * @since 3.10.0
4816
5007
  */
4817
- export interface brand<S extends Top, B> extends
4818
- Bottom<
4819
- S["Type"] & DistributeBrands<B>,
4820
- S["Encoded"],
4821
- S["DecodingServices"],
4822
- S["EncodingServices"],
5008
+ export interface brand<S extends Constraint, B> extends
5009
+ BottomLazy<
4823
5010
  S["ast"],
4824
5011
  brand<S, B>,
4825
- S["~type.make.in"],
4826
- S["Type"] & DistributeBrands<B>,
4827
5012
  S["~type.parameters"],
4828
- S["Type"] & DistributeBrands<B>,
4829
5013
  S["~type.mutability"],
4830
5014
  S["~type.optionality"],
4831
5015
  S["~type.constructor.default"],
@@ -4833,6 +5017,13 @@ export interface brand<S extends Top, B> extends
4833
5017
  S["~encoded.optionality"]
4834
5018
  >
4835
5019
  {
5020
+ readonly "Type": S["Type"] & DistributeBrands<B>
5021
+ readonly "Encoded": S["Encoded"]
5022
+ readonly "DecodingServices": S["DecodingServices"]
5023
+ readonly "EncodingServices": S["EncodingServices"]
5024
+ readonly "~type.make.in": S["~type.make.in"]
5025
+ readonly "~type.make": S["Type"] & DistributeBrands<B>
5026
+ readonly "Iso": S["Type"] & DistributeBrands<B>
4836
5027
  readonly schema: S
4837
5028
  readonly identifier: string
4838
5029
  }
@@ -4857,7 +5048,7 @@ export interface brand<S extends Top, B> extends
4857
5048
  * @since 3.10.0
4858
5049
  */
4859
5050
  export function brand<B extends string>(identifier: B) {
4860
- return <S extends Top>(schema: S): brand<S["Rebuild"], B> =>
5051
+ return <S extends ConstraintRebuildable>(schema: S): brand<S["Rebuild"], B> =>
4861
5052
  make(SchemaAST.brand(schema.ast, identifier), { schema, identifier })
4862
5053
  }
4863
5054
 
@@ -4882,18 +5073,11 @@ export function fromBrand<A extends Brand.Brand<any>>(identifier: string, ctor:
4882
5073
  * @category decoding
4883
5074
  * @since 4.0.0
4884
5075
  */
4885
- export interface middlewareDecoding<S extends Top, RD> extends
4886
- Bottom<
4887
- S["Type"],
4888
- S["Encoded"],
4889
- RD,
4890
- S["EncodingServices"],
5076
+ export interface middlewareDecoding<S extends Constraint, RD> extends
5077
+ BottomLazy<
4891
5078
  S["ast"],
4892
5079
  middlewareDecoding<S, RD>,
4893
- S["~type.make.in"],
4894
- S["Iso"],
4895
5080
  S["~type.parameters"],
4896
- S["~type.make"],
4897
5081
  S["~type.mutability"],
4898
5082
  S["~type.optionality"],
4899
5083
  S["~type.constructor.default"],
@@ -4901,6 +5085,13 @@ export interface middlewareDecoding<S extends Top, RD> extends
4901
5085
  S["~encoded.optionality"]
4902
5086
  >
4903
5087
  {
5088
+ readonly "Type": S["Type"]
5089
+ readonly "Encoded": S["Encoded"]
5090
+ readonly "DecodingServices": RD
5091
+ readonly "EncodingServices": S["EncodingServices"]
5092
+ readonly "~type.make.in": S["~type.make.in"]
5093
+ readonly "~type.make": S["~type.make"]
5094
+ readonly "Iso": S["Iso"]
4904
5095
  readonly schema: S
4905
5096
  }
4906
5097
 
@@ -4929,7 +5120,7 @@ export interface middlewareDecoding<S extends Top, RD> extends
4929
5120
  * @category decoding
4930
5121
  * @since 4.0.0
4931
5122
  */
4932
- export function middlewareDecoding<S extends Top, RD>(
5123
+ export function middlewareDecoding<S extends Constraint, RD>(
4933
5124
  decode: (
4934
5125
  effect: Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, S["DecodingServices"]>,
4935
5126
  options: SchemaAST.ParseOptions
@@ -4948,18 +5139,11 @@ export function middlewareDecoding<S extends Top, RD>(
4948
5139
  * @category encoding
4949
5140
  * @since 4.0.0
4950
5141
  */
4951
- export interface middlewareEncoding<S extends Top, RE> extends
4952
- Bottom<
4953
- S["Type"],
4954
- S["Encoded"],
4955
- S["DecodingServices"],
4956
- RE,
5142
+ export interface middlewareEncoding<S extends Constraint, RE> extends
5143
+ BottomLazy<
4957
5144
  S["ast"],
4958
5145
  middlewareEncoding<S, RE>,
4959
- S["~type.make.in"],
4960
- S["Iso"],
4961
5146
  S["~type.parameters"],
4962
- S["~type.make"],
4963
5147
  S["~type.mutability"],
4964
5148
  S["~type.optionality"],
4965
5149
  S["~type.constructor.default"],
@@ -4967,6 +5151,13 @@ export interface middlewareEncoding<S extends Top, RE> extends
4967
5151
  S["~encoded.optionality"]
4968
5152
  >
4969
5153
  {
5154
+ readonly "Type": S["Type"]
5155
+ readonly "Encoded": S["Encoded"]
5156
+ readonly "DecodingServices": S["DecodingServices"]
5157
+ readonly "EncodingServices": RE
5158
+ readonly "~type.make.in": S["~type.make.in"]
5159
+ readonly "~type.make": S["~type.make"]
5160
+ readonly "Iso": S["Iso"]
4970
5161
  readonly schema: S
4971
5162
  }
4972
5163
 
@@ -4995,7 +5186,7 @@ export interface middlewareEncoding<S extends Top, RE> extends
4995
5186
  * @category encoding
4996
5187
  * @since 4.0.0
4997
5188
  */
4998
- export function middlewareEncoding<S extends Top, RE>(
5189
+ export function middlewareEncoding<S extends Constraint, RE>(
4999
5190
  encode: (
5000
5191
  effect: Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, S["EncodingServices"]>,
5001
5192
  options: SchemaAST.ParseOptions
@@ -5030,9 +5221,9 @@ export function middlewareEncoding<S extends Top, RE>(
5030
5221
  * @category error handling
5031
5222
  * @since 4.0.0
5032
5223
  */
5033
- export function catchDecoding<S extends Top>(
5224
+ export function catchDecoding<S extends Constraint>(
5034
5225
  f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue>
5035
- ): (self: S) => S["Rebuild"] {
5226
+ ): (self: S) => middlewareDecoding<S, S["DecodingServices"]> {
5036
5227
  return catchDecodingWithContext(f)
5037
5228
  }
5038
5229
 
@@ -5056,11 +5247,11 @@ export function catchDecoding<S extends Top>(
5056
5247
  * @category error handling
5057
5248
  * @since 4.0.0
5058
5249
  */
5059
- export function catchDecodingWithContext<S extends Top, R = never>(
5250
+ export function catchDecodingWithContext<S extends Constraint, R = never>(
5060
5251
  f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>
5061
5252
  ) {
5062
5253
  return (self: S): middlewareDecoding<S, S["DecodingServices"] | R> =>
5063
- self.pipe(middlewareDecoding(Effect.catchEager(f)))
5254
+ middlewareDecoding<S, S["DecodingServices"] | R>(Effect.catchEager(f))(self)
5064
5255
  }
5065
5256
 
5066
5257
  /**
@@ -5075,9 +5266,9 @@ export function catchDecodingWithContext<S extends Top, R = never>(
5075
5266
  * @category error handling
5076
5267
  * @since 4.0.0
5077
5268
  */
5078
- export function catchEncoding<S extends Top>(
5269
+ export function catchEncoding<S extends Constraint>(
5079
5270
  f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue>
5080
- ): (self: S) => S["Rebuild"] {
5271
+ ): (self: S) => middlewareEncoding<S, S["EncodingServices"]> {
5081
5272
  return catchEncodingWithContext(f)
5082
5273
  }
5083
5274
 
@@ -5101,11 +5292,11 @@ export function catchEncoding<S extends Top>(
5101
5292
  * @category error handling
5102
5293
  * @since 4.0.0
5103
5294
  */
5104
- export function catchEncodingWithContext<S extends Top, R = never>(
5295
+ export function catchEncodingWithContext<S extends Constraint, R = never>(
5105
5296
  f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, R>
5106
5297
  ) {
5107
5298
  return (self: S): middlewareEncoding<S, S["EncodingServices"] | R> =>
5108
- self.pipe(middlewareEncoding(Effect.catchEager(f)))
5299
+ middlewareEncoding<S, S["EncodingServices"] | R>(Effect.catchEager(f))(self)
5109
5300
  }
5110
5301
 
5111
5302
  /**
@@ -5114,18 +5305,11 @@ export function catchEncodingWithContext<S extends Top, R = never>(
5114
5305
  * @category transforming
5115
5306
  * @since 4.0.0
5116
5307
  */
5117
- export interface decodeTo<To extends Top, From extends Top, RD = never, RE = never> extends
5118
- Bottom<
5119
- To["Type"],
5120
- From["Encoded"],
5121
- To["DecodingServices"] | From["DecodingServices"] | RD,
5122
- To["EncodingServices"] | From["EncodingServices"] | RE,
5308
+ export interface decodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never> extends
5309
+ BottomLazy<
5123
5310
  To["ast"],
5124
5311
  decodeTo<To, From, RD, RE>,
5125
- To["~type.make.in"],
5126
- To["Iso"],
5127
5312
  To["~type.parameters"],
5128
- To["~type.make"],
5129
5313
  To["~type.mutability"],
5130
5314
  To["~type.optionality"],
5131
5315
  To["~type.constructor.default"],
@@ -5133,6 +5317,13 @@ export interface decodeTo<To extends Top, From extends Top, RD = never, RE = nev
5133
5317
  From["~encoded.optionality"]
5134
5318
  >
5135
5319
  {
5320
+ readonly "Type": To["Type"]
5321
+ readonly "Encoded": From["Encoded"]
5322
+ readonly "DecodingServices": To["DecodingServices"] | From["DecodingServices"] | RD
5323
+ readonly "EncodingServices": To["EncodingServices"] | From["EncodingServices"] | RE
5324
+ readonly "~type.make.in": To["~type.make.in"]
5325
+ readonly "~type.make": To["~type.make"]
5326
+ readonly "Iso": To["Iso"]
5136
5327
  readonly from: From
5137
5328
  readonly to: To
5138
5329
  }
@@ -5143,7 +5334,7 @@ export interface decodeTo<To extends Top, From extends Top, RD = never, RE = nev
5143
5334
  * @category transforming
5144
5335
  * @since 3.10.0
5145
5336
  */
5146
- export interface compose<To extends Top, From extends Top> extends decodeTo<To, From> {}
5337
+ export interface compose<To extends Constraint, From extends Constraint> extends decodeTo<To, From> {}
5147
5338
 
5148
5339
  /**
5149
5340
  * Creates a schema that transforms from a source schema to a target schema.
@@ -5193,15 +5384,15 @@ export interface compose<To extends Top, From extends Top> extends decodeTo<To,
5193
5384
  * @category transforming
5194
5385
  * @since 4.0.0
5195
5386
  */
5196
- export function decodeTo<To extends Top>(to: To): <From extends Top>(from: From) => compose<To, From>
5197
- export function decodeTo<To extends Top, From extends Top, RD = never, RE = never>(
5387
+ export function decodeTo<To extends Constraint>(to: To): <From extends Constraint>(from: From) => compose<To, From>
5388
+ export function decodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
5198
5389
  to: To,
5199
5390
  transformation: {
5200
5391
  readonly decode: SchemaGetter.Getter<NoInfer<To["Encoded"]>, NoInfer<From["Type"]>, RD>
5201
5392
  readonly encode: SchemaGetter.Getter<NoInfer<From["Type"]>, NoInfer<To["Encoded"]>, RE>
5202
5393
  }
5203
5394
  ): (from: From) => decodeTo<To, From, RD, RE>
5204
- export function decodeTo<To extends Top, From extends Top, RD = never, RE = never>(
5395
+ export function decodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
5205
5396
  to: To,
5206
5397
  transformation?: {
5207
5398
  readonly decode: SchemaGetter.Getter<To["Encoded"], From["Type"], RD>
@@ -5266,12 +5457,12 @@ export function decodeTo<To extends Top, From extends Top, RD = never, RE = neve
5266
5457
  * @category transforming
5267
5458
  * @since 3.10.0
5268
5459
  */
5269
- export function decode<S extends Top, RD = never, RE = never>(transformation: {
5460
+ export function decode<S extends Constraint, RD = never, RE = never>(transformation: {
5270
5461
  readonly decode: SchemaGetter.Getter<S["Type"], S["Type"], RD>
5271
5462
  readonly encode: SchemaGetter.Getter<S["Type"], S["Type"], RE>
5272
5463
  }) {
5273
5464
  return (self: S): decodeTo<toType<S>, S, RD, RE> => {
5274
- return self.pipe(decodeTo(toType(self), transformation))
5465
+ return decodeTo<toType<S>, S, RD, RE>(toType(self), transformation)(self)
5275
5466
  }
5276
5467
  }
5277
5468
 
@@ -5304,17 +5495,17 @@ export function decode<S extends Top, RD = never, RE = never>(transformation: {
5304
5495
  * @category transforming
5305
5496
  * @since 4.0.0
5306
5497
  */
5307
- export function encodeTo<To extends Top>(
5498
+ export function encodeTo<To extends Constraint>(
5308
5499
  to: To
5309
- ): <From extends Top>(from: From) => decodeTo<From, To>
5310
- export function encodeTo<To extends Top, From extends Top, RD = never, RE = never>(
5500
+ ): <From extends Constraint>(from: From) => decodeTo<From, To>
5501
+ export function encodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
5311
5502
  to: To,
5312
5503
  transformation: {
5313
5504
  readonly decode: SchemaGetter.Getter<NoInfer<From["Encoded"]>, NoInfer<To["Type"]>, RD>
5314
5505
  readonly encode: SchemaGetter.Getter<NoInfer<To["Type"]>, NoInfer<From["Encoded"]>, RE>
5315
5506
  }
5316
5507
  ): (from: From) => decodeTo<From, To, RD, RE>
5317
- export function encodeTo<To extends Top, From extends Top, RD = never, RE = never>(
5508
+ export function encodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
5318
5509
  to: To,
5319
5510
  transformation?: {
5320
5511
  readonly decode: SchemaGetter.Getter<From["Encoded"], To["Type"], RD>
@@ -5323,8 +5514,8 @@ export function encodeTo<To extends Top, From extends Top, RD = never, RE = neve
5323
5514
  ) {
5324
5515
  return (from: From): decodeTo<From, To, RD, RE> => {
5325
5516
  return transformation ?
5326
- to.pipe(decodeTo(from, transformation)) :
5327
- to.pipe(decodeTo(from))
5517
+ decodeTo<From, To, RD, RE>(from, transformation)(to) :
5518
+ decodeTo<From>(from)(to)
5328
5519
  }
5329
5520
  }
5330
5521
 
@@ -5353,12 +5544,12 @@ export function encodeTo<To extends Top, From extends Top, RD = never, RE = neve
5353
5544
  * @category transforming
5354
5545
  * @since 3.10.0
5355
5546
  */
5356
- export function encode<S extends Top, RD = never, RE = never>(transformation: {
5547
+ export function encode<S extends Constraint, RD = never, RE = never>(transformation: {
5357
5548
  readonly decode: SchemaGetter.Getter<S["Encoded"], S["Encoded"], RD>
5358
5549
  readonly encode: SchemaGetter.Getter<S["Encoded"], S["Encoded"], RE>
5359
5550
  }) {
5360
5551
  return (self: S): decodeTo<S, toEncoded<S>, RD, RE> => {
5361
- return toEncoded(self).pipe(decodeTo(self, transformation))
5552
+ return decodeTo<S, toEncoded<S>, RD, RE>(self, transformation)(toEncoded(self))
5362
5553
  }
5363
5554
  }
5364
5555
 
@@ -5382,18 +5573,11 @@ export interface WithoutConstructorDefault {
5382
5573
  * @category constructors
5383
5574
  * @since 3.10.0
5384
5575
  */
5385
- export interface withConstructorDefault<S extends Top & WithoutConstructorDefault> extends
5386
- Bottom<
5387
- S["Type"],
5388
- S["Encoded"],
5389
- S["DecodingServices"],
5390
- S["EncodingServices"],
5576
+ export interface withConstructorDefault<S extends Constraint & WithoutConstructorDefault> extends
5577
+ BottomLazy<
5391
5578
  S["ast"],
5392
5579
  withConstructorDefault<S>,
5393
- S["~type.make.in"],
5394
- S["Iso"],
5395
5580
  S["~type.parameters"],
5396
- S["~type.make"],
5397
5581
  S["~type.mutability"],
5398
5582
  S["~type.optionality"],
5399
5583
  "with-default",
@@ -5401,6 +5585,13 @@ export interface withConstructorDefault<S extends Top & WithoutConstructorDefaul
5401
5585
  S["~encoded.optionality"]
5402
5586
  >
5403
5587
  {
5588
+ readonly "Type": S["Type"]
5589
+ readonly "Encoded": S["Encoded"]
5590
+ readonly "DecodingServices": S["DecodingServices"]
5591
+ readonly "EncodingServices": S["EncodingServices"]
5592
+ readonly "~type.make.in": S["~type.make.in"]
5593
+ readonly "~type.make": S["~type.make"]
5594
+ readonly "Iso": S["Iso"]
5404
5595
  readonly schema: S
5405
5596
  }
5406
5597
 
@@ -5431,7 +5622,7 @@ export interface withConstructorDefault<S extends Top & WithoutConstructorDefaul
5431
5622
  * @category constructors
5432
5623
  * @since 3.10.0
5433
5624
  */
5434
- export function withConstructorDefault<S extends Top & WithoutConstructorDefault>(
5625
+ export function withConstructorDefault<S extends Constraint & WithoutConstructorDefault>(
5435
5626
  // `S["~type.make.in"]` instead of `S["Type"]` is intentional here because
5436
5627
  // it makes easier to define the default value if there are nested defaults
5437
5628
  defaultValue: Effect.Effect<S["~type.make.in"], SchemaError>
@@ -5446,7 +5637,9 @@ export function withConstructorDefault<S extends Top & WithoutConstructorDefault
5446
5637
  * @category decoding
5447
5638
  * @since 4.0.0
5448
5639
  */
5449
- export interface withDecodingDefaultKey<S extends Top, R = never> extends decodeTo<S, optionalKey<toEncoded<S>>, R> {
5640
+ export interface withDecodingDefaultKey<S extends Constraint, R = never>
5641
+ extends decodeTo<S, optionalKey<toEncoded<S>>, R>
5642
+ {
5450
5643
  readonly "Rebuild": withDecodingDefaultKey<S, R>
5451
5644
  }
5452
5645
 
@@ -5500,7 +5693,7 @@ export type DecodingDefaultOptions = {
5500
5693
  * @category decoding
5501
5694
  * @since 4.0.0
5502
5695
  */
5503
- export function withDecodingDefaultKey<S extends Top, R = never>(
5696
+ export function withDecodingDefaultKey<S extends Constraint, R = never>(
5504
5697
  defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>,
5505
5698
  options?: DecodingDefaultOptions
5506
5699
  ) {
@@ -5519,7 +5712,7 @@ export function withDecodingDefaultKey<S extends Top, R = never>(
5519
5712
  * @category decoding
5520
5713
  * @since 4.0.0
5521
5714
  */
5522
- export interface withDecodingDefaultTypeKey<S extends Top, R = never>
5715
+ export interface withDecodingDefaultTypeKey<S extends Constraint, R = never>
5523
5716
  extends decodeTo<withDecodingDefaultKey<toType<S>, R>, optionalKey<S>>
5524
5717
  {
5525
5718
  readonly "Rebuild": withDecodingDefaultTypeKey<S, R>
@@ -5547,7 +5740,7 @@ export interface withDecodingDefaultTypeKey<S extends Top, R = never>
5547
5740
  * @category decoding
5548
5741
  * @since 4.0.0
5549
5742
  */
5550
- export function withDecodingDefaultTypeKey<S extends Top, R = never>(
5743
+ export function withDecodingDefaultTypeKey<S extends Constraint, R = never>(
5551
5744
  defaultValue: Effect.Effect<S["Type"], SchemaError, R>,
5552
5745
  options?: DecodingDefaultOptions
5553
5746
  ) {
@@ -5565,7 +5758,7 @@ export function withDecodingDefaultTypeKey<S extends Top, R = never>(
5565
5758
  * @category decoding
5566
5759
  * @since 3.10.0
5567
5760
  */
5568
- export interface withDecodingDefault<S extends Top, R = never> extends decodeTo<S, optional<toEncoded<S>>, R> {
5761
+ export interface withDecodingDefault<S extends Constraint, R = never> extends decodeTo<S, optional<toEncoded<S>>, R> {
5569
5762
  readonly "Rebuild": withDecodingDefault<S, R>
5570
5763
  }
5571
5764
 
@@ -5608,7 +5801,7 @@ export interface withDecodingDefault<S extends Top, R = never> extends decodeTo<
5608
5801
  * @category decoding
5609
5802
  * @since 3.10.0
5610
5803
  */
5611
- export function withDecodingDefault<S extends Top, R = never>(
5804
+ export function withDecodingDefault<S extends Constraint, R = never>(
5612
5805
  defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>,
5613
5806
  options?: DecodingDefaultOptions
5614
5807
  ) {
@@ -5627,7 +5820,7 @@ export function withDecodingDefault<S extends Top, R = never>(
5627
5820
  * @category decoding
5628
5821
  * @since 4.0.0
5629
5822
  */
5630
- export interface withDecodingDefaultType<S extends Top, R = never>
5823
+ export interface withDecodingDefaultType<S extends Constraint, R = never>
5631
5824
  extends decodeTo<withDecodingDefault<toType<S>, R>, optional<S>>
5632
5825
  {
5633
5826
  readonly "Rebuild": withDecodingDefaultType<S, R>
@@ -5660,7 +5853,7 @@ export interface withDecodingDefaultType<S extends Top, R = never>
5660
5853
  * @category decoding
5661
5854
  * @since 4.0.0
5662
5855
  */
5663
- export function withDecodingDefaultType<S extends Top, R = never>(
5856
+ export function withDecodingDefaultType<S extends Constraint, R = never>(
5664
5857
  defaultValue: Effect.Effect<S["Type"], SchemaError, R>,
5665
5858
  options?: DecodingDefaultOptions
5666
5859
  ) {
@@ -5815,8 +6008,8 @@ type Flatten<Schemas> = Schemas extends readonly [infer Head, ...infer Tail]
5815
6008
 
5816
6009
  type TaggedUnionUtils<
5817
6010
  Tag extends PropertyKey,
5818
- Members extends ReadonlyArray<Top & { readonly Type: { readonly [K in Tag]: PropertyKey } }>,
5819
- Flattened extends ReadonlyArray<Top & { readonly Type: { readonly [K in Tag]: PropertyKey } }> = Flatten<
6011
+ Members extends ReadonlyArray<Constraint & { readonly Type: { readonly [K in Tag]: PropertyKey } }>,
6012
+ Flattened extends ReadonlyArray<Constraint & { readonly Type: { readonly [K in Tag]: PropertyKey } }> = Flatten<
5820
6013
  Members
5821
6014
  >
5822
6015
  > = {
@@ -5850,7 +6043,7 @@ type TaggedUnionUtils<
5850
6043
  */
5851
6044
  export type toTaggedUnion<
5852
6045
  Tag extends PropertyKey,
5853
- Members extends ReadonlyArray<Top & { readonly Type: { readonly [K in Tag]: PropertyKey } }>
6046
+ Members extends ReadonlyArray<Constraint & { readonly Type: { readonly [K in Tag]: PropertyKey } }>
5854
6047
  > = Union<Members> & TaggedUnionUtils<Tag, Members>
5855
6048
 
5856
6049
  /**
@@ -5878,7 +6071,7 @@ export type toTaggedUnion<
5878
6071
  * @since 4.0.0
5879
6072
  */
5880
6073
  export function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag) {
5881
- return <const Members extends ReadonlyArray<Top & { readonly Type: { readonly [K in Tag]: PropertyKey } }>>(
6074
+ return <const Members extends ReadonlyArray<Constraint & { readonly Type: { readonly [K in Tag]: PropertyKey } }>>(
5882
6075
  self: Union<Members>
5883
6076
  ): toTaggedUnion<Tag, Members> => {
5884
6077
  const cases: Record<PropertyKey, unknown> = {}
@@ -5889,7 +6082,7 @@ export function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag) {
5889
6082
 
5890
6083
  return Object.assign(self, { cases, isAnyOf, guards, match }) as any
5891
6084
 
5892
- function walk(schema: Top) {
6085
+ function walk(schema: Constraint) {
5893
6086
  const ast = schema.ast
5894
6087
 
5895
6088
  if (
@@ -5932,17 +6125,19 @@ export function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag) {
5932
6125
  * @category models
5933
6126
  * @since 4.0.0
5934
6127
  */
5935
- export interface TaggedUnion<Cases extends Record<string, Top>> extends
5936
- Bottom<
5937
- { [K in keyof Cases]: Cases[K]["Type"] }[keyof Cases],
5938
- { [K in keyof Cases]: Cases[K]["Encoded"] }[keyof Cases],
5939
- { [K in keyof Cases]: Cases[K]["DecodingServices"] }[keyof Cases],
5940
- { [K in keyof Cases]: Cases[K]["EncodingServices"] }[keyof Cases],
6128
+ export interface TaggedUnion<Cases extends Record<string, Constraint>> extends
6129
+ BottomLazy<
5941
6130
  SchemaAST.Union<SchemaAST.Objects>,
5942
- TaggedUnion<Cases>,
5943
- { [K in keyof Cases]: Cases[K]["~type.make"] }[keyof Cases]
6131
+ TaggedUnion<Cases>
5944
6132
  >
5945
6133
  {
6134
+ readonly "Type": { [K in keyof Cases]: Cases[K]["Type"] }[keyof Cases]
6135
+ readonly "Encoded": { [K in keyof Cases]: Cases[K]["Encoded"] }[keyof Cases]
6136
+ readonly "DecodingServices": { [K in keyof Cases]: Cases[K]["DecodingServices"] }[keyof Cases]
6137
+ readonly "EncodingServices": { [K in keyof Cases]: Cases[K]["EncodingServices"] }[keyof Cases]
6138
+ readonly "~type.make.in": { [K in keyof Cases]: Cases[K]["~type.make"] }[keyof Cases]
6139
+ readonly "~type.make": { [K in keyof Cases]: Cases[K]["~type.make"] }[keyof Cases]
6140
+ readonly "Iso": { [K in keyof Cases]: Cases[K]["Type"] }[keyof Cases]
5946
6141
  readonly cases: Cases
5947
6142
  readonly isAnyOf: <const Keys>(
5948
6143
  keys: ReadonlyArray<Keys>
@@ -6005,17 +6200,10 @@ export function TaggedUnion<const CasesByTag extends Record<string, Struct.Field
6005
6200
  * @since 4.0.0
6006
6201
  */
6007
6202
  export interface Opaque<Self, S extends Top, Brand> extends
6008
- Bottom<
6009
- Self,
6010
- S["Encoded"],
6011
- S["DecodingServices"],
6012
- S["EncodingServices"],
6203
+ BottomLazy<
6013
6204
  S["ast"],
6014
6205
  S["Rebuild"],
6015
- S["~type.make.in"],
6016
- S["Iso"],
6017
6206
  S["~type.parameters"],
6018
- S["~type.make"],
6019
6207
  S["~type.mutability"],
6020
6208
  S["~type.optionality"],
6021
6209
  S["~type.constructor.default"],
@@ -6023,6 +6211,13 @@ export interface Opaque<Self, S extends Top, Brand> extends
6023
6211
  S["~encoded.optionality"]
6024
6212
  >
6025
6213
  {
6214
+ readonly "Type": Self
6215
+ readonly "Encoded": S["Encoded"]
6216
+ readonly "DecodingServices": S["DecodingServices"]
6217
+ readonly "EncodingServices": S["EncodingServices"]
6218
+ readonly "~type.make.in": S["~type.make.in"]
6219
+ readonly "~type.make": S["~type.make"]
6220
+ readonly "Iso": S["Iso"]
6026
6221
  new(_: never): S["Type"] & Brand
6027
6222
  }
6028
6223
 
@@ -6101,7 +6296,7 @@ export function instanceOf<C extends abstract new(...args: any) => any, Iso = In
6101
6296
  * @since 4.0.0
6102
6297
  */
6103
6298
  export function link<T>() {
6104
- return <To extends Top>(
6299
+ return <To extends Constraint>(
6105
6300
  encodeTo: To,
6106
6301
  transformation: {
6107
6302
  readonly decode: SchemaGetter.Getter<T, NoInfer<To["Type"]>>
@@ -8114,7 +8309,7 @@ export function isPropertiesLengthBetween(minimum: number, maximum: number, anno
8114
8309
  * @category Object checks
8115
8310
  * @since 4.0.0
8116
8311
  */
8117
- export function isPropertyNames(keySchema: Top, annotations?: Annotations.Filter) {
8312
+ export function isPropertyNames(keySchema: Constraint, annotations?: Annotations.Filter) {
8118
8313
  const propertyNames = toEncoded(keySchema)
8119
8314
  const parser = SchemaParser._issue(propertyNames.ast)
8120
8315
  return makeFilter<object>(
@@ -8240,7 +8435,7 @@ export const Char: Char = String.check(isLengthBetween(1, 1))
8240
8435
  * @category Option
8241
8436
  * @since 3.10.0
8242
8437
  */
8243
- export interface Option<A extends Top> extends
8438
+ export interface Option<A extends Constraint> extends
8244
8439
  declareConstructor<
8245
8440
  Option_.Option<A["Type"]>,
8246
8441
  Option_.Option<A["Encoded"]>,
@@ -8263,7 +8458,7 @@ export interface Option<A extends Top> extends
8263
8458
  * @category Option
8264
8459
  * @since 4.0.0
8265
8460
  */
8266
- export type OptionIso<A extends Top> =
8461
+ export type OptionIso<A extends Constraint> =
8267
8462
  | { readonly _tag: "None" }
8268
8463
  | { readonly _tag: "Some"; readonly value: A["Iso"] }
8269
8464
 
@@ -8273,7 +8468,7 @@ export type OptionIso<A extends Top> =
8273
8468
  * @category Option
8274
8469
  * @since 3.10.0
8275
8470
  */
8276
- export function Option<A extends Top>(value: A): Option<A> {
8471
+ export function Option<A extends Constraint>(value: A): Option<A> {
8277
8472
  const schema = declareConstructor<
8278
8473
  Option_.Option<A["Type"]>,
8279
8474
  Option_.Option<A["Encoded"]>,
@@ -8342,7 +8537,7 @@ export function Option<A extends Top>(value: A): Option<A> {
8342
8537
  * @category Option
8343
8538
  * @since 3.10.0
8344
8539
  */
8345
- export interface OptionFromNullOr<S extends Top> extends decodeTo<Option<toType<S>>, NullOr<S>> {
8540
+ export interface OptionFromNullOr<S extends Constraint> extends decodeTo<Option<toType<S>>, NullOr<S>> {
8346
8541
  readonly "Rebuild": OptionFromNullOr<S>
8347
8542
  }
8348
8543
 
@@ -8357,7 +8552,7 @@ export interface OptionFromNullOr<S extends Top> extends decodeTo<Option<toType<
8357
8552
  * @category Option
8358
8553
  * @since 3.10.0
8359
8554
  */
8360
- export function OptionFromNullOr<S extends Top>(schema: S): OptionFromNullOr<S> {
8555
+ export function OptionFromNullOr<S extends Constraint>(schema: S): OptionFromNullOr<S> {
8361
8556
  return NullOr(schema).pipe(decodeTo(
8362
8557
  Option(toType(schema)),
8363
8558
  SchemaTransformation.optionFromNullOr()
@@ -8370,7 +8565,7 @@ export function OptionFromNullOr<S extends Top>(schema: S): OptionFromNullOr<S>
8370
8565
  * @category Option
8371
8566
  * @since 3.10.0
8372
8567
  */
8373
- export interface OptionFromUndefinedOr<S extends Top> extends decodeTo<Option<toType<S>>, UndefinedOr<S>> {
8568
+ export interface OptionFromUndefinedOr<S extends Constraint> extends decodeTo<Option<toType<S>>, UndefinedOr<S>> {
8374
8569
  readonly "Rebuild": OptionFromUndefinedOr<S>
8375
8570
  }
8376
8571
 
@@ -8386,7 +8581,7 @@ export interface OptionFromUndefinedOr<S extends Top> extends decodeTo<Option<to
8386
8581
  * @category Option
8387
8582
  * @since 3.10.0
8388
8583
  */
8389
- export function OptionFromUndefinedOr<S extends Top>(schema: S): OptionFromUndefinedOr<S> {
8584
+ export function OptionFromUndefinedOr<S extends Constraint>(schema: S): OptionFromUndefinedOr<S> {
8390
8585
  return UndefinedOr(schema).pipe(decodeTo(
8391
8586
  Option(toType(schema)),
8392
8587
  SchemaTransformation.optionFromUndefinedOr()
@@ -8399,7 +8594,7 @@ export function OptionFromUndefinedOr<S extends Top>(schema: S): OptionFromUndef
8399
8594
  * @category Option
8400
8595
  * @since 3.10.0
8401
8596
  */
8402
- export interface OptionFromNullishOr<S extends Top> extends decodeTo<Option<toType<S>>, NullishOr<S>> {
8597
+ export interface OptionFromNullishOr<S extends Constraint> extends decodeTo<Option<toType<S>>, NullishOr<S>> {
8403
8598
  readonly "Rebuild": OptionFromNullishOr<S>
8404
8599
  }
8405
8600
 
@@ -8416,7 +8611,7 @@ export interface OptionFromNullishOr<S extends Top> extends decodeTo<Option<toTy
8416
8611
  * @category Option
8417
8612
  * @since 3.10.0
8418
8613
  */
8419
- export function OptionFromNullishOr<S extends Top>(
8614
+ export function OptionFromNullishOr<S extends Constraint>(
8420
8615
  schema: S,
8421
8616
  options?: {
8422
8617
  onNoneEncoding: null | undefined
@@ -8434,7 +8629,7 @@ export function OptionFromNullishOr<S extends Top>(
8434
8629
  * @category Option
8435
8630
  * @since 4.0.0
8436
8631
  */
8437
- export interface OptionFromOptionalKey<S extends Top> extends decodeTo<Option<toType<S>>, optionalKey<S>> {
8632
+ export interface OptionFromOptionalKey<S extends Constraint> extends decodeTo<Option<toType<S>>, optionalKey<S>> {
8438
8633
  readonly "Rebuild": OptionFromOptionalKey<S>
8439
8634
  }
8440
8635
 
@@ -8449,7 +8644,7 @@ export interface OptionFromOptionalKey<S extends Top> extends decodeTo<Option<to
8449
8644
  * @category Option
8450
8645
  * @since 4.0.0
8451
8646
  */
8452
- export function OptionFromOptionalKey<S extends Top>(schema: S): OptionFromOptionalKey<S> {
8647
+ export function OptionFromOptionalKey<S extends Constraint>(schema: S): OptionFromOptionalKey<S> {
8453
8648
  return optionalKey(schema).pipe(decodeTo(
8454
8649
  Option(toType(schema)),
8455
8650
  SchemaTransformation.optionFromOptionalKey()
@@ -8462,7 +8657,7 @@ export function OptionFromOptionalKey<S extends Top>(schema: S): OptionFromOptio
8462
8657
  * @category Option
8463
8658
  * @since 4.0.0
8464
8659
  */
8465
- export interface OptionFromOptional<S extends Top> extends decodeTo<Option<toType<S>>, optional<S>> {
8660
+ export interface OptionFromOptional<S extends Constraint> extends decodeTo<Option<toType<S>>, optional<S>> {
8466
8661
  readonly "Rebuild": OptionFromOptional<S>
8467
8662
  }
8468
8663
 
@@ -8479,7 +8674,7 @@ export interface OptionFromOptional<S extends Top> extends decodeTo<Option<toTyp
8479
8674
  * @category Option
8480
8675
  * @since 4.0.0
8481
8676
  */
8482
- export function OptionFromOptional<S extends Top>(schema: S): OptionFromOptional<S> {
8677
+ export function OptionFromOptional<S extends Constraint>(schema: S): OptionFromOptional<S> {
8483
8678
  return optional(schema).pipe(decodeTo(
8484
8679
  Option(toType(schema)),
8485
8680
  SchemaTransformation.optionFromOptional<any>()
@@ -8492,7 +8687,9 @@ export function OptionFromOptional<S extends Top>(schema: S): OptionFromOptional
8492
8687
  * @category Option
8493
8688
  * @since 4.0.0
8494
8689
  */
8495
- export interface OptionFromOptionalNullOr<S extends Top> extends decodeTo<Option<toType<S>>, optional<NullOr<S>>> {
8690
+ export interface OptionFromOptionalNullOr<S extends Constraint>
8691
+ extends decodeTo<Option<toType<S>>, optional<NullOr<S>>>
8692
+ {
8496
8693
  readonly "Rebuild": OptionFromOptionalNullOr<S>
8497
8694
  }
8498
8695
 
@@ -8510,7 +8707,7 @@ export interface OptionFromOptionalNullOr<S extends Top> extends decodeTo<Option
8510
8707
  * @category Option
8511
8708
  * @since 4.0.0
8512
8709
  */
8513
- export function OptionFromOptionalNullOr<S extends Top>(
8710
+ export function OptionFromOptionalNullOr<S extends Constraint>(
8514
8711
  schema: S,
8515
8712
  options?: {
8516
8713
  readonly onNoneEncoding: "omit" | null | undefined
@@ -8537,7 +8734,7 @@ export function OptionFromOptionalNullOr<S extends Top>(
8537
8734
  * @category schemas
8538
8735
  * @since 4.0.0
8539
8736
  */
8540
- export interface Result<A extends Top, E extends Top> extends
8737
+ export interface Result<A extends Constraint, E extends Constraint> extends
8541
8738
  declareConstructor<
8542
8739
  Result_.Result<A["Type"], E["Type"]>,
8543
8740
  Result_.Result<A["Encoded"], E["Encoded"]>,
@@ -8561,7 +8758,7 @@ export interface Result<A extends Top, E extends Top> extends
8561
8758
  * @category schemas
8562
8759
  * @since 4.0.0
8563
8760
  */
8564
- export type ResultIso<A extends Top, E extends Top> =
8761
+ export type ResultIso<A extends Constraint, E extends Constraint> =
8565
8762
  | { readonly _tag: "Success"; readonly success: A["Iso"] }
8566
8763
  | { readonly _tag: "Failure"; readonly failure: E["Iso"] }
8567
8764
 
@@ -8571,7 +8768,7 @@ export type ResultIso<A extends Top, E extends Top> =
8571
8768
  * @category schemas
8572
8769
  * @since 4.0.0
8573
8770
  */
8574
- export function Result<A extends Top, E extends Top>(
8771
+ export function Result<A extends Constraint, E extends Constraint>(
8575
8772
  success: A,
8576
8773
  failure: E
8577
8774
  ): Result<A, E> {
@@ -8654,7 +8851,7 @@ export function Result<A extends Top, E extends Top>(
8654
8851
  * @category Redacted
8655
8852
  * @since 3.10.0
8656
8853
  */
8657
- export interface Redacted<S extends Top> extends
8854
+ export interface Redacted<S extends Constraint> extends
8658
8855
  declareConstructor<
8659
8856
  Redacted_.Redacted<S["Type"]>,
8660
8857
  Redacted_.Redacted<S["Encoded"]>,
@@ -8685,10 +8882,11 @@ export interface Redacted<S extends Top> extends
8685
8882
  * into JSON, it will fail with an error. This is useful when the wrapped schema is
8686
8883
  * sensitive and should not be exposed in JSON.
8687
8884
  *
8885
+ * @see {@link RedactedFromValue} for decoding raw values and wrapping them in `Redacted`.
8688
8886
  * @category Redacted
8689
8887
  * @since 3.10.0
8690
8888
  */
8691
- export function Redacted<S extends Top>(value: S, options?: {
8889
+ export function Redacted<S extends Constraint>(value: S, options?: {
8692
8890
  readonly label?: string | undefined
8693
8891
  readonly disallowJsonEncode?: boolean | undefined
8694
8892
  }): Redacted<S> {
@@ -8765,7 +8963,7 @@ export function Redacted<S extends Top>(value: S, options?: {
8765
8963
  * @category Redacted
8766
8964
  * @since 4.0.0
8767
8965
  */
8768
- export interface RedactedFromValue<S extends Top>
8966
+ export interface RedactedFromValue<S extends Constraint>
8769
8967
  extends decodeTo<Redacted<toType<S>>, middlewareDecoding<S, S["DecodingServices"]>>
8770
8968
  {
8771
8969
  readonly "Rebuild": RedactedFromValue<S>
@@ -8778,8 +8976,8 @@ export interface RedactedFromValue<S extends Top>
8778
8976
  * @category Redacted
8779
8977
  * @since 4.0.0
8780
8978
  */
8781
- export function redact<S extends Top>(schema: S): middlewareDecoding<S, S["DecodingServices"]> {
8782
- return schema.pipe(middlewareDecoding(Effect.mapErrorEager(SchemaIssue.redact)))
8979
+ export function redact<S extends Constraint>(schema: S): middlewareDecoding<S, S["DecodingServices"]> {
8980
+ return middlewareDecoding<S, S["DecodingServices"]>(Effect.mapErrorEager(SchemaIssue.redact))(schema)
8783
8981
  }
8784
8982
 
8785
8983
  /**
@@ -8787,10 +8985,11 @@ export function redact<S extends Top>(schema: S): middlewareDecoding<S, S["Decod
8787
8985
  * expects the input to already be a `Redacted` instance, this schema decodes
8788
8986
  * the raw value and wraps it.
8789
8987
  *
8988
+ * @see {@link Redacted} for schemas whose input is already a `Redacted` value.
8790
8989
  * @category Redacted
8791
8990
  * @since 4.0.0
8792
8991
  */
8793
- export function RedactedFromValue<S extends Top>(value: S, options?: {
8992
+ export function RedactedFromValue<S extends Constraint>(value: S, options?: {
8794
8993
  readonly label?: string | undefined
8795
8994
  readonly disallowEncode?: boolean | undefined
8796
8995
  }): RedactedFromValue<S> {
@@ -8819,7 +9018,7 @@ export function RedactedFromValue<S extends Top>(value: S, options?: {
8819
9018
  * @category CauseReason
8820
9019
  * @since 4.0.0
8821
9020
  */
8822
- export interface CauseReason<E extends Top, D extends Top> extends
9021
+ export interface CauseReason<E extends Constraint, D extends Constraint> extends
8823
9022
  declareConstructor<
8824
9023
  Cause_.Reason<E["Type"]>,
8825
9024
  Cause_.Reason<E["Encoded"]>,
@@ -8843,7 +9042,7 @@ export interface CauseReason<E extends Top, D extends Top> extends
8843
9042
  * @category CauseReason
8844
9043
  * @since 4.0.0
8845
9044
  */
8846
- export type CauseReasonIso<E extends Top, D extends Top> = {
9045
+ export type CauseReasonIso<E extends Constraint, D extends Constraint> = {
8847
9046
  readonly _tag: "Fail"
8848
9047
  readonly error: E["Iso"]
8849
9048
  } | {
@@ -8874,7 +9073,7 @@ export type CauseReasonIso<E extends Top, D extends Top> = {
8874
9073
  * @category CauseReason
8875
9074
  * @since 4.0.0
8876
9075
  */
8877
- export function CauseReason<E extends Top, D extends Top>(error: E, defect: D): CauseReason<E, D> {
9076
+ export function CauseReason<E extends Constraint, D extends Constraint>(error: E, defect: D): CauseReason<E, D> {
8878
9077
  const schema = declareConstructor<Cause_.Reason<E["Type"]>, Cause_.Reason<E["Encoded"]>, CauseReasonIso<E, D>>()(
8879
9078
  [error, defect],
8880
9079
  ([error, defect]) => (input, ast, options) => {
@@ -8992,7 +9191,7 @@ function causeReasonToFormatter<E>(error: Formatter<E>, defect: Formatter<unknow
8992
9191
  * @category Cause
8993
9192
  * @since 3.10.0
8994
9193
  */
8995
- export interface Cause<E extends Top, D extends Top> extends
9194
+ export interface Cause<E extends Constraint, D extends Constraint> extends
8996
9195
  declareConstructor<
8997
9196
  Cause_.Cause<E["Type"]>,
8998
9197
  Cause_.Cause<E["Encoded"]>,
@@ -9020,7 +9219,7 @@ export interface Cause<E extends Top, D extends Top> extends
9020
9219
  * @category Cause
9021
9220
  * @since 4.0.0
9022
9221
  */
9023
- export type CauseIso<E extends Top, D extends Top> = ReadonlyArray<CauseReasonIso<E, D>>
9222
+ export type CauseIso<E extends Constraint, D extends Constraint> = ReadonlyArray<CauseReasonIso<E, D>>
9024
9223
 
9025
9224
  /**
9026
9225
  * Creates a schema for `Cause` values using separate schemas for typed failures
@@ -9043,7 +9242,7 @@ export type CauseIso<E extends Top, D extends Top> = ReadonlyArray<CauseReasonIs
9043
9242
  * @category Cause
9044
9243
  * @since 3.10.0
9045
9244
  */
9046
- export function Cause<E extends Top, D extends Top>(error: E, defect: D): Cause<E, D> {
9245
+ export function Cause<E extends Constraint, D extends Constraint>(error: E, defect: D): Cause<E, D> {
9047
9246
  const schema = declareConstructor<Cause_.Cause<E["Type"]>, Cause_.Cause<E["Encoded"]>, CauseIso<E, D>>()(
9048
9247
  [error, defect],
9049
9248
  ([error, defect]) => {
@@ -9269,7 +9468,7 @@ export function Defect(options?: ErrorOptions): Defect {
9269
9468
  * @category Exit
9270
9469
  * @since 3.10.0
9271
9470
  */
9272
- export interface Exit<A extends Top, E extends Top, D extends Top> extends
9471
+ export interface Exit<A extends Constraint, E extends Constraint, D extends Constraint> extends
9273
9472
  declareConstructor<
9274
9473
  Exit_.Exit<A["Type"], E["Type"]>,
9275
9474
  Exit_.Exit<A["Encoded"], E["Encoded"]>,
@@ -9294,7 +9493,7 @@ export interface Exit<A extends Top, E extends Top, D extends Top> extends
9294
9493
  * @category Exit
9295
9494
  * @since 4.0.0
9296
9495
  */
9297
- export type ExitIso<A extends Top, E extends Top, D extends Top> = {
9496
+ export type ExitIso<A extends Constraint, E extends Constraint, D extends Constraint> = {
9298
9497
  readonly _tag: "Success"
9299
9498
  readonly value: A["Iso"]
9300
9499
  } | {
@@ -9314,7 +9513,11 @@ export type ExitIso<A extends Top, E extends Top, D extends Top> = {
9314
9513
  * @category Exit
9315
9514
  * @since 3.10.0
9316
9515
  */
9317
- export function Exit<A extends Top, E extends Top, D extends Top>(value: A, error: E, defect: D): Exit<A, E, D> {
9516
+ export function Exit<A extends Constraint, E extends Constraint, D extends Constraint>(
9517
+ value: A,
9518
+ error: E,
9519
+ defect: D
9520
+ ): Exit<A, E, D> {
9318
9521
  const schema = declareConstructor<
9319
9522
  Exit_.Exit<A["Type"], E["Type"]>,
9320
9523
  Exit_.Exit<A["Encoded"], E["Encoded"]>,
@@ -9421,7 +9624,7 @@ export function Exit<A extends Top, E extends Top, D extends Top>(value: A, erro
9421
9624
  * @category ReadonlyMap
9422
9625
  * @since 4.0.0
9423
9626
  */
9424
- export interface $ReadonlyMap<Key extends Top, Value extends Top> extends
9627
+ export interface $ReadonlyMap<Key extends Constraint, Value extends Constraint> extends
9425
9628
  declareConstructor<
9426
9629
  globalThis.ReadonlyMap<Key["Type"], Value["Type"]>,
9427
9630
  globalThis.ReadonlyMap<Key["Encoded"], Value["Encoded"]>,
@@ -9441,7 +9644,9 @@ export interface $ReadonlyMap<Key extends Top, Value extends Top> extends
9441
9644
  * @category ReadonlyMap
9442
9645
  * @since 4.0.0
9443
9646
  */
9444
- export type ReadonlyMapIso<Key extends Top, Value extends Top> = ReadonlyArray<readonly [Key["Iso"], Value["Iso"]]>
9647
+ export type ReadonlyMapIso<Key extends Constraint, Value extends Constraint> = ReadonlyArray<
9648
+ readonly [Key["Iso"], Value["Iso"]]
9649
+ >
9445
9650
 
9446
9651
  function oneOfArbitraries<T>(
9447
9652
  fc: typeof FastCheck,
@@ -9540,7 +9745,10 @@ function entriesArbitrary<K, V, Out>(
9540
9745
  * @category ReadonlyMap
9541
9746
  * @since 3.10.0
9542
9747
  */
9543
- export function ReadonlyMap<Key extends Top, Value extends Top>(key: Key, value: Value): $ReadonlyMap<Key, Value> {
9748
+ export function ReadonlyMap<Key extends Constraint, Value extends Constraint>(
9749
+ key: Key,
9750
+ value: Value
9751
+ ): $ReadonlyMap<Key, Value> {
9544
9752
  const schema = declareConstructor<
9545
9753
  globalThis.ReadonlyMap<Key["Type"], Value["Type"]>,
9546
9754
  globalThis.ReadonlyMap<Key["Encoded"], Value["Encoded"]>,
@@ -9601,7 +9809,7 @@ export function ReadonlyMap<Key extends Top, Value extends Top>(key: Key, value:
9601
9809
  * @category HashMap
9602
9810
  * @since 3.10.0
9603
9811
  */
9604
- export interface HashMap<Key extends Top, Value extends Top> extends
9812
+ export interface HashMap<Key extends Constraint, Value extends Constraint> extends
9605
9813
  declareConstructor<
9606
9814
  HashMap_.HashMap<Key["Type"], Value["Type"]>,
9607
9815
  HashMap_.HashMap<Key["Encoded"], Value["Encoded"]>,
@@ -9621,7 +9829,9 @@ export interface HashMap<Key extends Top, Value extends Top> extends
9621
9829
  * @category HashMap
9622
9830
  * @since 4.0.0
9623
9831
  */
9624
- export type HashMapIso<Key extends Top, Value extends Top> = ReadonlyArray<readonly [Key["Iso"], Value["Iso"]]>
9832
+ export type HashMapIso<Key extends Constraint, Value extends Constraint> = ReadonlyArray<
9833
+ readonly [Key["Iso"], Value["Iso"]]
9834
+ >
9625
9835
 
9626
9836
  /**
9627
9837
  * Schema for hash maps whose keys and values conform to the provided schemas.
@@ -9629,7 +9839,7 @@ export type HashMapIso<Key extends Top, Value extends Top> = ReadonlyArray<reado
9629
9839
  * @category HashMap
9630
9840
  * @since 3.10.0
9631
9841
  */
9632
- export function HashMap<Key extends Top, Value extends Top>(key: Key, value: Value): HashMap<Key, Value> {
9842
+ export function HashMap<Key extends Constraint, Value extends Constraint>(key: Key, value: Value): HashMap<Key, Value> {
9633
9843
  const schema = declareConstructor<
9634
9844
  HashMap_.HashMap<Key["Type"], Value["Type"]>,
9635
9845
  HashMap_.HashMap<Key["Encoded"], Value["Encoded"]>,
@@ -9691,7 +9901,7 @@ export function HashMap<Key extends Top, Value extends Top>(key: Key, value: Val
9691
9901
  * @category ReadonlySet
9692
9902
  * @since 4.0.0
9693
9903
  */
9694
- export interface $ReadonlySet<Value extends Top> extends
9904
+ export interface $ReadonlySet<Value extends Constraint> extends
9695
9905
  declareConstructor<
9696
9906
  globalThis.ReadonlySet<Value["Type"]>,
9697
9907
  globalThis.ReadonlySet<Value["Encoded"]>,
@@ -9710,7 +9920,7 @@ export interface $ReadonlySet<Value extends Top> extends
9710
9920
  * @category ReadonlySet
9711
9921
  * @since 4.0.0
9712
9922
  */
9713
- export type ReadonlySetIso<Value extends Top> = ReadonlyArray<Value["Iso"]>
9923
+ export type ReadonlySetIso<Value extends Constraint> = ReadonlyArray<Value["Iso"]>
9714
9924
 
9715
9925
  /**
9716
9926
  * Schema for readonly sets whose values conform to the provided element schema.
@@ -9718,7 +9928,7 @@ export type ReadonlySetIso<Value extends Top> = ReadonlyArray<Value["Iso"]>
9718
9928
  * @category ReadonlySet
9719
9929
  * @since 3.10.0
9720
9930
  */
9721
- export function ReadonlySet<Value extends Top>(value: Value): $ReadonlySet<Value> {
9931
+ export function ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value> {
9722
9932
  const schema = declareConstructor<
9723
9933
  globalThis.ReadonlySet<Value["Type"]>,
9724
9934
  globalThis.ReadonlySet<Value["Encoded"]>,
@@ -9780,7 +9990,7 @@ export function ReadonlySet<Value extends Top>(value: Value): $ReadonlySet<Value
9780
9990
  * @category HashSet
9781
9991
  * @since 3.10.0
9782
9992
  */
9783
- export interface HashSet<Value extends Top> extends
9993
+ export interface HashSet<Value extends Constraint> extends
9784
9994
  declareConstructor<
9785
9995
  HashSet_.HashSet<Value["Type"]>,
9786
9996
  HashSet_.HashSet<Value["Encoded"]>,
@@ -9799,7 +10009,7 @@ export interface HashSet<Value extends Top> extends
9799
10009
  * @category HashSet
9800
10010
  * @since 4.0.0
9801
10011
  */
9802
- export type HashSetIso<Value extends Top> = ReadonlyArray<Value["Iso"]>
10012
+ export type HashSetIso<Value extends Constraint> = ReadonlyArray<Value["Iso"]>
9803
10013
 
9804
10014
  /**
9805
10015
  * Schema for hash sets whose values conform to the provided element schema.
@@ -9807,7 +10017,7 @@ export type HashSetIso<Value extends Top> = ReadonlyArray<Value["Iso"]>
9807
10017
  * @category HashSet
9808
10018
  * @since 3.10.0
9809
10019
  */
9810
- export function HashSet<Value extends Top>(value: Value): HashSet<Value> {
10020
+ export function HashSet<Value extends Constraint>(value: Value): HashSet<Value> {
9811
10021
  const schema = declareConstructor<
9812
10022
  HashSet_.HashSet<Value["Type"]>,
9813
10023
  HashSet_.HashSet<Value["Encoded"]>,
@@ -9869,7 +10079,7 @@ export function HashSet<Value extends Top>(value: Value): HashSet<Value> {
9869
10079
  * @category Chunk
9870
10080
  * @since 3.10.0
9871
10081
  */
9872
- export interface Chunk<Value extends Top> extends
10082
+ export interface Chunk<Value extends Constraint> extends
9873
10083
  declareConstructor<
9874
10084
  Chunk_.Chunk<Value["Type"]>,
9875
10085
  Chunk_.Chunk<Value["Encoded"]>,
@@ -9895,7 +10105,7 @@ export interface Chunk<Value extends Top> extends
9895
10105
  * @category Chunk
9896
10106
  * @since 4.0.0
9897
10107
  */
9898
- export type ChunkIso<Value extends Top> = ReadonlyArray<Value["Iso"]>
10108
+ export type ChunkIso<Value extends Constraint> = ReadonlyArray<Value["Iso"]>
9899
10109
 
9900
10110
  /**
9901
10111
  * Schema for chunks whose values conform to the provided element schema.
@@ -9903,7 +10113,7 @@ export type ChunkIso<Value extends Top> = ReadonlyArray<Value["Iso"]>
9903
10113
  * @category Chunk
9904
10114
  * @since 3.10.0
9905
10115
  */
9906
- export function Chunk<Value extends Top>(value: Value): Chunk<Value> {
10116
+ export function Chunk<Value extends Constraint>(value: Value): Chunk<Value> {
9907
10117
  const schema = declareConstructor<
9908
10118
  Chunk_.Chunk<Value["Type"]>,
9909
10119
  Chunk_.Chunk<Value["Encoded"]>,
@@ -10121,7 +10331,7 @@ type DateArbitraryConstraints = FastCheck.DateConstraints & {
10121
10331
  }
10122
10332
 
10123
10333
  function dateArbitraryConstraints<T = globalThis.Date>(
10124
- constraint: Annotations.ToArbitrary.Constraint | undefined,
10334
+ constraint: Annotations.ToArbitrary.GenerationConstraint | undefined,
10125
10335
  ordered: Annotations.ToArbitrary.OrderedConstraint<T> | undefined,
10126
10336
  base?: DateArbitraryConstraints | undefined,
10127
10337
  toDate?: (value: T) => globalThis.Date
@@ -10679,7 +10889,7 @@ export const UnknownFromJsonString: UnknownFromJsonString = fromJsonString(Unkno
10679
10889
  * @category models
10680
10890
  * @since 4.0.0
10681
10891
  */
10682
- export interface fromJsonString<S extends Top> extends decodeTo<S, String> {
10892
+ export interface fromJsonString<S extends Constraint> extends decodeTo<S, String> {
10683
10893
  readonly "Rebuild": fromJsonString<S>
10684
10894
  }
10685
10895
 
@@ -10749,7 +10959,7 @@ export interface fromJsonString<S extends Top> extends decodeTo<S, String> {
10749
10959
  * @category constructors
10750
10960
  * @since 4.0.0
10751
10961
  */
10752
- export function fromJsonString<S extends Top>(schema: S): fromJsonString<S> {
10962
+ export function fromJsonString<S extends Constraint>(schema: S): fromJsonString<S> {
10753
10963
  return String.annotate({
10754
10964
  expected: "a string that will be decoded as JSON",
10755
10965
  contentMediaType: "application/json",
@@ -10901,7 +11111,7 @@ export const FormData: FormData = instanceOf(globalThis.FormData, {
10901
11111
  * @category FormData
10902
11112
  * @since 4.0.0
10903
11113
  */
10904
- export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
11114
+ export interface fromFormData<S extends Constraint> extends decodeTo<S, FormData> {
10905
11115
  readonly "Rebuild": fromFormData<S>
10906
11116
  }
10907
11117
 
@@ -10921,10 +11131,8 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
10921
11131
  *
10922
11132
  * You can express nested values using bracket notation.
10923
11133
  *
10924
- * If you want to decode values that are not strings, use
10925
- * `Schema.toCodecStringTree` with the `keepDeclarations: true` option.
10926
- * This serializer preserves values such as numbers and `Blob` objects when
10927
- * compatible with the schema.
11134
+ * If you want to decode string fields into non-string primitive values, use
11135
+ * `Schema.toCodecStringTree`.
10928
11136
  *
10929
11137
  * **Example** (Decoding a flat structure)
10930
11138
  *
@@ -10978,8 +11186,7 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
10978
11186
  * Schema.toCodecStringTree(
10979
11187
  * Schema.Struct({
10980
11188
  * a: Schema.Int
10981
- * }),
10982
- * { keepDeclarations: true }
11189
+ * })
10983
11190
  * )
10984
11191
  * )
10985
11192
  *
@@ -10993,7 +11200,7 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
10993
11200
  * @category decoding
10994
11201
  * @since 4.0.0
10995
11202
  */
10996
- export function fromFormData<S extends Top>(schema: S): fromFormData<S> {
11203
+ export function fromFormData<S extends Constraint>(schema: S): fromFormData<S> {
10997
11204
  return FormData.pipe(decodeTo(schema, SchemaTransformation.fromFormData))
10998
11205
  }
10999
11206
 
@@ -11042,7 +11249,7 @@ export const URLSearchParams: URLSearchParams = instanceOf(globalThis.URLSearchP
11042
11249
  * @category search params
11043
11250
  * @since 4.0.0
11044
11251
  */
11045
- export interface fromURLSearchParams<S extends Top> extends decodeTo<S, URLSearchParams> {
11252
+ export interface fromURLSearchParams<S extends Constraint> extends decodeTo<S, URLSearchParams> {
11046
11253
  readonly "Rebuild": fromURLSearchParams<S>
11047
11254
  }
11048
11255
 
@@ -11126,7 +11333,7 @@ export interface fromURLSearchParams<S extends Top> extends decodeTo<S, URLSearc
11126
11333
  * @category decoding
11127
11334
  * @since 4.0.0
11128
11335
  */
11129
- export function fromURLSearchParams<S extends Top>(schema: S): fromURLSearchParams<S> {
11336
+ export function fromURLSearchParams<S extends Constraint>(schema: S): fromURLSearchParams<S> {
11130
11337
  return URLSearchParams.pipe(decodeTo(schema, SchemaTransformation.fromURLSearchParams))
11131
11338
  }
11132
11339
 
@@ -12145,18 +12352,11 @@ export const DateTimeZonedFromString: DateTimeZonedFromString = DateTimeZonedStr
12145
12352
  * @category models
12146
12353
  * @since 3.10.0
12147
12354
  */
12148
- export interface Class<Self, S extends Top & { readonly fields: Struct.Fields }, Inherited> extends
12149
- Bottom<
12150
- Self,
12151
- S["Encoded"],
12152
- S["DecodingServices"],
12153
- S["EncodingServices"],
12355
+ export interface Class<Self, S extends Constraint & { readonly fields: Struct.Fields }, Inherited> extends
12356
+ BottomLazy<
12154
12357
  SchemaAST.Declaration,
12155
12358
  decodeTo<declareConstructor<Self, S["Encoded"], readonly [S], S["Iso"]>, S>,
12156
- RequiredKeys<S["~type.make.in"]> extends never ? void | S["~type.make.in"] : S["~type.make.in"],
12157
- S["Iso"],
12158
12359
  readonly [S],
12159
- Self,
12160
12360
  S["~type.mutability"],
12161
12361
  S["~type.optionality"],
12162
12362
  S["~type.constructor.default"],
@@ -12164,6 +12364,14 @@ export interface Class<Self, S extends Top & { readonly fields: Struct.Fields },
12164
12364
  S["~encoded.optionality"]
12165
12365
  >
12166
12366
  {
12367
+ readonly "Type": Self
12368
+ readonly "Encoded": S["Encoded"]
12369
+ readonly "DecodingServices": S["DecodingServices"]
12370
+ readonly "EncodingServices": S["EncodingServices"]
12371
+ readonly "~type.make.in": RequiredKeys<S["~type.make.in"]> extends never ? void | S["~type.make.in"]
12372
+ : S["~type.make.in"]
12373
+ readonly "~type.make": Self
12374
+ readonly "Iso": S["Iso"]
12167
12375
  new(
12168
12376
  ...args: {} extends S["~type.make.in"] ? [props?: S["~type.make.in"], options?: MakeOptions]
12169
12377
  : [props: S["~type.make.in"], options?: MakeOptions]
@@ -12194,15 +12402,48 @@ export interface Class<Self, S extends Top & { readonly fields: Struct.Fields },
12194
12402
  } | undefined
12195
12403
  ): Struct<Simplify<Readonly<To>>>
12196
12404
 
12405
+ /**
12406
+ * Returns a function that creates a schema-backed subclass with this class's
12407
+ * fields plus additional fields.
12408
+ *
12409
+ * **When to use**
12410
+ *
12411
+ * Use when you need a subclass whose constructor validates both inherited
12412
+ * fields and newly added fields.
12413
+ *
12414
+ * **Details**
12415
+ *
12416
+ * The returned function accepts either a field map or a `Struct`. When you
12417
+ * pass a `Struct`, checks attached to that extension schema are preserved and
12418
+ * combined with checks from the base class schema.
12419
+ *
12420
+ * **Gotchas**
12421
+ *
12422
+ * Checks from a `Struct` argument are evaluated against the full subclass
12423
+ * value after inherited and extension fields are merged. Object-wide checks
12424
+ * such as `isMaxProperties` count inherited fields too.
12425
+ */
12197
12426
  extend<Extended = never, Static = {}, Brand = {}>(
12198
12427
  identifier: string
12199
- ): <NewFields extends Struct.Fields>(
12200
- fields: NewFields,
12201
- annotations?: Annotations.Declaration<Extended, readonly [Struct<Simplify<Assign<S["fields"], NewFields>>>]>
12202
- ) => [Extended] extends [never] ? MissingSelfGeneric<"Base.extend"> : InheritStaticMembers<
12203
- Class<Extended, Struct<Simplify<Assign<S["fields"], NewFields>>>, Self & Brand>,
12204
- Static
12205
- >
12428
+ ): {
12429
+ <NewFields extends Struct.Fields>(
12430
+ fields: NewFields,
12431
+ annotations?: Annotations.Declaration<Extended, readonly [Struct<Simplify<Assign<S["fields"], NewFields>>>]>
12432
+ ): [Extended] extends [never] ? MissingSelfGeneric<"Base.extend"> : InheritStaticMembers<
12433
+ Class<Extended, Struct<Simplify<Assign<S["fields"], NewFields>>>, Self & Brand>,
12434
+ Static
12435
+ >
12436
+ <Extension extends Struct<Struct.Fields>>(
12437
+ schema: Extension,
12438
+ annotations?: Annotations.Declaration<
12439
+ Extended,
12440
+ readonly [Struct<Simplify<Assign<S["fields"], Extension["fields"]>>>]
12441
+ >
12442
+ ): [Extended] extends [never] ? MissingSelfGeneric<"Base.extend"> : InheritStaticMembers<
12443
+ Class<Extended, Struct<Simplify<Assign<S["fields"], Extension["fields"]>>>, Self & Brand>,
12444
+ Static
12445
+ >
12446
+ }
12206
12447
  }
12207
12448
 
12208
12449
  // Merges custom static members from a parent class onto the extended class,
@@ -12270,18 +12511,20 @@ function makeClass<
12270
12511
  static check(...checks: readonly [SchemaAST.Check<Self>, ...Array<SchemaAST.Check<Self>>]) {
12271
12512
  return this.rebuild(SchemaAST.appendChecks(this.ast, checks))
12272
12513
  }
12273
- static extend<Extended>(
12514
+ static extend(
12274
12515
  identifier: string
12275
- ): <NewFields extends Struct.Fields>(
12276
- fields: NewFields,
12277
- annotations?: Annotations.Declaration<Extended, readonly [Struct<Simplify<Assign<S["fields"], NewFields>>>]>
12278
- ) => Class<Extended, Struct<Simplify<Assign<S["fields"], NewFields>>>, Self> {
12279
- return (newFields, annotations) => {
12280
- const fields = { ...struct.fields, ...newFields }
12516
+ ) {
12517
+ return (
12518
+ schema: Struct.Fields | Struct<Struct.Fields>,
12519
+ annotations?: Annotations.Declaration<any, readonly [any]>
12520
+ ) => {
12521
+ const extension = isStruct(schema) ? schema : Struct(schema)
12522
+ const fields = { ...struct.fields, ...extension.fields }
12523
+ const ast = SchemaAST.struct(fields, struct.ast.checks, { identifier })
12281
12524
  return makeClass(
12282
12525
  this,
12283
12526
  identifier,
12284
- makeStruct(SchemaAST.struct(fields, struct.ast.checks, { identifier }), fields),
12527
+ makeStruct(SchemaAST.appendChecks(ast, extension.ast.checks), fields),
12285
12528
  annotations,
12286
12529
  proto
12287
12530
  )
@@ -12315,7 +12558,7 @@ function getClassTypeId(identifier: string) {
12315
12558
  return `~effect/Schema/Class/${identifier}`
12316
12559
  }
12317
12560
 
12318
- function getClassSchemaFactory<S extends Top>(
12561
+ function getClassSchemaFactory<S extends Constraint>(
12319
12562
  from: S,
12320
12563
  identifier: string,
12321
12564
  annotations: Annotations.Declaration<any, readonly [S]> | undefined
@@ -12324,34 +12567,34 @@ function getClassSchemaFactory<S extends Top>(
12324
12567
  return <Self extends (new(...args: ReadonlyArray<any>) => any) & { readonly identifier: string }>(
12325
12568
  self: Self
12326
12569
  ): decodeTo<declareConstructor<Self, S["Encoded"], readonly [S]>, S> => {
12327
- if (memo === undefined) {
12328
- const transformation = getClassTransformation(self)
12329
- const to = make<declareConstructor<Self, S["Encoded"], readonly [S]>>(
12330
- new SchemaAST.Declaration(
12331
- [from.ast],
12332
- () => (input, ast) => {
12333
- return input instanceof self ||
12334
- Predicate.hasProperty(input, getClassTypeId(identifier)) ?
12335
- Effect.succeed(input) :
12336
- Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)))
12337
- },
12338
- {
12339
- identifier,
12340
- [SchemaAST.ClassTypeId]: ([from]: readonly [SchemaAST.AST]) => new SchemaAST.Link(from, transformation),
12341
- toCodec: ([from]: readonly [Codec<S["Encoded"]>]) => new SchemaAST.Link(from.ast, transformation),
12342
- toArbitrary: ([from]: readonly [Annotations.ToArbitrary.TypeParameter<S["Type"]>]) => () => ({
12343
- arbitrary: from.arbitrary.map((args: S["Type"]) => new self(args)),
12344
- terminal: from.terminal?.map((args: S["Type"]) => new self(args))
12345
- }),
12346
- toFormatter: ([from]: readonly [Formatter<S["Type"]>]) => (t: Self) => `${self.identifier}(${from(t)})`,
12347
- "~sentinels": SchemaAST.collectSentinels(from.ast),
12348
- ...annotations
12349
- }
12350
- )
12351
- )
12352
- memo = from.pipe(decodeTo(to, transformation))
12570
+ if (memo !== undefined) {
12571
+ return memo
12353
12572
  }
12354
- return memo
12573
+ const transformation = getClassTransformation(self)
12574
+ const to = make<declareConstructor<Self, S["Encoded"], readonly [S]>>(
12575
+ new SchemaAST.Declaration(
12576
+ [from.ast],
12577
+ () => (input, ast) => {
12578
+ return input instanceof self ||
12579
+ Predicate.hasProperty(input, getClassTypeId(identifier)) ?
12580
+ Effect.succeed(input) :
12581
+ Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)))
12582
+ },
12583
+ {
12584
+ identifier,
12585
+ [SchemaAST.ClassTypeId]: ([from]: readonly [SchemaAST.AST]) => new SchemaAST.Link(from, transformation),
12586
+ toCodec: ([from]: readonly [Codec<S["Encoded"]>]) => new SchemaAST.Link(from.ast, transformation),
12587
+ toArbitrary: ([from]: readonly [Annotations.ToArbitrary.TypeParameter<S["Type"]>]) => () => ({
12588
+ arbitrary: from.arbitrary.map((args: S["Type"]) => new self(args)),
12589
+ terminal: from.terminal?.map((args: S["Type"]) => new self(args))
12590
+ }),
12591
+ toFormatter: ([from]: readonly [Formatter<S["Type"]>]) => (t: Self) => `${self.identifier}(${from(t)})`,
12592
+ "~sentinels": SchemaAST.collectSentinels(from.ast),
12593
+ ...annotations
12594
+ }
12595
+ )
12596
+ )
12597
+ return memo = decodeTo<declareConstructor<Self, S["Encoded"], readonly [S]>, S>(to, transformation)(from)
12355
12598
  }
12356
12599
  }
12357
12600
 
@@ -13069,7 +13312,7 @@ export type LazyArbitrary<T> = (fc: typeof FastCheck) => FastCheck.Arbitrary<T>
13069
13312
  * @category Arbitrary
13070
13313
  * @since 4.0.0
13071
13314
  */
13072
- export function toArbitraryLazy<S extends Top>(schema: S): LazyArbitrary<S["Type"]> {
13315
+ export function toArbitraryLazy<S extends Constraint>(schema: S): LazyArbitrary<S["Type"]> {
13073
13316
  const lawc = InternalArbitrary.memoized(schema.ast)
13074
13317
  return (fc) => lawc(fc, {})
13075
13318
  }
@@ -13103,12 +13346,12 @@ export function toArbitraryLazy<S extends Top>(schema: S): LazyArbitrary<S["Type
13103
13346
  * @category Arbitrary
13104
13347
  * @since 4.0.0
13105
13348
  */
13106
- export function toArbitrary<S extends Top>(schema: S): FastCheck.Arbitrary<S["Type"]>
13107
- export function toArbitrary<S extends Top>(
13349
+ export function toArbitrary<S extends Constraint>(schema: S): FastCheck.Arbitrary<S["Type"]>
13350
+ export function toArbitrary<S extends Constraint>(
13108
13351
  schema: S,
13109
13352
  options: { readonly report: true }
13110
13353
  ): Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>
13111
- export function toArbitrary<S extends Top>(
13354
+ export function toArbitrary<S extends Constraint>(
13112
13355
  schema: S,
13113
13356
  options?: { readonly report?: boolean }
13114
13357
  ): FastCheck.Arbitrary<S["Type"]> | Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>> {
@@ -13159,14 +13402,14 @@ export function overrideToFormatter<S extends Top>(toFormatter: () => Formatter<
13159
13402
  * @category Formatter
13160
13403
  * @since 4.0.0
13161
13404
  */
13162
- export function toFormatter<T>(schema: Schema<T>, options?: {
13405
+ export function toFormatter<S extends Constraint>(schema: S, options?: {
13163
13406
  readonly onBefore?:
13164
13407
  | ((ast: SchemaAST.AST, recur: (ast: SchemaAST.AST) => Formatter<any>) => Formatter<any> | undefined)
13165
13408
  | undefined
13166
- }): Formatter<T> {
13409
+ }): Formatter<S["Type"]> {
13167
13410
  return recur(schema.ast)
13168
13411
 
13169
- function recur(ast: SchemaAST.AST): Formatter<T> {
13412
+ function recur(ast: SchemaAST.AST): Formatter<S["Type"]> {
13170
13413
  // ---------------------------------------------
13171
13414
  // handle annotation
13172
13415
  // ---------------------------------------------
@@ -13350,7 +13593,7 @@ export function toEquivalence<T>(schema: Schema<T>): Equivalence.Equivalence<T>
13350
13593
  * @category Representation
13351
13594
  * @since 4.0.0
13352
13595
  */
13353
- export function toRepresentation(schema: Top): SchemaRepresentation.Document {
13596
+ export function toRepresentation(schema: Constraint): SchemaRepresentation.Document {
13354
13597
  return InternalStandard.fromAST(schema.ast)
13355
13598
  }
13356
13599
 
@@ -13451,7 +13694,10 @@ export interface ToJsonSchemaOptions {
13451
13694
  * @category converting
13452
13695
  * @since 4.0.0
13453
13696
  */
13454
- export function toJsonSchemaDocument(schema: Top, options?: ToJsonSchemaOptions): JsonSchema.Document<"draft-2020-12"> {
13697
+ export function toJsonSchemaDocument(
13698
+ schema: Constraint,
13699
+ options?: ToJsonSchemaOptions
13700
+ ): JsonSchema.Document<"draft-2020-12"> {
13455
13701
  const sd = toRepresentation(schema)
13456
13702
  const jd = InternalStandard.toJsonSchemaDocument(sd, options)
13457
13703
  return {
@@ -13465,6 +13711,33 @@ export function toJsonSchemaDocument(schema: Top, options?: ToJsonSchemaOptions)
13465
13711
  // Canonical Codecs
13466
13712
  // -----------------------------------------------------------------------------
13467
13713
 
13714
+ /**
13715
+ * Type-level representation returned by {@link toCodecJson}.
13716
+ *
13717
+ * @category Canonical Codecs
13718
+ * @since 4.0.0
13719
+ */
13720
+ export interface toCodecJson<S extends Constraint> extends
13721
+ BottomLazy<
13722
+ S["ast"],
13723
+ toCodecJson<S>,
13724
+ S["~type.parameters"],
13725
+ S["~type.mutability"],
13726
+ S["~type.optionality"],
13727
+ S["~type.constructor.default"],
13728
+ S["~encoded.mutability"],
13729
+ S["~encoded.optionality"]
13730
+ >
13731
+ {
13732
+ readonly "Type": S["Type"]
13733
+ readonly "Encoded": Json
13734
+ readonly "DecodingServices": S["DecodingServices"]
13735
+ readonly "EncodingServices": S["EncodingServices"]
13736
+ readonly "~type.make.in": S["~type.make.in"]
13737
+ readonly "~type.make": S["~type.make"]
13738
+ readonly "Iso": S["Iso"]
13739
+ }
13740
+
13468
13741
  /**
13469
13742
  * Derives a canonical JSON codec from a schema. The encoded form is `Json`, and
13470
13743
  * decoding produces the schema's `Type`.
@@ -13472,11 +13745,11 @@ export function toJsonSchemaDocument(schema: Top, options?: ToJsonSchemaOptions)
13472
13745
  * @category Canonical Codecs
13473
13746
  * @since 4.0.0
13474
13747
  */
13475
- export function toCodecJson<T, E, RD, RE>(schema: Codec<T, E, RD, RE>): Codec<T, Json, RD, RE> {
13748
+ export function toCodecJson<S extends Constraint>(schema: S): toCodecJson<S> {
13476
13749
  return make(toCodecJsonTop(schema.ast))
13477
13750
  }
13478
13751
 
13479
- const toCodecJsonTop = SchemaAST.toCodec((ast) => {
13752
+ const toCodecJsonTop = SchemaAST.applyToSelfOrLastLinkEncoding((ast) => {
13480
13753
  const out = toCodecJsonBase(ast, toCodecJsonTop)
13481
13754
  return out !== ast && SchemaAST.isOptional(ast) ? SchemaAST.optionalKeyLastLink(out) : out
13482
13755
  })
@@ -13511,7 +13784,7 @@ function toCodecJsonBase(ast: SchemaAST.AST, recur: (ast: SchemaAST.AST) => Sche
13511
13784
  if (ast.propertySignatures.some((ps) => typeof ps.name !== "string")) {
13512
13785
  throw new globalThis.Error("Objects property names must be strings", { cause: ast })
13513
13786
  }
13514
- return ast.recur(recur)
13787
+ return ast.recur(recur, SchemaAST.parameterFromString)
13515
13788
  }
13516
13789
  case "Union": {
13517
13790
  const sortedTypes = InternalSchema.jsonReorder(ast.types)
@@ -13543,7 +13816,7 @@ function toCodecJsonBase(ast: SchemaAST.AST, recur: (ast: SchemaAST.AST) => Sche
13543
13816
  * @category Canonical Codecs
13544
13817
  * @since 4.0.0
13545
13818
  */
13546
- export function toCodecIso<S extends Top>(schema: S): Codec<S["Type"], S["Iso"]> {
13819
+ export function toCodecIso<S extends Constraint>(schema: S): Codec<S["Type"], S["Iso"]> {
13547
13820
  return make(toCodecIsoTop(SchemaAST.toType(schema.ast)))
13548
13821
  }
13549
13822
 
@@ -13581,6 +13854,33 @@ function toCodecIsoBase(ast: SchemaAST.AST, recur: (ast: SchemaAST.AST) => Schem
13581
13854
  */
13582
13855
  export type StringTree = Tree<string | undefined>
13583
13856
 
13857
+ /**
13858
+ * Type-level representation returned by {@link toCodecStringTree}.
13859
+ *
13860
+ * @category Canonical Codecs
13861
+ * @since 4.0.0
13862
+ */
13863
+ export interface toCodecStringTree<S extends Constraint> extends
13864
+ BottomLazy<
13865
+ S["ast"],
13866
+ toCodecStringTree<S>,
13867
+ ReadonlyArray<Constraint>,
13868
+ S["~type.mutability"],
13869
+ S["~type.optionality"],
13870
+ S["~type.constructor.default"],
13871
+ S["~encoded.mutability"],
13872
+ S["~encoded.optionality"]
13873
+ >
13874
+ {
13875
+ readonly "Type": S["Type"]
13876
+ readonly "Encoded": StringTree
13877
+ readonly "DecodingServices": S["DecodingServices"]
13878
+ readonly "EncodingServices": S["EncodingServices"]
13879
+ readonly "~type.make.in": S["~type.make.in"]
13880
+ readonly "~type.make": S["~type.make"]
13881
+ readonly "Iso": S["Iso"]
13882
+ }
13883
+
13584
13884
  /**
13585
13885
  * Converts a schema to the StringTree canonical codec, where every leaf value
13586
13886
  * becomes a string while preserving the original structure.
@@ -13590,33 +13890,60 @@ export type StringTree = Tree<string | undefined>
13590
13890
  * Declarations are converted to `undefined` (unless they have a
13591
13891
  * `toCodecJson` or `toCodec` annotation).
13592
13892
  *
13593
- * Options:
13893
+ * @category Canonical Codecs
13894
+ * @since 4.0.0
13895
+ */
13896
+ export function toCodecStringTree<S extends Constraint>(schema: S): toCodecStringTree<S> {
13897
+ return make(serializerStringTree(schema.ast))
13898
+ }
13899
+
13900
+ /**
13901
+ * Type-level representation returned by {@link toCodecArrayFromSingle}.
13902
+ *
13903
+ * @category Canonical Codecs
13904
+ * @since 4.0.0
13905
+ */
13906
+ export interface toCodecArrayFromSingle<S extends Constraint> extends
13907
+ BottomLazy<
13908
+ S["ast"],
13909
+ toCodecArrayFromSingle<S>,
13910
+ S["~type.parameters"],
13911
+ S["~type.mutability"],
13912
+ S["~type.optionality"],
13913
+ S["~type.constructor.default"],
13914
+ S["~encoded.mutability"],
13915
+ S["~encoded.optionality"]
13916
+ >
13917
+ {
13918
+ readonly "Type": S["Type"]
13919
+ readonly "Encoded": S["Encoded"]
13920
+ readonly "DecodingServices": S["DecodingServices"]
13921
+ readonly "EncodingServices": S["EncodingServices"]
13922
+ readonly "~type.make.in": S["~type.make.in"]
13923
+ readonly "~type.make": S["~type.make"]
13924
+ readonly "Iso": S["Iso"]
13925
+ }
13926
+
13927
+ /**
13928
+ * Allows array schemas to decode from either an array input or a single value
13929
+ * input.
13594
13930
  *
13595
- * - `keepDeclarations`: if `true`, it **does not** convert declarations to
13596
- * `undefined` but instead keeps them as they are (unless they have a
13597
- * `toCodecJson` or `toCodec` annotation).
13931
+ * **When to use**
13598
13932
  *
13599
- * Defaults to `false`.
13933
+ * Use when you need to accept transport formats that may represent a
13934
+ * single-item array as a bare value, such as query-string or form-data adapters.
13935
+ *
13936
+ * **Gotchas**
13937
+ *
13938
+ * This combinator is intentionally not part of `toCodecStringTree`; it adds a
13939
+ * decoding convenience rather than a canonical StringTree representation. It
13940
+ * does not parse comma-separated strings.
13600
13941
  *
13601
13942
  * @category Canonical Codecs
13602
13943
  * @since 4.0.0
13603
13944
  */
13604
- export function toCodecStringTree<T, E, RD, RE>(schema: Codec<T, E, RD, RE>): Codec<T, StringTree, RD, RE>
13605
- export function toCodecStringTree<T, E, RD, RE>(
13606
- schema: Codec<T, E, RD, RE>,
13607
- options: { readonly keepDeclarations: true } // Used in FormData
13608
- ): Codec<T, unknown, RD, RE>
13609
- export function toCodecStringTree<T, E, RD, RE>(
13610
- schema: Codec<T, E, RD, RE>,
13611
- options?: { readonly keepDeclarations?: boolean | undefined }
13612
- ): Codec<T, unknown, RD, RE> {
13613
- return make(
13614
- toCodecEnsureArray(
13615
- options?.keepDeclarations === true
13616
- ? serializerStringTreeKeepDeclarations(schema.ast)
13617
- : serializerStringTree(schema.ast)
13618
- )
13619
- )
13945
+ export function toCodecArrayFromSingle<S extends Constraint>(schema: S): toCodecArrayFromSingle<S> {
13946
+ return make(toCodecArrayFromSingleTop(schema.ast))
13620
13947
  }
13621
13948
 
13622
13949
  type XmlEncoderOptions = {
@@ -13791,7 +14118,7 @@ function serializerTree(
13791
14118
  if (ast.propertySignatures.some((ps) => typeof ps.name !== "string")) {
13792
14119
  throw new globalThis.Error("Objects property names must be strings", { cause: ast })
13793
14120
  }
13794
- return ast.recur(recur)
14121
+ return ast.recur(recur, SchemaAST.parameterFromString)
13795
14122
  }
13796
14123
  case "Union": {
13797
14124
  const sortedTypes = treeReorder(ast.types)
@@ -13832,7 +14159,15 @@ const booleanToString = new SchemaAST.Link(
13832
14159
  )
13833
14160
  )
13834
14161
 
13835
- const serializerStringTree = SchemaAST.toCodec((ast) => {
14162
+ const SERIALIZER_ENSURE_ARRAY = "~effect/Schema/SERIALIZER_ENSURE_ARRAY"
14163
+
14164
+ const isSerializerArrayFromSingle = (ast: SchemaAST.AST): boolean =>
14165
+ SchemaAST.isUnion(ast) && ast.annotations?.[SERIALIZER_ENSURE_ARRAY] === true
14166
+
14167
+ const serializerStringTree = SchemaAST.applyToSelfOrLastLinkEncoding((ast) => {
14168
+ if (isSerializerArrayFromSingle(ast)) {
14169
+ return ast
14170
+ }
13836
14171
  const out = serializerTree(ast, serializerStringTree, (ast) => SchemaAST.replaceEncoding(ast, [unknownToUndefined]))
13837
14172
  if (out !== ast && SchemaAST.isOptional(ast)) {
13838
14173
  return SchemaAST.optionalKeyLastLink(out)
@@ -13848,53 +14183,46 @@ const unknownToUndefined = new SchemaAST.Link(
13848
14183
  )
13849
14184
  )
13850
14185
 
13851
- const serializerStringTreeKeepDeclarations = SchemaAST.toCodec((ast) => {
13852
- const out = serializerTree(ast, serializerStringTreeKeepDeclarations, identity)
13853
- if (out !== ast && SchemaAST.isOptional(ast)) {
13854
- return SchemaAST.optionalKeyLastLink(out)
13855
- }
13856
- return out
13857
- })
14186
+ const toArrayFromSingleInputElement = (ast: SchemaAST.AST): SchemaAST.AST =>
14187
+ SchemaAST.isOptional(ast) ? SchemaAST.optionalKey(SchemaAST.unknown) : SchemaAST.unknown
13858
14188
 
13859
- const SERIALIZER_ENSURE_ARRAY = "~effect/Schema/SERIALIZER_ENSURE_ARRAY"
14189
+ const arrayFromSingleTransformation = new SchemaTransformation.Transformation(
14190
+ SchemaGetter.transform((input: ReadonlyArray<unknown> | string) => typeof input === "string" ? [input] : input),
14191
+ SchemaGetter.passthrough()
14192
+ )
13860
14193
 
13861
- const toCodecEnsureArray = SchemaAST.toCodec((ast) => {
13862
- if (SchemaAST.isUnion(ast) && ast.annotations?.[SERIALIZER_ENSURE_ARRAY]) {
14194
+ const toCodecArrayFromSingleTop = SchemaAST.applyToSelfOrLastLinkEncoding((ast) => {
14195
+ if (isSerializerArrayFromSingle(ast)) {
13863
14196
  return ast
13864
14197
  }
13865
- const out = onSerializerEnsureArray(ast)
14198
+ const out = onSerializerArrayFromSingle(ast)
13866
14199
  if (SchemaAST.isArrays(out)) {
13867
- const ensure = new SchemaAST.Union(
13868
- [
13869
- out,
13870
- SchemaAST.decodeTo(
13871
- SchemaAST.string,
13872
- out,
13873
- new SchemaTransformation.Transformation(
13874
- SchemaGetter.split(),
13875
- SchemaGetter.passthrough()
13876
- )
13877
- )
13878
- ],
13879
- "anyOf",
13880
- { [SERIALIZER_ENSURE_ARRAY]: true }
14200
+ const ensure = SchemaAST.decodeTo(
14201
+ new SchemaAST.Union(
14202
+ [
14203
+ new SchemaAST.Arrays(
14204
+ out.isMutable,
14205
+ out.elements.map(toArrayFromSingleInputElement),
14206
+ out.rest.map(toArrayFromSingleInputElement)
14207
+ ),
14208
+ SchemaAST.string
14209
+ ],
14210
+ "anyOf",
14211
+ { [SERIALIZER_ENSURE_ARRAY]: true }
14212
+ ),
14213
+ out,
14214
+ arrayFromSingleTransformation
13881
14215
  )
13882
14216
  return SchemaAST.isOptional(ast) ? SchemaAST.optionalKey(ensure) : ensure
13883
14217
  }
13884
14218
  return out
13885
14219
  })
13886
14220
 
13887
- function onSerializerEnsureArray(ast: SchemaAST.AST): SchemaAST.AST {
13888
- switch (ast._tag) {
13889
- default:
13890
- return ast
13891
- case "Declaration":
13892
- case "Arrays":
13893
- case "Objects":
13894
- case "Union":
13895
- case "Suspend":
13896
- return ast.recur(toCodecEnsureArray)
13897
- }
14221
+ function onSerializerArrayFromSingle(ast: SchemaAST.AST): SchemaAST.AST {
14222
+ return ast._tag === "Declaration" || ast._tag === "Arrays" || ast._tag === "Objects" || ast._tag === "Union" ||
14223
+ ast._tag === "Suspend"
14224
+ ? ast.recur(toCodecArrayFromSingleTop)
14225
+ : ast
13898
14226
  }
13899
14227
 
13900
14228
  // -----------------------------------------------------------------------------
@@ -13908,7 +14236,7 @@ function onSerializerEnsureArray(ast: SchemaAST.AST): SchemaAST.AST {
13908
14236
  * @category Optic
13909
14237
  * @since 4.0.0
13910
14238
  */
13911
- export function toIso<S extends Top>(schema: S): Optic_.Iso<S["Type"], S["Iso"]> {
14239
+ export function toIso<S extends Constraint>(schema: S): Optic_.Iso<S["Type"], S["Iso"]> {
13912
14240
  const serializer = toCodecIso(schema)
13913
14241
  return Optic_.makeIso(SchemaParser.encodeSync(serializer), SchemaParser.decodeSync(serializer))
13914
14242
  }
@@ -13919,7 +14247,7 @@ export function toIso<S extends Top>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>
13919
14247
  * @category Optic
13920
14248
  * @since 4.0.0
13921
14249
  */
13922
- export function toIsoSource<S extends Top>(_: S): Optic_.Iso<S["Type"], S["Type"]> {
14250
+ export function toIsoSource<S extends Constraint>(_: S): Optic_.Iso<S["Type"], S["Type"]> {
13923
14251
  return Optic_.id()
13924
14252
  }
13925
14253
 
@@ -13929,7 +14257,7 @@ export function toIsoSource<S extends Top>(_: S): Optic_.Iso<S["Type"], S["Type"
13929
14257
  * @category Optic
13930
14258
  * @since 4.0.0
13931
14259
  */
13932
- export function toIsoFocus<S extends Top>(_: S): Optic_.Iso<S["Iso"], S["Iso"]> {
14260
+ export function toIsoFocus<S extends Constraint>(_: S): Optic_.Iso<S["Iso"], S["Iso"]> {
13933
14261
  return Optic_.id()
13934
14262
  }
13935
14263
 
@@ -13939,18 +14267,11 @@ export function toIsoFocus<S extends Top>(_: S): Optic_.Iso<S["Iso"], S["Iso"]>
13939
14267
  * @category Optic
13940
14268
  * @since 4.0.0
13941
14269
  */
13942
- export interface overrideToCodecIso<S extends Top, Iso> extends
13943
- Bottom<
13944
- S["Type"],
13945
- S["Encoded"],
13946
- S["DecodingServices"],
13947
- S["EncodingServices"],
14270
+ export interface overrideToCodecIso<S extends Constraint, Iso> extends
14271
+ BottomLazy<
13948
14272
  S["ast"],
13949
14273
  overrideToCodecIso<S, Iso>,
13950
- S["~type.make.in"],
13951
- Iso,
13952
14274
  S["~type.parameters"],
13953
- S["~type.make"],
13954
14275
  S["~type.mutability"],
13955
14276
  S["~type.optionality"],
13956
14277
  S["~type.constructor.default"],
@@ -13958,6 +14279,13 @@ export interface overrideToCodecIso<S extends Top, Iso> extends
13958
14279
  S["~encoded.optionality"]
13959
14280
  >
13960
14281
  {
14282
+ readonly "Type": S["Type"]
14283
+ readonly "Encoded": S["Encoded"]
14284
+ readonly "DecodingServices": S["DecodingServices"]
14285
+ readonly "EncodingServices": S["EncodingServices"]
14286
+ readonly "~type.make.in": S["~type.make.in"]
14287
+ readonly "~type.make": S["~type.make"]
14288
+ readonly "Iso": Iso
13961
14289
  readonly schema: S
13962
14290
  }
13963
14291
 
@@ -13978,7 +14306,7 @@ export interface overrideToCodecIso<S extends Top, Iso> extends
13978
14306
  * @category Optic
13979
14307
  * @since 4.0.0
13980
14308
  */
13981
- export function overrideToCodecIso<S extends Top, Iso>(
14309
+ export function overrideToCodecIso<S extends Constraint, Iso>(
13982
14310
  to: Codec<Iso>,
13983
14311
  transformation: {
13984
14312
  readonly decode: SchemaGetter.Getter<S["Type"], Iso>
@@ -14051,7 +14379,7 @@ export interface TreeRecord<A> {
14051
14379
  * @category Tree
14052
14380
  * @since 4.0.0
14053
14381
  */
14054
- export function Tree<S extends Top>(node: S) {
14382
+ export function Tree<S extends Constraint>(node: S) {
14055
14383
  const Tree$ref = suspend((): Codec<
14056
14384
  Tree<S["Type"]>,
14057
14385
  Tree<S["Encoded"]>,
@@ -14168,7 +14496,7 @@ export const MutableJson: Codec<MutableJson> = make(SchemaAST.MutableJson)
14168
14496
  * @category Schema Resolvers
14169
14497
  * @since 4.0.0
14170
14498
  */
14171
- export function resolveAnnotations<S extends Top>(
14499
+ export function resolveAnnotations<S extends Constraint>(
14172
14500
  schema: S
14173
14501
  ): Annotations.Bottom<S["Type"], S["~type.parameters"]> | undefined {
14174
14502
  return InternalAnnotations.resolve(schema.ast)
@@ -14182,7 +14510,7 @@ export function resolveAnnotations<S extends Top>(
14182
14510
  * @category Schema Resolvers
14183
14511
  * @since 4.0.0
14184
14512
  */
14185
- export function resolveAnnotationsKey<S extends Top>(schema: S): Annotations.Key<S["Type"]> | undefined {
14513
+ export function resolveAnnotationsKey<S extends Constraint>(schema: S): Annotations.Key<S["Type"]> | undefined {
14186
14514
  return schema.ast.context?.annotations
14187
14515
  }
14188
14516
 
@@ -14311,7 +14639,7 @@ export declare namespace Annotations {
14311
14639
  * @category models
14312
14640
  * @since 4.0.0
14313
14641
  */
14314
- export interface Bottom<T, TypeParameters extends ReadonlyArray<Top>> extends Documentation<T> {
14642
+ export interface Bottom<T, TypeParameters extends ReadonlyArray<Constraint>> extends Documentation<T> {
14315
14643
  /**
14316
14644
  * Complete message to use when this schema node reports an issue.
14317
14645
  *
@@ -14371,7 +14699,7 @@ export declare namespace Annotations {
14371
14699
  * @category utility types
14372
14700
  * @since 4.0.0
14373
14701
  */
14374
- export type Type<TypeParameters extends ReadonlyArray<Top>> = {
14702
+ export type Type<TypeParameters extends ReadonlyArray<Constraint>> = {
14375
14703
  readonly [K in keyof TypeParameters]: Codec<TypeParameters[K]["Type"]>
14376
14704
  }
14377
14705
  /**
@@ -14380,7 +14708,7 @@ export declare namespace Annotations {
14380
14708
  * @category utility types
14381
14709
  * @since 4.0.0
14382
14710
  */
14383
- export type Encoded<TypeParameters extends ReadonlyArray<Top>> = {
14711
+ export type Encoded<TypeParameters extends ReadonlyArray<Constraint>> = {
14384
14712
  readonly [K in keyof TypeParameters]: Codec<TypeParameters[K]["Encoded"]>
14385
14713
  }
14386
14714
  }
@@ -14395,7 +14723,7 @@ export declare namespace Annotations {
14395
14723
  * @category models
14396
14724
  * @since 4.0.0
14397
14725
  */
14398
- export interface Declaration<T, TypeParameters extends ReadonlyArray<Top> = readonly []>
14726
+ export interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint> = readonly []>
14399
14727
  extends Bottom<T, TypeParameters>
14400
14728
  {
14401
14729
  readonly toCodec?:
@@ -14508,7 +14836,7 @@ export declare namespace Annotations {
14508
14836
  * @since 4.0.0
14509
14837
  */
14510
14838
  export interface Filter {
14511
- readonly constraint?: Constraint | undefined
14839
+ readonly constraint?: GenerationConstraint | undefined
14512
14840
  readonly candidate?: Candidate | undefined
14513
14841
  }
14514
14842
 
@@ -14560,10 +14888,10 @@ export declare namespace Annotations {
14560
14888
  *
14561
14889
  * **Details**
14562
14890
  *
14563
- * `Constraint` is a generation hint for the current schema AST node, not a
14564
- * self-describing validation contract. Each generator consumes the fields it
14565
- * understands for the current node and ignores the rest; final schema
14566
- * filters still validate every generated value.
14891
+ * `GenerationConstraint` is a generation hint for the current schema AST
14892
+ * node, not a self-describing validation contract. Each generator consumes
14893
+ * the fields it understands for the current node and ignores the rest;
14894
+ * final schema filters still validate every generated value.
14567
14895
  *
14568
14896
  * `minLength` and `maxLength` represent node-local cardinality: string
14569
14897
  * length for strings, array length for arrays, final own-property count for
@@ -14576,7 +14904,7 @@ export declare namespace Annotations {
14576
14904
  * @category models
14577
14905
  * @since 4.0.0
14578
14906
  */
14579
- export interface Constraint {
14907
+ export interface GenerationConstraint {
14580
14908
  readonly minLength?: number | undefined
14581
14909
  readonly maxLength?: number | undefined
14582
14910
  readonly patterns?: readonly [string, ...Array<string>]
@@ -14619,7 +14947,7 @@ export declare namespace Annotations {
14619
14947
  * @since 4.0.0
14620
14948
  */
14621
14949
  export interface Context {
14622
- readonly constraint?: ToArbitrary.Constraint | undefined
14950
+ readonly constraint?: ToArbitrary.GenerationConstraint | undefined
14623
14951
  readonly recursion?: ToArbitrary.Recursion | undefined
14624
14952
  }
14625
14953
 
@@ -14685,7 +15013,7 @@ export declare namespace Annotations {
14685
15013
  * @category models
14686
15014
  * @since 4.0.0
14687
15015
  */
14688
- export interface Declaration<T, TypeParameters extends ReadonlyArray<Top>> {
15016
+ export interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint>> {
14689
15017
  (
14690
15018
  /* Arbitrary derivations for any type parameters of the schema (if present) */
14691
15019
  typeParameters: { readonly [K in keyof TypeParameters]: TypeParameter<TypeParameters[K]["Type"]> }
@@ -14762,7 +15090,7 @@ export declare namespace Annotations {
14762
15090
  * @category models
14763
15091
  * @since 4.0.0
14764
15092
  */
14765
- export interface Declaration<T, TypeParameters extends ReadonlyArray<Top>> {
15093
+ export interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint>> {
14766
15094
  (
14767
15095
  /* Formatters for any type parameters of the schema (if present) */
14768
15096
  typeParameters: { readonly [K in keyof TypeParameters]: Formatter<TypeParameters[K]["Type"]> }
@@ -14787,7 +15115,7 @@ export declare namespace Annotations {
14787
15115
  * @category models
14788
15116
  * @since 4.0.0
14789
15117
  */
14790
- export interface Declaration<T, TypeParameters extends ReadonlyArray<Top>> {
15118
+ export interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint>> {
14791
15119
  (
14792
15120
  /* Equivalences for any type parameters of the schema (if present) */
14793
15121
  typeParameters: { readonly [K in keyof TypeParameters]: Equivalence.Equivalence<TypeParameters[K]["Type"]> }