@zio.dev/zio-blocks 0.0.51 → 0.0.55

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 (164) hide show
  1. package/adr/2026-07-18-data-migration.md +123 -0
  2. package/guides/async-getting-started.md +687 -0
  3. package/guides/compile-time-resource-safety-with-scope.md +6 -0
  4. package/guides/getting-started-with-mux.md +0 -112
  5. package/guides/query-dsl-extending.md +1 -1
  6. package/guides/query-dsl-fluent-builder.md +1 -1
  7. package/guides/query-dsl-reified-optics.md +1 -1
  8. package/guides/query-dsl-sql.md +395 -1
  9. package/guides/sql-checked-interpolation.md +173 -0
  10. package/guides/sql-transactions.md +286 -0
  11. package/guides/telemetry-guide.md +131 -70
  12. package/guides/zio-schema-migration.md +6 -6
  13. package/index.md +200 -583
  14. package/package.json +1 -1
  15. package/reference/async.md +1379 -531
  16. package/reference/chunk.md +3 -3
  17. package/reference/codegen/index.md +1 -1
  18. package/reference/combinators.md +4 -4
  19. package/reference/config/config-decoder.md +460 -0
  20. package/reference/config/config-source.md +489 -0
  21. package/reference/config/errors.md +278 -0
  22. package/reference/config/flags.md +369 -0
  23. package/reference/config/formats.md +314 -0
  24. package/reference/config/index.md +304 -0
  25. package/reference/config/rollout.md +336 -0
  26. package/reference/context.md +6 -49
  27. package/reference/data-migration.md +269 -0
  28. package/reference/datastar/attributes.md +302 -0
  29. package/reference/datastar/events.md +234 -0
  30. package/reference/datastar/index.md +256 -0
  31. package/reference/datastar/signals.md +230 -0
  32. package/reference/datastar/sse.md +295 -0
  33. package/reference/datastar.md +2 -2
  34. package/reference/docs.md +2 -2
  35. package/reference/endpoint/bulk-creation.md +96 -0
  36. package/reference/endpoint/index.md +9 -89
  37. package/reference/endpoint/path-codec.md +12 -24
  38. package/reference/endpoint/route-pattern.md +4 -6
  39. package/reference/endpoint/segment-codec.md +19 -32
  40. package/reference/html.md +313 -9
  41. package/reference/htmx/index.md +4 -52
  42. package/reference/htmx/response-headers.md +240 -0
  43. package/reference/http-model/headers.md +735 -0
  44. package/reference/http-model/index.md +3 -1
  45. package/reference/http-model/model.md +107 -71
  46. package/reference/http-model/schema-codecs.md +522 -0
  47. package/reference/http-model/schema.md +6 -3
  48. package/reference/http-model/server-sent-event.md +341 -0
  49. package/reference/jwt.md +195 -0
  50. package/reference/maybe.md +128 -11
  51. package/reference/media-type.md +2 -2
  52. package/reference/mux.md +254 -0
  53. package/reference/mux.mdx +7 -2
  54. package/reference/openapi.md +3 -3
  55. package/reference/projection.md +654 -0
  56. package/reference/resource-management/resource.md +2 -98
  57. package/reference/resource-management/scope.md +1 -209
  58. package/reference/resource-management/wire.md +4 -50
  59. package/reference/ringbuffer/advanced.mdx +1 -1
  60. package/reference/ringbuffer/index.mdx +3 -3
  61. package/reference/ringbuffer/mpmc.mdx +38 -4
  62. package/reference/ringbuffer/mpsc.mdx +36 -4
  63. package/reference/ringbuffer/spmc.mdx +1 -1
  64. package/reference/ringbuffer/spsc.mdx +87 -15
  65. package/reference/schema/allows.md +0 -96
  66. package/reference/schema/binding.md +2 -2
  67. package/reference/schema/built-in-codecs/avro.md +2 -2
  68. package/reference/schema/built-in-codecs/bson.md +50 -20
  69. package/reference/schema/built-in-codecs/csv.md +2 -2
  70. package/reference/schema/built-in-codecs/index.md +3 -3
  71. package/reference/schema/built-in-codecs/json/index.md +2 -2
  72. package/reference/schema/built-in-codecs/messagepack.md +3 -3
  73. package/reference/schema/built-in-codecs/thrift.md +2 -2
  74. package/reference/schema/built-in-codecs/toon.md +3 -3
  75. package/reference/schema/built-in-codecs/yaml.md +2 -2
  76. package/reference/schema/codec.md +11 -11
  77. package/reference/schema/dynamic-optic.md +48 -3
  78. package/reference/schema/dynamic-schema.md +3 -3
  79. package/reference/schema/index.md +2 -0
  80. package/reference/schema/path-interpolator.md +2 -0
  81. package/reference/schema/reflect-transformer.md +140 -0
  82. package/reference/schema/schema-evolution/as.md +4 -4
  83. package/reference/schema/schema-evolution/into.md +2 -2
  84. package/reference/schema/schema-expr.md +2 -2
  85. package/reference/schema/schema-search.md +263 -0
  86. package/reference/schema/schema.md +10 -2
  87. package/reference/schema/type-class-derivation.md +1 -1
  88. package/reference/smithy.md +502 -3
  89. package/reference/sql/db-codec-deriver.md +3 -3
  90. package/reference/sql/db-codec.md +22 -22
  91. package/reference/sql/db-con.md +4 -4
  92. package/reference/sql/db-connection.md +1 -1
  93. package/reference/sql/db-param.md +1 -1
  94. package/reference/sql/db-result-reader.md +4 -2
  95. package/reference/sql/db-tx.md +46 -14
  96. package/reference/sql/ddl.md +1 -1
  97. package/reference/sql/frag.md +44 -10
  98. package/reference/sql/index.md +7 -7
  99. package/reference/sql/repo.md +15 -15
  100. package/reference/sql/sql-dialect.md +1 -1
  101. package/reference/sql/sql-logger.md +1 -1
  102. package/reference/sql/sql-name-mapper.md +3 -3
  103. package/reference/sql/table-metadata.md +3 -3
  104. package/reference/sql/table.md +10 -10
  105. package/reference/sql/transactor-zio.md +1 -1
  106. package/reference/sql/transactor.md +21 -11
  107. package/reference/sql-zio.md +1 -1
  108. package/reference/streams/core/index.md +32 -0
  109. package/reference/streams/{pipeline.md → core/pipeline.md} +210 -74
  110. package/reference/streams/{sink.md → core/sink.md} +331 -353
  111. package/reference/streams/{stream.md → core/stream.md} +919 -209
  112. package/reference/streams/execution-and-compatibility/async-execution.md +822 -0
  113. package/reference/streams/execution-and-compatibility/index.md +35 -0
  114. package/reference/streams/execution-and-compatibility/platform-differences.md +297 -0
  115. package/reference/streams/execution-and-compatibility/scala-2-compatibility.md +88 -0
  116. package/reference/streams/execution-and-compatibility/zero-boxing.md +393 -0
  117. package/reference/streams/index.md +140 -67
  118. package/reference/streams/primitives/index.md +30 -0
  119. package/reference/streams/primitives/reader.md +1992 -0
  120. package/reference/streams/{writer.md → primitives/writer.md} +254 -98
  121. package/reference/telemetry/common/any-value.md +90 -0
  122. package/reference/telemetry/common/attribute-key.md +87 -0
  123. package/reference/telemetry/common/attributes.md +118 -0
  124. package/reference/telemetry/common/index.md +39 -0
  125. package/reference/telemetry/common/instrumentation-scope.md +24 -0
  126. package/reference/telemetry/common/resource.md +34 -0
  127. package/reference/telemetry/index.md +311 -0
  128. package/reference/telemetry/logging/index.md +197 -0
  129. package/reference/telemetry/logging/log-enrichment.md +72 -0
  130. package/reference/telemetry/logging/log-formatter.md +100 -0
  131. package/reference/telemetry/logging/log-record-processor.md +56 -0
  132. package/reference/telemetry/logging/log-record.md +44 -0
  133. package/reference/telemetry/logging/log-writer.md +64 -0
  134. package/reference/telemetry/logging/logger-provider.md +142 -0
  135. package/reference/telemetry/logging/logger.md +83 -0
  136. package/reference/telemetry/logging/severity.md +62 -0
  137. package/reference/telemetry/metrics/index.md +150 -0
  138. package/reference/telemetry/metrics/instruments.md +183 -0
  139. package/reference/telemetry/metrics/labeled-instruments.md +74 -0
  140. package/reference/telemetry/metrics/meter-provider.md +76 -0
  141. package/reference/telemetry/metrics/meter.md +98 -0
  142. package/reference/telemetry/metrics/metric-data.md +57 -0
  143. package/reference/telemetry/otel/custom-exporter.md +216 -0
  144. package/reference/telemetry/otel/index.md +212 -0
  145. package/reference/telemetry/tracing/index.md +155 -0
  146. package/reference/telemetry/tracing/sampler.md +89 -0
  147. package/reference/telemetry/tracing/span-builder.md +57 -0
  148. package/reference/telemetry/tracing/span-context.md +39 -0
  149. package/reference/telemetry/tracing/span-data.md +32 -0
  150. package/reference/telemetry/tracing/span-kind.md +55 -0
  151. package/reference/telemetry/tracing/span-processor.md +53 -0
  152. package/reference/telemetry/tracing/span-status.md +47 -0
  153. package/reference/telemetry/tracing/span.md +117 -0
  154. package/reference/telemetry/tracing/tracer-provider.md +91 -0
  155. package/reference/telemetry/tracing/tracer.md +52 -0
  156. package/reference/typeid.md +0 -64
  157. package/sidebars.js +150 -12
  158. package/undocumented-report.md +528 -270
  159. package/reference/config.md +0 -158
  160. package/reference/streams/concurrent-operators.md +0 -106
  161. package/reference/streams/reader.md +0 -1284
  162. package/reference/streams/scala-2-compatibility.md +0 -55
  163. package/reference/streams/zero-boxing.md +0 -275
  164. package/reference/telemetry.md +0 -693
package/index.md CHANGED
@@ -3,144 +3,141 @@ id: index
3
3
  title: "ZIO Blocks"
4
4
  ---
5
5
 
6
- **Modular, zero-dependency building blocks for modern Scala applications.**
6
+ **Modular building blocks for modern Scala applications—no effect system required.**
7
7
 
8
- [![Development](https://img.shields.io/badge/Project%20Stage-Development-green.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-blocks/workflows/CI/badge.svg) [![ZIO Blocks](https://img.shields.io/github/stars/zio/zio-blocks?style=social)](https://github.com/zio/zio-blocks)
8
+ [![Development](https://img.shields.io/badge/Project%20Stage-Development-green.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-blocks/workflows/CI/badge.svg) [![Maven Central](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Fdev%2Fzio%2Fzio-blocks-config_3%2Fmaven-metadata.xml&label=Maven%20Central)](https://central.sonatype.com/artifact/dev.zio/zio-blocks-config_3) [![Sonatype Snapshot](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven-snapshots%2Fdev%2Fzio%2Fzio-blocks-config_3%2Fmaven-metadata.xml&label=Sonatype%20Snapshot)](https://central.sonatype.com/repository/maven-snapshots/dev/zio/zio-blocks-config_3/) [![ZIO Blocks](https://img.shields.io/github/stars/zio/zio-blocks?style=social)](https://github.com/zio/zio-blocks)
9
9
 
10
10
  ## What Is ZIO Blocks?
11
11
 
12
12
  ZIO Blocks is a **family of type-safe, modular building blocks** for Scala applications. Each block is a standalone library with zero or minimal dependencies, designed to work with *any* Scala stack—ZIO, Cats Effect, Kyo, Ox, Akka, or plain Scala.
13
13
 
14
- The philosophy is simple: **use what you need, nothing more**. Each block is independently useful, cross-platform (JVM, JS), and designed to compose with other blocks or your existing code.
14
+ The philosophy is simple: **use what you need, nothing more**. Each block is independently useful and designed to compose with other blocks or your existing code.
15
15
 
16
- ## The Blocks
17
-
18
- | Block | Description | Status |
19
- |-------|-------------|--------|
20
- | **Schema** | Type-safe schemas with automatic codec derivation | ✅ Available |
21
- | **Chunk** | High-performance immutable indexed sequences | ✅ Available |
22
- | **Scope** | Compile-time safe resource management and DI | ✅ Available |
23
- | **Docs** | GitHub Flavored Markdown parsing and rendering | ✅ Available |
24
- | **Codegen** | Generic Scala code generation IR and emitter | ✅ Available |
25
- | **TypeId** | Compile-time type identity with rich metadata | ✅ Available |
26
- | **Context** | Type-indexed heterogeneous collections | ✅ Available |
27
- | **MediaType** | Type-safe IANA media types with 2,600+ predefined types | ✅ Available |
28
- | **OpenAPI** | Type-safe OpenAPI 3.1 specification generation | ✅ Available |
29
- | **Ring Buffer** | High-performance bounded ring buffers (SPSC, MPSC, SPMC, MPMC) | ✅ Available |
30
- | **Streams** | Pull-based streaming primitives | ✅ Available |
31
- | **SQL** | Type-safe JDBC wrapper with schema-derived codecs and CRUD repository | ✅ Available |
32
- | **Async** | Zero-allocation asynchronous effect type with direct-style `await` | ✅ Available |
33
-
34
- ## Config
35
-
36
- Type-safe configuration loading, feature flags, rollout logic, and source adapters for YAML, JSON, and HOCON.
37
-
38
- See the [Config reference](reference/config.md) for the full API surface, supported rollout syntax, and format-adapter entry points.
39
-
40
- ### Key Features
41
-
42
- - **Static flags**: Resolve once at class load with `StaticFlag[A]`
43
- - **Typed config loading**: Decode case classes with `Config.load[A]`
44
- - **Flag sources**: Register custom flag sources in `FlagSource.Registry`
45
- - **Source composition**: Combine sources with `orElse` and keep provenance
46
- - **Rollout DSL**: Select values with path and percentage rules
47
- - **File adapters**: Parse YAML, JSON, and HOCON into `ConfigSource`
48
-
49
- ### Installation
50
-
51
- ```scala
52
- libraryDependencies += "dev.zio" %% "zio-blocks-config" % "0.0.51"
53
- libraryDependencies += "dev.zio" %% "zio-blocks-config-yaml" % "0.0.51"
54
- libraryDependencies += "dev.zio" %% "zio-blocks-config-json" % "0.0.51"
55
- libraryDependencies += "dev.zio" %% "zio-blocks-config-hocon" % "0.0.51"
56
- ```
57
-
58
- ### Quick Start: StaticFlag
59
-
60
- ```scala
61
- import zio.blocks.config._
62
-
63
- object poolSize extends StaticFlag[Int](10)
64
-
65
- val size: Int = poolSize()
66
- ```
67
-
68
- ### Quick Start: Config.load[A]
69
-
70
- The snippet below uses Scala 3 syntax.
71
-
72
- ```scala
73
- import zio.blocks.config._
74
- import zio.blocks.scope.Unscoped
75
-
76
- final case class AppConfig(host: String, port: Int) derives Schema, Unscoped
77
-
78
- val cfg = Config.load[AppConfig](ConfigSource.fromMap(Map("host" -> "localhost", "port" -> "8080")))
79
- ```
80
-
81
- ### Example: FlagSource Plugin
82
-
83
- ```scala
84
- package myapp
85
-
86
- import zio.blocks.config._
87
-
88
- object poolSize extends StaticFlag[Int](10)
89
-
90
- FlagSource.Registry.register(
91
- FlagSource.fromMap(Map("myapp.poolSize" -> "20"), "demo")
92
- )
93
-
94
- val size = poolSize()
95
- ```
16
+ ## Core Principles
96
17
 
97
- :::note
98
- Register a `FlagSource` before the first reference to a `StaticFlag` object. `StaticFlag` resolves during object initialization, so a source registered later will not change a flag that has already been loaded. The lookup key is the flag object's fully qualified name (`myapp.poolSize` in this example).
99
- :::
18
+ - **Zero Lock-In**: No dependency on ZIO, Cats Effect, or any other effect system. Use a block with whatever stack you already have.
19
+ - **Modular**: Each block is a separate artifact. Depend on exactly what you need.
20
+ - **Cross-Platform**: Most blocks cross-build for JVM and Scala.js, and for Scala 2.13 and 3.x with source compatibility—adopt Scala 3 on your timeline, not ours. The catalog below records the exceptions per block.
21
+ - **High Performance**: Implementations that avoid boxing, minimize allocations, and use platform-specific features where they pay off.
22
+ - **Type Safety**: Scala's type system carries the correctness guarantees, without runtime overhead.
100
23
 
101
- ### Example: ConfigSource Composition with Provenance
24
+ ## Getting Started
102
25
 
103
- The snippet below uses Scala 3 syntax.
26
+ Add a block and use it. Nothing else to wire up—no runtime to install, no effect
27
+ type to adopt:
104
28
 
105
29
  ```scala
106
- import zio.blocks.config._
107
- import zio.blocks.scope.Unscoped
108
-
109
- val defaults = ConfigSource.fromMap(Map("app.host" -> "localhost"), "defaults")
110
- val env = ConfigSource.fromMap(Map("app.port" -> "8080"), "env")
111
- val source = env.orElse(defaults).prefix("app")
112
-
113
- final case class AppConfig(host: String, port: Int) derives Schema, Unscoped
114
-
115
- val loaded = Config.loadWithProvenance[AppConfig](source)
116
- val hostProv = loaded.map(_.provenanceOf("host"))
30
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.55"
117
31
  ```
118
32
 
119
- ### Example: Rollout DSL
120
-
121
33
  ```scala
122
- import zio.blocks.config._
123
-
124
- val bucket = Rollout.bucketFor("user-123")
125
- val choice = Rollout.select("true@prod/50%;false", "prod", bucket)
126
- ```
127
-
128
- `prod/50%` applies the choice to the `prod` path and enables it for roughly half of the `prod` buckets. The trailing `false` entry is the catch-all fallback for every non-matching case.
129
-
130
- ### File Format Adapters
34
+ import zio.blocks.schema._
131
35
 
132
- - **YAML**: `ConfigSource.fromYaml(...)` (requires `config-yaml` dependency and `import zio.blocks.config.yaml._`)
133
- - **JSON**: `ConfigSource.fromJson(...)` (requires `config-json` dependency and `import zio.blocks.config.json._`)
134
- - **HOCON**: `ConfigSource.fromHocon(...)` (requires `config-hocon` dependency and `import zio.blocks.config.hocon._`)
36
+ case class Person(name: String, age: Int)
135
37
 
136
- ## Core Principles
38
+ object Person {
39
+ implicit val schema: Schema[Person] = Schema.derived
40
+ }
137
41
 
138
- - **Zero Lock-In**: No dependencies on ZIO, Cats Effect, or any effect system. Use with whatever stack you prefer.
139
- - **Modular**: Each block is a separate artifact. Import only what you need.
140
- - **Cross-Platform**: Full support for JVM and Scala.js.
141
- - **Cross-Version**: Full support for Scala 2.13 and Scala 3.x with source compatibility—adopt Scala 3 on your timeline, not ours.
142
- - **High Performance**: Optimized implementations that avoid boxing, minimize allocations, and leverage platform-specific features.
143
- - **Type Safety**: Leverage Scala's type system for correctness without runtime overhead.
42
+ val alice = Person("Alice", 30)
43
+
44
+ // One schema, every format
45
+ val jsonStr = alice.toJsonString // {"name":"Alice","age":30}
46
+ val parsed = """{"name":"Bob","age":25}""".fromJson[Person]
47
+ ```
48
+
49
+ The four blocks below get a full walkthrough because they have no close
50
+ equivalent elsewhere in Scala. Every other block is one row away in the catalog,
51
+ and each row links to its own reference page.
52
+
53
+ ## All Blocks
54
+
55
+ Every block is published under the `dev.zio` organization. Most cross-build for
56
+ **Scala 2.13 and 3.x** on both **JVM and Scala.js** with full source compatibility —
57
+ adopt Scala 3 on your timeline, not ours. The handful of modules that are narrower
58
+ say so in their own row.
59
+
60
+ ### Schema & Serialization
61
+
62
+ JSON support is built into `zio-blocks-schema`; the modules below add further formats.
63
+
64
+ | Block | Artifact | Platform | Scala | Description |
65
+ |-------|----------|----------|-------|-------------|
66
+ | [Schema](./reference/schema/index.md) | `zio-blocks-schema` | JVM · JS | 2.13 · 3.x | Type-safe schemas with automatic codec, optic, and validator derivation |
67
+ | [Avro Codec](./reference/schema/built-in-codecs/avro.md) | `zio-blocks-schema-avro` | JVM | 2.13 · 3.x | Apache Avro binary serialization with automatic schema generation |
68
+ | [BSON Codec](./reference/schema/built-in-codecs/bson.md) | `zio-blocks-schema-bson` | JVM | 2.13 · 3.x | MongoDB-compatible BSON serialization with native type support |
69
+ | [CSV Codec](./reference/schema/built-in-codecs/csv.md) | `zio-blocks-schema-csv` | JVM · JS | 2.13 · 3.x | RFC 4180-compliant CSV serialization |
70
+ | [MessagePack Codec](./reference/schema/built-in-codecs/messagepack.md) | `zio-blocks-schema-messagepack` | JVM · JS | 2.13 · 3.x | Compact binary serialization with optimized streaming |
71
+ | [Thrift Codec](./reference/schema/built-in-codecs/thrift.md) | `zio-blocks-schema-thrift` | JVM | 2.13 · 3.x | Apache Thrift binary serialization with TBinaryProtocol |
72
+ | [TOON Codec](./reference/schema/built-in-codecs/toon.md) | `zio-blocks-schema-toon` | JVM · JS | 2.13 · 3.x | Token-oriented notation 30–60% smaller than JSON, tuned for LLM prompts |
73
+ | [XML Codec](./reference/schema/built-in-codecs/xml.md) | `zio-blocks-schema-xml` | JVM · JS | 2.13 · 3.x | Zero-dependency XML serialization with fluent navigation and patching |
74
+ | [YAML Codec](./reference/schema/built-in-codecs/yaml.md) | `zio-blocks-schema-yaml` | JVM · JS | 2.13 · 3.x | Human-readable YAML serialization with JSON interop |
75
+
76
+ ### Core Data Types
77
+
78
+ | Block | Artifact | Platform | Scala | Description |
79
+ |-------|----------|----------|-------|-------------|
80
+ | [Chunk](./reference/chunk.md) | `zio-blocks-chunk` | JVM · JS | 2.13 · 3.x | High-performance immutable indexed sequences with zero-boxing builders |
81
+ | [Maybe](./reference/maybe.md) | `zio-blocks-maybe` | JVM · JS | 2.13 · 3.x | Low-allocation optional values backed by `null` |
82
+ | [Combinators](./reference/combinators.md) | `zio-blocks-combinators` | JVM · JS | 2.13 · 3.x | Compile-time composition and decomposition of tuples, eithers, and unions |
83
+ | [TypeId](./reference/typeid.md) | `zio-blocks-typeid` | JVM · JS | 2.13 · 3.x | Compile-time type identity with rich metadata |
84
+ | [Context](./reference/context.md) | `zio-blocks-context` | JVM · JS | 2.13 · 3.x | Type-indexed heterogeneous collections |
85
+ | [MediaType](./reference/media-type.md) | `zio-blocks-mediatype` | JVM · JS | 2.13 · 3.x | Type-safe IANA media types with 2,600+ predefined types |
86
+
87
+ ### Concurrency & Streaming
88
+
89
+ | Block | Artifact | Platform | Scala | Description |
90
+ |-------|----------|----------|-------|-------------|
91
+ | [Async](./reference/async.md) | `zio-blocks-async` | JVM · JS | 2.13 · 3.x | Zero-allocation asynchronous effect type with direct-style `await` |
92
+ | [Streams](./reference/streams/index.md) | `zio-blocks-streams` | JVM · JS | 2.13 · 3.x | Pull-based streaming with typed errors, zero boxing, and synchronous or asynchronous execution |
93
+ | [Ring Buffer](./reference/ringbuffer/index.mdx) | `zio-blocks-ringbuffer` | JVM · JS | 2.13 · 3.x | Lock-free bounded ring buffers (SPSC, SPMC, MPSC, MPMC) |
94
+ | [Mux](./reference/mux.mdx) | `zio-blocks-mux` | JVM · JS | 2.13 · 3.x | Thread-safe multiplexer for HTTP/2, QUIC, and WebSocket-style protocols |
95
+
96
+ ### Resources & Configuration
97
+
98
+ | Block | Artifact | Platform | Scala | Description |
99
+ |-------|----------|----------|-------|-------------|
100
+ | [Scope](./reference/resource-management/index.md) | `zio-blocks-scope` | JVM · JS | 2.13 · 3.x | Compile-time safe resource management and dependency injection |
101
+ | [Config](./reference/config/index.md) | `zio-blocks-config` | JVM · JS | 2.13 · 3.x | Typed configuration loading, feature flags, and rollout rules |
102
+ | [Config YAML](./reference/config/formats.md) | `zio-blocks-config-yaml` | JVM · JS | 2.13 · 3.x | YAML source adapter for `ConfigSource` |
103
+ | [Config JSON](./reference/config/formats.md) | `zio-blocks-config-json` | JVM · JS | 2.13 · 3.x | JSON source adapter for `ConfigSource` |
104
+ | [Config HOCON](./reference/config/formats.md) | `zio-blocks-config-hocon` | JVM · JS | 2.13 · 3.x | HOCON source adapter for `ConfigSource` |
105
+
106
+ ### Web & HTTP
107
+
108
+ | Block | Artifact | Platform | Scala | Description |
109
+ |-------|----------|----------|-------|-------------|
110
+ | [HTTP Model](./reference/http-model/index.md) | `zio-blocks-http-model` | JVM · JS | 2.13 · 3.x | Pure HTTP data model with URL parsing, headers, cookies, and forms |
111
+ | [HTTP Model Schema](./reference/http-model/schema.md) | `zio-blocks-http-model-schema` | JVM · JS | 2.13 · 3.x | Schema-based typed access to the HTTP model |
112
+ | [Endpoint](./reference/endpoint/index.md) | `zio-blocks-endpoint` | JVM · JS | 2.13 · 3.x | Type-safe HTTP endpoint descriptors with composable codecs and typed auth |
113
+ | [HTML](./reference/html.md) | `zio-blocks-html` | JVM · JS | 2.13 · 3.x | Type-safe HTML templating with XSS protection |
114
+ | [HTMX](./reference/htmx/index.md) | `zio-blocks-http-htmx` | JVM · JS | 3.x | Typed HTMX DSL for compile-time-checked HTMX attributes |
115
+ | [Datastar](./reference/datastar/index.md) | `zio-blocks-datastar` | JVM · JS | 3.x | Typed Datastar attribute and signal DSL, plus the SSE events that patch a live page |
116
+ | [OpenAPI](./reference/openapi.md) | `zio-blocks-openapi` | JVM · JS | 2.13 · 3.x | Type-safe OpenAPI 3.1 specification generation and rendering |
117
+ | [JWT](./reference/jwt.md) | `zio-blocks-jwt` | JVM · JS | 2.13 · 3.x | Zero-dependency JWT signing and verification with HMAC, RSA, ECDSA and EdDSA support |
118
+
119
+ ### Persistence
120
+
121
+ | Block | Artifact | Platform | Scala | Description |
122
+ |-------|----------|----------|-------|-------------|
123
+ | [SQL](./reference/sql/index.md) | `zio-blocks-sql` | JVM · JS | 3.x | Type-safe JDBC wrapper with schema-derived codecs and a CRUD repository |
124
+ | [SQL — ZIO](./reference/sql-zio.md) | `zio-blocks-sql-zio` | JVM | 3.x | ZIO integration with `ZIO.attemptBlocking` and `ZLayer` |
125
+ | [Projection](./reference/projection.md) | `zio-blocks-projection` | JVM | 3.x | Event-sourced projections with per-entity SQLite storage |
126
+
127
+ ### Observability
128
+
129
+ | Block | Artifact | Platform | Scala | Description |
130
+ |-------|----------|----------|-------|-------------|
131
+ | [Telemetry](./reference/telemetry/index.md) | `zio-blocks-telemetry` | JVM · JS | 2.13 · 3.x | Zero-dependency OpenTelemetry-aligned tracing, logging, and metrics |
132
+ | [OTLP Export](./reference/telemetry/otel/index.md) | `zio-blocks-telemetry-otel` | JVM | 2.13 · 3.x | OTLP exporters bridging telemetry signals to an OpenTelemetry collector |
133
+
134
+ ### Tooling & Codegen
135
+
136
+ | Block | Artifact | Platform | Scala | Description |
137
+ |-------|----------|----------|-------|-------------|
138
+ | [Codegen](./reference/codegen/index.md) | `zio-blocks-codegen` | JVM | 2.13 · 3.x | Generic Scala code generation IR and emitter |
139
+ | [Docs](./reference/docs.md) | `zio-blocks-markdown` | JVM · JS | 2.13 · 3.x | GitHub Flavored Markdown parsing, rendering, and programmatic construction |
140
+ | [Smithy](./reference/smithy.md) | `zio-blocks-smithy` | JVM | 2.13 · 3.x | Smithy IDL parser and AST library for API modeling |
144
141
 
145
142
  ---
146
143
 
@@ -180,7 +177,7 @@ val thriftCodec = Schema[Person].derive(ThriftFormat) // Thrift
180
177
 
181
178
  ### Key Features
182
179
 
183
- - **Universal Data Formats**: JSON, Avro, TOON (compact LLM-optimized format), MessagePack, Thrift, and BSON, with Protobuf planned.
180
+ - **Universal Data Formats**: JSON built in, plus Avro, BSON, CSV, MessagePack, Thrift, TOON, XML, and YAML as separate modules, with Protobuf planned.
184
181
  - **High Performance**: Register-based design stores primitives directly in byte arrays, enabling zero-allocation serialization.
185
182
  - **Reflective Optics**: Type-safe lenses, prisms, and traversals with embedded structural metadata.
186
183
  - **Automatic Derivation**: Derive type class instances for any type with a schema.
@@ -188,17 +185,12 @@ val thriftCodec = Schema[Person].derive(ThriftFormat) // Thrift
188
185
  ### Installation
189
186
 
190
187
  ```scala
191
- libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.51"
192
-
193
- // Optional format modules:
194
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.51"
195
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.51"
196
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.51"
197
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.51"
198
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.51"
188
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.55"
199
189
  ```
200
190
 
201
- ### Example: Optics
191
+ See the [Schema & Serialization](#schema--serialization) rows above for the optional format modules.
192
+
193
+ ### Example
202
194
 
203
195
  ```scala
204
196
  import zio.blocks.schema._
@@ -218,64 +210,10 @@ val person = Person("Alice", 30, Address("123 Main St", "Springfield"))
218
210
  val updated = Person.age.replace(person, 31)
219
211
  ```
220
212
 
221
- ---
222
-
223
- ## Chunk
224
-
225
- A high-performance, immutable indexed sequence optimized for the patterns common in streaming, parsing, and data processing. Think of it as `Vector` but faster for the operations that matter most.
226
-
227
- ### Why Chunk?
228
-
229
- Standard library collections make trade-offs that aren't ideal for streaming and binary data processing:
230
-
231
- - `Vector` is general-purpose but not optimized for concatenation patterns
232
- - `Array` is mutable and boxes primitives when used generically
233
- - `List` has O(n) random access
213
+ ### Learn More
234
214
 
235
- Chunk is designed for:
236
-
237
- - **Fast concatenation** via balanced trees (Conc-Trees)
238
- - **Zero-boxing** for primitive types with specialized builders
239
- - **Efficient slicing** without copying
240
- - **Seamless interop** with `ByteBuffer`, `Array`, and standard collections
241
-
242
- ### Key Features
243
-
244
- - **Specialized Builders**: Dedicated builders for `Byte`, `Int`, `Long`, `Double`, etc. avoid boxing overhead.
245
- - **Balanced Concatenation**: Based on Conc-Trees for O(log n) concatenation while maintaining O(1) indexed access.
246
- - **Bit Operations**: First-class support for bit-level operations, bit chunks backed by `Byte`, `Int`, or `Long` arrays.
247
- - **NonEmptyChunk**: A statically-guaranteed non-empty variant for APIs that require at least one element.
248
- - **Full Scala Collection Integration**: Implements `IndexedSeq` for seamless interop.
249
-
250
- ### Installation
251
-
252
- ```scala
253
- libraryDependencies += "dev.zio" %% "zio-blocks-chunk" % "0.0.51"
254
- ```
255
-
256
- ### Example
257
-
258
- ```scala
259
- import zio.blocks.chunk._
260
-
261
- // Create chunks
262
- val bytes = Chunk[Byte](1, 2, 3, 4, 5)
263
- val moreBytes = Chunk.fromArray(Array[Byte](6, 7, 8))
264
-
265
- // Efficient concatenation (O(log n))
266
- val combined = bytes ++ moreBytes
267
-
268
- // Zero-copy slicing
269
- val slice = combined.slice(2, 6)
270
-
271
- // Bit operations
272
- val bits = bytes.asBitsByte
273
- val masked = bits & Chunk.fill(bits.length)(true)
274
-
275
- // NonEmptyChunk for type-safe non-emptiness
276
- val nonEmpty = NonEmptyChunk(1, 2, 3)
277
- val head: Int = nonEmpty.head // Always safe, no Option needed
278
- ```
215
+ - [Schema reference](./reference/schema/index.md) — the full API surface, from `Reflect` and `Binding` through optics, validation, and schema evolution
216
+ - [Migrating from ZIO Schema](./guides/zio-schema-migration.md) — a step-by-step port from ZIO Schema 1.x
279
217
 
280
218
  ---
281
219
 
@@ -339,10 +277,10 @@ Scope.global.scoped { scope =>
339
277
  ### Installation
340
278
 
341
279
  ```scala
342
- libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.51"
280
+ libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.55"
343
281
  ```
344
282
 
345
- ### Example: Basic Resource Management
283
+ ### Example
346
284
 
347
285
  ```scala
348
286
  import zio.blocks.scope.*
@@ -366,279 +304,77 @@ Scope.global.scoped { scope =>
366
304
  // Database closed
367
305
  ```
368
306
 
369
- ### Example: Dependency Injection
370
-
371
- ```scala
372
- import zio.blocks.scope.*
307
+ ### Learn More
373
308
 
374
- case class Config(dbUrl: String)
375
- class Database(config: Config) extends AutoCloseable { ... }
376
- class UserRepo(db: Database) { ... }
377
- class UserService(repo: UserRepo) extends AutoCloseable { ... }
378
-
379
- // Resource.from auto-wires the dependency graph
380
- // Only provide leaf values - concrete classes are auto-wired
381
- val serviceResource: Resource[UserService] = Resource.from[UserService](
382
- Wire(Config("jdbc:postgresql://localhost/mydb"))
383
- )
384
-
385
- serviceResource.use(_.createUser("Alice"))
386
- // Cleanup runs LIFO: UserService → Database (UserRepo has no cleanup)
387
- ```
388
-
389
- ### Example: Nested Scopes with Transactions
390
-
391
- ```scala
392
- Scope.global.scoped { connScope =>
393
- import connScope.*
394
-
395
- val conn = allocate(Resource.fromAutoCloseable(new Connection))
396
-
397
- // Transaction lives in child scope - cleaned up before connection
398
- val result: String = scoped { txScope =>
399
- import txScope.*
400
- val c = lower(conn)
401
- val tx = $(c)(_.beginTransaction()).allocate
402
- $(tx)(_.execute("INSERT INTO users VALUES (1, 'Alice')"))
403
- $(tx)(_.commit())
404
- "success"
405
- }
406
- // Transaction closed here, connection still open
407
-
408
- println(result)
409
- }
410
- // Connection closed here
411
- ```
412
-
413
- ### Getting Started
414
-
415
- New to Scope? Check out the [Scope Tutorial](./guides/compile-time-resource-safety-with-scope.md) for a comprehensive step-by-step guide that walks you through the concepts, patterns, and real-world examples. The tutorial is designed for newcomers and covers everything from basic resource management to advanced dependency injection.
416
-
417
- For detailed API documentation, see the [Scope Reference](./reference/resource-management/scope.md).
309
+ - [Compile-Time Resource Safety with Scope](./guides/compile-time-resource-safety-with-scope.md) — the step-by-step tutorial, from basic resource management through dependency injection
310
+ - [Resource Management & DI reference](./reference/resource-management/index.md) — `Scope`, `Resource`, `Wire`, `Unscoped`, and finalization order
418
311
 
419
312
  ---
420
313
 
421
- ## Docs
422
-
423
- A zero-dependency GitHub Flavored Markdown library for parsing, rendering, and programmatic construction of Markdown documents.
424
-
425
- ### Why Docs?
426
-
427
- Generating documentation, README files, or any Markdown content programmatically is common but error-prone with string concatenation. Docs provides:
428
-
429
- - **Type-safe AST**: Build Markdown documents with compile-time guarantees
430
- - **Compile-time validation**: The `md"..."` interpolator validates syntax at compile time
431
- - **Multiple renderers**: Output to Markdown, HTML, or ANSI terminal
432
- - **Round-trip parsing**: Parse Markdown to AST and render back to Markdown
314
+ ## Async
433
315
 
434
- ### Key Features
316
+ A lightweight, zero-dependency asynchronous effect type. A ready `Async[A]` *is*
317
+ an `A`, so synchronous code composed with `map` / `flatMap` allocates nothing on
318
+ the happy path while still suspending on genuinely asynchronous work.
435
319
 
436
- - **GFM Compliant**: Tables, strikethrough, autolinks, task lists, fenced code blocks
437
- - **Zero Dependencies**: Only depends on zio-blocks-chunk
438
- - **Cross-Platform**: Full support for JVM and Scala.js
439
- - **Type-Safe Interpolator**: `md"# Hello $name"` with compile-time validation
440
- - **Multiple Renderers**: Markdown, HTML (full document or fragment), ANSI terminal
320
+ ### The Problem
441
321
 
442
- ### Installation
322
+ Asynchronous Scala forces a choice between two costs. `Future` allocates for
323
+ every combinator and needs an `ExecutionContext` threaded everywhere, even when
324
+ the value is already available. Full effect systems avoid that but ask you to
325
+ adopt a runtime, a set of type classes, and a programming model across your
326
+ whole codebase—a heavy price for a library that only occasionally suspends.
443
327
 
444
- ```scala
445
- libraryDependencies += "dev.zio" %% "zio-blocks-docs" % "0.0.51"
446
- ```
328
+ ### The Solution
447
329
 
448
- ### Example
330
+ `Async[A]` is a value, not a wrapper. When the result is already known, the
331
+ representation *is* the result, so composing ready values costs nothing:
449
332
 
450
333
  ```scala
451
- import zio.blocks.docs._
452
-
453
- // Parse Markdown
454
- val doc = Parser.parse("# Hello\n\nThis is **bold** text.")
455
- // Right(Doc(Chunk(Heading(H1, "Hello"), Paragraph(...))))
456
-
457
- // Render to HTML
458
- val html = doc.map(_.toHtml)
459
- // Full HTML5 document with <html>, <head>, <body>
460
-
461
- // Render to HTML fragment (just the content)
462
- val fragment = doc.map(_.toHtmlFragment)
463
- // "<h1>Hello</h1><p>This is <strong>bold</strong> text.</p>"
464
-
465
- // Render to terminal with ANSI colors
466
- val terminal = doc.map(_.toTerminal)
467
-
468
- // Use the type-safe interpolator
469
- val name = "World"
470
- val greeting = md"# Hello $name"
471
- // Doc containing: Heading(H1, Chunk(Text("Hello World")))
472
-
473
- // Build documents programmatically
474
- import zio.blocks.chunk.Chunk
475
-
476
- val manual = Doc(Chunk(
477
- Block.Heading(HeadingLevel.H1, Chunk(Inline.Text("API Reference"))),
478
- Block.Paragraph(Chunk(
479
- Inline.Text("See "),
480
- Inline.Link(Chunk(Inline.Text("docs")), "/docs", None),
481
- Inline.Text(" for details.")
482
- ))
483
- ))
334
+ import zio.blocks.async._
484
335
 
485
- // Render back to Markdown
486
- val markdown = Renderer.render(manual)
336
+ // Constructors collapse to bare values; transformers inline with no allocation
337
+ val computed: Int =
338
+ Async.succeed(20).map(_ + 1).flatMap(n => Async.succeed(n * 2)).block
339
+ // computed: Int = 42
487
340
  ```
488
341
 
489
- ### Supported GFM Features
490
-
491
- | Feature | Supported |
492
- |---------|-----------|
493
- | Headings (ATX) | ✅ |
494
- | Paragraphs | ✅ |
495
- | Emphasis/Strong | ✅ |
496
- | Code (inline & fenced) | ✅ |
497
- | Links & Images | ✅ |
498
- | Lists (bullet, ordered, task) | ✅ |
499
- | Blockquotes | ✅ |
500
- | Tables | ✅ |
501
- | Strikethrough | ✅ |
502
- | Autolinks | ✅ |
503
- | Hard/Soft breaks | ✅ |
504
- | HTML (passthrough) | ✅ |
505
-
506
- ### Limitations
507
-
508
- - **No frontmatter**: YAML/TOML headers are not parsed
509
- - **No HTML entity decoding**: `&amp;` stays as-is
510
- - **No footnotes**: GFM footnote extension not supported
511
- - **No emoji shortcodes**: `:smile:` not converted to emoji
512
-
513
- ---
514
-
515
- ## TypeId
516
-
517
- Compile-time type identity with rich metadata. TypeId captures comprehensive information about Scala types including name, owner, type parameters, variance, parent types, and annotations.
518
-
519
342
  ### Key Features
520
343
 
521
- - **Rich Metadata**: Captures type name, owner, kind (class/trait/object/enum), parent types, and annotations
522
- - **Higher-Kinded Support**: Works with proper types and type constructors via `AnyKind`
523
- - **Subtype Checking**: Runtime subtype/supertype relationship checks using compile-time extracted information
524
- - **Cross-Platform**: Works identically on JVM and Scala.js
344
+ - **Zero Allocation on the Happy Path**: A completed `Async[A]` is represented as the `A` itself; `map` and `flatMap` over ready values allocate nothing.
345
+ - **Direct-Style `await`**: `Async.async { ... }` rewrites `.await` calls at compile time into a non-blocking `flatMap` chain—straight-line code, asynchronous execution.
346
+ - **No Runtime to Adopt**: No `ExecutionContext` to thread, no type class hierarchy, no effect system dependency.
347
+ - **Interop Built In**: Bridges to `Future` and `CompletionStage`, plus `Async.promise` for callback-based APIs.
525
348
 
526
349
  ### Installation
527
350
 
528
351
  ```scala
529
- libraryDependencies += "dev.zio" %% "zio-blocks-typeid" % "0.0.51"
352
+ libraryDependencies += "dev.zio" %% "zio-blocks-async" % "0.0.55"
530
353
  ```
531
354
 
532
355
  ### Example
533
356
 
534
- ```scala
535
- import zio.blocks.typeid._
536
-
537
- // Get TypeId for any type
538
- val listId = TypeId.of[List[Int]]
539
- println(listId.name) // "List"
540
- println(listId.fullName) // "scala.collection.immutable.List"
541
- println(listId.arity) // 1 (type constructor)
542
-
543
- // Check type relationships
544
- trait Animal
545
- case class Dog(name: String) extends Animal
546
-
547
- val dogId = TypeId.of[Dog]
548
- val animalId = TypeId.of[Animal]
549
- dogId.isSubtypeOf(animalId) // true
550
-
551
- // Access structural information
552
- dogId.isCaseClass // true
553
- dogId.isSealed // false
554
- ```
555
-
556
- ---
557
-
558
- ## Context
559
-
560
- A type-indexed heterogeneous collection that stores values by their types with compile-time type safety.
561
-
562
- ### Key Features
563
-
564
- - **Type-Safe Lookup**: Retrieve values by type with compile-time guarantees
565
- - **Covariant**: `Context[Specific]` is a subtype of `Context[General]`
566
- - **Subtype Matching**: Lookup by supertype finds matching subtypes
567
- - **Cached Access**: O(1) subsequent lookups after first retrieval
568
-
569
- ### Installation
570
-
571
- ```scala
572
- libraryDependencies += "dev.zio" %% "zio-blocks-context" % "0.0.51"
573
- ```
574
-
575
- ### Example
357
+ Write straight-line asynchronous code with `Async.async` and `.await`, rewritten
358
+ at compile time into a non-blocking `flatMap` chain:
576
359
 
577
360
  ```scala
578
- import zio.blocks.context._
579
-
580
- case class Config(debug: Boolean)
581
- case class Metrics(count: Int)
582
-
583
- // Create a context with multiple values
584
- val ctx: Context[Config & Metrics] = Context(
585
- Config(debug = true),
586
- Metrics(count = 42)
587
- )
588
-
589
- // Retrieve values by type
590
- val config: Config = ctx.get[Config]
591
- val metrics: Metrics = ctx.get[Metrics]
592
-
593
- // Add or update values
594
- val updated = ctx.update[Metrics](m => m.copy(count = m.count + 1))
595
-
596
- // Combine contexts
597
- val ctx1 = Context(Config(false))
598
- val ctx2 = Context(Metrics(0))
599
- val merged: Context[Config & Metrics] = ctx1 ++ ctx2
600
- ```
601
-
602
- ---
603
-
604
- ## Ring Buffer
605
-
606
- High-performance, bounded ring buffers for inter-thread communication. Four lock-free variants cover every producer/consumer pattern (SPSC, MPSC, SPMC, MPMC).
607
-
608
- ### Why Ring Buffer?
609
-
610
- Standard `java.util.concurrent` queues use node allocation (`ConcurrentLinkedQueue`) or coarse locking (`ArrayBlockingQueue`). Ring buffers avoid both:
611
-
612
- - **Zero allocation** on the hot path—pre-allocated circular array
613
- - **Lock-free** on the fast path—CAS or release/acquire semantics only
614
- - **Cache-friendly**—sequential memory access with 128-byte padding between producer/consumer fields
615
-
616
- ### Key Features
617
-
618
- - **Four concurrency patterns**: SPSC, SPMC, MPSC, MPMC—pick the most constrained variant for your use case
619
- - **Cross-platform**: Same API on JVM and Scala.js (JS uses sequential implementations)
361
+ import zio.blocks.async._
620
362
 
621
- ### Installation
363
+ def fetch(id: Int): Async[String] = Async.succeed(s"item-$id")
622
364
 
623
- ```scala
624
- libraryDependencies += "dev.zio" %% "zio-blocks-ringbuffer" % "0.0.51"
365
+ val program: Async[Int] =
366
+ Async.async {
367
+ val a = fetch(1).await
368
+ val b = fetch(2).await
369
+ (a + b).length
370
+ }
625
371
  ```
626
372
 
627
- ### Example
628
-
629
- ```scala
630
- import zio.blocks.ringbuffer._
373
+ ### Learn More
631
374
 
632
- // SPSC: fastest, for dedicated producer-consumer pairs
633
- val spsc = SpscRingBuffer[String](1024)
634
- spsc.offer("hello") // true
635
- spsc.take() // "hello"
636
-
637
- // MPMC: general-purpose, any number of threads
638
- val mpmc = MpmcRingBuffer[String](1024)
639
- mpmc.offer("hello") // false if full
640
- mpmc.take() // null if empty
641
- ```
375
+ - [Getting Started with Async](./guides/async-getting-started.md) — create, compose, and run async effects
376
+ - [Async reference](./reference/async.md) — the full API, including `zip`, `catchAll`, `collectAll`, the `Async.promise` callback bridge, and `Future` / `CompletionStage` interop
377
+ - [`async-examples`](https://github.com/zio/zio-blocks/blob/main/async-examples/src/main/scala/async/AsyncShowcaseExample.scala) — a single-file order-fulfillment demo (`sbt "++3.9.0; async-examples/run"`)
642
378
 
643
379
  ---
644
380
 
@@ -678,11 +414,10 @@ val frag = sql"SELECT * FROM user WHERE email = ${"alice@example.com"}"
678
414
  ### Installation
679
415
 
680
416
  ```scala
681
- // Core module (Scala 3, JVM + Scala.js)
682
- libraryDependencies += "dev.zio" %% "zio-blocks-sql" % "0.0.51"
417
+ libraryDependencies += "dev.zio" %% "zio-blocks-sql" % "0.0.55"
683
418
 
684
- // ZIO integration (Scala 3, JVM only)
685
- libraryDependencies += "dev.zio" %% "zio-blocks-sql-zio" % "0.0.51"
419
+ // Optional ZIO integration
420
+ libraryDependencies += "dev.zio" %% "zio-blocks-sql-zio" % "0.0.55"
686
421
  ```
687
422
 
688
423
  ### Example
@@ -709,58 +444,10 @@ val program = transactor.transact:
709
444
  sql"SELECT * FROM product WHERE price < ${15.0}".query[Product]
710
445
  ```
711
446
 
712
- ---
713
-
714
- ## Streams (In Development)
715
-
716
- A pull-based streaming library for composable, backpressure-aware data processing.
447
+ ### Learn More
717
448
 
718
- ```scala
719
- import zio.blocks.streams._
720
-
721
- // Coming soon: efficient pull-based streams
722
- // that compose with any effect system
723
- ```
724
-
725
- ---
726
-
727
- ## Async
728
-
729
- A lightweight, zero-dependency asynchronous effect type. A ready `Async[A]` *is*
730
- an `A`, so synchronous code composed with `map` / `flatMap` allocates nothing on
731
- the happy path while still suspending on genuinely asynchronous work.
732
-
733
- ```scala
734
- import zio.blocks.async._
735
-
736
- // Constructors collapse to bare values; transformers inline with no allocation
737
- val computed: Int =
738
- Async.succeed(20).map(_ + 1).flatMap(n => Async.succeed(n * 2)).block
739
- // computed: Int = 42
740
- ```
741
-
742
- Write straight-line asynchronous code with `Async.async` and `.await`, rewritten
743
- at compile time into a non-blocking `flatMap` chain:
744
-
745
- ```scala
746
- import zio.blocks.async._
747
-
748
- def fetch(id: Int): Async[String] = Async.succeed(s"item-$id")
749
-
750
- val program: Async[Int] =
751
- Async.async {
752
- val a = fetch(1).await
753
- val b = fetch(2).await
754
- (a + b).length
755
- }
756
- ```
757
-
758
- See the [Async reference](./reference/async.md) for the full API, including
759
- `zip`, `catchAll`, `collectAll`, the `Async.promise` callback bridge, and
760
- `Future` / `CompletionStage` interop.
761
-
762
- **Runnable tour:** the [`async-examples`](https://github.com/zio/zio-blocks/blob/main/async-examples/src/main/scala/async/AsyncShowcaseExample.scala)
763
- module is a single-file order-fulfillment demo (`sbt "++3.8.3; async-examples/run"`).
449
+ - [SQL reference](./reference/sql/index.md) — `DbCodec`, `Frag`, `Table`, `Repo`, `Transactor`, dialects, and DDL generation
450
+ - [Query DSL guide](./guides/query-dsl-reified-optics.md) — a four-part series building a type-safe query language on reified optics
764
451
 
765
452
  ---
766
453
 
@@ -779,102 +466,32 @@ ZIO Blocks works with any Scala stack:
779
466
 
780
467
  Each block has zero dependencies on effect systems. Use the blocks directly, or integrate them with your effect system of choice.
781
468
 
782
- ## Scala & Platform Support
783
-
784
- ZIO Blocks supports **Scala 2.13** and **Scala 3.x** with full source compatibility. Write your code once and compile it against either version—migrate to Scala 3 when your team is ready, not when your dependencies force you.
785
-
786
- | Platform | Schema | Chunk | Scope | Docs | TypeId | Context | Ring Buffer | Streams | SQL | Async |
787
- |----------|--------|-------|-------|------|--------|---------|-------------|---------|-----|-------|
788
- | JVM | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | ✅ | ✅ |
789
- | Scala.js | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | ✅ | ✅ |
790
-
791
- ## Documentation
792
-
793
- ### Core Schema Concepts
794
-
795
- - [Schema](./reference/schema/schema.md) - Core schema definitions and derivation
796
- - [Allows](./reference/schema/allows.md) - Compile-time structural grammar constraints
797
- - [Reflect](./reference/schema/reflect.md) - Structural reflection API
798
- - [Binding](./reference/schema/binding.md) - Runtime constructors and deconstructors
799
- - [BindingResolver](reference/schema/binding-resolver.md) - Binding lookup and schema rebinding
800
- - [Registers](./reference/schema/registers.md) - Register-based primitive storage
801
-
802
- ### Optics & Navigation
803
-
804
- - [Optics](./reference/schema/optics.md) - Lenses, prisms, and traversals
805
- - [SchemaExpr](./reference/schema/schema-expr.md) - Schema-aware expressions for queries and validation
806
- - [Path Interpolator](./reference/schema/path-interpolator.md) - Type-safe path construction
807
- - [DynamicValue](./reference/schema/dynamic-value.md) - Schema-less dynamic values
808
- - [DynamicSchema](./reference/schema/dynamic-schema.md) - Type-erased schemas for validation and cross-process transport
809
-
810
- ### Serialization
811
-
812
- - [Codec & Format](./reference/schema/codec.md) - Codec, Format, BinaryCodec & TextCodec
813
- - [JSON](./reference/schema/built-in-codecs/json/index.md) - JSON codec and parsing
814
- - [JsonPatch](./reference/schema/built-in-codecs/json/json-patch.md) - Diff and patch JSON values
815
- - [JsonDiffer](./reference/schema/built-in-codecs/json/json-differ.md) - Compute minimal diffs between JSON values
816
- - [JSON Schema](./reference/schema/built-in-codecs/json/json-schema.md) - JSON Schema generation and validation
817
- - [XML Codec](./reference/schema/built-in-codecs/xml.md) - Zero-dependency XML serialization with fluent navigation and patching
818
- - [CSV Codec](./reference/schema/built-in-codecs/csv.md) - RFC 4180-compliant CSV serialization with schema-driven derivation
819
- - [BSON Codec](./reference/schema/built-in-codecs/bson.md) - MongoDB-compatible BSON serialization with native type support
820
- - [Avro Codec](./reference/schema/built-in-codecs/avro.md) - Apache Avro binary serialization with automatic schema generation
821
- - [MessagePack Codec](./reference/schema/built-in-codecs/messagepack.md) - Compact binary serialization with optimized streaming
822
- - [Thrift Codec](./reference/schema/built-in-codecs/thrift.md) - Apache Thrift binary serialization with TBinaryProtocol
823
- - [YAML Codec](./reference/schema/built-in-codecs/yaml.md) - Human-readable YAML serialization with JSON interop
824
- - [TOON Codec](./reference/schema/built-in-codecs/toon.md) - Compact token-oriented notation 30-60% smaller than JSON, optimized for LLM prompts
825
- - [Built-in Codecs](./reference/schema/built-in-codecs/index.md) - Overview of all supported serialization formats
826
- - [Extension Syntax](./reference/schema/syntax.md) - `.toJson`, `.fromJson`, and more
827
-
828
- ### Data Operations
829
-
830
- - [Patching](./reference/schema/patch.md) - Serializable data transformations
831
- - [SchemaError](./reference/schema/schema-error.md) - Structured error type for schema operations
832
- - [Validation](./reference/schema/validation.md) - Data validation and error handling
833
- - [Schema Evolution](reference/schema/schema-evolution/index.md) - One-way and bidirectional type-safe conversions
834
- - [Into](reference/schema/schema-evolution/into.md) - One-way conversion with validation
835
- - [As](reference/schema/schema-evolution/as.md) - Bidirectional round-trip conversion
836
-
837
- ### Other Blocks
838
-
839
- - [Chunk](./reference/chunk.md) - High-performance immutable sequences
840
- - [Maybe](./reference/maybe.md) - Low-allocation optional values using null
841
- - [Mux](./reference/mux.mdx) - Thread-safe multiplexer for ID-multiplexed protocols (HTTP/2, QUIC, WebSockets) with lock-free per-stream queues
842
- - [Scope](./reference/resource-management/scope.md) - Compile-time safe resource management and DI
843
- - [Wire](./reference/resource-management/wire.md) - Recipes for constructing services and dependencies
844
- - [TypeId](./reference/typeid.md) - Type identity and metadata
845
- - [Context](./reference/context.md) - Type-indexed heterogeneous collections
846
- - [Combinators](./reference/combinators.md) - Compile-time composition and decomposition of values (Tuples, Eithers, Unions)
847
- - [Docs (Markdown)](./reference/docs.md) - Markdown parsing and rendering
848
- - [HTML](./reference/html.md) - Type-safe HTML templating with XSS protection
849
- - [HTMX](./reference/htmx/index.md) - Typed HTMX DSL for safe, compile-time HTMX attribute declarations
850
- - [HTTP Model](./reference/http-model/index.md) - Pure HTTP data model with URL parsing, headers, cookies, and forms
851
- - [Endpoint](./reference/endpoint/index.md) - Pure, type-safe HTTP endpoint descriptors with composable codecs and typed auth
852
- - [MediaType](./reference/media-type.md) - Type-safe IANA media types
853
- - [Smithy](./reference/smithy.md) - Smithy IDL parser and AST library for API modeling
854
- - [OpenAPI](./reference/openapi.md) - Type-safe OpenAPI 3.1 specification generation and rendering
855
- - [Ring Buffer](./reference/ringbuffer/index.mdx) - High-performance bounded ring buffers
856
- - [Stream](./reference/streams/stream.md) - Lazy, pull-based, type-safe streaming with resource safety
857
- - [Pipeline](./reference/streams/pipeline.md) - Reusable, composable stream transformations
858
- - [Sink](./reference/streams/sink.md) - Stream consumers that produce typed results
859
- - [Reader](./reference/streams/reader.md) - Low-level pull-based sources for streaming
860
- - [Writer](./reference/streams/writer.md) - Low-level push-based sinks for streaming
861
- - [SQL](./reference/sql/index.md) - Type-safe JDBC wrapper with schema-derived codecs and repository
862
- - [DbCodec](./reference/sql/db-codec.md) - Bidirectional codec between Scala values and database columns
863
- - [Frag](./reference/sql/frag.md) - Immutable SQL fragment with safe parameterization via `sql"..."` interpolator
864
- - [Table](./reference/sql/table.md) - Schema-derived table metadata binding Scala types to database tables
865
- - [Repo](./reference/sql/repo.md) - Type-safe CRUD repository with pre-built SQL operations
866
- - [Transactor](./reference/sql/transactor.md) - Connection lifecycle and transaction management
867
- - [DbCon](./reference/sql/db-con.md) - Implicit context carrying connection, dialect, and logger
868
- - [DbTx](./reference/sql/db-tx.md) - Transactional scope marker extending `DbCon`
869
- - [SqlDialect](./reference/sql/sql-dialect.md) - Database-specific SQL rendering (PostgreSQL, SQLite)
870
- - [TransactorZIO](./reference/sql/transactor-zio.md) - ZIO integration with `ZIO.attemptBlocking` and `ZLayer`
871
- - [Async](./reference/async.md) - Zero-allocation asynchronous effect type with direct-style `await`
872
-
873
- ### Guides
874
-
875
- - [Getting Started with Mux](./guides/getting-started-with-mux.md) - Learn how to manage multiplexed bidirectional message streams with capacity limits
876
- - [Migrating from ZIO Schema](./guides/zio-schema-migration.md) - Step-by-step guide to migrating from ZIO Schema 1.x to ZIO Blocks Schema
469
+ ## Guides
470
+
471
+ - [Getting Started with Async](./guides/async-getting-started.md) - Create, compose, and run zero-allocation async effects with the `Async[A]` type
472
+ - [Compile-Time Resource Safety with Scope](./guides/compile-time-resource-safety-with-scope.md) - Resource management and dependency injection, from first principles
473
+ - [Getting Started with Mux](./guides/getting-started-with-mux.md) - Manage multiplexed bidirectional message streams with capacity limits
474
+ - [Telemetry: Architecture, Patterns, and Real-World Usage](./guides/telemetry-guide.md) - Wire tracing, logging, and metrics into a running application
475
+ - [Migrating from ZIO Schema](./guides/zio-schema-migration.md) - Step-by-step migration from ZIO Schema 1.x to ZIO Blocks Schema
877
476
  - [Query DSL Part 1: Expressions](./guides/query-dsl-reified-optics.md) - Build type-safe, composable query expressions
878
477
  - [Query DSL Part 2: SQL Generation](./guides/query-dsl-sql.md) - Translate query expressions into SQL
879
- - [Query DSL Part 3: Extending the Expression Language](./guides/query-dsl-extending.md) - Add custom operators beyond SchemaExpr
880
- - [Query DSL Part 4: A Fluent SQL Builder](./guides/query-dsl-fluent-builder.md) - Build type-safe SELECT, UPDATE, INSERT, DELETE statements
478
+ - [Query DSL Part 3: Extending the Expression Language](./guides/query-dsl-extending.md) - Add custom operators beyond `SchemaExpr`
479
+ - [Query DSL Part 4: A Fluent SQL Builder](./guides/query-dsl-fluent-builder.md) - Build type-safe SELECT, UPDATE, INSERT, and DELETE statements
480
+
481
+ ## Full API Reference
482
+
483
+ Every block in the catalog above links to its own reference page. The blocks
484
+ large enough to have several pages start from an overview:
485
+
486
+ - [Schema](./reference/schema/index.md) - core type system, dynamic values, optics, validation, and schema evolution
487
+ - [Built-in Codecs](./reference/schema/built-in-codecs/index.md) - JSON, Avro, BSON, CSV, MessagePack, Thrift, TOON, XML, and YAML
488
+ - [Schema Evolution](./reference/schema/schema-evolution/index.md) - one-way and bidirectional type-safe conversions
489
+ - [Telemetry](./reference/telemetry/index.md) - tracing, logging, metrics, and OTLP export
490
+ - [SQL](./reference/sql/index.md) - codecs, fragments, tables, repositories, transactors, and dialects
491
+ - [Resource Management & DI](./reference/resource-management/index.md) - `Scope`, `Resource`, `Wire`, `Unscoped`, and finalization
492
+ - [Streams](./reference/streams/index.md) - `Stream`, `Pipeline`, `Sink`, and the low-level readers and writers
493
+ - [Endpoint](./reference/endpoint/index.md) - endpoint descriptors, HTTP codecs, route patterns, and typed auth
494
+ - [HTTP Model](./reference/http-model/index.md) - the pure HTTP data model and its schema-based typed access
495
+ - [HTMX](./reference/htmx/index.md) - the typed HTMX attribute DSL
496
+ - [Ring Buffer](./reference/ringbuffer/index.mdx) - the SPSC, SPMC, MPSC, and MPMC variants
497
+ - [Code Generation](./reference/codegen/index.md) - the Scala code generation IR and emitter