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/dist/Schema.js CHANGED
@@ -31,6 +31,7 @@ import * as HashSet_ from "./HashSet.js";
31
31
  import * as Cookies_ from "./http/Cookies.js";
32
32
  import * as Headers_ from "./http/Headers.js";
33
33
  import * as UrlParams_ from "./http/UrlParams.js";
34
+ import { NodeInspectSymbol } from "./Inspectable.js";
34
35
  import * as core from "./internal/core.js";
35
36
  import { effectIsExit } from "./internal/effect.js";
36
37
  import * as InternalGraph from "./internal/graph.js";
@@ -48,6 +49,8 @@ import * as InternalToJsonSchemaDocument from "./internal/schema/toJsonSchemaDoc
48
49
  import * as InternalToRepresentation from "./internal/schema/toRepresentation.js";
49
50
  import { isSchemaError as isSchemaErrorInternal, SchemaErrorTypeId } from "./internal/schemaError.js";
50
51
  import { getStackTraceLimit, setStackTraceLimit } from "./internal/stackTraceLimit.js";
52
+ import * as Dns_ from "./net/Dns.js";
53
+ import * as Host_ from "./net/Host.js";
51
54
  import * as IpInterface_ from "./net/IpInterface.js";
52
55
  import * as IpNetwork_ from "./net/IpNetwork.js";
53
56
  import * as NetAddress_ from "./net/NetAddress.js";
@@ -376,6 +379,15 @@ export class SchemaError extends /*#__PURE__*/Data.TaggedError("SchemaError") {
376
379
  get message() {
377
380
  return SchemaIssue.defaultFormatter(this.issue);
378
381
  }
382
+ toJSON() {
383
+ return {
384
+ _tag: this._tag,
385
+ message: this.message
386
+ };
387
+ }
388
+ [NodeInspectSymbol]() {
389
+ return this.toJSON();
390
+ }
379
391
  toString() {
380
392
  return `SchemaError(${this.message})`;
381
393
  }
@@ -4528,7 +4540,8 @@ export function isMultipleOf(divisor, annotations) {
4528
4540
  *
4529
4541
  * JSON Schema:
4530
4542
  *
4531
- * This check corresponds to the `type: "integer"` constraint in JSON Schema.
4543
+ * This check corresponds to `type: "integer"` with `minimum: Number.MIN_SAFE_INTEGER`
4544
+ * and `maximum: Number.MAX_SAFE_INTEGER` in JSON Schema.
4532
4545
  *
4533
4546
  * Arbitrary:
4534
4547
  *
@@ -4545,9 +4558,11 @@ export function isInt(annotations) {
4545
4558
  id: "effect/schema/isInt",
4546
4559
  payload: null
4547
4560
  },
4548
- toJsonSchema: () => [{
4549
- type: "integer"
4550
- }, true],
4561
+ toJsonSchema: () => ({
4562
+ type: "integer",
4563
+ minimum: globalThis.Number.MIN_SAFE_INTEGER,
4564
+ maximum: globalThis.Number.MAX_SAFE_INTEGER
4565
+ }),
4551
4566
  toCode: () => ({
4552
4567
  runtime: "Schema.isInt()"
4553
4568
  }),
@@ -8160,6 +8175,113 @@ export const UnixPathAddressFromString = /*#__PURE__*/String.pipe(decodeTo(UnixP
8160
8175
  export const SocketAddress = /*#__PURE__*/declare(NetAddress_.isSocketAddress, {
8161
8176
  identifier: "SocketAddress"
8162
8177
  });
8178
+ /**
8179
+ * Schema for normalized DNS domain names.
8180
+ *
8181
+ * **Details**
8182
+ *
8183
+ * Only names already in normalized form (lowercase ASCII, with
8184
+ * internationalized labels in `xn--` form) are accepted. Use
8185
+ * {@link DomainNameFromString} to normalize arbitrary input.
8186
+ *
8187
+ * @stability experimental
8188
+ * @category schemas
8189
+ * @since 4.0.0
8190
+ */
8191
+ export const DomainName = /*#__PURE__*/String.check(makeFilter(Host_.isDomainName, {
8192
+ expected: "a normalized domain name"
8193
+ })).pipe(brand("~effect/net/Host/DomainName")).annotate({
8194
+ identifier: "DomainName"
8195
+ });
8196
+ /**
8197
+ * Schema for DNS domain names decoded from strings, normalizing case and
8198
+ * converting internationalized names to their ASCII form.
8199
+ *
8200
+ * @stability experimental
8201
+ * @category schemas
8202
+ * @since 4.0.0
8203
+ */
8204
+ export const DomainNameFromString = /*#__PURE__*/netAddressFromString(DomainName, Host_.domainNameFromString, name => name, "DomainNameFromString");
8205
+ /**
8206
+ * Schema for canonical scoped IPv6 literals such as `fe80::1%eth0`.
8207
+ *
8208
+ * @stability experimental
8209
+ * @category schemas
8210
+ * @since 4.0.0
8211
+ */
8212
+ export const ScopedIpv6Literal = /*#__PURE__*/String.check(makeFilter(NetAddress_.isScopedIpv6Literal, {
8213
+ expected: "a canonical scoped IPv6 literal"
8214
+ })).pipe(brand("~effect/net/NetAddress/ScopedIpv6Literal")).annotate({
8215
+ identifier: "ScopedIpv6Literal"
8216
+ });
8217
+ /**
8218
+ * Schema for scoped IPv6 literals decoded from strings, normalizing the address
8219
+ * and numeric zones.
8220
+ *
8221
+ * @stability experimental
8222
+ * @category schemas
8223
+ * @since 4.0.0
8224
+ */
8225
+ export const ScopedIpv6LiteralFromString = /*#__PURE__*/netAddressFromString(ScopedIpv6Literal, NetAddress_.scopedIpv6LiteralFromString, literal => literal, "ScopedIpv6LiteralFromString");
8226
+ /**
8227
+ * Schema for hosts: numeric IP addresses, scoped IPv6 literals, or domain names.
8228
+ *
8229
+ * @stability experimental
8230
+ * @category schemas
8231
+ * @since 4.0.0
8232
+ */
8233
+ export const Host = /*#__PURE__*/Union([IpAddress, ScopedIpv6Literal, DomainName]).annotate({
8234
+ identifier: "Host"
8235
+ });
8236
+ /**
8237
+ * Schema for hosts decoded from strings. Numeric IP strings decode to IP
8238
+ * addresses; other strings decode to scoped IPv6 literals or domain names.
8239
+ *
8240
+ * @stability experimental
8241
+ * @category schemas
8242
+ * @since 4.0.0
8243
+ */
8244
+ export const HostFromString = /*#__PURE__*/Union([IpAddressFromString, ScopedIpv6LiteralFromString, DomainNameFromString]).annotate({
8245
+ identifier: "HostFromString"
8246
+ });
8247
+ /**
8248
+ * Schema for already-constructed unresolved host and port values.
8249
+ *
8250
+ * @stability experimental
8251
+ * @category schemas
8252
+ * @since 4.0.0
8253
+ */
8254
+ export const HostPort = /*#__PURE__*/declare(Host_.isHostPort, {
8255
+ identifier: "HostPort"
8256
+ });
8257
+ /**
8258
+ * Schema for unresolved endpoints encoded as `host:port` or `[IPv6]:port`
8259
+ * strings.
8260
+ *
8261
+ * @stability experimental
8262
+ * @category schemas
8263
+ * @since 4.0.0
8264
+ */
8265
+ export const HostPortFromString = /*#__PURE__*/netAddressFromString(HostPort, Host_.hostPortFromString, Host_.formatHostPort, "HostPortFromString");
8266
+ /**
8267
+ * Schema for TCP and UDP port numbers from 0 through 65535.
8268
+ *
8269
+ * **Details**
8270
+ *
8271
+ * Port 0 is accepted because it asks the operating system to choose a port
8272
+ * when binding, and it matches the port range of `InetAddress` and `HostPort`.
8273
+ * `Config.Port` accepts only 1 through 65535.
8274
+ *
8275
+ * @stability experimental
8276
+ * @category schemas
8277
+ * @since 4.0.0
8278
+ */
8279
+ export const Port = /*#__PURE__*/Int.check(/*#__PURE__*/isBetween({
8280
+ minimum: 0,
8281
+ maximum: 65535
8282
+ }, {
8283
+ expected: "a port number"
8284
+ }));
8163
8285
  // -----------------------------------------------------------------------------
8164
8286
  // Duration schemas
8165
8287
  // -----------------------------------------------------------------------------
@@ -8324,6 +8446,235 @@ export const DurationFromNanos = /*#__PURE__*/BigInt.pipe(/*#__PURE__*/decodeTo(
8324
8446
  * @since 3.10.0
8325
8447
  */
8326
8448
  export const DurationFromMillis = /*#__PURE__*/Number.pipe(/*#__PURE__*/decodeTo(Duration, durationFromMillis));
8449
+ /**
8450
+ * Schema for supported DNS record types such as `"A"` or `"SRV"`.
8451
+ *
8452
+ * @stability experimental
8453
+ * @category schemas
8454
+ * @since 4.0.0
8455
+ */
8456
+ export const DnsRecordType = /*#__PURE__*/Literals(Dns_.recordTypes);
8457
+ // Addresses in JSON records must already be canonical; normalizing input is
8458
+ // left to the `*FromString` schemas.
8459
+ const dnsCanonicalAddress = (schema, parse) => String.pipe(decodeTo(schema, SchemaTransformation.transformEffect({
8460
+ decode: (input, options) => {
8461
+ const result = parse(input);
8462
+ if (Result_.isFailure(result)) {
8463
+ return Effect.fail(new SchemaIssue.InvalidValue({
8464
+ message: result.failure.message
8465
+ }, input, options));
8466
+ }
8467
+ return NetAddress_.formatIp(result.success) === input ? Effect.succeed(result.success) : Effect.fail(new SchemaIssue.InvalidValue({
8468
+ message: "expected a canonical address"
8469
+ }, input, options));
8470
+ },
8471
+ encode: address => Effect.succeed(NetAddress_.formatIp(address))
8472
+ })));
8473
+ const dnsUint8 = /*#__PURE__*/Int.check(/*#__PURE__*/isBetween({
8474
+ minimum: 0,
8475
+ maximum: 0xff
8476
+ }));
8477
+ const dnsUint16 = /*#__PURE__*/Int.check(/*#__PURE__*/isBetween({
8478
+ minimum: 0,
8479
+ maximum: 0xffff
8480
+ }));
8481
+ const dnsUint32 = /*#__PURE__*/Int.check(/*#__PURE__*/isBetween({
8482
+ minimum: 0,
8483
+ maximum: 0xffffffff
8484
+ }));
8485
+ // SOA timers are written as whole seconds, as in zone files.
8486
+ const dnsSeconds = /*#__PURE__*/dnsUint32.pipe(/*#__PURE__*/decodeTo(Duration, /*#__PURE__*/SchemaTransformation.transform({
8487
+ decode: Duration_.seconds,
8488
+ encode: Duration_.toSeconds
8489
+ })));
8490
+ // Each record type is an opaque value whose JSON form is a plain object tagged
8491
+ // by record type, such as `{ "_tag": "MX", "exchange": "mail.example.com", "priority": 10 }`.
8492
+ const dnsRecordOfType = (type, fields) => declare(u => Dns_.isDnsRecord(u) && u._tag === type, {
8493
+ identifier: `Dns${type.charAt(0)}${type.slice(1).toLowerCase()}Record`,
8494
+ toCodecJson: () => {
8495
+ const json = TaggedStruct(type, fields);
8496
+ return link()(json, SchemaTransformation.transformEffect({
8497
+ decode: (input, options) => {
8498
+ const {
8499
+ _tag,
8500
+ ...rest
8501
+ } = input;
8502
+ const result = Dns_.makeRecord(type, rest);
8503
+ return Result_.isSuccess(result) ? Effect.succeed(result.success) : Effect.fail(new SchemaIssue.InvalidValue({
8504
+ message: result.failure.message
8505
+ }, input, options));
8506
+ },
8507
+ // Records hold only their tag and fields as own properties.
8508
+ encode: record => Effect.succeed({
8509
+ ...record
8510
+ })
8511
+ }));
8512
+ }
8513
+ });
8514
+ /**
8515
+ * Schema for already-constructed IPv4 address (`A`) DNS records.
8516
+ *
8517
+ * @stability experimental
8518
+ * @category schemas
8519
+ * @since 4.0.0
8520
+ */
8521
+ export const DnsARecord = /*#__PURE__*/dnsRecordOfType("A", {
8522
+ address: /*#__PURE__*/dnsCanonicalAddress(Ipv4Address, NetAddress_.ipv4FromString)
8523
+ });
8524
+ /**
8525
+ * Schema for already-constructed IPv6 address (`AAAA`) DNS records.
8526
+ *
8527
+ * @stability experimental
8528
+ * @category schemas
8529
+ * @since 4.0.0
8530
+ */
8531
+ export const DnsAaaaRecord = /*#__PURE__*/dnsRecordOfType("AAAA", {
8532
+ address: /*#__PURE__*/dnsCanonicalAddress(Ipv6Address, NetAddress_.ipv6FromString)
8533
+ });
8534
+ /**
8535
+ * Schema for already-constructed certification authority authorization (`CAA`) DNS records.
8536
+ *
8537
+ * @stability experimental
8538
+ * @category schemas
8539
+ * @since 4.0.0
8540
+ */
8541
+ export const DnsCaaRecord = /*#__PURE__*/dnsRecordOfType("CAA", {
8542
+ critical: Boolean,
8543
+ tag: /*#__PURE__*/String.check(/*#__PURE__*/isPattern(/^[a-z0-9]+$/i)),
8544
+ value: String
8545
+ });
8546
+ /**
8547
+ * Schema for already-constructed canonical name (`CNAME`) DNS records.
8548
+ *
8549
+ * @stability experimental
8550
+ * @category schemas
8551
+ * @since 4.0.0
8552
+ */
8553
+ export const DnsCnameRecord = /*#__PURE__*/dnsRecordOfType("CNAME", {
8554
+ target: DomainName
8555
+ });
8556
+ /**
8557
+ * Schema for already-constructed mail exchange (`MX`) DNS records.
8558
+ *
8559
+ * @stability experimental
8560
+ * @category schemas
8561
+ * @since 4.0.0
8562
+ */
8563
+ export const DnsMxRecord = /*#__PURE__*/dnsRecordOfType("MX", {
8564
+ exchange: DomainName,
8565
+ priority: dnsUint16
8566
+ });
8567
+ /**
8568
+ * Schema for already-constructed naming authority pointer (`NAPTR`) DNS records.
8569
+ *
8570
+ * @stability experimental
8571
+ * @category schemas
8572
+ * @since 4.0.0
8573
+ */
8574
+ export const DnsNaptrRecord = /*#__PURE__*/dnsRecordOfType("NAPTR", {
8575
+ order: dnsUint16,
8576
+ preference: dnsUint16,
8577
+ flags: String,
8578
+ service: String,
8579
+ regexp: String,
8580
+ replacement: DomainName
8581
+ });
8582
+ /**
8583
+ * Schema for already-constructed name server (`NS`) DNS records.
8584
+ *
8585
+ * @stability experimental
8586
+ * @category schemas
8587
+ * @since 4.0.0
8588
+ */
8589
+ export const DnsNsRecord = /*#__PURE__*/dnsRecordOfType("NS", {
8590
+ host: DomainName
8591
+ });
8592
+ /**
8593
+ * Schema for already-constructed pointer (`PTR`) DNS records.
8594
+ *
8595
+ * @stability experimental
8596
+ * @category schemas
8597
+ * @since 4.0.0
8598
+ */
8599
+ export const DnsPtrRecord = /*#__PURE__*/dnsRecordOfType("PTR", {
8600
+ host: NonEmptyString
8601
+ });
8602
+ /**
8603
+ * Schema for already-constructed start of authority (`SOA`) DNS records.
8604
+ *
8605
+ * @stability experimental
8606
+ * @category schemas
8607
+ * @since 4.0.0
8608
+ */
8609
+ export const DnsSoaRecord = /*#__PURE__*/dnsRecordOfType("SOA", {
8610
+ primary: DomainName,
8611
+ admin: NonEmptyString,
8612
+ serial: dnsUint32,
8613
+ refresh: dnsSeconds,
8614
+ retry: dnsSeconds,
8615
+ expire: dnsSeconds,
8616
+ minimum: dnsSeconds
8617
+ });
8618
+ /**
8619
+ * Schema for already-constructed service locator (`SRV`) DNS records.
8620
+ *
8621
+ * @stability experimental
8622
+ * @category schemas
8623
+ * @since 4.0.0
8624
+ */
8625
+ export const DnsSrvRecord = /*#__PURE__*/dnsRecordOfType("SRV", {
8626
+ target: DomainName,
8627
+ port: dnsUint16,
8628
+ priority: dnsUint16,
8629
+ weight: dnsUint16
8630
+ });
8631
+ /**
8632
+ * Schema for already-constructed TLS authentication (`TLSA`) DNS records.
8633
+ *
8634
+ * **Details**
8635
+ *
8636
+ * The default JSON serializer encodes the certificate association `data` as a
8637
+ * hex string.
8638
+ *
8639
+ * @stability experimental
8640
+ * @category schemas
8641
+ * @since 4.0.0
8642
+ */
8643
+ export const DnsTlsaRecord = /*#__PURE__*/dnsRecordOfType("TLSA", {
8644
+ certUsage: dnsUint8,
8645
+ selector: dnsUint8,
8646
+ matchingType: dnsUint8,
8647
+ data: Uint8ArrayFromHex
8648
+ });
8649
+ /**
8650
+ * Schema for already-constructed text (`TXT`) DNS records.
8651
+ *
8652
+ * @stability experimental
8653
+ * @category schemas
8654
+ * @since 4.0.0
8655
+ */
8656
+ export const DnsTxtRecord = /*#__PURE__*/dnsRecordOfType("TXT", {
8657
+ chunks: /*#__PURE__*/NonEmptyArray(String)
8658
+ });
8659
+ /**
8660
+ * Schema for already-constructed DNS records of any supported record type.
8661
+ *
8662
+ * **Details**
8663
+ *
8664
+ * The default JSON serializer encodes records as objects tagged by record type,
8665
+ * with addresses and names as canonical strings, SOA timers as whole seconds,
8666
+ * and TLSA data as hex, such as
8667
+ * `{ "_tag": "SRV", "target": "db.internal", "port": 5432, "priority": 10, "weight": 5 }`.
8668
+ * Decoding accepts only canonical addresses and normalized domain names, and
8669
+ * reports invalid fields with their path.
8670
+ *
8671
+ * @stability experimental
8672
+ * @category schemas
8673
+ * @since 4.0.0
8674
+ */
8675
+ export const DnsRecord = /*#__PURE__*/Union([DnsARecord, DnsAaaaRecord, DnsCaaRecord, DnsCnameRecord, DnsMxRecord, DnsNaptrRecord, DnsNsRecord, DnsPtrRecord, DnsSoaRecord, DnsSrvRecord, DnsTlsaRecord, DnsTxtRecord]).annotate({
8676
+ identifier: "DnsRecord"
8677
+ });
8327
8678
  /**
8328
8679
  * Creates a schema for `Exit` values using schemas for the success value, typed
8329
8680
  * failure, and unexpected defect channels.