effect 4.1.0 → 4.1.2
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/README.md +30 -0
- package/THIRD_PARTY_NOTICES.md +62 -0
- package/ai-docs/package.json +2 -2
- package/dist/BigDecimal.d.ts +139 -7
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +83 -14
- package/dist/BigDecimal.js.map +1 -1
- package/dist/ByteSize.d.ts.map +1 -1
- package/dist/ByteSize.js +27 -14
- package/dist/ByteSize.js.map +1 -1
- package/dist/Equal.d.ts +2 -2
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +3 -3
- package/dist/Equal.js.map +1 -1
- package/dist/Hash.d.ts +3 -2
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +5 -4
- package/dist/Hash.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +38 -32
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +27 -6
- package/dist/JsonSchema.js.map +1 -1
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +0 -7
- package/dist/MutableRef.js.map +1 -1
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +5 -1
- package/dist/Path.js.map +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +2 -1
- package/dist/Pool.js.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +0 -8
- package/dist/Ref.js.map +1 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +8 -3
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +2 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +4 -2
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +4 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +2 -2
- package/dist/SchemaTransformation.js +2 -2
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +6 -5
- package/dist/Stream.js.map +1 -1
- package/dist/ai/McpClient.d.ts +171 -19
- package/dist/ai/McpClient.d.ts.map +1 -1
- package/dist/ai/McpClient.js +277 -66
- package/dist/ai/McpClient.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +108 -0
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpSchema.js +99 -0
- package/dist/ai/McpSchema.js.map +1 -1
- package/dist/ai/McpServer.d.ts +120 -6
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +258 -49
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +20 -11
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +5 -7
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/internal/mcpCore.js +72 -3
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +44 -8
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +12 -0
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +3 -3
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSkills.d.ts +2 -0
- package/dist/ai/internal/mcpSkills.d.ts.map +1 -0
- package/dist/ai/internal/mcpSkills.js +428 -0
- package/dist/ai/internal/mcpSkills.js.map +1 -0
- package/dist/ai/internal/structured-output.js +11 -2
- package/dist/ai/internal/structured-output.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +30 -11
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Entity.d.ts +26 -0
- package/dist/cluster/Entity.d.ts.map +1 -1
- package/dist/cluster/Entity.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +6 -6
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +1 -3
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Reply.d.ts +1 -1
- package/dist/cluster/Reply.d.ts.map +1 -1
- package/dist/cluster/Reply.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +13 -2
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts +13 -0
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +4 -1
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/internal/clusterAbandon.d.ts.map +1 -1
- package/dist/cluster/internal/clusterAbandon.js +6 -4
- package/dist/cluster/internal/clusterAbandon.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +63 -11
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/cluster/internal/transactionNotifications.d.ts +5 -0
- package/dist/cluster/internal/transactionNotifications.d.ts.map +1 -0
- package/dist/cluster/internal/transactionNotifications.js +5 -0
- package/dist/cluster/internal/transactionNotifications.js.map +1 -0
- package/dist/crypto/Aead.d.ts +2 -1
- package/dist/crypto/Aead.d.ts.map +1 -1
- package/dist/crypto/Aead.js +2 -2
- package/dist/crypto/Aead.js.map +1 -1
- package/dist/crypto/Cipher.d.ts +2 -1
- package/dist/crypto/Cipher.d.ts.map +1 -1
- package/dist/crypto/Cipher.js +2 -2
- package/dist/crypto/Cipher.js.map +1 -1
- package/dist/crypto/KeyAgreement.d.ts +3 -2
- package/dist/crypto/KeyAgreement.d.ts.map +1 -1
- package/dist/crypto/KeyAgreement.js +2 -2
- package/dist/crypto/KeyAgreement.js.map +1 -1
- package/dist/crypto/KeyFormat.d.ts +33 -1
- package/dist/crypto/KeyFormat.d.ts.map +1 -1
- package/dist/crypto/KeyFormat.js.map +1 -1
- package/dist/crypto/KeyWrap.d.ts +4 -3
- package/dist/crypto/KeyWrap.d.ts.map +1 -1
- package/dist/crypto/KeyWrap.js +2 -2
- package/dist/crypto/KeyWrap.js.map +1 -1
- package/dist/crypto/Mac.d.ts +2 -1
- package/dist/crypto/Mac.d.ts.map +1 -1
- package/dist/crypto/Mac.js +2 -2
- package/dist/crypto/Mac.js.map +1 -1
- package/dist/crypto/Signature.d.ts +3 -2
- package/dist/crypto/Signature.d.ts.map +1 -1
- package/dist/crypto/Signature.js +2 -2
- package/dist/crypto/Signature.js.map +1 -1
- package/dist/crypto/WebCrypto.d.ts +19 -0
- package/dist/crypto/WebCrypto.d.ts.map +1 -1
- package/dist/crypto/WebCrypto.js.map +1 -1
- package/dist/crypto/internal/asymmetric.js.map +1 -1
- package/dist/crypto/internal/key.js +3 -2
- package/dist/crypto/internal/key.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +26 -3
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Json5.d.ts +44 -0
- package/dist/encoding/Json5.d.ts.map +1 -0
- package/dist/encoding/Json5.js +56 -0
- package/dist/encoding/Json5.js.map +1 -0
- package/dist/encoding/Jsonc.d.ts +47 -0
- package/dist/encoding/Jsonc.d.ts.map +1 -0
- package/dist/encoding/Jsonc.js +120 -0
- package/dist/encoding/Jsonc.js.map +1 -0
- package/dist/encoding/Ndjson.d.ts +5 -4
- package/dist/encoding/Ndjson.d.ts.map +1 -1
- package/dist/encoding/Ndjson.js +6 -5
- package/dist/encoding/Ndjson.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts +94 -0
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +219 -6
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Sse.d.ts +3 -1
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +5 -3
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/encoding/index.d.ts +10 -0
- package/dist/encoding/index.d.ts.map +1 -1
- package/dist/encoding/index.js +10 -0
- package/dist/encoding/index.js.map +1 -1
- package/dist/eventlog/EventLog.d.ts +7 -0
- package/dist/eventlog/EventLog.d.ts.map +1 -1
- package/dist/eventlog/EventLog.js +7 -0
- package/dist/eventlog/EventLog.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts +7 -1
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +55 -24
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.d.ts +10 -0
- package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/EventLogServerUnencrypted.d.ts +17 -0
- package/dist/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerUnencrypted.js +14 -2
- package/dist/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.d.ts +21 -0
- package/dist/eventlog/EventLogSessionAuth.d.ts.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.js +22 -0
- package/dist/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/graphql/GraphQLClient.d.ts +3 -1
- package/dist/graphql/GraphQLClient.d.ts.map +1 -1
- package/dist/graphql/GraphQLClient.js.map +1 -1
- package/dist/graphql/GraphQLClientError.d.ts +14 -9
- package/dist/graphql/GraphQLClientError.d.ts.map +1 -1
- package/dist/graphql/GraphQLClientError.js +14 -21
- package/dist/graphql/GraphQLClientError.js.map +1 -1
- package/dist/graphql/GraphQLProtocol.d.ts +12 -3
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -1
- package/dist/graphql/GraphQLProtocol.js +4 -1
- package/dist/graphql/GraphQLProtocol.js.map +1 -1
- package/dist/http/HttpClient.d.ts +204 -16
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +93 -13
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +38 -22
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/internal/mimeTypes.d.ts +4 -1
- package/dist/http/internal/mimeTypes.d.ts.map +1 -1
- package/dist/http/internal/mimeTypes.js +4 -1
- package/dist/http/internal/mimeTypes.js.map +1 -1
- package/dist/http-api/HttpApiSchema.js +1 -1
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/internal/dateTime.js +66 -27
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +10 -0
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/glob.js +234 -56
- package/dist/internal/glob.js.map +1 -1
- package/dist/internal/graphql.js +21 -7
- package/dist/internal/graphql.js.map +1 -1
- package/dist/internal/graphqlHeaders.d.ts +7 -0
- package/dist/internal/graphqlHeaders.d.ts.map +1 -1
- package/dist/internal/graphqlHeaders.js +11 -0
- package/dist/internal/graphqlHeaders.js.map +1 -1
- package/dist/internal/jsonParser.d.ts +5 -0
- package/dist/internal/jsonParser.d.ts.map +1 -0
- package/dist/internal/jsonParser.js +280 -0
- package/dist/internal/jsonParser.js.map +1 -0
- package/dist/internal/persistence.js +8 -1
- package/dist/internal/persistence.js.map +1 -1
- package/dist/internal/request.js +29 -42
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +7 -8
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/sql.js +16 -0
- package/dist/internal/sql.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/jose/JoseError.d.ts +285 -0
- package/dist/jose/JoseError.d.ts.map +1 -0
- package/dist/jose/JoseError.js +269 -0
- package/dist/jose/JoseError.js.map +1 -0
- package/dist/jose/Jwe.d.ts +128 -0
- package/dist/jose/Jwe.d.ts.map +1 -0
- package/dist/jose/Jwe.js +134 -0
- package/dist/jose/Jwe.js.map +1 -0
- package/dist/jose/Jwk.d.ts +597 -0
- package/dist/jose/Jwk.d.ts.map +1 -0
- package/dist/jose/Jwk.js +503 -0
- package/dist/jose/Jwk.js.map +1 -0
- package/dist/jose/Jwks.d.ts +236 -0
- package/dist/jose/Jwks.d.ts.map +1 -0
- package/dist/jose/Jwks.js +306 -0
- package/dist/jose/Jwks.js.map +1 -0
- package/dist/jose/Jws.d.ts +177 -0
- package/dist/jose/Jws.d.ts.map +1 -0
- package/dist/jose/Jws.js +183 -0
- package/dist/jose/Jws.js.map +1 -0
- package/dist/jose/Jwt.d.ts +270 -0
- package/dist/jose/Jwt.d.ts.map +1 -0
- package/dist/jose/Jwt.js +293 -0
- package/dist/jose/Jwt.js.map +1 -0
- package/dist/jose/index.d.ts +51 -0
- package/dist/jose/index.d.ts.map +1 -0
- package/dist/jose/index.js +52 -0
- package/dist/jose/index.js.map +1 -0
- package/dist/jose/internal/compact.d.ts +2 -0
- package/dist/jose/internal/compact.d.ts.map +1 -0
- package/dist/jose/internal/compact.js +179 -0
- package/dist/jose/internal/compact.js.map +1 -0
- package/dist/net/Host.d.ts.map +1 -1
- package/dist/net/Host.js +5 -10
- package/dist/net/Host.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +4 -0
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +40 -12
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpSerialization.d.ts +1 -1
- package/dist/observability/OtlpSerialization.d.ts.map +1 -1
- package/dist/observability/OtlpSerialization.js +10 -4
- package/dist/observability/OtlpSerialization.js.map +1 -1
- package/dist/observability/internal/otlpProtobuf.js +3 -3
- package/dist/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/observability/internal/protobuf.js +6 -0
- package/dist/observability/internal/protobuf.js.map +1 -1
- package/dist/persistence/CircuitBreaker.d.ts +98 -38
- package/dist/persistence/CircuitBreaker.d.ts.map +1 -1
- package/dist/persistence/CircuitBreaker.js +67 -29
- package/dist/persistence/CircuitBreaker.js.map +1 -1
- package/dist/persistence/RateLimiter.d.ts +15 -0
- package/dist/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/persistence/RateLimiter.js +76 -16
- package/dist/persistence/RateLimiter.js.map +1 -1
- package/dist/persistence/index.d.ts +1 -1
- package/dist/persistence/index.js +1 -1
- package/dist/reactivity/AtomRegistry.js +17 -7
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/rpc/Rpc.d.ts +1 -1
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +14 -2
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +38 -21
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcMessage.d.ts +3 -2
- package/dist/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/rpc/RpcMessage.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +10 -1
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/sql/Migrator.d.ts +9 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +18 -6
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +46 -3
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +40 -15
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +46 -3
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +32 -26
- package/dist/sql/Statement.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +4 -0
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +5 -0
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +7 -3
- package/src/BigDecimal.ts +170 -16
- package/src/ByteSize.ts +29 -14
- package/src/Equal.ts +3 -3
- package/src/Hash.ts +5 -4
- package/src/Iterable.ts +28 -19
- package/src/JsonSchema.ts +45 -7
- package/src/MutableRef.ts +1 -8
- package/src/Path.ts +6 -1
- package/src/Pool.ts +2 -1
- package/src/Ref.ts +0 -8
- package/src/Schedule.ts +8 -6
- package/src/Schema.ts +3 -2
- package/src/SchemaRepresentation.ts +4 -2
- package/src/SchemaTransformation.ts +2 -2
- package/src/Stream.ts +6 -5
- package/src/ai/McpClient.ts +488 -91
- package/src/ai/McpSchema.ts +119 -0
- package/src/ai/McpServer.ts +302 -56
- package/src/ai/Prompt.ts +16 -11
- package/src/ai/Tool.ts +5 -10
- package/src/ai/internal/mcpCore.ts +165 -12
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +42 -9
- package/src/ai/internal/mcpProtocol.ts +15 -0
- package/src/ai/internal/mcpRuntime.ts +6 -3
- package/src/ai/internal/mcpSkills.ts +480 -0
- package/src/ai/internal/structured-output.ts +10 -4
- package/src/cluster/ClusterWorkflowEngine.ts +48 -33
- package/src/cluster/Entity.ts +52 -0
- package/src/cluster/MessageStorage.ts +3 -6
- package/src/cluster/Reply.ts +1 -1
- package/src/cluster/Runners.ts +16 -2
- package/src/cluster/Sharding.ts +17 -1
- package/src/cluster/internal/clusterAbandon.ts +7 -7
- package/src/cluster/internal/entityManager.ts +89 -15
- package/src/cluster/internal/transactionNotifications.ts +7 -0
- package/src/crypto/Aead.ts +3 -3
- package/src/crypto/Cipher.ts +3 -3
- package/src/crypto/KeyAgreement.ts +4 -4
- package/src/crypto/KeyFormat.ts +30 -1
- package/src/crypto/KeyWrap.ts +6 -6
- package/src/crypto/Mac.ts +3 -3
- package/src/crypto/Signature.ts +4 -4
- package/src/crypto/WebCrypto.ts +20 -0
- package/src/crypto/internal/asymmetric.ts +2 -1
- package/src/crypto/internal/key.ts +12 -5
- package/src/encoding/Base64Url.ts +27 -3
- package/src/encoding/Json5.ts +59 -0
- package/src/encoding/Jsonc.ts +126 -0
- package/src/encoding/Ndjson.ts +6 -5
- package/src/encoding/SchemaBinary.ts +228 -7
- package/src/encoding/Sse.ts +5 -3
- package/src/encoding/index.ts +12 -0
- package/src/eventlog/EventLog.ts +7 -0
- package/src/eventlog/EventLogServer.ts +67 -24
- package/src/eventlog/EventLogServerEncrypted.ts +5 -0
- package/src/eventlog/EventLogServerUnencrypted.ts +19 -2
- package/src/eventlog/EventLogSessionAuth.ts +26 -0
- package/src/graphql/GraphQLClient.ts +3 -1
- package/src/graphql/GraphQLClientError.ts +15 -22
- package/src/graphql/GraphQLProtocol.ts +12 -3
- package/src/http/HttpClient.ts +244 -33
- package/src/http/HttpServerRequest.ts +61 -23
- package/src/http/internal/mimeTypes.ts +4 -1
- package/src/http-api/HttpApiSchema.ts +1 -1
- package/src/internal/dateTime.ts +80 -27
- package/src/internal/effect.ts +6 -0
- package/src/internal/glob.ts +279 -63
- package/src/internal/graphql.ts +27 -9
- package/src/internal/graphqlHeaders.ts +13 -0
- package/src/internal/jsonParser.ts +307 -0
- package/src/internal/persistence.ts +9 -1
- package/src/internal/request.ts +51 -58
- package/src/internal/schema/fromJsonSchemaDocument.ts +11 -10
- package/src/internal/sql.ts +25 -0
- package/src/internal/version.ts +1 -1
- package/src/jose/JoseError.ts +329 -0
- package/src/jose/Jwe.ts +196 -0
- package/src/jose/Jwk.ts +777 -0
- package/src/jose/Jwks.ts +418 -0
- package/src/jose/Jws.ts +312 -0
- package/src/jose/Jwt.ts +493 -0
- package/src/jose/index.ts +58 -0
- package/src/jose/internal/compact.ts +195 -0
- package/src/net/Host.ts +5 -10
- package/src/observability/OtlpExporter.ts +42 -18
- package/src/observability/OtlpSerialization.ts +13 -5
- package/src/observability/internal/otlpProtobuf.ts +6 -6
- package/src/observability/internal/protobuf.ts +10 -0
- package/src/persistence/CircuitBreaker.ts +113 -48
- package/src/persistence/RateLimiter.ts +97 -19
- package/src/persistence/index.ts +1 -1
- package/src/reactivity/AtomRegistry.ts +19 -8
- package/src/rpc/Rpc.ts +3 -1
- package/src/rpc/RpcClient.ts +44 -24
- package/src/rpc/RpcMessage.ts +3 -2
- package/src/rpc/RpcServer.ts +12 -1
- package/src/sql/Migrator.ts +35 -18
- package/src/sql/SqlClient.ts +91 -22
- package/src/sql/Statement.ts +60 -35
- package/src/workflow/Workflow.ts +4 -0
- package/src/workflow/WorkflowEngine.ts +5 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
const json5Space = /(?:[\t\n\v\f\r \u00A0\u2028\u2029\uFEFF\p{Zs}]|\/\/[^\n\r\u2028\u2029]*|\/\*[^]*?\*\/)*/uy
|
|
2
|
+
const idStart = /[$_\p{ID_Start}]/u
|
|
3
|
+
const idPart = /[$\u200C\u200D\p{ID_Continue}]/u
|
|
4
|
+
const idName = /[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*/uy
|
|
5
|
+
const hexDigits = /[\da-fA-F]*/y
|
|
6
|
+
const isDigit = (code: number) => code >= 0x30 && code <= 0x39
|
|
7
|
+
const isAsciiIdPart = (code: number) =>
|
|
8
|
+
(code >= 0x61 && code <= 0x7a) || (code >= 0x41 && code <= 0x5a) || isDigit(code) || code === 0x5f || code === 0x24
|
|
9
|
+
|
|
10
|
+
const jsoncSpace = /(?:[ \t\r\n]|\/\/[^\r\n]*|\/\*[^]*?\*\/)*/uy
|
|
11
|
+
const jsonNumber = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/y
|
|
12
|
+
|
|
13
|
+
// The escapes JSON and JSON5 share, indexed by the character after the backslash.
|
|
14
|
+
// A null prototype keeps absent entries from resolving to inherited properties.
|
|
15
|
+
const escapes: Record<number, string | undefined> = Object.create(null)
|
|
16
|
+
for (const [escape, value] of ["\"\"", "\\\\", "//", "b\b", "f\f", "n\n", "r\r", "t\t"]) {
|
|
17
|
+
escapes[escape.charCodeAt(0)] = value
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Runs of string content that need no further inspection.
|
|
21
|
+
const json5Double = /[^"\\\n\r]*/y
|
|
22
|
+
const json5Single = /[^'\\\n\r]*/y
|
|
23
|
+
// JSON forbids unescaped U+0000 through U+001F.
|
|
24
|
+
// oxlint-disable-next-line no-control-regex
|
|
25
|
+
const jsonDouble = /[^"\\\x00-\x1f]*/y
|
|
26
|
+
|
|
27
|
+
type Format = "JSON5" | "JSONC"
|
|
28
|
+
|
|
29
|
+
export const syntaxError = (text: string, at: number, format: Format): SyntaxError => {
|
|
30
|
+
const json5 = format === "JSON5"
|
|
31
|
+
const lines = text.slice(0, at).split(json5 ? /\r\n|[\n\r\u2028\u2029]/ : /\r\n|[\n\r]/)
|
|
32
|
+
return new SyntaxError(
|
|
33
|
+
`Invalid ${json5 ? "JSON5" : "JSONC"} at line ${lines.length}, column ${lines[lines.length - 1].length + 1}`
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type Frame =
|
|
38
|
+
| { readonly object: true; readonly value: Record<string, unknown>; key: string; first: boolean }
|
|
39
|
+
| { readonly object: false; readonly value: Array<unknown>; first: boolean }
|
|
40
|
+
|
|
41
|
+
const set = (object: Record<string, unknown>, key: string, value: unknown): void => {
|
|
42
|
+
// Members are own data properties, as with JSON.parse. Assignment creates one unless
|
|
43
|
+
// the key is inherited (`__proto__`, `constructor`, added accessors, ...), where it
|
|
44
|
+
// could run a setter or throw, so inherited keys are defined directly.
|
|
45
|
+
if (key in Object.prototype) {
|
|
46
|
+
Object.defineProperty(object, key, { value, writable: true, enumerable: true, configurable: true })
|
|
47
|
+
} else object[key] = value
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// JSONC only uses the strict mode to locate errors after JSON.parse fails.
|
|
51
|
+
export const parse = (text: string, format: Format): unknown => {
|
|
52
|
+
const json5 = format === "JSON5"
|
|
53
|
+
const space = json5 ? json5Space : jsoncSpace
|
|
54
|
+
// JSON strings forbid raw characters below U+0020; JSON5 strings only forbid line breaks.
|
|
55
|
+
const plainFloor = json5 ? 0 : 0x20
|
|
56
|
+
let i = 0
|
|
57
|
+
|
|
58
|
+
const fail = (at: number): never => {
|
|
59
|
+
throw syntaxError(text, at, format)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Skips whitespace and comments, rejecting a `/` that starts neither. */
|
|
63
|
+
const skip = () => {
|
|
64
|
+
// ASCII whitespace dominates formatted documents; the pattern handles the rest.
|
|
65
|
+
let code = text.charCodeAt(i)
|
|
66
|
+
while (code === 0x20 || code === 0x0a || code === 0x0d || code === 0x09) code = text.charCodeAt(++i)
|
|
67
|
+
if (code > 0x20 && code !== 0x2f && code < 0xa0) return
|
|
68
|
+
space.lastIndex = i
|
|
69
|
+
space.test(text)
|
|
70
|
+
i = space.lastIndex
|
|
71
|
+
if (text.charCodeAt(i) === 0x2f) {
|
|
72
|
+
fail(text.charAt(i + 1) === "*" ? text.length : i + 1)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Advances past a sticky pattern at `i`, returning the matched length. */
|
|
77
|
+
const run = (pattern: RegExp) => {
|
|
78
|
+
pattern.lastIndex = i
|
|
79
|
+
const length = pattern.test(text) ? pattern.lastIndex - i : 0
|
|
80
|
+
i += length
|
|
81
|
+
return length
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const word = <A>(literal: string, result: A): A => {
|
|
85
|
+
if (!text.startsWith(literal, i)) {
|
|
86
|
+
let at = i
|
|
87
|
+
while (text.charAt(at) === literal[at - i]) at++
|
|
88
|
+
fail(at)
|
|
89
|
+
}
|
|
90
|
+
i += literal.length
|
|
91
|
+
return result
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const hex = (count: number) => {
|
|
95
|
+
let value = 0
|
|
96
|
+
for (const end = i + count; i < end; i++) {
|
|
97
|
+
const code = text.charCodeAt(i)
|
|
98
|
+
const lower = code | 0x20
|
|
99
|
+
if (isDigit(code)) value = value * 16 + code - 0x30
|
|
100
|
+
else if (lower >= 0x61 && lower <= 0x66) value = value * 16 + lower - 0x57
|
|
101
|
+
else fail(i)
|
|
102
|
+
}
|
|
103
|
+
return String.fromCharCode(value)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const number = () => {
|
|
107
|
+
if (!json5) {
|
|
108
|
+
const start = i
|
|
109
|
+
if (run(jsonNumber) === 0) fail(i)
|
|
110
|
+
return Number(text.slice(start, i))
|
|
111
|
+
}
|
|
112
|
+
let code = text.charCodeAt(i)
|
|
113
|
+
let sign = 1
|
|
114
|
+
if (code === 0x2b || code === 0x2d) {
|
|
115
|
+
if (code === 0x2d) sign = -1
|
|
116
|
+
code = text.charCodeAt(++i)
|
|
117
|
+
}
|
|
118
|
+
const start = i
|
|
119
|
+
if (code === 0x49) return word("Infinity", sign * Infinity)
|
|
120
|
+
if (code === 0x4e) return word("NaN", NaN)
|
|
121
|
+
if (code === 0x30 && (text.charCodeAt(i + 1) | 0x20) === 0x78) {
|
|
122
|
+
i += 2
|
|
123
|
+
if (run(hexDigits) === 0) fail(i)
|
|
124
|
+
return sign * Number(text.slice(start, i))
|
|
125
|
+
}
|
|
126
|
+
// Integers below 2^53 are accumulated directly; anything else goes through Number.
|
|
127
|
+
let integer = 0
|
|
128
|
+
if (code === 0x30) code = text.charCodeAt(++i)
|
|
129
|
+
else if (isDigit(code)) {
|
|
130
|
+
do {
|
|
131
|
+
integer = integer * 10 + code - 0x30
|
|
132
|
+
code = text.charCodeAt(++i)
|
|
133
|
+
} while (isDigit(code))
|
|
134
|
+
} else if (code !== 0x2e) fail(i)
|
|
135
|
+
if (code !== 0x2e && code !== 0x65 && code !== 0x45 && i - start < 16) return sign * integer
|
|
136
|
+
if (code === 0x2e) {
|
|
137
|
+
const fraction = ++i
|
|
138
|
+
while (isDigit(text.charCodeAt(i))) i++
|
|
139
|
+
// A leading decimal point needs digits after it; a trailing one does not.
|
|
140
|
+
if (i === fraction && fraction === start + 1) fail(i)
|
|
141
|
+
code = text.charCodeAt(i)
|
|
142
|
+
}
|
|
143
|
+
if (code === 0x65 || code === 0x45) {
|
|
144
|
+
code = text.charCodeAt(++i)
|
|
145
|
+
if (code === 0x2b || code === 0x2d) i++
|
|
146
|
+
const exponent = i
|
|
147
|
+
while (isDigit(text.charCodeAt(i))) i++
|
|
148
|
+
if (i === exponent) fail(i)
|
|
149
|
+
}
|
|
150
|
+
return sign * Number(text.slice(start, i))
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const string = (quote: number) => {
|
|
154
|
+
const plain = quote === 0x27 ? json5Single : json5 ? json5Double : jsonDouble
|
|
155
|
+
let result = ""
|
|
156
|
+
for (i++;;) {
|
|
157
|
+
// Plain content runs until the quote, an escape, a line break, a control character
|
|
158
|
+
// JSON forbids, or the end of input, where `code` is NaN and fails the last test.
|
|
159
|
+
const start = i
|
|
160
|
+
let code = text.charCodeAt(i)
|
|
161
|
+
// Short runs are cheaper to scan by hand; long runs are handed to the pattern.
|
|
162
|
+
const handoff = i + 24
|
|
163
|
+
while (code !== quote && code !== 0x5c && code !== 0x0a && code !== 0x0d && code >= plainFloor) {
|
|
164
|
+
if (++i === handoff) {
|
|
165
|
+
run(plain)
|
|
166
|
+
code = text.charCodeAt(i)
|
|
167
|
+
break
|
|
168
|
+
}
|
|
169
|
+
code = text.charCodeAt(i)
|
|
170
|
+
}
|
|
171
|
+
result += text.slice(start, i)
|
|
172
|
+
i++
|
|
173
|
+
if (code === quote) return result
|
|
174
|
+
// Anything else that stops a plain run is an escape or a forbidden character.
|
|
175
|
+
if (code !== 0x5c) fail(i - 1)
|
|
176
|
+
const escape = text.charCodeAt(i++)
|
|
177
|
+
const simple = escapes[escape]
|
|
178
|
+
if (simple !== undefined) result += simple
|
|
179
|
+
else if (escape === 0x75) result += hex(4)
|
|
180
|
+
else if (!json5 || i > text.length || (escape >= 0x31 && escape <= 0x39)) fail(i - 1)
|
|
181
|
+
else if (escape === 0x76) result += "\v"
|
|
182
|
+
else if (escape === 0x78) result += hex(2)
|
|
183
|
+
else if (escape === 0x30) {
|
|
184
|
+
if (isDigit(text.charCodeAt(i))) fail(i)
|
|
185
|
+
result += "\0"
|
|
186
|
+
} else if (escape === 0x0d) {
|
|
187
|
+
// A CR LF line continuation contributes nothing, like a single line terminator.
|
|
188
|
+
if (text.charCodeAt(i) === 0x0a) i++
|
|
189
|
+
} else if (escape !== 0x0a && escape !== 0x2028 && escape !== 0x2029) result += text[i - 1]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const identifier = () => {
|
|
194
|
+
const start = i
|
|
195
|
+
let code = text.charCodeAt(i)
|
|
196
|
+
if (isAsciiIdPart(code) && !isDigit(code)) {
|
|
197
|
+
do code = text.charCodeAt(++i)
|
|
198
|
+
while (isAsciiIdPart(code))
|
|
199
|
+
// Past an ASCII name, only an escape or a non-ASCII character can continue it.
|
|
200
|
+
if (code !== 0x5c && !(code >= 0x80)) return text.slice(start, i)
|
|
201
|
+
i = start
|
|
202
|
+
}
|
|
203
|
+
run(idName)
|
|
204
|
+
let name = text.slice(start, i)
|
|
205
|
+
if (name !== "" && text.charAt(i) !== "\\") return name
|
|
206
|
+
// Escapes are validated one code point at a time.
|
|
207
|
+
for (;;) {
|
|
208
|
+
const at = i
|
|
209
|
+
const valid = name === "" ? idStart : idPart
|
|
210
|
+
let c = String.fromCodePoint(text.codePointAt(i) ?? 0)
|
|
211
|
+
if (c === "\\") {
|
|
212
|
+
if (text.charAt(i + 1) !== "u") fail(i + 1)
|
|
213
|
+
i += 2
|
|
214
|
+
c = hex(4)
|
|
215
|
+
if (!valid.test(c)) fail(at)
|
|
216
|
+
} else if (i < text.length && valid.test(c)) i += c.length
|
|
217
|
+
else if (name === "") fail(i)
|
|
218
|
+
else return name
|
|
219
|
+
name += c
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const stack: Array<Frame> = []
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Reads a value at `i`, which must already be past any whitespace. Opening a
|
|
227
|
+
* collection returns `undefined`; the collection is completed later.
|
|
228
|
+
*/
|
|
229
|
+
const value = (): unknown => {
|
|
230
|
+
const code = text.charCodeAt(i)
|
|
231
|
+
switch (code) {
|
|
232
|
+
case 0x7b:
|
|
233
|
+
stack.push({ object: true, value: {}, key: "", first: true })
|
|
234
|
+
i++
|
|
235
|
+
return undefined
|
|
236
|
+
case 0x5b:
|
|
237
|
+
stack.push({ object: false, value: [], first: true })
|
|
238
|
+
i++
|
|
239
|
+
return undefined
|
|
240
|
+
case 0x22:
|
|
241
|
+
return string(0x22)
|
|
242
|
+
case 0x27:
|
|
243
|
+
return json5 ? string(0x27) : fail(i)
|
|
244
|
+
case 0x6e:
|
|
245
|
+
return word("null", null)
|
|
246
|
+
case 0x74:
|
|
247
|
+
return word("true", true)
|
|
248
|
+
case 0x66:
|
|
249
|
+
return word("false", false)
|
|
250
|
+
case 0x2b:
|
|
251
|
+
case 0x2d:
|
|
252
|
+
case 0x2e:
|
|
253
|
+
case 0x49:
|
|
254
|
+
case 0x4e:
|
|
255
|
+
return number()
|
|
256
|
+
}
|
|
257
|
+
return isDigit(code) ? number() : fail(i)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** After a member: consumes a comma unless the collection ends. */
|
|
261
|
+
const separated = (close: number) => {
|
|
262
|
+
skip()
|
|
263
|
+
const code = text.charCodeAt(i)
|
|
264
|
+
if (code === close) return
|
|
265
|
+
if (code !== 0x2c) fail(i)
|
|
266
|
+
i++
|
|
267
|
+
skip()
|
|
268
|
+
if (!json5 && text.charCodeAt(i) === close) fail(i)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
skip()
|
|
272
|
+
let result = value()
|
|
273
|
+
// An explicit stack keeps deep nesting off the call stack.
|
|
274
|
+
while (stack.length > 0) {
|
|
275
|
+
const frame = stack[stack.length - 1]
|
|
276
|
+
const close = frame.object ? 0x7d : 0x5d
|
|
277
|
+
if (frame.first) skip()
|
|
278
|
+
else separated(close)
|
|
279
|
+
if (text.charCodeAt(i) === close) {
|
|
280
|
+
stack.pop()
|
|
281
|
+
i++
|
|
282
|
+
const parent = stack[stack.length - 1]
|
|
283
|
+
if (parent === undefined) result = frame.value
|
|
284
|
+
else if (parent.object) set(parent.value, parent.key, frame.value)
|
|
285
|
+
else parent.value.push(frame.value)
|
|
286
|
+
continue
|
|
287
|
+
}
|
|
288
|
+
frame.first = false
|
|
289
|
+
if (!frame.object) {
|
|
290
|
+
const item = value()
|
|
291
|
+
if (item !== undefined) frame.value.push(item)
|
|
292
|
+
} else {
|
|
293
|
+
const quote = text.charCodeAt(i)
|
|
294
|
+
if (!json5 && quote !== 0x22) fail(i)
|
|
295
|
+
const key = quote === 0x22 || quote === 0x27 ? string(quote) : identifier()
|
|
296
|
+
skip()
|
|
297
|
+
if (text.charCodeAt(i++) !== 0x3a) fail(i - 1)
|
|
298
|
+
skip()
|
|
299
|
+
const item = value()
|
|
300
|
+
if (item === undefined) frame.key = key
|
|
301
|
+
else set(frame.value, key, item)
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
skip()
|
|
305
|
+
if (i < text.length) fail(i)
|
|
306
|
+
return result
|
|
307
|
+
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
/** @internal */
|
|
2
2
|
export const sqlCleanupBatchSize = 1000
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Percent-encodes `%` and `:` so the result contains no `:` and distinct inputs
|
|
6
|
+
* stay distinct.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const escapeKeySegment = (segment: string): string => segment.replace(/%/g, "%25").replace(/:/g, "%3A")
|
|
11
|
+
|
|
4
12
|
/**
|
|
5
13
|
* Key prefix for a persistence store. The store id is escaped so the namespace
|
|
6
14
|
* always ends at its first `:`, and distinct store / key pairs never collide.
|
|
7
15
|
*
|
|
8
16
|
* @internal
|
|
9
17
|
*/
|
|
10
|
-
export const storeNamespace = (storeId: string): string => `${storeId
|
|
18
|
+
export const storeNamespace = (storeId: string): string => `${escapeKeySegment(storeId)}:`
|
|
11
19
|
|
|
12
20
|
/** @internal */
|
|
13
21
|
export const escapeRedisGlob = (pattern: string): string => pattern.replace(/[\\*?[\]]/g, "\\$&")
|
package/src/internal/request.ts
CHANGED
|
@@ -96,10 +96,10 @@ const makeBatchMap = (resolver: RequestResolver<any>): BatchMap => {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
interface Batch {
|
|
99
|
-
key: unknown
|
|
100
|
-
context: Context.Context<never>
|
|
101
|
-
resolver: RequestResolver<any>
|
|
102
|
-
map: BatchMap
|
|
99
|
+
readonly key: unknown
|
|
100
|
+
readonly context: Context.Context<never>
|
|
101
|
+
readonly resolver: RequestResolver<any>
|
|
102
|
+
readonly map: BatchMap
|
|
103
103
|
readonly entrySet: Set<Request.Entry<any>>
|
|
104
104
|
readonly entries: Set<Request.Entry<any>>
|
|
105
105
|
readonly delayEffect: Effect<void>
|
|
@@ -107,9 +107,53 @@ interface Batch {
|
|
|
107
107
|
fiber?: Fiber<unknown, unknown> | undefined
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
const batchPool: Array<Batch> = []
|
|
111
110
|
const pendingBatches = new WeakMap<RequestResolver<any>, BatchMap>()
|
|
112
111
|
|
|
112
|
+
// Batches are built outside `addEntry` so their callbacks do not share a closure
|
|
113
|
+
// context with per-request entries, which would keep completed requests alive.
|
|
114
|
+
const makeBatch = (
|
|
115
|
+
key: unknown,
|
|
116
|
+
context: Context.Context<never>,
|
|
117
|
+
resolver: RequestResolver<any>,
|
|
118
|
+
map: BatchMap
|
|
119
|
+
): Batch => {
|
|
120
|
+
const batch: Batch = {
|
|
121
|
+
key,
|
|
122
|
+
context,
|
|
123
|
+
resolver,
|
|
124
|
+
map,
|
|
125
|
+
entrySet: new Set(),
|
|
126
|
+
entries: new Set(),
|
|
127
|
+
delayEffect: effect.flatMap(
|
|
128
|
+
withFiber((delayFiber) => {
|
|
129
|
+
// Reentrant delay callbacks may fill the batch and interrupt this fiber.
|
|
130
|
+
batch.fiber = delayFiber
|
|
131
|
+
return batch.resolver.delay
|
|
132
|
+
}),
|
|
133
|
+
(_) => runBatch(batch)
|
|
134
|
+
) as Effect<void>,
|
|
135
|
+
run: effect.onExit(
|
|
136
|
+
effect.suspend(() =>
|
|
137
|
+
batch.resolver.runAll(Array.from(batch.entries) as NonEmptyArray<Request.Entry<any>>, batch.key)
|
|
138
|
+
),
|
|
139
|
+
(exit) => {
|
|
140
|
+
for (const entry of batch.entrySet) {
|
|
141
|
+
entry.completeUnsafe(
|
|
142
|
+
exit._tag === "Success"
|
|
143
|
+
? exitDie(
|
|
144
|
+
new Error("Effect.request: RequestResolver did not complete request", { cause: entry.request })
|
|
145
|
+
)
|
|
146
|
+
: exit
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
batch.entries.clear()
|
|
150
|
+
return effect.void
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
return batch
|
|
155
|
+
}
|
|
156
|
+
|
|
113
157
|
const addEntry = <A extends Request.Any>(
|
|
114
158
|
resolver: RequestResolver<A>,
|
|
115
159
|
request: A,
|
|
@@ -146,58 +190,7 @@ const addEntry = <A extends Request.Any>(
|
|
|
146
190
|
batch = batchMap.get(key)
|
|
147
191
|
const isNewBatch = batch === undefined
|
|
148
192
|
if (!batch) {
|
|
149
|
-
|
|
150
|
-
batch = batchPool.pop()!
|
|
151
|
-
batch.key = key
|
|
152
|
-
batch.context = fiber.context
|
|
153
|
-
batch.resolver = resolver
|
|
154
|
-
batch.map = batchMap
|
|
155
|
-
} else {
|
|
156
|
-
const newBatch: Batch = {
|
|
157
|
-
key,
|
|
158
|
-
context: fiber.context,
|
|
159
|
-
resolver,
|
|
160
|
-
map: batchMap,
|
|
161
|
-
entrySet: new Set(),
|
|
162
|
-
entries: new Set(),
|
|
163
|
-
delayEffect: effect.flatMap(
|
|
164
|
-
withFiber((delayFiber) => {
|
|
165
|
-
// Reentrant delay callbacks may fill the batch and interrupt this fiber.
|
|
166
|
-
newBatch.fiber = delayFiber
|
|
167
|
-
return newBatch.resolver.delay
|
|
168
|
-
}),
|
|
169
|
-
(_) => runBatch(newBatch)
|
|
170
|
-
) as Effect<void>,
|
|
171
|
-
run: effect.onExit(
|
|
172
|
-
effect.suspend(() =>
|
|
173
|
-
newBatch.resolver.runAll(Array.from(newBatch.entries) as NonEmptyArray<Request.Entry<any>>, newBatch.key)
|
|
174
|
-
),
|
|
175
|
-
(exit) => {
|
|
176
|
-
for (const entry of newBatch.entrySet) {
|
|
177
|
-
entry.completeUnsafe(
|
|
178
|
-
exit._tag === "Success"
|
|
179
|
-
? exitDie(
|
|
180
|
-
new Error("Effect.request: RequestResolver did not complete request", { cause: entry.request })
|
|
181
|
-
)
|
|
182
|
-
: exit
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
newBatch.entries.clear()
|
|
186
|
-
if (batchPool.length < 128) {
|
|
187
|
-
newBatch.entrySet.clear()
|
|
188
|
-
newBatch.key = undefined
|
|
189
|
-
newBatch.context = undefined as any
|
|
190
|
-
newBatch.fiber = undefined
|
|
191
|
-
newBatch.resolver = undefined as any
|
|
192
|
-
newBatch.map = undefined as any
|
|
193
|
-
batchPool.push(newBatch)
|
|
194
|
-
}
|
|
195
|
-
return effect.void
|
|
196
|
-
}
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
batch = newBatch
|
|
200
|
-
}
|
|
193
|
+
batch = makeBatch(key, fiber.context, resolver, batchMap)
|
|
201
194
|
batchMap.set(key, batch)
|
|
202
195
|
}
|
|
203
196
|
|
|
@@ -205,7 +198,7 @@ const addEntry = <A extends Request.Any>(
|
|
|
205
198
|
batch.entries.add(entry)
|
|
206
199
|
if (isNewBatch) {
|
|
207
200
|
const delayFiber = effect.runForkWith(fiber.context)(batch.delayEffect, { scheduler: fiber.cache.scheduler })
|
|
208
|
-
// A synchronous delay may have already run
|
|
201
|
+
// A synchronous delay may have already run this batch.
|
|
209
202
|
if (completed || batchMap.get(key) !== batch) return entry
|
|
210
203
|
batch.fiber = delayFiber
|
|
211
204
|
}
|
|
@@ -755,8 +755,9 @@ export function fromJsonSchemaMultiDocument(
|
|
|
755
755
|
return out
|
|
756
756
|
}
|
|
757
757
|
case "Union":
|
|
758
|
-
|
|
759
|
-
|
|
758
|
+
// Finite primitive literal sets intersect without expansion, so they can be duplicated across branches.
|
|
759
|
+
return !isLiteralSet(representation) &&
|
|
760
|
+
(representation.types.length > 1 || representation.types.some(hasChoices))
|
|
760
761
|
case "Arrays":
|
|
761
762
|
return representation.elements.some((element) => hasChoices(element.type)) ||
|
|
762
763
|
representation.rest.some(hasChoices)
|
|
@@ -796,18 +797,20 @@ export function fromJsonSchemaMultiDocument(
|
|
|
796
797
|
return representation.literal
|
|
797
798
|
}
|
|
798
799
|
|
|
800
|
+
function isLiteralSet(union: ImportedUnion): boolean {
|
|
801
|
+
return (union.options?.mode ?? "anyOf") === "anyOf" &&
|
|
802
|
+
union.types.every((type) => literalValue(type) !== undefined)
|
|
803
|
+
}
|
|
804
|
+
|
|
799
805
|
function intersectLiteralUnions(
|
|
800
806
|
left: ImportedUnion,
|
|
801
807
|
right: ImportedUnion,
|
|
802
808
|
path: Path
|
|
803
809
|
): ImportedJsonSchemaRepresentation | undefined {
|
|
804
|
-
if ((left
|
|
805
|
-
|
|
806
|
-
}
|
|
807
|
-
const rightByValue = new Map<string | number | boolean | null, ImportedJsonSchemaRepresentation>()
|
|
810
|
+
if (!isLiteralSet(left) || !isLiteralSet(right)) return undefined
|
|
811
|
+
const rightByValue = new Map<ReturnType<typeof literalValue>, ImportedJsonSchemaRepresentation>()
|
|
808
812
|
for (const representation of right.types) {
|
|
809
813
|
const value = literalValue(representation)
|
|
810
|
-
if (value === undefined) return undefined
|
|
811
814
|
const previous = rightByValue.get(value)
|
|
812
815
|
rightByValue.set(value, {
|
|
813
816
|
...representation,
|
|
@@ -816,9 +819,7 @@ export function fromJsonSchemaMultiDocument(
|
|
|
816
819
|
}
|
|
817
820
|
const types: Array<ImportedJsonSchemaRepresentation> = []
|
|
818
821
|
for (const representation of left.types) {
|
|
819
|
-
const
|
|
820
|
-
if (value === undefined) return undefined
|
|
821
|
-
const match = rightByValue.get(value)
|
|
822
|
+
const match = rightByValue.get(literalValue(representation))
|
|
822
823
|
if (match !== undefined) types.push(intersect(representation, annotate(match, right), path))
|
|
823
824
|
}
|
|
824
825
|
return makeUnion(left, types)
|
package/src/internal/sql.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { Clock } from "../Clock.ts"
|
|
1
2
|
import * as Context from "../Context.ts"
|
|
3
|
+
import type * as Fiber from "../Fiber.ts"
|
|
4
|
+
import type * as Tracer from "../Tracer.ts"
|
|
5
|
+
import { TracerTimingEnabled } from "./references.ts"
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* The transaction service of the innermost transaction started with
|
|
@@ -12,3 +16,24 @@ export const CurrentTransactionService = Context.Reference<Context.Key<any, obje
|
|
|
12
16
|
"effect/sql/CurrentTransactionService",
|
|
13
17
|
{ defaultValue: () => undefined }
|
|
14
18
|
)
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The clock to measure connection wait time with, or `undefined` without span
|
|
22
|
+
* timing, when the span has no start time to measure from.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export const waitClock = (fiber: Fiber.Fiber<unknown, unknown>): Clock | undefined =>
|
|
27
|
+
fiber.getRef(TracerTimingEnabled) ? fiber.getRef(Clock) : undefined
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Records the time from the span's start to the connection hand-off as
|
|
31
|
+
* `db.client.connection.wait_time_ms`.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export const recordConnectionWait = (span: Tracer.Span, clock: Clock): void =>
|
|
36
|
+
span.attribute(
|
|
37
|
+
"db.client.connection.wait_time_ms",
|
|
38
|
+
Number(clock.currentTimeNanosUnsafe() - span.status.startTime) / 1e6
|
|
39
|
+
)
|
package/src/internal/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = "4.1.
|
|
2
|
+
export const version = "4.1.2"
|