@zio.dev/zio-blocks 0.0.33 → 0.0.51

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 (150) hide show
  1. package/guides/compile-time-resource-safety-with-scope.md +16 -17
  2. package/guides/getting-started-with-mux.md +1507 -0
  3. package/guides/query-dsl-extending.md +161 -102
  4. package/guides/query-dsl-fluent-builder.md +217 -157
  5. package/guides/query-dsl-reified-optics.md +12 -10
  6. package/guides/query-dsl-sql.md +246 -165
  7. package/guides/telemetry-guide.md +1069 -0
  8. package/guides/zio-schema-migration.md +29 -22
  9. package/index.md +292 -50
  10. package/package.json +1 -1
  11. package/plans/config-follow-up-prs.md +188 -0
  12. package/plans/config-pr-assessment-roadmap.md +310 -0
  13. package/reference/MuxDataFlow.jsx +250 -0
  14. package/reference/async.md +651 -0
  15. package/reference/chunk.md +3533 -308
  16. package/reference/codegen/case-class.md +436 -0
  17. package/reference/codegen/emitter-config.md +383 -0
  18. package/reference/codegen/examples.md +664 -0
  19. package/reference/codegen/field.md +316 -0
  20. package/reference/codegen/index.md +317 -0
  21. package/reference/codegen/scala-emitter.md +392 -0
  22. package/reference/codegen/scala-file.md +276 -0
  23. package/reference/codegen/sealed-trait.md +408 -0
  24. package/reference/codegen/type-definition.md +340 -0
  25. package/reference/codegen/type-ref.md +201 -0
  26. package/reference/combinators.md +347 -117
  27. package/reference/config.md +158 -0
  28. package/reference/context.md +4 -4
  29. package/reference/datastar.md +346 -0
  30. package/reference/docs.md +1461 -345
  31. package/reference/endpoint/auth-type.md +146 -0
  32. package/reference/endpoint/endpoint.md +297 -0
  33. package/reference/endpoint/http-codec.md +249 -0
  34. package/reference/endpoint/index.md +825 -0
  35. package/reference/endpoint/path-codec.md +237 -0
  36. package/reference/endpoint/route-pattern.md +196 -0
  37. package/reference/endpoint/route-tree.md +111 -0
  38. package/reference/endpoint/segment-codec.md +212 -0
  39. package/reference/html.md +1120 -0
  40. package/reference/htmx/attribute-values.md +359 -0
  41. package/reference/htmx/hx-encoding.md +111 -0
  42. package/reference/htmx/hx-params.md +204 -0
  43. package/reference/htmx/hx-swap.md +276 -0
  44. package/reference/htmx/hx-sync.md +251 -0
  45. package/reference/htmx/hx-target.md +314 -0
  46. package/reference/htmx/hx-trigger.md +457 -0
  47. package/reference/htmx/hx-url-update.md +239 -0
  48. package/reference/htmx/index.md +855 -0
  49. package/reference/http-model/index.md +47 -0
  50. package/reference/http-model/model.md +1481 -0
  51. package/reference/http-model/schema.md +747 -0
  52. package/reference/maybe.md +826 -0
  53. package/reference/media-type.md +2 -2
  54. package/reference/mux.mdx +823 -0
  55. package/reference/openapi.md +1351 -0
  56. package/reference/resource-management/defer-handle.md +1 -1
  57. package/reference/resource-management/resource.md +31 -2
  58. package/reference/resource-management/scope.md +28 -12
  59. package/reference/resource-management/wire.md +3 -7
  60. package/reference/ringbuffer/MpmcDiagram.jsx +717 -0
  61. package/reference/ringbuffer/MpscDiagram.jsx +618 -0
  62. package/reference/ringbuffer/SpmcDiagram.jsx +680 -0
  63. package/reference/ringbuffer/SpscDiagram.jsx +677 -0
  64. package/reference/ringbuffer/advanced.mdx +109 -0
  65. package/reference/ringbuffer/index.mdx +145 -0
  66. package/reference/ringbuffer/mpmc.mdx +151 -0
  67. package/reference/ringbuffer/mpsc.mdx +132 -0
  68. package/reference/ringbuffer/spmc.mdx +108 -0
  69. package/reference/ringbuffer/spsc.mdx +344 -0
  70. package/reference/{allows.md → schema/allows.md} +4 -4
  71. package/reference/{binding-resolver.md → schema/binding-resolver.md} +1 -1
  72. package/reference/{binding.md → schema/binding.md} +2 -3
  73. package/reference/schema/built-in-codecs/avro.md +451 -0
  74. package/reference/schema/built-in-codecs/bson.md +480 -0
  75. package/reference/schema/built-in-codecs/csv.md +564 -0
  76. package/reference/schema/built-in-codecs/index.md +77 -0
  77. package/reference/schema/built-in-codecs/json/index.md +295 -0
  78. package/reference/schema/built-in-codecs/json/json-config.md +217 -0
  79. package/reference/{json-patch.md → schema/built-in-codecs/json/json-patch.md} +5 -5
  80. package/reference/{json-schema.md → schema/built-in-codecs/json/json-schema.md} +14 -47
  81. package/reference/schema/built-in-codecs/json/json-selection.md +322 -0
  82. package/reference/{json.md → schema/built-in-codecs/json/json.md} +32 -64
  83. package/reference/schema/built-in-codecs/messagepack.md +508 -0
  84. package/reference/schema/built-in-codecs/thrift.md +433 -0
  85. package/reference/schema/built-in-codecs/toon.md +1078 -0
  86. package/reference/{xml.md → schema/built-in-codecs/xml.md} +13 -9
  87. package/reference/schema/built-in-codecs/yaml.md +552 -0
  88. package/reference/{codec.md → schema/codec.md} +10 -10
  89. package/reference/{dynamic-optic.md → schema/dynamic-optic.md} +151 -5
  90. package/reference/{dynamic-schema.md → schema/dynamic-schema.md} +8 -8
  91. package/reference/schema/format.md +92 -0
  92. package/reference/schema/index.md +50 -0
  93. package/reference/schema/migration.md +297 -0
  94. package/reference/{modifier.md → schema/modifier.md} +58 -7
  95. package/reference/{optics.md → schema/optics.md} +2 -2
  96. package/reference/{patch.md → schema/patch.md} +1 -1
  97. package/{path-interpolator.md → reference/schema/path-interpolator.md} +165 -72
  98. package/reference/{schema-evolution → schema/schema-evolution}/as.md +8 -8
  99. package/reference/{schema-evolution → schema/schema-evolution}/index.md +2 -2
  100. package/reference/{schema-evolution → schema/schema-evolution}/into.md +8 -8
  101. package/reference/{schema-expr.md → schema/schema-expr.md} +110 -175
  102. package/reference/{schema.md → schema/schema.md} +12 -0
  103. package/reference/{structural-types.md → schema/structural-types.md} +1 -1
  104. package/reference/{type-class-derivation.md → schema/type-class-derivation.md} +63 -1
  105. package/reference/smithy.md +533 -0
  106. package/reference/sql/db-codec-deriver.md +71 -0
  107. package/reference/sql/db-codec.md +687 -0
  108. package/reference/sql/db-con.md +271 -0
  109. package/reference/sql/db-connection.md +153 -0
  110. package/reference/sql/db-param-writer.md +77 -0
  111. package/reference/sql/db-param.md +66 -0
  112. package/reference/sql/db-result-reader.md +146 -0
  113. package/reference/sql/db-tx.md +82 -0
  114. package/reference/sql/db-value.md +41 -0
  115. package/reference/sql/ddl.md +85 -0
  116. package/reference/sql/frag.md +254 -0
  117. package/reference/sql/index.md +341 -0
  118. package/reference/sql/repo.md +600 -0
  119. package/reference/sql/sql-dialect.md +73 -0
  120. package/reference/sql/sql-logger.md +62 -0
  121. package/reference/sql/sql-name-mapper.md +70 -0
  122. package/reference/sql/table-metadata.md +134 -0
  123. package/reference/sql/table.md +448 -0
  124. package/reference/sql/transactor-zio.md +399 -0
  125. package/reference/sql/transactor.md +353 -0
  126. package/reference/sql-zio.md +112 -0
  127. package/reference/streams/concurrent-operators.md +106 -0
  128. package/reference/streams/index.md +653 -0
  129. package/reference/streams/pipeline.md +718 -0
  130. package/reference/streams/reader.md +1284 -0
  131. package/reference/streams/scala-2-compatibility.md +55 -0
  132. package/reference/streams/sink.md +1426 -0
  133. package/reference/streams/stream.md +2526 -0
  134. package/reference/streams/writer.md +1045 -0
  135. package/reference/streams/zero-boxing.md +275 -0
  136. package/reference/telemetry.md +693 -0
  137. package/reference/typeid.md +5 -19
  138. package/sidebars.js +238 -43
  139. package/reference/formats.md +0 -694
  140. package/reference/http-model.md +0 -1716
  141. package/reference/streams.md +0 -989
  142. package/ringbuffer.md +0 -249
  143. /package/reference/{json-differ.md → schema/built-in-codecs/json/json-differ.md} +0 -0
  144. /package/reference/{dynamic-value.md → schema/dynamic-value.md} +0 -0
  145. /package/reference/{lazy.md → schema/lazy.md} +0 -0
  146. /package/reference/{reflect.md → schema/reflect.md} +0 -0
  147. /package/reference/{registers.md → schema/registers.md} +0 -0
  148. /package/reference/{schema-error.md → schema/schema-error.md} +0 -0
  149. /package/reference/{syntax.md → schema/syntax.md} +0 -0
  150. /package/reference/{validation.md → schema/validation.md} +0 -0
@@ -38,13 +38,13 @@ libraryDependencies += "dev.zio" %% "zio-schema-avro" % "1.x.x"
38
38
  **After (ZIO Blocks Schema):**
39
39
 
40
40
  ```scala
41
- libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
41
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.51"
42
42
  // Optional codec modules:
43
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.33"
44
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.33"
45
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.33"
46
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.33"
47
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.33"
43
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.51"
44
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.51"
45
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.51"
46
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.51"
47
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.51"
48
48
  ```
49
49
 
50
50
  Key points:
@@ -488,7 +488,7 @@ sealed trait Event
488
488
  @caseName("user_created")
489
489
  case class UserCreated(userId: String) extends Event
490
490
 
491
- // ZIO Blocks Schema — use Modifier.rename on the case, Modifier.config for discriminator
491
+ // ZIO Blocks Schema — use Modifier.rename on the case, Modifier.discriminator on the sealed trait
492
492
  import zio.blocks.schema._
493
493
 
494
494
  sealed trait Event
@@ -496,11 +496,14 @@ sealed trait Event
496
496
  case class UserCreated(userId: String) extends Event
497
497
  ```
498
498
 
499
- For discriminator key configuration on the enclosing sealed trait, use `Modifier.config` on the reflect node after derivation:
499
+ For discriminator key configuration on the enclosing sealed trait, use `Modifier.discriminator` on the sealed trait:
500
500
 
501
501
  ```scala
502
+ @Modifier.discriminator("type")
503
+ sealed trait Event
504
+
502
505
  implicit val schema: Schema[Event] =
503
- Schema.derived[Event].modifier(Modifier.config("json.discriminator", "type"))
506
+ Schema.derived[Event]
504
507
  ```
505
508
 
506
509
  ### Programmatic Annotation
@@ -735,11 +738,15 @@ dynSchema.conforms(value) // true
735
738
  dynSchema.check(value) // None (no error)
736
739
  ```
737
740
 
738
- :::warning
739
- ZIO Schema's `Migration` system for schema-to-schema migration (i.e., automatically migrating values from one version of a type to another) is **not yet available** in ZIO Blocks Schema. The `schema.migrate[B](newSchema)` and `schema.coerce[B](newSchema)` methods do not exist. If your application relies on schema migration, you have two options:
741
+ :::info
742
+ ZIO Blocks Schema now includes an explicit migration API for evolving values between schema versions. The entry point is [`Migration.newBuilder[A, B]`](../reference/schema/migration), which builds a typed `Migration[A, B]` backed by a serializable `DynamicMigration`.
743
+
744
+ This is a different model from ZIO Schema's `schema.migrate[B](newSchema)` / `schema.coerce[B](newSchema)` APIs:
745
+
746
+ 1. Build a migration explicitly with operations like `addField`, `dropField`, `renameField`, `changeFieldType`, and `migrateField`.
747
+ 2. Apply the resulting `Migration[A, B]` to typed values, or inspect/transport the underlying `DynamicMigration`.
740
748
 
741
- 1. Implement migration logic manually using `DynamicValue` transformations and `DynamicSchema` for validation.
742
- 2. Wait for schema migration support to be added to ZIO Blocks Schema (it is on the roadmap).
749
+ Use this when you want structural schema evolution as first-class data rather than implicit derivation.
743
750
  :::
744
751
 
745
752
  ### Schema Serialization
@@ -1127,7 +1134,7 @@ The following ZIO Schema features do not yet have equivalents in ZIO Blocks Sche
1127
1134
  | Feature | Status |
1128
1135
  |---|---|
1129
1136
  | `Schema.fail` / fail schemas | Not available |
1130
- | `Schema.migrate[B]` / `Schema.coerce[B]` | Not available — schema migration is planned |
1137
+ | `Schema.migrate[B]` / `Schema.coerce[B]` | Replaced by explicit [`Migration.newBuilder[A, B]`](../reference/schema/migration) |
1131
1138
  | `MetaSchema` / schema serialization | Partial — `DynamicSchema` covers structural inspection; full schema round-trip is not available |
1132
1139
  | `Fallback[A, B]` schema | Not available |
1133
1140
  | `NonEmptyChunk` / `NonEmptyMap` schemas | Not available — use wrapper types |
@@ -1185,11 +1192,11 @@ sbt "schema-examples/compile"
1185
1192
 
1186
1193
  ## Going Further
1187
1194
 
1188
- - [Schema Reference](../reference/schema.md) — full `Schema[A]` API
1189
- - [Reflect Reference](../reference/reflect.md) — the `Reflect[F, A]` node types
1190
- - [Binding Reference](../reference/binding.md) — constructors, deconstructors, and the register system
1191
- - [Optics Reference](../reference/optics.md) — `Lens`, `Prism`, `Optional`, `Traversal`
1192
- - [Type Class Derivation Guide](../reference/type-class-derivation.md) — implementing `Deriver[TC]`
1193
- - [Codec Reference](../reference/codec.md) — the `Format` and `Codec` infrastructure
1194
- - [DynamicValue Reference](../reference/dynamic-value.md) — the `DynamicValue` API
1195
- - [Validation Reference](../reference/validation.md) — built-in validation constraints
1195
+ - [Schema Reference](../reference/schema/schema.md) — full `Schema[A]` API
1196
+ - [Reflect Reference](../reference/schema/reflect.md) — the `Reflect[F, A]` node types
1197
+ - [Binding Reference](../reference/schema/binding.md) — constructors, deconstructors, and the register system
1198
+ - [Optics Reference](../reference/schema/optics.md) — `Lens`, `Prism`, `Optional`, `Traversal`
1199
+ - [Type Class Derivation Guide](../reference/schema/type-class-derivation.md) — implementing `Deriver[TC]`
1200
+ - [Codec Reference](../reference/schema/codec.md) — the `Format` and `Codec` infrastructure
1201
+ - [DynamicValue Reference](../reference/schema/dynamic-value.md) — the `DynamicValue` API
1202
+ - [Validation Reference](../reference/schema/validation.md) — built-in validation constraints
package/index.md CHANGED
@@ -21,11 +21,117 @@ The philosophy is simple: **use what you need, nothing more**. Each block is ind
21
21
  | **Chunk** | High-performance immutable indexed sequences | ✅ Available |
22
22
  | **Scope** | Compile-time safe resource management and DI | ✅ Available |
23
23
  | **Docs** | GitHub Flavored Markdown parsing and rendering | ✅ Available |
24
+ | **Codegen** | Generic Scala code generation IR and emitter | ✅ Available |
24
25
  | **TypeId** | Compile-time type identity with rich metadata | ✅ Available |
25
26
  | **Context** | Type-indexed heterogeneous collections | ✅ Available |
26
27
  | **MediaType** | Type-safe IANA media types with 2,600+ predefined types | ✅ Available |
28
+ | **OpenAPI** | Type-safe OpenAPI 3.1 specification generation | ✅ Available |
27
29
  | **Ring Buffer** | High-performance bounded ring buffers (SPSC, MPSC, SPMC, MPMC) | ✅ Available |
28
- | **Streams** | Pull-based streaming primitives | 🚧 In Development |
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
+ ```
96
+
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
+ :::
100
+
101
+ ### Example: ConfigSource Composition with Provenance
102
+
103
+ The snippet below uses Scala 3 syntax.
104
+
105
+ ```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"))
117
+ ```
118
+
119
+ ### Example: Rollout DSL
120
+
121
+ ```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
131
+
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._`)
29
135
 
30
136
  ## Core Principles
31
137
 
@@ -82,14 +188,14 @@ val thriftCodec = Schema[Person].derive(ThriftFormat) // Thrift
82
188
  ### Installation
83
189
 
84
190
  ```scala
85
- libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
191
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.51"
86
192
 
87
193
  // Optional format modules:
88
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.33"
89
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.33"
90
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.33"
91
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.33"
92
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.33"
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"
93
199
  ```
94
200
 
95
201
  ### Example: Optics
@@ -144,7 +250,7 @@ Chunk is designed for:
144
250
  ### Installation
145
251
 
146
252
  ```scala
147
- libraryDependencies += "dev.zio" %% "zio-blocks-chunk" % "0.0.33"
253
+ libraryDependencies += "dev.zio" %% "zio-blocks-chunk" % "0.0.51"
148
254
  ```
149
255
 
150
256
  ### Example
@@ -233,7 +339,7 @@ Scope.global.scoped { scope =>
233
339
  ### Installation
234
340
 
235
341
  ```scala
236
- libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.33"
342
+ libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.51"
237
343
  ```
238
344
 
239
345
  ### Example: Basic Resource Management
@@ -276,13 +382,7 @@ val serviceResource: Resource[UserService] = Resource.from[UserService](
276
382
  Wire(Config("jdbc:postgresql://localhost/mydb"))
277
383
  )
278
384
 
279
- Scope.global.scoped { scope =>
280
- import scope.*
281
-
282
- val service = allocate(serviceResource)
283
-
284
- $(service)(_.createUser("Alice"))
285
- }
385
+ serviceResource.use(_.createUser("Alice"))
286
386
  // Cleanup runs LIFO: UserService → Database (UserRepo has no cleanup)
287
387
  ```
288
388
 
@@ -342,7 +442,7 @@ Generating documentation, README files, or any Markdown content programmatically
342
442
  ### Installation
343
443
 
344
444
  ```scala
345
- libraryDependencies += "dev.zio" %% "zio-blocks-docs" % "0.0.33"
445
+ libraryDependencies += "dev.zio" %% "zio-blocks-docs" % "0.0.51"
346
446
  ```
347
447
 
348
448
  ### Example
@@ -426,7 +526,7 @@ Compile-time type identity with rich metadata. TypeId captures comprehensive inf
426
526
  ### Installation
427
527
 
428
528
  ```scala
429
- libraryDependencies += "dev.zio" %% "zio-blocks-typeid" % "0.0.33"
529
+ libraryDependencies += "dev.zio" %% "zio-blocks-typeid" % "0.0.51"
430
530
  ```
431
531
 
432
532
  ### Example
@@ -469,7 +569,7 @@ A type-indexed heterogeneous collection that stores values by their types with c
469
569
  ### Installation
470
570
 
471
571
  ```scala
472
- libraryDependencies += "dev.zio" %% "zio-blocks-context" % "0.0.33"
572
+ libraryDependencies += "dev.zio" %% "zio-blocks-context" % "0.0.51"
473
573
  ```
474
574
 
475
575
  ### Example
@@ -521,7 +621,7 @@ Standard `java.util.concurrent` queues use node allocation (`ConcurrentLinkedQue
521
621
  ### Installation
522
622
 
523
623
  ```scala
524
- libraryDependencies += "dev.zio" %% "zio-blocks-ringbuffer" % "0.0.33"
624
+ libraryDependencies += "dev.zio" %% "zio-blocks-ringbuffer" % "0.0.51"
525
625
  ```
526
626
 
527
627
  ### Example
@@ -542,6 +642,75 @@ mpmc.take() // null if empty
542
642
 
543
643
  ---
544
644
 
645
+ ## SQL
646
+
647
+ A thin, type-safe JDBC wrapper that maps Scala case classes to database tables using the same `Schema` you use for JSON and Avro codecs. No ORM runtime, no code generation — just composable SQL fragments, a derived repository abstraction, and a direct ZIO integration.
648
+
649
+ ### The Problem
650
+
651
+ JDBC is powerful but tedious: manual `ResultSet` traversal, index-based parameter binding, and repetitive CRUD boilerplate make even simple database access error-prone. ORMs solve the boilerplate but add heavy runtimes, hidden queries, and opaque magic.
652
+
653
+ ### The Solution
654
+
655
+ ZIO Blocks SQL derives everything from a single `Schema[A]`:
656
+
657
+ ```scala
658
+ case class User(id: Long, name: String, email: String)
659
+ object User:
660
+ given Schema[User] = Schema.derived
661
+
662
+ // Derive the table, codec, and repository in one line
663
+ val repo = Repo.derived[User, Long]
664
+
665
+ // Use the sql"..." interpolator for custom queries
666
+ val frag = sql"SELECT * FROM user WHERE email = ${"alice@example.com"}"
667
+ ```
668
+
669
+ ### Key Features
670
+
671
+ - **Schema-derived codecs**: `DbCodec[A]` is auto-derived from `Schema[A]` — column names, types, and nullability come for free.
672
+ - **Composable fragments**: The `sql"..."` interpolator creates `Frag` values that compose safely with `++`. SQL injection is structurally impossible.
673
+ - **CRUD repository**: `Repo[E, ID]` provides `all`, `find`, `findAll`, `insert`, `insertAll`, `update`, `delete`, `deleteAll`, and `clear` out of the box.
674
+ - **DDL generation**: `Table.createTable(dialect)` generates type-accurate `CREATE TABLE IF NOT EXISTS` SQL from the schema.
675
+ - **ZIO integration**: `TransactorZIO` lifts blocking JDBC calls into `Task` (or `ZIO`) with proper bracketing and rollback.
676
+ - **Effect-system agnostic core**: The `zio-blocks-sql` module has no ZIO dependency — use it with any effect system or plain Scala.
677
+
678
+ ### Installation
679
+
680
+ ```scala
681
+ // Core module (Scala 3, JVM + Scala.js)
682
+ libraryDependencies += "dev.zio" %% "zio-blocks-sql" % "0.0.51"
683
+
684
+ // ZIO integration (Scala 3, JVM only)
685
+ libraryDependencies += "dev.zio" %% "zio-blocks-sql-zio" % "0.0.51"
686
+ ```
687
+
688
+ ### Example
689
+
690
+ ```scala
691
+ import zio.blocks.schema._
692
+ import zio.blocks.sql._
693
+ import zio.blocks.sql.zio._
694
+
695
+ case class Product(id: Long, name: String, price: Double)
696
+ object Product:
697
+ given Schema[Product] = Schema.derived
698
+ given DbCodec[Product] = summon[Schema[Product]].deriving(DbCodecDeriver).derive
699
+
700
+ val repo = Repo.derived[Product, Long]
701
+ val transactor = TransactorZIO.fromUrl("jdbc:postgresql://localhost/shop", SqlDialect.PostgreSQL)
702
+
703
+ // Batch insert, then query with a custom filter
704
+ val program = transactor.transact:
705
+ repo.insertAll(List(
706
+ Product(1L, "Widget", 9.99),
707
+ Product(2L, "Gadget", 29.99)
708
+ ))
709
+ sql"SELECT * FROM product WHERE price < ${15.0}".query[Product]
710
+ ```
711
+
712
+ ---
713
+
545
714
  ## Streams (In Development)
546
715
 
547
716
  A pull-based streaming library for composable, backpressure-aware data processing.
@@ -555,6 +724,46 @@ import zio.blocks.streams._
555
724
 
556
725
  ---
557
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"`).
764
+
765
+ ---
766
+
558
767
  ## Compatibility
559
768
 
560
769
  ZIO Blocks works with any Scala stack:
@@ -574,63 +783,96 @@ Each block has zero dependencies on effect systems. Use the blocks directly, or
574
783
 
575
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.
576
785
 
577
- | Platform | Schema | Chunk | Scope | Docs | TypeId | Context | Ring Buffer | Streams |
578
- |----------|--------|-------|-------|------|--------|---------|-------------|---------|
579
- | JVM | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
580
- | Scala.js | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
786
+ | Platform | Schema | Chunk | Scope | Docs | TypeId | Context | Ring Buffer | Streams | SQL | Async |
787
+ |----------|--------|-------|-------|------|--------|---------|-------------|---------|-----|-------|
788
+ | JVM | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | ✅ | ✅ |
789
+ | Scala.js | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | ✅ | ✅ |
581
790
 
582
791
  ## Documentation
583
792
 
584
793
  ### Core Schema Concepts
585
794
 
586
- - [Schema](./reference/schema.md) - Core schema definitions and derivation
587
- - [Allows](./reference/allows.md) - Compile-time structural grammar constraints
588
- - [Reflect](./reference/reflect.md) - Structural reflection API
589
- - [Binding](./reference/binding.md) - Runtime constructors and deconstructors
590
- - [BindingResolver](./reference/binding-resolver.md) - Binding lookup and schema rebinding
591
- - [Registers](./reference/registers.md) - Register-based primitive storage
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
592
801
 
593
802
  ### Optics & Navigation
594
803
 
595
- - [Optics](./reference/optics.md) - Lenses, prisms, and traversals
596
- - [SchemaExpr](./reference/schema-expr.md) - Schema-aware expressions for queries and validation
597
- - [Path Interpolator](./path-interpolator.md) - Type-safe path construction
598
- - [DynamicValue](./reference/dynamic-value.md) - Schema-less dynamic values
599
- - [DynamicSchema](./reference/dynamic-schema.md) - Type-erased schemas for validation and cross-process transport
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
600
809
 
601
810
  ### Serialization
602
811
 
603
- - [Codec & Format](./reference/codec.md) - Codec, Format, BinaryCodec & TextCodec
604
- - [JSON](./reference/json.md) - JSON codec and parsing
605
- - [JsonPatch](./reference/json-patch.md) - Diff and patch JSON values
606
- - [JsonDiffer](./reference/json-differ.md) - Compute minimal diffs between JSON values
607
- - [JSON Schema](./reference/json-schema.md) - JSON Schema generation and validation
608
- - [Formats](./reference/formats.md) - Avro, TOON, MessagePack, BSON, Thrift
609
- - [Extension Syntax](./reference/syntax.md) - `.toJson`, `.fromJson`, and more
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
610
827
 
611
828
  ### Data Operations
612
829
 
613
- - [Patching](./reference/patch.md) - Serializable data transformations
614
- - [SchemaError](./reference/schema-error.md) - Structured error type for schema operations
615
- - [Validation](./reference/validation.md) - Data validation and error handling
616
- - [Schema Evolution](./reference/schema-evolution/index.md) - One-way and bidirectional type-safe conversions
617
- - [Into](./reference/schema-evolution/into.md) - One-way conversion with validation
618
- - [As](./reference/schema-evolution/as.md) - Bidirectional round-trip conversion
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
619
836
 
620
837
  ### Other Blocks
621
838
 
622
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
623
842
  - [Scope](./reference/resource-management/scope.md) - Compile-time safe resource management and DI
624
843
  - [Wire](./reference/resource-management/wire.md) - Recipes for constructing services and dependencies
625
844
  - [TypeId](./reference/typeid.md) - Type identity and metadata
626
845
  - [Context](./reference/context.md) - Type-indexed heterogeneous collections
846
+ - [Combinators](./reference/combinators.md) - Compile-time composition and decomposition of values (Tuples, Eithers, Unions)
627
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
628
852
  - [MediaType](./reference/media-type.md) - Type-safe IANA media types
629
- - [HTTP Model](./reference/http-model.md) - Pure HTTP data model with URL parsing, headers, cookies, and forms
630
- - [Ring Buffer](./ringbuffer.md) - High-performance bounded ring buffers
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`
631
872
 
632
873
  ### Guides
633
874
 
875
+ - [Getting Started with Mux](./guides/getting-started-with-mux.md) - Learn how to manage multiplexed bidirectional message streams with capacity limits
634
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
635
877
  - [Query DSL Part 1: Expressions](./guides/query-dsl-reified-optics.md) - Build type-safe, composable query expressions
636
878
  - [Query DSL Part 2: SQL Generation](./guides/query-dsl-sql.md) - Translate query expressions into SQL
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@zio.dev/zio-blocks",
3
3
  "description": "ZIO Blocks Documentation",
4
4
  "license": "Apache-2.0",
5
- "version": "0.0.33",
5
+ "version": "0.0.51",
6
6
  "repository": {
7
7
  "url": "https://github.com/zio/zio-blocks"
8
8
  }