@zio.dev/zio-blocks 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/guides/query-dsl-extending.md +1 -1
- package/guides/query-dsl-fluent-builder.md +1 -1
- package/guides/query-dsl-reified-optics.md +1 -1
- package/guides/query-dsl-sql.md +1 -1
- package/guides/zio-schema-migration.md +6 -6
- package/index.md +13 -13
- package/package.json +1 -1
- package/reference/codec.md +10 -10
- package/reference/context.md +1 -1
- package/reference/docs.md +1 -1
- package/reference/dynamic-schema.md +7 -7
- package/reference/json-patch.md +2 -2
- package/reference/media-type.md +2 -2
- package/reference/resource-management/resource.md +2 -2
- package/reference/resource-management/scope.md +1 -1
- package/reference/resource-management/wire.md +2 -2
- package/reference/schema-evolution/as.md +7 -7
- package/reference/schema-evolution/into.md +7 -7
- package/reference/schema-expr.md +2 -2
- package/reference/schema.md +1 -1
- package/reference/type-class-derivation.md +1 -1
- package/reference/typeid.md +2936 -583
- package/reference/xml.md +21 -183
- package/ringbuffer.md +1 -1
- package/superpowers/plans/2026-03-19-docs-critique-subagent.md +407 -0
- package/superpowers/specs/2026-03-19-docs-critique-subagent-design.md +222 -0
|
@@ -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.
|
|
55
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
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.
|
|
60
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
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.
|
|
46
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
```scala
|
package/guides/query-dsl-sql.md
CHANGED
|
@@ -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.
|
|
46
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
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.
|
|
41
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
42
42
|
// Optional codec modules:
|
|
43
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.
|
|
44
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.
|
|
45
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.
|
|
46
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.
|
|
47
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.
|
|
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"
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
Key points:
|
package/index.md
CHANGED
|
@@ -5,7 +5,7 @@ title: "ZIO Blocks"
|
|
|
5
5
|
|
|
6
6
|
**Modular, zero-dependency building blocks for modern Scala applications.**
|
|
7
7
|
|
|
8
|
-
[](https://github.com/zio/zio/wiki/Project-Stages)  [](https://github.com/zio/zio/wiki/Project-Stages)  [](https://github.com/zio/zio-blocks)
|
|
9
9
|
|
|
10
10
|
## What Is ZIO Blocks?
|
|
11
11
|
|
|
@@ -82,14 +82,14 @@ val thriftCodec = Schema[Person].derive(ThriftFormat) // Thrift
|
|
|
82
82
|
### Installation
|
|
83
83
|
|
|
84
84
|
```scala
|
|
85
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.
|
|
85
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
86
86
|
|
|
87
87
|
// Optional format modules:
|
|
88
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.
|
|
89
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.
|
|
90
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.
|
|
91
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.
|
|
92
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.
|
|
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"
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
### Example: Optics
|
|
@@ -144,7 +144,7 @@ Chunk is designed for:
|
|
|
144
144
|
### Installation
|
|
145
145
|
|
|
146
146
|
```scala
|
|
147
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-chunk" % "0.0.
|
|
147
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-chunk" % "0.0.33"
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
### Example
|
|
@@ -233,7 +233,7 @@ Scope.global.scoped { scope =>
|
|
|
233
233
|
### Installation
|
|
234
234
|
|
|
235
235
|
```scala
|
|
236
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.
|
|
236
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.33"
|
|
237
237
|
```
|
|
238
238
|
|
|
239
239
|
### Example: Basic Resource Management
|
|
@@ -342,7 +342,7 @@ Generating documentation, README files, or any Markdown content programmatically
|
|
|
342
342
|
### Installation
|
|
343
343
|
|
|
344
344
|
```scala
|
|
345
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-docs" % "0.0.
|
|
345
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-docs" % "0.0.33"
|
|
346
346
|
```
|
|
347
347
|
|
|
348
348
|
### Example
|
|
@@ -426,7 +426,7 @@ Compile-time type identity with rich metadata. TypeId captures comprehensive inf
|
|
|
426
426
|
### Installation
|
|
427
427
|
|
|
428
428
|
```scala
|
|
429
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-typeid" % "0.0.
|
|
429
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-typeid" % "0.0.33"
|
|
430
430
|
```
|
|
431
431
|
|
|
432
432
|
### Example
|
|
@@ -469,7 +469,7 @@ A type-indexed heterogeneous collection that stores values by their types with c
|
|
|
469
469
|
### Installation
|
|
470
470
|
|
|
471
471
|
```scala
|
|
472
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-context" % "0.0.
|
|
472
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-context" % "0.0.33"
|
|
473
473
|
```
|
|
474
474
|
|
|
475
475
|
### Example
|
|
@@ -521,7 +521,7 @@ Standard `java.util.concurrent` queues use node allocation (`ConcurrentLinkedQue
|
|
|
521
521
|
### Installation
|
|
522
522
|
|
|
523
523
|
```scala
|
|
524
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-ringbuffer" % "0.0.
|
|
524
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-ringbuffer" % "0.0.33"
|
|
525
525
|
```
|
|
526
526
|
|
|
527
527
|
### Example
|
package/package.json
CHANGED
package/reference/codec.md
CHANGED
|
@@ -48,26 +48,26 @@ val result: Either[SchemaError, Person] = Person.codec.decode(bytes)
|
|
|
48
48
|
To include the base schema module with JSON support, add the following dependency to your `build.sbt`:
|
|
49
49
|
|
|
50
50
|
```scala
|
|
51
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.
|
|
51
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
Additional format modules are separate artifacts:
|
|
55
55
|
|
|
56
56
|
```scala
|
|
57
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.
|
|
58
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.
|
|
59
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-csv" % "0.0.
|
|
60
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.
|
|
61
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.
|
|
62
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.
|
|
63
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-xml" % "0.0.
|
|
64
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema-yaml" % "0.0.
|
|
57
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema-avro" % "0.0.33"
|
|
58
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema-bson" % "0.0.33"
|
|
59
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema-csv" % "0.0.33"
|
|
60
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema-messagepack" % "0.0.33"
|
|
61
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema-thrift" % "0.0.33"
|
|
62
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema-toon" % "0.0.33"
|
|
63
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema-xml" % "0.0.33"
|
|
64
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema-yaml" % "0.0.33"
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
For cross-platform projects (Scala.js):
|
|
68
68
|
|
|
69
69
|
```scala
|
|
70
|
-
libraryDependencies += "dev.zio" %%% "zio-blocks-schema" % "0.0.
|
|
70
|
+
libraryDependencies += "dev.zio" %%% "zio-blocks-schema" % "0.0.33"
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
Supported Scala versions: 2.13.x and 3.x.
|
package/reference/context.md
CHANGED
|
@@ -116,7 +116,7 @@ val config = ctx.get[Config] // Compile-time proof it exists
|
|
|
116
116
|
Add the ZIO Blocks Context module to your `build.sbt`:
|
|
117
117
|
|
|
118
118
|
```scala
|
|
119
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-context" % "0.0.
|
|
119
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-context" % "0.0.33"
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
## Construction
|
package/reference/docs.md
CHANGED
|
@@ -10,7 +10,7 @@ Complete API reference for the zio-blocks-docs module - a zero-dependency GitHub
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
12
|
```scala
|
|
13
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-docs" % "0.0.
|
|
13
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-docs" % "0.0.33"
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Core Types
|
|
@@ -77,13 +77,13 @@ We can inspect the schema's structure by printing it:
|
|
|
77
77
|
dynamic
|
|
78
78
|
// res1: DynamicSchema = DynamicSchema(
|
|
79
79
|
// Record(
|
|
80
|
-
// fields =
|
|
80
|
+
// fields = IndexedSeq(
|
|
81
81
|
// Term(
|
|
82
82
|
// name = "name",
|
|
83
83
|
// value = Primitive(
|
|
84
84
|
// primitiveType = String(None),
|
|
85
85
|
// typeId = String,
|
|
86
|
-
// primitiveBinding = zio.blocks.schema.binding.NoBinding$$anon$1@
|
|
86
|
+
// primitiveBinding = zio.blocks.schema.binding.NoBinding$$anon$1@5ca5d848,
|
|
87
87
|
// doc = Doc(blocks = IndexedSeq(), metadata = Map()),
|
|
88
88
|
// modifiers = List(),
|
|
89
89
|
// storedDefaultValue = None,
|
|
@@ -97,7 +97,7 @@ dynamic
|
|
|
97
97
|
// value = Primitive(
|
|
98
98
|
// primitiveType = Int(None),
|
|
99
99
|
// typeId = Int,
|
|
100
|
-
// primitiveBinding = zio.blocks.schema.binding.NoBinding$$anon$1@
|
|
100
|
+
// primitiveBinding = zio.blocks.schema.binding.NoBinding$$anon$1@5ca5d848,
|
|
101
101
|
// doc = Doc(blocks = IndexedSeq(), metadata = Map()),
|
|
102
102
|
// modifiers = List(),
|
|
103
103
|
// storedDefaultValue = None,
|
|
@@ -109,13 +109,13 @@ dynamic
|
|
|
109
109
|
// Term(
|
|
110
110
|
// name = "address",
|
|
111
111
|
// value = Record(
|
|
112
|
-
// fields =
|
|
112
|
+
// fields = IndexedSeq(
|
|
113
113
|
// Term(
|
|
114
114
|
// name = "street",
|
|
115
115
|
// value = Primitive(
|
|
116
116
|
// primitiveType = String(None),
|
|
117
117
|
// typeId = String,
|
|
118
|
-
// primitiveBinding = zio.blocks.schema.binding.NoBinding$$anon$1@
|
|
118
|
+
// primitiveBinding = zio.blocks.schema.binding.NoBinding$$anon$1@5ca5d848,
|
|
119
119
|
// doc = Doc(blocks = IndexedSeq(), metadata = Map()),
|
|
120
120
|
// modifiers = List(),
|
|
121
121
|
// storedDefaultValue = None,
|
|
@@ -232,7 +232,7 @@ dynSchema.check(valid)
|
|
|
232
232
|
dynSchema.check(missing)
|
|
233
233
|
// res8: Option[SchemaError] = Some(
|
|
234
234
|
// SchemaError(
|
|
235
|
-
// List(MissingField(source = DynamicOptic(
|
|
235
|
+
// List(MissingField(source = DynamicOptic(IndexedSeq()), fieldName = "y"))
|
|
236
236
|
// )
|
|
237
237
|
// )
|
|
238
238
|
dynSchema.check(wrongType)
|
|
@@ -240,7 +240,7 @@ dynSchema.check(wrongType)
|
|
|
240
240
|
// SchemaError(
|
|
241
241
|
// List(
|
|
242
242
|
// ExpectationMismatch(
|
|
243
|
-
// source = DynamicOptic(
|
|
243
|
+
// source = DynamicOptic(IndexedSeq(Field("y"))),
|
|
244
244
|
// expectation = "Expected Int, got String"
|
|
245
245
|
// )
|
|
246
246
|
// )
|
package/reference/json-patch.md
CHANGED
|
@@ -386,7 +386,7 @@ modeJson.patch(modePatch, PatchMode.Strict)
|
|
|
386
386
|
// SchemaError(
|
|
387
387
|
// List(
|
|
388
388
|
// ExpectationMismatch(
|
|
389
|
-
// source = DynamicOptic(
|
|
389
|
+
// source = DynamicOptic(IndexedSeq()),
|
|
390
390
|
// expectation = "Key 'a' already exists in object"
|
|
391
391
|
// )
|
|
392
392
|
// )
|
|
@@ -723,7 +723,7 @@ fieldPatch.apply(doc)
|
|
|
723
723
|
// res40: Either[SchemaError, Json] = Left(
|
|
724
724
|
// SchemaError(
|
|
725
725
|
// List(
|
|
726
|
-
// MissingField(source = DynamicOptic(
|
|
726
|
+
// MissingField(source = DynamicOptic(IndexedSeq()), fieldName = "updatedAt")
|
|
727
727
|
// )
|
|
728
728
|
// )
|
|
729
729
|
// )
|
package/reference/media-type.md
CHANGED
|
@@ -75,13 +75,13 @@ textAny.matches(html) // true
|
|
|
75
75
|
Add the following to your `build.sbt`:
|
|
76
76
|
|
|
77
77
|
```scala
|
|
78
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-mediatype" % "0.0.
|
|
78
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-mediatype" % "0.0.33"
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
For cross-platform projects (Scala.js):
|
|
82
82
|
|
|
83
83
|
```scala
|
|
84
|
-
libraryDependencies += "dev.zio" %%% "zio-blocks-mediatype" % "0.0.
|
|
84
|
+
libraryDependencies += "dev.zio" %%% "zio-blocks-mediatype" % "0.0.33"
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
Supported Scala versions: 2.13.x and 3.x.
|
|
@@ -36,13 +36,13 @@ Without Resources, managing complex initialization and cleanup is tedious and er
|
|
|
36
36
|
Add the ZIO Blocks Scope module to your `build.sbt`:
|
|
37
37
|
|
|
38
38
|
```scala
|
|
39
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.
|
|
39
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.33"
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
For cross-platform (Scala.js):
|
|
43
43
|
|
|
44
44
|
```scala
|
|
45
|
-
libraryDependencies += "dev.zio" %%% "zio-blocks-scope" % "0.0.
|
|
45
|
+
libraryDependencies += "dev.zio" %%% "zio-blocks-scope" % "0.0.33"
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Supported Scala versions: 2.13.x and 3.x.
|
|
@@ -55,7 +55,7 @@ If you've used `try/finally`, `Using`, or ZIO's `Scope`, this is the same proble
|
|
|
55
55
|
Add the following dependency to your `build.sbt`:
|
|
56
56
|
|
|
57
57
|
```scala
|
|
58
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.
|
|
58
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.33"
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
Supported Scala versions: **2.13.x** and **3.x**.
|
|
@@ -92,13 +92,13 @@ Scope.global.scoped { scope =>
|
|
|
92
92
|
Add the following dependency to your `build.sbt`:
|
|
93
93
|
|
|
94
94
|
```scala
|
|
95
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.
|
|
95
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-scope" % "0.0.33"
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
For cross-platform (Scala.js):
|
|
99
99
|
|
|
100
100
|
```scala
|
|
101
|
-
libraryDependencies += "dev.zio" %%% "zio-blocks-scope" % "0.0.
|
|
101
|
+
libraryDependencies += "dev.zio" %%% "zio-blocks-scope" % "0.0.33"
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
Supported Scala versions: 2.13.x and 3.x.
|
|
@@ -39,13 +39,13 @@ The bidirectional data flow looks like this:
|
|
|
39
39
|
`As` is part of `zio-blocks-schema`:
|
|
40
40
|
|
|
41
41
|
```scala
|
|
42
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.
|
|
42
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
For Scala.js and Scala Native, use `%%%`:
|
|
46
46
|
|
|
47
47
|
```scala
|
|
48
|
-
libraryDependencies += "dev.zio" %%% "zio-blocks-schema" % "0.0.
|
|
48
|
+
libraryDependencies += "dev.zio" %%% "zio-blocks-schema" % "0.0.33"
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
Supported Scala versions: 2.13.x and 3.x.
|
|
@@ -89,7 +89,7 @@ manualAs.from(Long.MaxValue)
|
|
|
89
89
|
// SchemaError(
|
|
90
90
|
// List(
|
|
91
91
|
// ConversionFailed(
|
|
92
|
-
// source = DynamicOptic(
|
|
92
|
+
// source = DynamicOptic(IndexedSeq()),
|
|
93
93
|
// details = "overflow",
|
|
94
94
|
// cause = None
|
|
95
95
|
// )
|
|
@@ -213,7 +213,7 @@ boxAs.from(LongBox(Long.MaxValue))
|
|
|
213
213
|
// SchemaError(
|
|
214
214
|
// List(
|
|
215
215
|
// ConversionFailed(
|
|
216
|
-
// source = DynamicOptic(
|
|
216
|
+
// source = DynamicOptic(IndexedSeq()),
|
|
217
217
|
// details = "Value 9223372036854775807 is out of range for Int [-2147483648, 2147483647]",
|
|
218
218
|
// cause = None
|
|
219
219
|
// )
|
|
@@ -240,7 +240,7 @@ trait As[A, B] {
|
|
|
240
240
|
|
|
241
241
|
```scala
|
|
242
242
|
val revAs: As[LongBox, IntBox] = boxAs.reverse
|
|
243
|
-
// revAs: As[LongBox, IntBox] = zio.blocks.schema.As$$anon$1@
|
|
243
|
+
// revAs: As[LongBox, IntBox] = zio.blocks.schema.As$$anon$1@6145661b
|
|
244
244
|
|
|
245
245
|
revAs.into(LongBox(5L))
|
|
246
246
|
// res11: Either[SchemaError, IntBox] = Right(IntBox(5))
|
|
@@ -302,7 +302,7 @@ We import `As.reverseInto` and use it to obtain the reverse `Into[Int, String]`:
|
|
|
302
302
|
import As.reverseInto
|
|
303
303
|
|
|
304
304
|
val intToStr: Into[Int, String] = reverseInto[String, Int]
|
|
305
|
-
// intToStr: Into[Int, String] = zio.blocks.schema.AsLowPriorityImplicits$$Lambda$
|
|
305
|
+
// intToStr: Into[Int, String] = zio.blocks.schema.AsLowPriorityImplicits$$Lambda$17549/0x00007faac29bf110@e1a6316
|
|
306
306
|
intToStr.into(42)
|
|
307
307
|
// res14: Either[SchemaError, String] = Right("42")
|
|
308
308
|
```
|
|
@@ -387,7 +387,7 @@ numericAs.from(LongModel(Long.MaxValue))
|
|
|
387
387
|
// SchemaError(
|
|
388
388
|
// List(
|
|
389
389
|
// ConversionFailed(
|
|
390
|
-
// source = DynamicOptic(
|
|
390
|
+
// source = DynamicOptic(IndexedSeq()),
|
|
391
391
|
// details = "Value 9223372036854775807 is out of range for Int [-2147483648, 2147483647]",
|
|
392
392
|
// cause = None
|
|
393
393
|
// )
|
|
@@ -69,13 +69,13 @@ Compare this to a manual implementation:
|
|
|
69
69
|
`Into` is part of the `zio-blocks-schema` module:
|
|
70
70
|
|
|
71
71
|
```scala
|
|
72
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.
|
|
72
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
For Scala.js:
|
|
76
76
|
|
|
77
77
|
```scala
|
|
78
|
-
libraryDependencies += "dev.zio" %%% "zio-blocks-schema" % "0.0.
|
|
78
|
+
libraryDependencies += "dev.zio" %%% "zio-blocks-schema" % "0.0.33"
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
Supported Scala versions: 2.13.x and 3.x.
|
|
@@ -241,7 +241,7 @@ Into[Long, Int].into(Long.MaxValue)
|
|
|
241
241
|
// SchemaError(
|
|
242
242
|
// List(
|
|
243
243
|
// ConversionFailed(
|
|
244
|
-
// source = DynamicOptic(
|
|
244
|
+
// source = DynamicOptic(IndexedSeq()),
|
|
245
245
|
// details = "Value 9223372036854775807 is out of range for Int [-2147483648, 2147483647]",
|
|
246
246
|
// cause = None
|
|
247
247
|
// )
|
|
@@ -253,7 +253,7 @@ Into[Double, Int].into(3.14)
|
|
|
253
253
|
// SchemaError(
|
|
254
254
|
// List(
|
|
255
255
|
// ConversionFailed(
|
|
256
|
-
// source = DynamicOptic(
|
|
256
|
+
// source = DynamicOptic(IndexedSeq()),
|
|
257
257
|
// details = "Value 3.14 cannot be precisely converted to Int",
|
|
258
258
|
// cause = None
|
|
259
259
|
// )
|
|
@@ -399,7 +399,7 @@ conv.into(Raw(Long.MaxValue))
|
|
|
399
399
|
// SchemaError(
|
|
400
400
|
// List(
|
|
401
401
|
// ConversionFailed(
|
|
402
|
-
// source = DynamicOptic(
|
|
402
|
+
// source = DynamicOptic(IndexedSeq()),
|
|
403
403
|
// details = "Value 9223372036854775807 is out of range for Int [-2147483648, 2147483647]",
|
|
404
404
|
// cause = None
|
|
405
405
|
// )
|
|
@@ -623,7 +623,7 @@ validate.into(PersonRaw("Bob", 200))
|
|
|
623
623
|
// SchemaError(
|
|
624
624
|
// List(
|
|
625
625
|
// ConversionFailed(
|
|
626
|
-
// source = DynamicOptic(
|
|
626
|
+
// source = DynamicOptic(IndexedSeq()),
|
|
627
627
|
// details = "Validation failed for field 'age': NonEmptyChunk(200 did not satisfy between(0, 150))",
|
|
628
628
|
// cause = None
|
|
629
629
|
// )
|
|
@@ -854,7 +854,7 @@ result
|
|
|
854
854
|
// SchemaError(
|
|
855
855
|
// List(
|
|
856
856
|
// ExpectationMismatch(
|
|
857
|
-
// source = DynamicOptic(
|
|
857
|
+
// source = DynamicOptic(IndexedSeq()),
|
|
858
858
|
// expectation = "Expected a record"
|
|
859
859
|
// )
|
|
860
860
|
// )
|
package/reference/schema-expr.md
CHANGED
|
@@ -70,13 +70,13 @@ val result: Either[OpticCheck, Seq[Boolean]] = combined.eval(alice)
|
|
|
70
70
|
## Installation
|
|
71
71
|
|
|
72
72
|
```scala
|
|
73
|
-
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.
|
|
73
|
+
libraryDependencies += "dev.zio" %% "zio-blocks-schema" % "0.0.33"
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
For cross-platform (Scala.js):
|
|
77
77
|
|
|
78
78
|
```scala
|
|
79
|
-
libraryDependencies += "dev.zio" %%% "zio-blocks-schema" % "0.0.
|
|
79
|
+
libraryDependencies += "dev.zio" %%% "zio-blocks-schema" % "0.0.33"
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
Supported Scala versions: 2.13.x and 3.x.
|
package/reference/schema.md
CHANGED
|
@@ -588,7 +588,7 @@ ZIO Blocks provides the `transform` method for creating schemas for wrapper type
|
|
|
588
588
|
|
|
589
589
|
```scala
|
|
590
590
|
final case class Schema[A](reflect: Reflect.Bound[A]) {
|
|
591
|
-
def transform[B](to: A => B, from: B => A): Schema[B] = ???
|
|
591
|
+
def transform[B](to: A => B, from: B => A)(implicit typeId: TypeId[B]): Schema[B] = ???
|
|
592
592
|
}
|
|
593
593
|
```
|
|
594
594
|
|
|
@@ -1455,7 +1455,7 @@ Now we can use the derived `Gen[Person]` instance to generate random `Person` va
|
|
|
1455
1455
|
|
|
1456
1456
|
```scala
|
|
1457
1457
|
val random = new Random(42) // Seeded for reproducible output
|
|
1458
|
-
// random: Random = scala.util.Random@
|
|
1458
|
+
// random: Random = scala.util.Random@643bb7d2
|
|
1459
1459
|
|
|
1460
1460
|
Person.gen.generate(random)
|
|
1461
1461
|
// res14: Person = Person(name = "p", age = -1360544799)
|