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.
- package/dist/Context.js +3 -3
- package/dist/Context.js.map +1 -1
- package/dist/Crypto.d.ts +33 -5
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +8 -2
- package/dist/Crypto.js.map +1 -1
- package/dist/DateTime.d.ts +9 -6
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +9 -6
- package/dist/DateTime.js.map +1 -1
- package/dist/Duration.d.ts +6 -6
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +27 -8
- package/dist/Duration.js.map +1 -1
- package/dist/FileSystem.d.ts +44 -2
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js.map +1 -1
- package/dist/Schema.d.ts +473 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +355 -4
- package/dist/Schema.js.map +1 -1
- package/dist/Stdio.d.ts +7 -1
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +1 -0
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +11 -11
- package/dist/Stream.js +5 -5
- package/dist/ai/McpServer.d.ts +6 -0
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +65 -23
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +5 -0
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +1 -0
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/cli/CliOutput.d.ts +27 -0
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +33 -10
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +6 -3
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Completions.d.ts +3 -3
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js +8 -5
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/GlobalFlag.d.ts +5 -4
- package/dist/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/cli/GlobalFlag.js +3 -3
- package/dist/cli/GlobalFlag.js.map +1 -1
- package/dist/cli/Prompt.d.ts +17 -1
- package/dist/cli/Prompt.d.ts.map +1 -1
- package/dist/cli/Prompt.js +119 -114
- package/dist/cli/Prompt.js.map +1 -1
- package/dist/cli/internal/ansi.d.ts +0 -1
- package/dist/cli/internal/ansi.d.ts.map +1 -1
- package/dist/cli/internal/ansi.js +20 -3
- package/dist/cli/internal/ansi.js.map +1 -1
- package/dist/cli/internal/completions/powershell.d.ts +2 -0
- package/dist/cli/internal/completions/powershell.d.ts.map +1 -0
- package/dist/cli/internal/completions/powershell.js +273 -0
- package/dist/cli/internal/completions/powershell.js.map +1 -0
- package/dist/cli/internal/completions/zsh.js +3 -2
- package/dist/cli/internal/completions/zsh.js.map +1 -1
- package/dist/cli/internal/wizard.d.ts +3 -3
- package/dist/cli/internal/wizard.d.ts.map +1 -1
- package/dist/cli/internal/wizard.js +21 -18
- package/dist/cli/internal/wizard.js.map +1 -1
- package/dist/cluster/ClusterSchema.d.ts +28 -0
- package/dist/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/cluster/ClusterSchema.js +30 -0
- package/dist/cluster/ClusterSchema.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +10 -18
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +18 -3
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +31 -11
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +8 -2
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +181 -62
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts +59 -19
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +84 -55
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts +68 -19
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +191 -113
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +104 -37
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +3 -6
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/HttpClient.d.ts +6 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +39 -2
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/http/HttpTraceContext.js +4 -2
- package/dist/http/HttpTraceContext.js.map +1 -1
- package/dist/internal/effect.js +12 -7
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/net/AddressResolver.d.ts +145 -0
- package/dist/net/AddressResolver.d.ts.map +1 -0
- package/dist/net/AddressResolver.js +114 -0
- package/dist/net/AddressResolver.js.map +1 -0
- package/dist/net/Dns.d.ts +596 -0
- package/dist/net/Dns.d.ts.map +1 -0
- package/dist/net/Dns.js +549 -0
- package/dist/net/Dns.js.map +1 -0
- package/dist/net/Host.d.ts +320 -0
- package/dist/net/Host.d.ts.map +1 -0
- package/dist/net/Host.js +342 -0
- package/dist/net/Host.js.map +1 -0
- package/dist/net/IpInterface.d.ts +76 -3
- package/dist/net/IpInterface.d.ts.map +1 -1
- package/dist/net/IpInterface.js +53 -4
- package/dist/net/IpInterface.js.map +1 -1
- package/dist/net/IpNetwork.d.ts +82 -8
- package/dist/net/IpNetwork.d.ts.map +1 -1
- package/dist/net/IpNetwork.js +60 -4
- package/dist/net/IpNetwork.js.map +1 -1
- package/dist/net/NetAddress.d.ts +388 -35
- package/dist/net/NetAddress.d.ts.map +1 -1
- package/dist/net/NetAddress.js +350 -34
- package/dist/net/NetAddress.js.map +1 -1
- package/dist/net/index.d.ts +15 -0
- package/dist/net/index.d.ts.map +1 -1
- package/dist/net/index.js +15 -0
- package/dist/net/index.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +15 -21
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/PrometheusMetrics.js +1 -0
- package/dist/observability/PrometheusMetrics.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts +32 -3
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +75 -16
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +22 -6
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +12 -5
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts +6 -0
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +42 -20
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/socket/DatagramSocket.d.ts +456 -0
- package/dist/socket/DatagramSocket.d.ts.map +1 -0
- package/dist/socket/DatagramSocket.js +535 -0
- package/dist/socket/DatagramSocket.js.map +1 -0
- package/dist/socket/Socket.d.ts +14 -1
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js +9 -1
- package/dist/socket/Socket.js.map +1 -1
- package/dist/socket/index.d.ts +5 -0
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js +5 -0
- package/dist/socket/index.js.map +1 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +7 -2
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +7 -1
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +31 -6
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/testing/TestCrypto.d.ts +73 -0
- package/dist/testing/TestCrypto.d.ts.map +1 -0
- package/dist/testing/TestCrypto.js +87 -0
- package/dist/testing/TestCrypto.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +5 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/workflow/DurableDeferred.d.ts +54 -0
- package/dist/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/workflow/DurableDeferred.js +78 -49
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +2 -1
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Context.ts +3 -3
- package/src/Crypto.ts +43 -9
- package/src/DateTime.ts +9 -6
- package/src/Duration.ts +36 -16
- package/src/FileSystem.ts +48 -2
- package/src/Schema.ts +669 -5
- package/src/Stdio.ts +9 -2
- package/src/Stream.ts +11 -11
- package/src/ai/McpServer.ts +63 -23
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +5 -0
- package/src/ai/internal/mcpProtocol.ts +3 -0
- package/src/ai/internal/mcpRuntime.ts +2 -0
- package/src/cli/CliOutput.ts +33 -16
- package/src/cli/Command.ts +4 -3
- package/src/cli/Completions.ts +9 -6
- package/src/cli/GlobalFlag.ts +19 -11
- package/src/cli/Prompt.ts +159 -149
- package/src/cli/internal/ansi.ts +26 -3
- package/src/cli/internal/completions/powershell.ts +322 -0
- package/src/cli/internal/completions/zsh.ts +4 -2
- package/src/cli/internal/wizard.ts +34 -26
- package/src/cluster/ClusterSchema.ts +32 -0
- package/src/cluster/ClusterWorkflowEngine.ts +13 -24
- package/src/cluster/MessageStorage.ts +45 -14
- package/src/cluster/Runners.ts +8 -2
- package/src/cluster/Sharding.ts +207 -49
- package/src/cluster/SqlMessageStorage.ts +118 -84
- package/src/cluster/SqlRunnerStorage.ts +224 -128
- package/src/cluster/internal/entityManager.ts +151 -55
- package/src/http/FindMyWay/internal/router.ts +4 -7
- package/src/http/HttpClient.ts +56 -2
- package/src/http/HttpTraceContext.ts +8 -2
- package/src/internal/effect.ts +15 -13
- package/src/internal/version.ts +1 -1
- package/src/net/AddressResolver.ts +222 -0
- package/src/net/Dns.ts +1035 -0
- package/src/net/Host.ts +472 -0
- package/src/net/IpInterface.ts +117 -7
- package/src/net/IpNetwork.ts +116 -17
- package/src/net/NetAddress.ts +611 -76
- package/src/net/index.ts +18 -0
- package/src/observability/OtlpMetrics.ts +12 -23
- package/src/observability/PrometheusMetrics.ts +1 -0
- package/src/persistence/PersistedQueue.ts +146 -53
- package/src/rpc/RpcClient.ts +41 -19
- package/src/rpc/RpcServer.ts +60 -25
- package/src/socket/DatagramSocket.ts +919 -0
- package/src/socket/Socket.ts +22 -2
- package/src/socket/index.ts +6 -0
- package/src/sql/Migrator.ts +21 -5
- package/src/sql/SqlClient.ts +39 -15
- package/src/testing/TestCrypto.ts +94 -0
- package/src/testing/index.ts +6 -0
- package/src/workflow/DurableDeferred.ts +123 -48
- 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
|
|
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
|
-
|
|
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.
|