effect 4.0.2 → 4.0.3

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 (243) hide show
  1. package/dist/Context.js +3 -3
  2. package/dist/Context.js.map +1 -1
  3. package/dist/Crypto.d.ts +33 -5
  4. package/dist/Crypto.d.ts.map +1 -1
  5. package/dist/Crypto.js +8 -2
  6. package/dist/Crypto.js.map +1 -1
  7. package/dist/DateTime.d.ts +9 -6
  8. package/dist/DateTime.d.ts.map +1 -1
  9. package/dist/DateTime.js +9 -6
  10. package/dist/DateTime.js.map +1 -1
  11. package/dist/Duration.d.ts +6 -6
  12. package/dist/Duration.d.ts.map +1 -1
  13. package/dist/Duration.js +27 -8
  14. package/dist/Duration.js.map +1 -1
  15. package/dist/FileSystem.d.ts +44 -2
  16. package/dist/FileSystem.d.ts.map +1 -1
  17. package/dist/FileSystem.js.map +1 -1
  18. package/dist/Schema.d.ts +473 -1
  19. package/dist/Schema.d.ts.map +1 -1
  20. package/dist/Schema.js +355 -4
  21. package/dist/Schema.js.map +1 -1
  22. package/dist/Stdio.d.ts +7 -1
  23. package/dist/Stdio.d.ts.map +1 -1
  24. package/dist/Stdio.js +1 -0
  25. package/dist/Stdio.js.map +1 -1
  26. package/dist/Stream.d.ts +11 -11
  27. package/dist/Stream.js +5 -5
  28. package/dist/ai/McpServer.d.ts +6 -0
  29. package/dist/ai/McpServer.d.ts.map +1 -1
  30. package/dist/ai/McpServer.js +65 -23
  31. package/dist/ai/McpServer.js.map +1 -1
  32. package/dist/ai/internal/mcpProtocol/v2026_07_28.js +5 -0
  33. package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
  34. package/dist/ai/internal/mcpProtocol.js.map +1 -1
  35. package/dist/ai/internal/mcpRuntime.js +1 -0
  36. package/dist/ai/internal/mcpRuntime.js.map +1 -1
  37. package/dist/cli/CliOutput.d.ts +27 -0
  38. package/dist/cli/CliOutput.d.ts.map +1 -1
  39. package/dist/cli/CliOutput.js +33 -10
  40. package/dist/cli/CliOutput.js.map +1 -1
  41. package/dist/cli/Command.d.ts.map +1 -1
  42. package/dist/cli/Command.js +6 -3
  43. package/dist/cli/Command.js.map +1 -1
  44. package/dist/cli/Completions.d.ts +3 -3
  45. package/dist/cli/Completions.d.ts.map +1 -1
  46. package/dist/cli/Completions.js +8 -5
  47. package/dist/cli/Completions.js.map +1 -1
  48. package/dist/cli/GlobalFlag.d.ts +5 -4
  49. package/dist/cli/GlobalFlag.d.ts.map +1 -1
  50. package/dist/cli/GlobalFlag.js +3 -3
  51. package/dist/cli/GlobalFlag.js.map +1 -1
  52. package/dist/cli/Prompt.d.ts +17 -1
  53. package/dist/cli/Prompt.d.ts.map +1 -1
  54. package/dist/cli/Prompt.js +119 -114
  55. package/dist/cli/Prompt.js.map +1 -1
  56. package/dist/cli/internal/ansi.d.ts +0 -1
  57. package/dist/cli/internal/ansi.d.ts.map +1 -1
  58. package/dist/cli/internal/ansi.js +20 -3
  59. package/dist/cli/internal/ansi.js.map +1 -1
  60. package/dist/cli/internal/completions/powershell.d.ts +2 -0
  61. package/dist/cli/internal/completions/powershell.d.ts.map +1 -0
  62. package/dist/cli/internal/completions/powershell.js +273 -0
  63. package/dist/cli/internal/completions/powershell.js.map +1 -0
  64. package/dist/cli/internal/completions/zsh.js +3 -2
  65. package/dist/cli/internal/completions/zsh.js.map +1 -1
  66. package/dist/cli/internal/wizard.d.ts +3 -3
  67. package/dist/cli/internal/wizard.d.ts.map +1 -1
  68. package/dist/cli/internal/wizard.js +21 -18
  69. package/dist/cli/internal/wizard.js.map +1 -1
  70. package/dist/cluster/ClusterSchema.d.ts +28 -0
  71. package/dist/cluster/ClusterSchema.d.ts.map +1 -1
  72. package/dist/cluster/ClusterSchema.js +30 -0
  73. package/dist/cluster/ClusterSchema.js.map +1 -1
  74. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  75. package/dist/cluster/ClusterWorkflowEngine.js +10 -18
  76. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  77. package/dist/cluster/MessageStorage.d.ts +18 -3
  78. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  79. package/dist/cluster/MessageStorage.js +31 -11
  80. package/dist/cluster/MessageStorage.js.map +1 -1
  81. package/dist/cluster/Runners.d.ts.map +1 -1
  82. package/dist/cluster/Runners.js +8 -2
  83. package/dist/cluster/Runners.js.map +1 -1
  84. package/dist/cluster/Sharding.d.ts.map +1 -1
  85. package/dist/cluster/Sharding.js +181 -62
  86. package/dist/cluster/Sharding.js.map +1 -1
  87. package/dist/cluster/SqlMessageStorage.d.ts +59 -19
  88. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  89. package/dist/cluster/SqlMessageStorage.js +84 -55
  90. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  91. package/dist/cluster/SqlRunnerStorage.d.ts +68 -19
  92. package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
  93. package/dist/cluster/SqlRunnerStorage.js +191 -113
  94. package/dist/cluster/SqlRunnerStorage.js.map +1 -1
  95. package/dist/cluster/internal/entityManager.js +104 -37
  96. package/dist/cluster/internal/entityManager.js.map +1 -1
  97. package/dist/http/FindMyWay/internal/router.js +3 -6
  98. package/dist/http/FindMyWay/internal/router.js.map +1 -1
  99. package/dist/http/HttpClient.d.ts +6 -0
  100. package/dist/http/HttpClient.d.ts.map +1 -1
  101. package/dist/http/HttpClient.js +39 -2
  102. package/dist/http/HttpClient.js.map +1 -1
  103. package/dist/http/HttpTraceContext.d.ts.map +1 -1
  104. package/dist/http/HttpTraceContext.js +4 -2
  105. package/dist/http/HttpTraceContext.js.map +1 -1
  106. package/dist/internal/effect.js +12 -7
  107. package/dist/internal/effect.js.map +1 -1
  108. package/dist/internal/version.js +1 -1
  109. package/dist/net/AddressResolver.d.ts +145 -0
  110. package/dist/net/AddressResolver.d.ts.map +1 -0
  111. package/dist/net/AddressResolver.js +114 -0
  112. package/dist/net/AddressResolver.js.map +1 -0
  113. package/dist/net/Dns.d.ts +596 -0
  114. package/dist/net/Dns.d.ts.map +1 -0
  115. package/dist/net/Dns.js +549 -0
  116. package/dist/net/Dns.js.map +1 -0
  117. package/dist/net/Host.d.ts +320 -0
  118. package/dist/net/Host.d.ts.map +1 -0
  119. package/dist/net/Host.js +342 -0
  120. package/dist/net/Host.js.map +1 -0
  121. package/dist/net/IpInterface.d.ts +76 -3
  122. package/dist/net/IpInterface.d.ts.map +1 -1
  123. package/dist/net/IpInterface.js +53 -4
  124. package/dist/net/IpInterface.js.map +1 -1
  125. package/dist/net/IpNetwork.d.ts +82 -8
  126. package/dist/net/IpNetwork.d.ts.map +1 -1
  127. package/dist/net/IpNetwork.js +60 -4
  128. package/dist/net/IpNetwork.js.map +1 -1
  129. package/dist/net/NetAddress.d.ts +388 -35
  130. package/dist/net/NetAddress.d.ts.map +1 -1
  131. package/dist/net/NetAddress.js +350 -34
  132. package/dist/net/NetAddress.js.map +1 -1
  133. package/dist/net/index.d.ts +15 -0
  134. package/dist/net/index.d.ts.map +1 -1
  135. package/dist/net/index.js +15 -0
  136. package/dist/net/index.js.map +1 -1
  137. package/dist/observability/OtlpMetrics.d.ts.map +1 -1
  138. package/dist/observability/OtlpMetrics.js +15 -21
  139. package/dist/observability/OtlpMetrics.js.map +1 -1
  140. package/dist/observability/PrometheusMetrics.js +1 -0
  141. package/dist/observability/PrometheusMetrics.js.map +1 -1
  142. package/dist/persistence/PersistedQueue.d.ts +32 -3
  143. package/dist/persistence/PersistedQueue.d.ts.map +1 -1
  144. package/dist/persistence/PersistedQueue.js +75 -16
  145. package/dist/persistence/PersistedQueue.js.map +1 -1
  146. package/dist/rpc/RpcClient.d.ts +22 -6
  147. package/dist/rpc/RpcClient.d.ts.map +1 -1
  148. package/dist/rpc/RpcClient.js +12 -5
  149. package/dist/rpc/RpcClient.js.map +1 -1
  150. package/dist/rpc/RpcServer.d.ts +6 -0
  151. package/dist/rpc/RpcServer.d.ts.map +1 -1
  152. package/dist/rpc/RpcServer.js +42 -20
  153. package/dist/rpc/RpcServer.js.map +1 -1
  154. package/dist/socket/DatagramSocket.d.ts +456 -0
  155. package/dist/socket/DatagramSocket.d.ts.map +1 -0
  156. package/dist/socket/DatagramSocket.js +535 -0
  157. package/dist/socket/DatagramSocket.js.map +1 -0
  158. package/dist/socket/Socket.d.ts +14 -1
  159. package/dist/socket/Socket.d.ts.map +1 -1
  160. package/dist/socket/Socket.js +9 -1
  161. package/dist/socket/Socket.js.map +1 -1
  162. package/dist/socket/index.d.ts +5 -0
  163. package/dist/socket/index.d.ts.map +1 -1
  164. package/dist/socket/index.js +5 -0
  165. package/dist/socket/index.js.map +1 -1
  166. package/dist/sql/Migrator.d.ts.map +1 -1
  167. package/dist/sql/Migrator.js +7 -2
  168. package/dist/sql/Migrator.js.map +1 -1
  169. package/dist/sql/SqlClient.d.ts +7 -1
  170. package/dist/sql/SqlClient.d.ts.map +1 -1
  171. package/dist/sql/SqlClient.js +31 -6
  172. package/dist/sql/SqlClient.js.map +1 -1
  173. package/dist/testing/TestCrypto.d.ts +73 -0
  174. package/dist/testing/TestCrypto.d.ts.map +1 -0
  175. package/dist/testing/TestCrypto.js +87 -0
  176. package/dist/testing/TestCrypto.js.map +1 -0
  177. package/dist/testing/index.d.ts +5 -0
  178. package/dist/testing/index.d.ts.map +1 -1
  179. package/dist/testing/index.js +5 -0
  180. package/dist/testing/index.js.map +1 -1
  181. package/dist/workflow/DurableDeferred.d.ts +54 -0
  182. package/dist/workflow/DurableDeferred.d.ts.map +1 -1
  183. package/dist/workflow/DurableDeferred.js +78 -49
  184. package/dist/workflow/DurableDeferred.js.map +1 -1
  185. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  186. package/dist/workflow/WorkflowEngine.js +2 -1
  187. package/dist/workflow/WorkflowEngine.js.map +1 -1
  188. package/package.json +1 -1
  189. package/src/Context.ts +3 -3
  190. package/src/Crypto.ts +43 -9
  191. package/src/DateTime.ts +9 -6
  192. package/src/Duration.ts +36 -16
  193. package/src/FileSystem.ts +48 -2
  194. package/src/Schema.ts +669 -5
  195. package/src/Stdio.ts +9 -2
  196. package/src/Stream.ts +11 -11
  197. package/src/ai/McpServer.ts +63 -23
  198. package/src/ai/internal/mcpProtocol/v2026_07_28.ts +5 -0
  199. package/src/ai/internal/mcpProtocol.ts +3 -0
  200. package/src/ai/internal/mcpRuntime.ts +2 -0
  201. package/src/cli/CliOutput.ts +33 -16
  202. package/src/cli/Command.ts +4 -3
  203. package/src/cli/Completions.ts +9 -6
  204. package/src/cli/GlobalFlag.ts +19 -11
  205. package/src/cli/Prompt.ts +159 -149
  206. package/src/cli/internal/ansi.ts +26 -3
  207. package/src/cli/internal/completions/powershell.ts +322 -0
  208. package/src/cli/internal/completions/zsh.ts +4 -2
  209. package/src/cli/internal/wizard.ts +34 -26
  210. package/src/cluster/ClusterSchema.ts +32 -0
  211. package/src/cluster/ClusterWorkflowEngine.ts +13 -24
  212. package/src/cluster/MessageStorage.ts +45 -14
  213. package/src/cluster/Runners.ts +8 -2
  214. package/src/cluster/Sharding.ts +207 -49
  215. package/src/cluster/SqlMessageStorage.ts +118 -84
  216. package/src/cluster/SqlRunnerStorage.ts +224 -128
  217. package/src/cluster/internal/entityManager.ts +151 -55
  218. package/src/http/FindMyWay/internal/router.ts +4 -7
  219. package/src/http/HttpClient.ts +56 -2
  220. package/src/http/HttpTraceContext.ts +8 -2
  221. package/src/internal/effect.ts +15 -13
  222. package/src/internal/version.ts +1 -1
  223. package/src/net/AddressResolver.ts +222 -0
  224. package/src/net/Dns.ts +1035 -0
  225. package/src/net/Host.ts +472 -0
  226. package/src/net/IpInterface.ts +117 -7
  227. package/src/net/IpNetwork.ts +116 -17
  228. package/src/net/NetAddress.ts +611 -76
  229. package/src/net/index.ts +18 -0
  230. package/src/observability/OtlpMetrics.ts +12 -23
  231. package/src/observability/PrometheusMetrics.ts +1 -0
  232. package/src/persistence/PersistedQueue.ts +146 -53
  233. package/src/rpc/RpcClient.ts +41 -19
  234. package/src/rpc/RpcServer.ts +60 -25
  235. package/src/socket/DatagramSocket.ts +919 -0
  236. package/src/socket/Socket.ts +22 -2
  237. package/src/socket/index.ts +6 -0
  238. package/src/sql/Migrator.ts +21 -5
  239. package/src/sql/SqlClient.ts +39 -15
  240. package/src/testing/TestCrypto.ts +94 -0
  241. package/src/testing/index.ts +6 -0
  242. package/src/workflow/DurableDeferred.ts +123 -48
  243. package/src/workflow/WorkflowEngine.ts +2 -1
package/src/Schema.ts CHANGED
@@ -37,6 +37,7 @@ import * as HashSet_ from "./HashSet.ts"
37
37
  import * as Cookies_ from "./http/Cookies.ts"
38
38
  import * as Headers_ from "./http/Headers.ts"
39
39
  import * as UrlParams_ from "./http/UrlParams.ts"
40
+ import { NodeInspectSymbol } from "./Inspectable.ts"
40
41
  import * as core from "./internal/core.ts"
41
42
  import { effectIsExit } from "./internal/effect.ts"
42
43
  import * as InternalGraph from "./internal/graph.ts"
@@ -56,6 +57,8 @@ import { isSchemaError as isSchemaErrorInternal, SchemaErrorTypeId } from "./int
56
57
  import { getStackTraceLimit, setStackTraceLimit } from "./internal/stackTraceLimit.ts"
57
58
  import type * as JsonPatch from "./JsonPatch.ts"
58
59
  import type * as JsonSchema from "./JsonSchema.ts"
60
+ import * as Dns_ from "./net/Dns.ts"
61
+ import * as Host_ from "./net/Host.ts"
59
62
  import * as IpInterface_ from "./net/IpInterface.ts"
60
63
  import * as IpNetwork_ from "./net/IpNetwork.ts"
61
64
  import * as NetAddress_ from "./net/NetAddress.ts"
@@ -1217,6 +1220,15 @@ export class SchemaError extends Data.TaggedError("SchemaError")<{
1217
1220
  override get message() {
1218
1221
  return SchemaIssue.defaultFormatter(this.issue)
1219
1222
  }
1223
+ override toJSON() {
1224
+ return {
1225
+ _tag: this._tag,
1226
+ message: this.message
1227
+ }
1228
+ }
1229
+ override [NodeInspectSymbol]() {
1230
+ return this.toJSON()
1231
+ }
1220
1232
  override toString() {
1221
1233
  return `SchemaError(${this.message})`
1222
1234
  }
@@ -7877,7 +7889,8 @@ export function isMultipleOf(
7877
7889
  *
7878
7890
  * JSON Schema:
7879
7891
  *
7880
- * This check corresponds to the `type: "integer"` constraint in JSON Schema.
7892
+ * This check corresponds to `type: "integer"` with `minimum: Number.MIN_SAFE_INTEGER`
7893
+ * and `maximum: Number.MAX_SAFE_INTEGER` in JSON Schema.
7881
7894
  *
7882
7895
  * Arbitrary:
7883
7896
  *
@@ -7896,7 +7909,11 @@ export function isInt(annotations?: Annotations.Filter) {
7896
7909
  id: "effect/schema/isInt",
7897
7910
  payload: null
7898
7911
  },
7899
- toJsonSchema: () => [{ type: "integer" }, true],
7912
+ toJsonSchema: () => ({
7913
+ type: "integer",
7914
+ minimum: globalThis.Number.MIN_SAFE_INTEGER,
7915
+ maximum: globalThis.Number.MAX_SAFE_INTEGER
7916
+ }),
7900
7917
  toCode: () => ({ runtime: "Schema.isInt()" }),
7901
7918
  arbitraryConstraint: {
7902
7919
  number: "integer"
@@ -11978,10 +11995,10 @@ export const DateTimeZonedFromString: DateTimeZonedFromString = DateTimeZonedStr
11978
11995
  decodeTo(DateTimeZoned, dateTimeZonedFromString)
11979
11996
  )
11980
11997
 
11981
- const netAddressFromString = <S extends declare<any>, E extends { readonly message: string }>(
11998
+ const netAddressFromString = <S extends Constraint, E extends { readonly message: string }>(
11982
11999
  declaration: S,
11983
- parse: (input: string) => Result_.Result<S["Type"], E>,
11984
- encode: (value: S["Type"]) => string,
12000
+ parse: (input: string) => Result_.Result<S["Encoded"], E>,
12001
+ encode: (value: S["Encoded"]) => string,
11985
12002
  identifier: string
11986
12003
  ) =>
11987
12004
  String.pipe(decodeTo(
@@ -13332,6 +13349,229 @@ export const SocketAddress: SocketAddress = declare(NetAddress_.isSocketAddress,
13332
13349
  identifier: "SocketAddress"
13333
13350
  })
13334
13351
 
13352
+ /**
13353
+ * Type-level representation of {@link DomainName}.
13354
+ *
13355
+ * @stability experimental
13356
+ * @category models
13357
+ * @since 4.0.0
13358
+ */
13359
+ export interface DomainName extends brand<String, "~effect/net/Host/DomainName"> {
13360
+ readonly "Rebuild": DomainName
13361
+ }
13362
+
13363
+ /**
13364
+ * Schema for normalized DNS domain names.
13365
+ *
13366
+ * **Details**
13367
+ *
13368
+ * Only names already in normalized form (lowercase ASCII, with
13369
+ * internationalized labels in `xn--` form) are accepted. Use
13370
+ * {@link DomainNameFromString} to normalize arbitrary input.
13371
+ *
13372
+ * @stability experimental
13373
+ * @category schemas
13374
+ * @since 4.0.0
13375
+ */
13376
+ export const DomainName: DomainName = String.check(
13377
+ makeFilter(Host_.isDomainName, { expected: "a normalized domain name" })
13378
+ ).pipe(brand("~effect/net/Host/DomainName")).annotate({ identifier: "DomainName" })
13379
+
13380
+ /**
13381
+ * Type-level representation of {@link DomainNameFromString}.
13382
+ *
13383
+ * @stability experimental
13384
+ * @category models
13385
+ * @since 4.0.0
13386
+ */
13387
+ export interface DomainNameFromString extends decodeTo<DomainName, String> {
13388
+ readonly "Rebuild": DomainNameFromString
13389
+ }
13390
+
13391
+ /**
13392
+ * Schema for DNS domain names decoded from strings, normalizing case and
13393
+ * converting internationalized names to their ASCII form.
13394
+ *
13395
+ * @stability experimental
13396
+ * @category schemas
13397
+ * @since 4.0.0
13398
+ */
13399
+ export const DomainNameFromString: DomainNameFromString = netAddressFromString(
13400
+ DomainName,
13401
+ Host_.domainNameFromString,
13402
+ (name) => name,
13403
+ "DomainNameFromString"
13404
+ )
13405
+
13406
+ /**
13407
+ * Type-level representation of {@link ScopedIpv6Literal}.
13408
+ *
13409
+ * @stability experimental
13410
+ * @category models
13411
+ * @since 4.0.0
13412
+ */
13413
+ export interface ScopedIpv6Literal extends brand<String, "~effect/net/NetAddress/ScopedIpv6Literal"> {
13414
+ readonly "Rebuild": ScopedIpv6Literal
13415
+ }
13416
+
13417
+ /**
13418
+ * Schema for canonical scoped IPv6 literals such as `fe80::1%eth0`.
13419
+ *
13420
+ * @stability experimental
13421
+ * @category schemas
13422
+ * @since 4.0.0
13423
+ */
13424
+ export const ScopedIpv6Literal: ScopedIpv6Literal = String.check(
13425
+ makeFilter(NetAddress_.isScopedIpv6Literal, { expected: "a canonical scoped IPv6 literal" })
13426
+ ).pipe(brand("~effect/net/NetAddress/ScopedIpv6Literal")).annotate({ identifier: "ScopedIpv6Literal" })
13427
+
13428
+ /**
13429
+ * Type-level representation of {@link ScopedIpv6LiteralFromString}.
13430
+ *
13431
+ * @stability experimental
13432
+ * @category models
13433
+ * @since 4.0.0
13434
+ */
13435
+ export interface ScopedIpv6LiteralFromString extends decodeTo<ScopedIpv6Literal, String> {
13436
+ readonly "Rebuild": ScopedIpv6LiteralFromString
13437
+ }
13438
+
13439
+ /**
13440
+ * Schema for scoped IPv6 literals decoded from strings, normalizing the address
13441
+ * and numeric zones.
13442
+ *
13443
+ * @stability experimental
13444
+ * @category schemas
13445
+ * @since 4.0.0
13446
+ */
13447
+ export const ScopedIpv6LiteralFromString: ScopedIpv6LiteralFromString = netAddressFromString(
13448
+ ScopedIpv6Literal,
13449
+ NetAddress_.scopedIpv6LiteralFromString,
13450
+ (literal) => literal,
13451
+ "ScopedIpv6LiteralFromString"
13452
+ )
13453
+
13454
+ /**
13455
+ * Type-level representation of {@link Host}.
13456
+ *
13457
+ * @stability experimental
13458
+ * @category models
13459
+ * @since 4.0.0
13460
+ */
13461
+ export interface Host extends Union<readonly [IpAddress, ScopedIpv6Literal, DomainName]> {
13462
+ readonly "Rebuild": Host
13463
+ }
13464
+
13465
+ /**
13466
+ * Schema for hosts: numeric IP addresses, scoped IPv6 literals, or domain names.
13467
+ *
13468
+ * @stability experimental
13469
+ * @category schemas
13470
+ * @since 4.0.0
13471
+ */
13472
+ export const Host: Host = Union([IpAddress, ScopedIpv6Literal, DomainName]).annotate({ identifier: "Host" })
13473
+
13474
+ /**
13475
+ * Type-level representation of {@link HostFromString}.
13476
+ *
13477
+ * @stability experimental
13478
+ * @category models
13479
+ * @since 4.0.0
13480
+ */
13481
+ export interface HostFromString
13482
+ extends Union<readonly [IpAddressFromString, ScopedIpv6LiteralFromString, DomainNameFromString]>
13483
+ {
13484
+ readonly "Rebuild": HostFromString
13485
+ }
13486
+
13487
+ /**
13488
+ * Schema for hosts decoded from strings. Numeric IP strings decode to IP
13489
+ * addresses; other strings decode to scoped IPv6 literals or domain names.
13490
+ *
13491
+ * @stability experimental
13492
+ * @category schemas
13493
+ * @since 4.0.0
13494
+ */
13495
+ export const HostFromString: HostFromString = Union([
13496
+ IpAddressFromString,
13497
+ ScopedIpv6LiteralFromString,
13498
+ DomainNameFromString
13499
+ ]).annotate({ identifier: "HostFromString" })
13500
+
13501
+ /**
13502
+ * Type-level representation of {@link HostPort}.
13503
+ *
13504
+ * @stability experimental
13505
+ * @category models
13506
+ * @since 4.0.0
13507
+ */
13508
+ export interface HostPort extends declare<Host_.HostPort> {
13509
+ readonly "Rebuild": HostPort
13510
+ }
13511
+
13512
+ /**
13513
+ * Schema for already-constructed unresolved host and port values.
13514
+ *
13515
+ * @stability experimental
13516
+ * @category schemas
13517
+ * @since 4.0.0
13518
+ */
13519
+ export const HostPort: HostPort = declare(Host_.isHostPort, {
13520
+ identifier: "HostPort"
13521
+ })
13522
+
13523
+ /**
13524
+ * Type-level representation of {@link HostPortFromString}.
13525
+ *
13526
+ * @stability experimental
13527
+ * @category models
13528
+ * @since 4.0.0
13529
+ */
13530
+ export interface HostPortFromString extends decodeTo<HostPort, String> {
13531
+ readonly "Rebuild": HostPortFromString
13532
+ }
13533
+
13534
+ /**
13535
+ * Schema for unresolved endpoints encoded as `host:port` or `[IPv6]:port`
13536
+ * strings.
13537
+ *
13538
+ * @stability experimental
13539
+ * @category schemas
13540
+ * @since 4.0.0
13541
+ */
13542
+ export const HostPortFromString: HostPortFromString = netAddressFromString(
13543
+ HostPort,
13544
+ Host_.hostPortFromString,
13545
+ Host_.formatHostPort,
13546
+ "HostPortFromString"
13547
+ )
13548
+
13549
+ /**
13550
+ * Type-level representation of {@link Port}.
13551
+ *
13552
+ * @stability experimental
13553
+ * @category models
13554
+ * @since 4.0.0
13555
+ */
13556
+ export interface Port extends Int {
13557
+ readonly "Rebuild": Port
13558
+ }
13559
+
13560
+ /**
13561
+ * Schema for TCP and UDP port numbers from 0 through 65535.
13562
+ *
13563
+ * **Details**
13564
+ *
13565
+ * Port 0 is accepted because it asks the operating system to choose a port
13566
+ * when binding, and it matches the port range of `InetAddress` and `HostPort`.
13567
+ * `Config.Port` accepts only 1 through 65535.
13568
+ *
13569
+ * @stability experimental
13570
+ * @category schemas
13571
+ * @since 4.0.0
13572
+ */
13573
+ export const Port: Port = Int.check(isBetween({ minimum: 0, maximum: 65535 }, { expected: "a port number" }))
13574
+
13335
13575
  // -----------------------------------------------------------------------------
13336
13576
  // Duration schemas
13337
13577
  // -----------------------------------------------------------------------------
@@ -13549,6 +13789,426 @@ export const DurationFromMillis: DurationFromMillis = Number.pipe(
13549
13789
  decodeTo(Duration, durationFromMillis)
13550
13790
  )
13551
13791
 
13792
+ // -----------------------------------------------------------------------------
13793
+ // DNS schemas
13794
+ // -----------------------------------------------------------------------------
13795
+
13796
+ /**
13797
+ * Type-level representation of {@link DnsRecordType}.
13798
+ *
13799
+ * @stability experimental
13800
+ * @category models
13801
+ * @since 4.0.0
13802
+ */
13803
+ export interface DnsRecordType extends Literals<ReadonlyArray<Dns_.RecordType>> {}
13804
+
13805
+ /**
13806
+ * Schema for supported DNS record types such as `"A"` or `"SRV"`.
13807
+ *
13808
+ * @stability experimental
13809
+ * @category schemas
13810
+ * @since 4.0.0
13811
+ */
13812
+ export const DnsRecordType: DnsRecordType = Literals(Dns_.recordTypes)
13813
+
13814
+ // Addresses in JSON records must already be canonical; normalizing input is
13815
+ // left to the `*FromString` schemas.
13816
+ const dnsCanonicalAddress = <A extends NetAddress_.IpAddress>(
13817
+ schema: Codec<A>,
13818
+ parse: (input: string) => Result_.Result<A, NetAddress_.NetAddressError>
13819
+ ) =>
13820
+ String.pipe(decodeTo(
13821
+ schema,
13822
+ SchemaTransformation.transformEffect({
13823
+ decode: (input, options) => {
13824
+ const result = parse(input)
13825
+ if (Result_.isFailure(result)) {
13826
+ return Effect.fail(new SchemaIssue.InvalidValue({ message: result.failure.message }, input, options))
13827
+ }
13828
+ return NetAddress_.formatIp(result.success) === input
13829
+ ? Effect.succeed(result.success)
13830
+ : Effect.fail(new SchemaIssue.InvalidValue({ message: "expected a canonical address" }, input, options))
13831
+ },
13832
+ encode: (address) => Effect.succeed(NetAddress_.formatIp(address))
13833
+ })
13834
+ ))
13835
+
13836
+ const dnsUint8 = Int.check(isBetween({ minimum: 0, maximum: 0xff }))
13837
+
13838
+ const dnsUint16 = Int.check(isBetween({ minimum: 0, maximum: 0xffff }))
13839
+
13840
+ const dnsUint32 = Int.check(isBetween({ minimum: 0, maximum: 0xffffffff }))
13841
+
13842
+ // SOA timers are written as whole seconds, as in zone files.
13843
+ const dnsSeconds = dnsUint32.pipe(decodeTo(
13844
+ Duration,
13845
+ SchemaTransformation.transform({ decode: Duration_.seconds, encode: Duration_.toSeconds })
13846
+ ))
13847
+
13848
+ // Each record type is an opaque value whose JSON form is a plain object tagged
13849
+ // by record type, such as `{ "_tag": "MX", "exchange": "mail.example.com", "priority": 10 }`.
13850
+ const dnsRecordOfType = <T extends Dns_.RecordType>(
13851
+ type: T,
13852
+ fields: { readonly [K in keyof Dns_.RecordFields<T>]-?: Codec<Dns_.RecordFields<T>[K], unknown> }
13853
+ ) =>
13854
+ declare((u): u is Dns_.RecordFor<T> => Dns_.isDnsRecord(u) && u._tag === type, {
13855
+ identifier: `Dns${type.charAt(0)}${type.slice(1).toLowerCase()}Record`,
13856
+ toCodecJson: () => {
13857
+ const json = TaggedStruct(type, fields)
13858
+ return link<Dns_.RecordFor<T>>()(
13859
+ json,
13860
+ SchemaTransformation.transformEffect({
13861
+ decode: (input, options) => {
13862
+ const { _tag, ...rest } = input as { readonly _tag: T }
13863
+ const result = Dns_.makeRecord(type, rest as Dns_.RecordFields<T>)
13864
+ return Result_.isSuccess(result)
13865
+ ? Effect.succeed(result.success)
13866
+ : Effect.fail(new SchemaIssue.InvalidValue({ message: result.failure.message }, input, options))
13867
+ },
13868
+ // Records hold only their tag and fields as own properties.
13869
+ encode: (record) => Effect.succeed({ ...record } as unknown as typeof json["Type"])
13870
+ })
13871
+ )
13872
+ }
13873
+ })
13874
+
13875
+ /**
13876
+ * Type-level representation of {@link DnsARecord}.
13877
+ *
13878
+ * @stability experimental
13879
+ * @category models
13880
+ * @since 4.0.0
13881
+ */
13882
+ export interface DnsARecord extends declare<Dns_.A> {
13883
+ readonly "Rebuild": DnsARecord
13884
+ }
13885
+
13886
+ /**
13887
+ * Schema for already-constructed IPv4 address (`A`) DNS records.
13888
+ *
13889
+ * @stability experimental
13890
+ * @category schemas
13891
+ * @since 4.0.0
13892
+ */
13893
+ export const DnsARecord: DnsARecord = dnsRecordOfType("A", {
13894
+ address: dnsCanonicalAddress(Ipv4Address, NetAddress_.ipv4FromString)
13895
+ })
13896
+
13897
+ /**
13898
+ * Type-level representation of {@link DnsAaaaRecord}.
13899
+ *
13900
+ * @stability experimental
13901
+ * @category models
13902
+ * @since 4.0.0
13903
+ */
13904
+ export interface DnsAaaaRecord extends declare<Dns_.Aaaa> {
13905
+ readonly "Rebuild": DnsAaaaRecord
13906
+ }
13907
+
13908
+ /**
13909
+ * Schema for already-constructed IPv6 address (`AAAA`) DNS records.
13910
+ *
13911
+ * @stability experimental
13912
+ * @category schemas
13913
+ * @since 4.0.0
13914
+ */
13915
+ export const DnsAaaaRecord: DnsAaaaRecord = dnsRecordOfType("AAAA", {
13916
+ address: dnsCanonicalAddress(Ipv6Address, NetAddress_.ipv6FromString)
13917
+ })
13918
+
13919
+ /**
13920
+ * Type-level representation of {@link DnsCaaRecord}.
13921
+ *
13922
+ * @stability experimental
13923
+ * @category models
13924
+ * @since 4.0.0
13925
+ */
13926
+ export interface DnsCaaRecord extends declare<Dns_.Caa> {
13927
+ readonly "Rebuild": DnsCaaRecord
13928
+ }
13929
+
13930
+ /**
13931
+ * Schema for already-constructed certification authority authorization (`CAA`) DNS records.
13932
+ *
13933
+ * @stability experimental
13934
+ * @category schemas
13935
+ * @since 4.0.0
13936
+ */
13937
+ export const DnsCaaRecord: DnsCaaRecord = dnsRecordOfType("CAA", {
13938
+ critical: Boolean,
13939
+ tag: String.check(isPattern(/^[a-z0-9]+$/i)),
13940
+ value: String
13941
+ })
13942
+
13943
+ /**
13944
+ * Type-level representation of {@link DnsCnameRecord}.
13945
+ *
13946
+ * @stability experimental
13947
+ * @category models
13948
+ * @since 4.0.0
13949
+ */
13950
+ export interface DnsCnameRecord extends declare<Dns_.Cname> {
13951
+ readonly "Rebuild": DnsCnameRecord
13952
+ }
13953
+
13954
+ /**
13955
+ * Schema for already-constructed canonical name (`CNAME`) DNS records.
13956
+ *
13957
+ * @stability experimental
13958
+ * @category schemas
13959
+ * @since 4.0.0
13960
+ */
13961
+ export const DnsCnameRecord: DnsCnameRecord = dnsRecordOfType("CNAME", { target: DomainName })
13962
+
13963
+ /**
13964
+ * Type-level representation of {@link DnsMxRecord}.
13965
+ *
13966
+ * @stability experimental
13967
+ * @category models
13968
+ * @since 4.0.0
13969
+ */
13970
+ export interface DnsMxRecord extends declare<Dns_.Mx> {
13971
+ readonly "Rebuild": DnsMxRecord
13972
+ }
13973
+
13974
+ /**
13975
+ * Schema for already-constructed mail exchange (`MX`) DNS records.
13976
+ *
13977
+ * @stability experimental
13978
+ * @category schemas
13979
+ * @since 4.0.0
13980
+ */
13981
+ export const DnsMxRecord: DnsMxRecord = dnsRecordOfType("MX", { exchange: DomainName, priority: dnsUint16 })
13982
+
13983
+ /**
13984
+ * Type-level representation of {@link DnsNaptrRecord}.
13985
+ *
13986
+ * @stability experimental
13987
+ * @category models
13988
+ * @since 4.0.0
13989
+ */
13990
+ export interface DnsNaptrRecord extends declare<Dns_.Naptr> {
13991
+ readonly "Rebuild": DnsNaptrRecord
13992
+ }
13993
+
13994
+ /**
13995
+ * Schema for already-constructed naming authority pointer (`NAPTR`) DNS records.
13996
+ *
13997
+ * @stability experimental
13998
+ * @category schemas
13999
+ * @since 4.0.0
14000
+ */
14001
+ export const DnsNaptrRecord: DnsNaptrRecord = dnsRecordOfType("NAPTR", {
14002
+ order: dnsUint16,
14003
+ preference: dnsUint16,
14004
+ flags: String,
14005
+ service: String,
14006
+ regexp: String,
14007
+ replacement: DomainName
14008
+ })
14009
+
14010
+ /**
14011
+ * Type-level representation of {@link DnsNsRecord}.
14012
+ *
14013
+ * @stability experimental
14014
+ * @category models
14015
+ * @since 4.0.0
14016
+ */
14017
+ export interface DnsNsRecord extends declare<Dns_.Ns> {
14018
+ readonly "Rebuild": DnsNsRecord
14019
+ }
14020
+
14021
+ /**
14022
+ * Schema for already-constructed name server (`NS`) DNS records.
14023
+ *
14024
+ * @stability experimental
14025
+ * @category schemas
14026
+ * @since 4.0.0
14027
+ */
14028
+ export const DnsNsRecord: DnsNsRecord = dnsRecordOfType("NS", { host: DomainName })
14029
+
14030
+ /**
14031
+ * Type-level representation of {@link DnsPtrRecord}.
14032
+ *
14033
+ * @stability experimental
14034
+ * @category models
14035
+ * @since 4.0.0
14036
+ */
14037
+ export interface DnsPtrRecord extends declare<Dns_.Ptr> {
14038
+ readonly "Rebuild": DnsPtrRecord
14039
+ }
14040
+
14041
+ /**
14042
+ * Schema for already-constructed pointer (`PTR`) DNS records.
14043
+ *
14044
+ * @stability experimental
14045
+ * @category schemas
14046
+ * @since 4.0.0
14047
+ */
14048
+ export const DnsPtrRecord: DnsPtrRecord = dnsRecordOfType("PTR", { host: NonEmptyString })
14049
+
14050
+ /**
14051
+ * Type-level representation of {@link DnsSoaRecord}.
14052
+ *
14053
+ * @stability experimental
14054
+ * @category models
14055
+ * @since 4.0.0
14056
+ */
14057
+ export interface DnsSoaRecord extends declare<Dns_.Soa> {
14058
+ readonly "Rebuild": DnsSoaRecord
14059
+ }
14060
+
14061
+ /**
14062
+ * Schema for already-constructed start of authority (`SOA`) DNS records.
14063
+ *
14064
+ * @stability experimental
14065
+ * @category schemas
14066
+ * @since 4.0.0
14067
+ */
14068
+ export const DnsSoaRecord: DnsSoaRecord = dnsRecordOfType("SOA", {
14069
+ primary: DomainName,
14070
+ admin: NonEmptyString,
14071
+ serial: dnsUint32,
14072
+ refresh: dnsSeconds,
14073
+ retry: dnsSeconds,
14074
+ expire: dnsSeconds,
14075
+ minimum: dnsSeconds
14076
+ })
14077
+
14078
+ /**
14079
+ * Type-level representation of {@link DnsSrvRecord}.
14080
+ *
14081
+ * @stability experimental
14082
+ * @category models
14083
+ * @since 4.0.0
14084
+ */
14085
+ export interface DnsSrvRecord extends declare<Dns_.Srv> {
14086
+ readonly "Rebuild": DnsSrvRecord
14087
+ }
14088
+
14089
+ /**
14090
+ * Schema for already-constructed service locator (`SRV`) DNS records.
14091
+ *
14092
+ * @stability experimental
14093
+ * @category schemas
14094
+ * @since 4.0.0
14095
+ */
14096
+ export const DnsSrvRecord: DnsSrvRecord = dnsRecordOfType("SRV", {
14097
+ target: DomainName,
14098
+ port: dnsUint16,
14099
+ priority: dnsUint16,
14100
+ weight: dnsUint16
14101
+ })
14102
+
14103
+ /**
14104
+ * Type-level representation of {@link DnsTlsaRecord}.
14105
+ *
14106
+ * @stability experimental
14107
+ * @category models
14108
+ * @since 4.0.0
14109
+ */
14110
+ export interface DnsTlsaRecord extends declare<Dns_.Tlsa> {
14111
+ readonly "Rebuild": DnsTlsaRecord
14112
+ }
14113
+
14114
+ /**
14115
+ * Schema for already-constructed TLS authentication (`TLSA`) DNS records.
14116
+ *
14117
+ * **Details**
14118
+ *
14119
+ * The default JSON serializer encodes the certificate association `data` as a
14120
+ * hex string.
14121
+ *
14122
+ * @stability experimental
14123
+ * @category schemas
14124
+ * @since 4.0.0
14125
+ */
14126
+ export const DnsTlsaRecord: DnsTlsaRecord = dnsRecordOfType("TLSA", {
14127
+ certUsage: dnsUint8,
14128
+ selector: dnsUint8,
14129
+ matchingType: dnsUint8,
14130
+ data: Uint8ArrayFromHex
14131
+ })
14132
+
14133
+ /**
14134
+ * Type-level representation of {@link DnsTxtRecord}.
14135
+ *
14136
+ * @stability experimental
14137
+ * @category models
14138
+ * @since 4.0.0
14139
+ */
14140
+ export interface DnsTxtRecord extends declare<Dns_.Txt> {
14141
+ readonly "Rebuild": DnsTxtRecord
14142
+ }
14143
+
14144
+ /**
14145
+ * Schema for already-constructed text (`TXT`) DNS records.
14146
+ *
14147
+ * @stability experimental
14148
+ * @category schemas
14149
+ * @since 4.0.0
14150
+ */
14151
+ export const DnsTxtRecord: DnsTxtRecord = dnsRecordOfType("TXT", { chunks: NonEmptyArray(String) })
14152
+
14153
+ /**
14154
+ * Type-level representation of {@link DnsRecord}.
14155
+ *
14156
+ * @stability experimental
14157
+ * @category models
14158
+ * @since 4.0.0
14159
+ */
14160
+ export interface DnsRecord extends
14161
+ Union<
14162
+ readonly [
14163
+ DnsARecord,
14164
+ DnsAaaaRecord,
14165
+ DnsCaaRecord,
14166
+ DnsCnameRecord,
14167
+ DnsMxRecord,
14168
+ DnsNaptrRecord,
14169
+ DnsNsRecord,
14170
+ DnsPtrRecord,
14171
+ DnsSoaRecord,
14172
+ DnsSrvRecord,
14173
+ DnsTlsaRecord,
14174
+ DnsTxtRecord
14175
+ ]
14176
+ >
14177
+ {
14178
+ readonly "Rebuild": DnsRecord
14179
+ }
14180
+
14181
+ /**
14182
+ * Schema for already-constructed DNS records of any supported record type.
14183
+ *
14184
+ * **Details**
14185
+ *
14186
+ * The default JSON serializer encodes records as objects tagged by record type,
14187
+ * with addresses and names as canonical strings, SOA timers as whole seconds,
14188
+ * and TLSA data as hex, such as
14189
+ * `{ "_tag": "SRV", "target": "db.internal", "port": 5432, "priority": 10, "weight": 5 }`.
14190
+ * Decoding accepts only canonical addresses and normalized domain names, and
14191
+ * reports invalid fields with their path.
14192
+ *
14193
+ * @stability experimental
14194
+ * @category schemas
14195
+ * @since 4.0.0
14196
+ */
14197
+ export const DnsRecord: DnsRecord = Union([
14198
+ DnsARecord,
14199
+ DnsAaaaRecord,
14200
+ DnsCaaRecord,
14201
+ DnsCnameRecord,
14202
+ DnsMxRecord,
14203
+ DnsNaptrRecord,
14204
+ DnsNsRecord,
14205
+ DnsPtrRecord,
14206
+ DnsSoaRecord,
14207
+ DnsSrvRecord,
14208
+ DnsTlsaRecord,
14209
+ DnsTxtRecord
14210
+ ]).annotate({ identifier: "DnsRecord" })
14211
+
13552
14212
  // -----------------------------------------------------------------------------
13553
14213
  // Exit schemas
13554
14214
  // -----------------------------------------------------------------------------
@@ -15141,6 +15801,10 @@ export interface Class<Self, S extends Constraint & { readonly fields: Struct.Fi
15141
15801
  *
15142
15802
  * **Gotchas**
15143
15803
  *
15804
+ * Fields with the same name replace inherited fields. Use this to refine
15805
+ * validation or change encoding. Effect does not check compatibility; the
15806
+ * caller must ensure the replacement preserves the base class contract.
15807
+ *
15144
15808
  * Checks from a `Struct` argument are evaluated against the full subclass
15145
15809
  * value after inherited and extension fields are merged. Object-wide checks
15146
15810
  * such as `isMaxProperties` count inherited fields too.