@zio.dev/zio-blocks 0.0.27 → 0.0.29

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 (38) hide show
  1. package/guides/query-dsl-extending.md +1 -1
  2. package/guides/query-dsl-fluent-builder.md +1 -1
  3. package/guides/query-dsl-reified-optics.md +1 -1
  4. package/guides/query-dsl-sql.md +1 -1
  5. package/guides/zio-schema-migration.md +6 -6
  6. package/index.md +69 -17
  7. package/package.json +1 -1
  8. package/path-interpolator.md +70 -9
  9. package/reference/allows.md +1155 -34
  10. package/reference/binding-resolver.md +469 -0
  11. package/reference/binding.md +1 -1
  12. package/reference/codec.md +8 -8
  13. package/reference/combinators.md +345 -0
  14. package/reference/context.md +639 -67
  15. package/reference/docs.md +1 -1
  16. package/reference/dynamic-optic.md +5 -0
  17. package/reference/dynamic-schema.md +602 -0
  18. package/reference/dynamic-value.md +5 -0
  19. package/reference/http-model.md +1716 -0
  20. package/reference/json-differ.md +320 -0
  21. package/reference/json-patch.md +803 -0
  22. package/reference/json.md +1 -1
  23. package/reference/media-type.md +2 -2
  24. package/reference/patch.md +4 -0
  25. package/reference/resource-management-di/index.md +49 -0
  26. package/reference/resource-management-di/resource.md +1125 -0
  27. package/{scope.md → reference/resource-management-di/scope.md} +92 -10
  28. package/reference/resource-management-di/wire.md +832 -0
  29. package/reference/schema-evolution/as.md +587 -0
  30. package/reference/schema-evolution/index.md +50 -0
  31. package/reference/schema-evolution/into.md +1027 -0
  32. package/reference/schema-expr.md +2 -2
  33. package/reference/structural-types.md +369 -0
  34. package/reference/type-class-derivation.md +31 -31
  35. package/reference/xml.md +606 -45
  36. package/ringbuffer.md +249 -0
  37. package/sidebars.js +31 -1
  38. package/reference/schema-evolution.md +0 -540
@@ -52,7 +52,7 @@ Since `SchemaExpr` is a sealed trait, you cannot add new cases to it. Instead, w
52
52
  This guide builds on [Part 1: Expressions](./query-dsl-reified-optics.md) and [Part 2: SQL Generation](./query-dsl-sql.md). You should be comfortable building `SchemaExpr` values and translating them to SQL.
53
53
 
54
54
  ```scala
55
- libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.27"
55
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.29"
56
56
  ```
57
57
 
58
58
  ```scala
@@ -57,7 +57,7 @@ In this guide, we solve both problems: bridge extensions eliminate `.toExpr`, an
57
57
  This guide builds on [Part 1: Expressions](./query-dsl-reified-optics.md), [Part 2: SQL Generation](./query-dsl-sql.md), and [Part 3: Extending the Expression Language](./query-dsl-extending.md).
58
58
 
59
59
  ```scala
60
- libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.27"
60
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.29"
61
61
  ```
62
62
 
63
63
  ## Domain Setup
@@ -43,7 +43,7 @@ In this guide, we'll solve this by using ZIO Blocks' `SchemaExpr` and reified op
43
43
  Add the ZIO Blocks Schema dependency:
44
44
 
45
45
  ```scala
46
- libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.27"
46
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.29"
47
47
  ```
48
48
 
49
49
  ```scala
@@ -43,7 +43,7 @@ Since `SchemaExpr` is a sealed trait, we can write a single interpreter that tra
43
43
  This guide builds on [Part 1: Expressions](./query-dsl-reified-optics.md). You should be comfortable building `SchemaExpr` values with optic operators (`===`, `>`, `&&`, etc.).
44
44
 
45
45
  ```scala
46
- libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.27"
46
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.29"
47
47
  ```
48
48
 
49
49
  ```scala
@@ -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.27"
41
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.29"
42
42
  // Optional codec modules:
43
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.27"
44
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.27"
45
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.27"
46
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.27"
47
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.27"
43
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.29"
44
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.29"
45
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.29"
46
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.29"
47
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.29"
48
48
  ```
49
49
 
50
50
  Key points:
package/index.md CHANGED
@@ -24,6 +24,7 @@ The philosophy is simple: **use what you need, nothing more**. Each block is ind
24
24
  | **TypeId** | Compile-time type identity with rich metadata | ✅ Available |
25
25
  | **Context** | Type-indexed heterogeneous collections | ✅ Available |
26
26
  | **MediaType** | Type-safe IANA media types with 2,600+ predefined types | ✅ Available |
27
+ | **Ring Buffer** | High-performance bounded ring buffers (SPSC, MPSC, SPMC, MPMC) | ✅ Available |
27
28
  | **Streams** | Pull-based streaming primitives | 🚧 In Development |
28
29
 
29
30
  ## Core Principles
@@ -81,14 +82,14 @@ val thriftCodec = Schema[Person].derive(ThriftFormat) // Thrift
81
82
  ### Installation
82
83
 
83
84
  ```scala
84
- libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.27"
85
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.29"
85
86
 
86
87
  // Optional format modules:
87
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.27"
88
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.27"
89
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.27"
90
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.27"
91
- libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.27"
88
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.29"
89
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.29"
90
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.29"
91
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.29"
92
+ libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.29"
92
93
  ```
93
94
 
94
95
  ### Example: Optics
@@ -143,7 +144,7 @@ Chunk is designed for:
143
144
  ### Installation
144
145
 
145
146
  ```scala
146
- libraryDependencies += "dev.zio" %% "zio-blocks-chunk" % "0.0.27"
147
+ libraryDependencies += "dev.zio" %% "zio-blocks-chunk" % "0.0.29"
147
148
  ```
148
149
 
149
150
  ### Example
@@ -232,7 +233,7 @@ Scope.global.scoped { scope =>
232
233
  ### Installation
233
234
 
234
235
  ```scala
235
- libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.27"
236
+ libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.29"
236
237
  ```
237
238
 
238
239
  ### Example: Basic Resource Management
@@ -335,7 +336,7 @@ Generating documentation, README files, or any Markdown content programmatically
335
336
  ### Installation
336
337
 
337
338
  ```scala
338
- libraryDependencies += "dev.zio" %% "zio-blocks-docs" % "0.0.27"
339
+ libraryDependencies += "dev.zio" %% "zio-blocks-docs" % "0.0.29"
339
340
  ```
340
341
 
341
342
  ### Example
@@ -419,7 +420,7 @@ Compile-time type identity with rich metadata. TypeId captures comprehensive inf
419
420
  ### Installation
420
421
 
421
422
  ```scala
422
- libraryDependencies += "dev.zio" %% "zio-blocks-typeid" % "0.0.27"
423
+ libraryDependencies += "dev.zio" %% "zio-blocks-typeid" % "0.0.29"
423
424
  ```
424
425
 
425
426
  ### Example
@@ -462,7 +463,7 @@ A type-indexed heterogeneous collection that stores values by their types with c
462
463
  ### Installation
463
464
 
464
465
  ```scala
465
- libraryDependencies += "dev.zio" %% "zio-blocks-context" % "0.0.27"
466
+ libraryDependencies += "dev.zio" %% "zio-blocks-context" % "0.0.29"
466
467
  ```
467
468
 
468
469
  ### Example
@@ -494,6 +495,47 @@ val merged: Context[Config & Metrics] = ctx1 ++ ctx2
494
495
 
495
496
  ---
496
497
 
498
+ ## Ring Buffer
499
+
500
+ High-performance, bounded ring buffers for inter-thread communication. Four lock-free variants cover every producer/consumer pattern (SPSC, MPSC, SPMC, MPMC).
501
+
502
+ ### Why Ring Buffer?
503
+
504
+ Standard `java.util.concurrent` queues use node allocation (`ConcurrentLinkedQueue`) or coarse locking (`ArrayBlockingQueue`). Ring buffers avoid both:
505
+
506
+ - **Zero allocation** on the hot path—pre-allocated circular array
507
+ - **Lock-free** on the fast path—CAS or release/acquire semantics only
508
+ - **Cache-friendly**—sequential memory access with 128-byte padding between producer/consumer fields
509
+
510
+ ### Key Features
511
+
512
+ - **Four concurrency patterns**: SPSC, SPMC, MPSC, MPMC—pick the most constrained variant for your use case
513
+ - **Cross-platform**: Same API on JVM and Scala.js (JS uses sequential implementations)
514
+
515
+ ### Installation
516
+
517
+ ```scala
518
+ libraryDependencies += "dev.zio" %% "zio-blocks-ringbuffer" % "0.0.29"
519
+ ```
520
+
521
+ ### Example
522
+
523
+ ```scala
524
+ import zio.blocks.ringbuffer._
525
+
526
+ // SPSC: fastest, for dedicated producer-consumer pairs
527
+ val spsc = SpscRingBuffer[String](1024)
528
+ spsc.offer("hello") // true
529
+ spsc.take() // "hello"
530
+
531
+ // MPMC: general-purpose, any number of threads
532
+ val mpmc = MpmcRingBuffer[String](1024)
533
+ mpmc.offer("hello") // false if full
534
+ mpmc.take() // null if empty
535
+ ```
536
+
537
+ ---
538
+
497
539
  ## Streams (In Development)
498
540
 
499
541
  A pull-based streaming library for composable, backpressure-aware data processing.
@@ -526,18 +568,20 @@ Each block has zero dependencies on effect systems. Use the blocks directly, or
526
568
 
527
569
  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.
528
570
 
529
- | Platform | Schema | Chunk | Scope | Docs | TypeId | Context | Streams |
530
- |----------|--------|-------|-------|------|--------|---------|---------|
531
- | JVM | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
532
- | Scala.js | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
571
+ | Platform | Schema | Chunk | Scope | Docs | TypeId | Context | Ring Buffer | Streams |
572
+ |----------|--------|-------|-------|------|--------|---------|-------------|---------|
573
+ | JVM | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
574
+ | Scala.js | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
533
575
 
534
576
  ## Documentation
535
577
 
536
578
  ### Core Schema Concepts
537
579
 
538
580
  - [Schema](./reference/schema.md) - Core schema definitions and derivation
581
+ - [Allows](./reference/allows.md) - Compile-time structural grammar constraints
539
582
  - [Reflect](./reference/reflect.md) - Structural reflection API
540
583
  - [Binding](./reference/binding.md) - Runtime constructors and deconstructors
584
+ - [BindingResolver](./reference/binding-resolver.md) - Binding lookup and schema rebinding
541
585
  - [Registers](./reference/registers.md) - Register-based primitive storage
542
586
 
543
587
  ### Optics & Navigation
@@ -546,11 +590,14 @@ ZIO Blocks supports **Scala 2.13** and **Scala 3.x** with full source compatibil
546
590
  - [SchemaExpr](./reference/schema-expr.md) - Schema-aware expressions for queries and validation
547
591
  - [Path Interpolator](./path-interpolator.md) - Type-safe path construction
548
592
  - [DynamicValue](./reference/dynamic-value.md) - Schema-less dynamic values
593
+ - [DynamicSchema](./reference/dynamic-schema.md) - Type-erased schemas for validation and cross-process transport
549
594
 
550
595
  ### Serialization
551
596
 
552
597
  - [Codec & Format](./reference/codec.md) - Codec, Format, BinaryCodec & TextCodec
553
598
  - [JSON](./reference/json.md) - JSON codec and parsing
599
+ - [JsonPatch](./reference/json-patch.md) - Diff and patch JSON values
600
+ - [JsonDiffer](./reference/json-differ.md) - Compute minimal diffs between JSON values
554
601
  - [JSON Schema](./reference/json-schema.md) - JSON Schema generation and validation
555
602
  - [Formats](./reference/formats.md) - Avro, TOON, MessagePack, BSON, Thrift
556
603
  - [Extension Syntax](./reference/syntax.md) - `.toJson`, `.fromJson`, and more
@@ -560,16 +607,21 @@ ZIO Blocks supports **Scala 2.13** and **Scala 3.x** with full source compatibil
560
607
  - [Patching](./reference/patch.md) - Serializable data transformations
561
608
  - [SchemaError](./reference/schema-error.md) - Structured error type for schema operations
562
609
  - [Validation](./reference/validation.md) - Data validation and error handling
563
- - [Schema Evolution](./reference/schema-evolution.md) - Migration and compatibility
610
+ - [Schema Evolution](./reference/schema-evolution/index.md) - One-way and bidirectional type-safe conversions
611
+ - [Into](./reference/schema-evolution/into.md) - One-way conversion with validation
612
+ - [As](./reference/schema-evolution/as.md) - Bidirectional round-trip conversion
564
613
 
565
614
  ### Other Blocks
566
615
 
567
616
  - [Chunk](./reference/chunk.md) - High-performance immutable sequences
568
- - [Scope](./scope.md) - Compile-time safe resource management and DI
617
+ - [Scope](./reference/resource-management-di/scope.md) - Compile-time safe resource management and DI
618
+ - [Wire](./reference/resource-management-di/wire.md) - Recipes for constructing services and dependencies
569
619
  - [TypeId](./reference/typeid.md) - Type identity and metadata
570
620
  - [Context](./reference/context.md) - Type-indexed heterogeneous collections
571
621
  - [Docs (Markdown)](./reference/docs.md) - Markdown parsing and rendering
572
622
  - [MediaType](./reference/media-type.md) - Type-safe IANA media types
623
+ - [HTTP Model](./reference/http-model.md) - Pure HTTP data model with URL parsing, headers, cookies, and forms
624
+ - [Ring Buffer](./ringbuffer.md) - High-performance bounded ring buffers
573
625
 
574
626
  ### Guides
575
627
 
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.27",
5
+ "version": "0.0.29",
6
6
  "repository": {
7
7
  "url": "https://github.com/zio/zio-blocks"
8
8
  }
@@ -212,6 +212,65 @@ p"<café>" // Unicode case names
212
212
  p"<A><B><C>" // Nested variants
213
213
  ```
214
214
 
215
+ ### Schema Search
216
+
217
+ Search for values matching a schema pattern anywhere in a data structure using the `#` prefix.
218
+
219
+ **Nominal types:**
220
+
221
+ ```scala
222
+ p"#Person" // Find all values of type Person
223
+ p"#User" // Find all values of type User
224
+ p"#Address" // Find all values of type Address
225
+ ```
226
+
227
+ **Primitive types:**
228
+
229
+ ```scala
230
+ p"#string" // Find all string values
231
+ p"#int" // Find all integer values
232
+ p"#boolean" // Find all boolean values
233
+ p"#uuid" // Find all UUID values
234
+ ```
235
+
236
+ **Structural records:**
237
+
238
+ ```scala
239
+ p"#record { name: string }" // Find records with a string 'name' field
240
+ p"#record { name: string, age: int }" // Find records with both fields
241
+ p"#record { items: list(Person) }" // Nested schema
242
+ ```
243
+
244
+ **Structural variants:**
245
+
246
+ ```scala
247
+ p"#variant { Left: int, Right: string }" // Find Either-like variants
248
+ ```
249
+
250
+ **Collections:**
251
+
252
+ ```scala
253
+ p"#list(string)" // Find lists of strings
254
+ p"#list(Person)" // Find lists of Person
255
+ p"#map(string, int)" // Find maps from string to int
256
+ p"#option(Person)" // Find optional Person values
257
+ ```
258
+
259
+ **Wildcard:**
260
+
261
+ ```scala
262
+ p"#_" // Find any value (matches everything)
263
+ ```
264
+
265
+ **Combined paths with search:**
266
+
267
+ ```scala
268
+ p".users#Person" // Search for Person in users field
269
+ p"#Person.name" // Find all Person values, then get name
270
+ p".items[*]#Person.email" // Elements then search then field
271
+ p"#list(Person)#Person" // Chained searches
272
+ ```
273
+
215
274
  ## Escape Sequences
216
275
 
217
276
  String and character literals support standard escape sequences:
@@ -623,15 +682,17 @@ val same = p".users[*].email"
623
682
  |------------------------------------------------------|-------------------|
624
683
  | `DynamicOptic.root.field("name")` | `.name` |
625
684
  | `DynamicOptic.root.field("address").field("street")` | `.address.street` |
626
- | `DynamicOptic.root.caseOf("Some")` | `<Some>` |
627
- | `DynamicOptic.root.at(0)` | `[0]` |
628
- | `DynamicOptic.root.atIndices(0, 2, 5)` | `[0,2,5]` |
629
- | `DynamicOptic.elements` | `[*]` |
630
- | `DynamicOptic.root.atKey("host")` | `{"host"}` |
631
- | `DynamicOptic.root.atKey(80)` | `{80}` |
632
- | `DynamicOptic.mapValues` | `{*}` |
633
- | `DynamicOptic.mapKeys` | `{*:}` |
634
- | `DynamicOptic.wrapped` | `.~` |
685
+ | `DynamicOptic.root.caseOf("Some")` | `<Some>` |
686
+ | `DynamicOptic.root.at(0)` | `[0]` |
687
+ | `DynamicOptic.root.atIndices(0, 2, 5)` | `[0,2,5]` |
688
+ | `DynamicOptic.elements` | `[*]` |
689
+ | `DynamicOptic.root.atKey("host")` | `{"host"}` |
690
+ | `DynamicOptic.root.atKey(80)` | `{80}` |
691
+ | `DynamicOptic.mapValues` | `{*}` |
692
+ | `DynamicOptic.mapKeys` | `{*:}` |
693
+ | `DynamicOptic.wrapped` | `.~` |
694
+ | `DynamicOptic.root.searchSchema(SchemaRepr.Nominal("Person"))` | `#Person` |
695
+ | `DynamicOptic.root.searchSchema(SchemaRepr.Primitive("string"))` | `#string` |
635
696
 
636
697
  ## Summary
637
698