diff --git a/tests/shared/src/test/scala-2/zio/schema/DynamicValueGen.scala b/tests/shared/src/test/scala-2/zio/schema/DynamicValueGen.scala index f91ce9281..e489a4f32 100644 --- a/tests/shared/src/test/scala-2/zio/schema/DynamicValueGen.scala +++ b/tests/shared/src/test/scala-2/zio/schema/DynamicValueGen.scala @@ -48,36 +48,36 @@ object DynamicValueGen { //scalafmt: { maxColumn = 400 } def anyDynamicValueOfSchema[A](schema: Schema[A]): Gen[Random with Sized, DynamicValue] = schema match { - case Schema.Primitive(standardType, _) => anyPrimitiveDynamicValue(standardType) - case s: Schema.Record[A] => anyDynamicValueWithStructure(s.structure) - case Schema.Enum1(case1, _) => anyDynamicValueOfEnum(Chunk(case1)) - case Schema.Enum2(case1, case2, _) => anyDynamicValueOfEnum(Chunk(case1, case2)) - case Schema.Enum3(case1, case2, case3, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3)) - case Schema.Enum4(case1, case2, case3, case4, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4)) - case Schema.Enum5(case1, case2, case3, case4, case5, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5)) - case Schema.Enum6(case1, case2, case3, case4, case5, case6, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6)) - case Schema.Enum7(case1, case2, case3, case4, case5, case6, case7, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7)) - case Schema.Enum8(case1, case2, case3, case4, case5, case6, case7, case8, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8)) - case Schema.Enum9(case1, case2, case3, case4, case5, case6, case7, case8, case9, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9)) - case Schema.Enum10(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10)) - case Schema.Enum11(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11)) - case Schema.Enum12(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12)) - case Schema.Enum13(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13)) - case Schema.Enum14(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14)) - case Schema.Enum15(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15)) - case Schema.Enum16(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16)) - case Schema.Enum17(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17)) - case Schema.Enum18(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18)) - case Schema.Enum19(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19)) - case Schema.Enum20(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20)) - case Schema.Enum21(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21)) - case Schema.Enum22(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, case22, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, case22)) - case Schema.EnumN(cases, _) => anyDynamicValueOfEnum(Chunk.fromIterable(cases.toSeq)) - case Schema.Sequence(schema, _, _, _, _) => Gen.chunkOfBounded(0, 2)(anyDynamicValueOfSchema(schema)).map(DynamicValue.Sequence(_)) - case Schema.MapSchema(ks, vs, _) => Gen.chunkOfBounded(0, 2)(anyDynamicValueOfSchema(ks).zip(anyDynamicValueOfSchema(vs))).map(DynamicValue.Dictionary(_)) - case Schema.SetSchema(schema, _) => Gen.setOfBounded(0, 2)(anyDynamicValueOfSchema(schema)).map(DynamicValue.SetValue(_)) - case Schema.Optional(schema, _) => Gen.oneOf(anyDynamicSomeValueOfSchema(schema), Gen.const(DynamicValue.NoneValue)) - case Schema.Tuple(left, right, _) => anyDynamicTupleValue(left, right) + case Schema.Primitive(standardType, _) => anyPrimitiveDynamicValue(standardType) + case s: Schema.Record[A] => anyDynamicValueWithStructure(s.structure) + case Schema.Enum1(_, case1, _) => anyDynamicValueOfEnum(Chunk(case1)) + case Schema.Enum2(_, case1, case2, _) => anyDynamicValueOfEnum(Chunk(case1, case2)) + case Schema.Enum3(_, case1, case2, case3, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3)) + case Schema.Enum4(_, case1, case2, case3, case4, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4)) + case Schema.Enum5(_, case1, case2, case3, case4, case5, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5)) + case Schema.Enum6(_, case1, case2, case3, case4, case5, case6, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6)) + case Schema.Enum7(_, case1, case2, case3, case4, case5, case6, case7, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7)) + case Schema.Enum8(_, case1, case2, case3, case4, case5, case6, case7, case8, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8)) + case Schema.Enum9(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9)) + case Schema.Enum10(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10)) + case Schema.Enum11(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11)) + case Schema.Enum12(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12)) + case Schema.Enum13(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13)) + case Schema.Enum14(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14)) + case Schema.Enum15(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15)) + case Schema.Enum16(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16)) + case Schema.Enum17(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17)) + case Schema.Enum18(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18)) + case Schema.Enum19(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19)) + case Schema.Enum20(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20)) + case Schema.Enum21(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21)) + case Schema.Enum22(_, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, case22, _) => anyDynamicValueOfEnum(Chunk(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, case22)) + case Schema.EnumN(_, cases, _) => anyDynamicValueOfEnum(Chunk.fromIterable(cases.toSeq)) + case Schema.Sequence(schema, _, _, _, _) => Gen.chunkOfBounded(0, 2)(anyDynamicValueOfSchema(schema)).map(DynamicValue.Sequence(_)) + case Schema.MapSchema(ks, vs, _) => Gen.chunkOfBounded(0, 2)(anyDynamicValueOfSchema(ks).zip(anyDynamicValueOfSchema(vs))).map(DynamicValue.Dictionary(_)) + case Schema.SetSchema(schema, _) => Gen.setOfBounded(0, 2)(anyDynamicValueOfSchema(schema)).map(DynamicValue.SetValue(_)) + case Schema.Optional(schema, _) => Gen.oneOf(anyDynamicSomeValueOfSchema(schema), Gen.const(DynamicValue.NoneValue)) + case Schema.Tuple(left, right, _) => anyDynamicTupleValue(left, right) case Schema.EitherSchema(left, right, _) => Gen.oneOf(anyDynamicLeftValueOfSchema(left), anyDynamicRightValueOfSchema(right)) case Schema.Transform(schema, _, _, _, _) => anyDynamicValueOfSchema(schema) @@ -103,19 +103,11 @@ object DynamicValueGen { case (l, r) => DynamicValue.Tuple(l, r) } - def anyDynamicValueOfEnumeration( - structure: ListMap[String, Schema[_]] - ): Gen[Random with Sized, DynamicValue.Enumeration] = - for { - index <- Gen.int(0, structure.size - 1) - value <- anyDynamicValueOfSchema(structure.values.toSeq(index)) - } yield DynamicValue.Enumeration(structure.keys.toSeq(index) -> value) - def anyDynamicValueOfEnum[A](cases: Chunk[Schema.Case[_, A]]): Gen[Random with Sized, DynamicValue.Enumeration] = for { index <- Gen.int(0, cases.size - 1) value <- anyDynamicValueOfSchema(cases(index).codec) - } yield DynamicValue.Enumeration(cases(index).id -> value) + } yield DynamicValue.Enumeration(TypeId.Structural, cases(index).id -> value) def anyDynamicValueWithStructure(structure: Chunk[Schema.Field[_]]): Gen[Random with Sized, DynamicValue.Record] = Gen @@ -124,7 +116,7 @@ object DynamicValueGen { .map(field => Gen.const(field.label).zip(anyDynamicValueOfSchema(field.schema))) ) .map { values => - DynamicValue.Record(ListMap.empty ++ values) + DynamicValue.Record(TypeId.Structural, ListMap.empty ++ values) } } diff --git a/tests/shared/src/test/scala-2/zio/schema/OrderingSpec.scala b/tests/shared/src/test/scala-2/zio/schema/OrderingSpec.scala index 8e32c6a0f..19e7f39fd 100644 --- a/tests/shared/src/test/scala-2/zio/schema/OrderingSpec.scala +++ b/tests/shared/src/test/scala-2/zio/schema/OrderingSpec.scala @@ -208,9 +208,10 @@ object OrderingSpec extends DefaultRunnableSpec { def genAnyOrderedPairRecord: Gen[Random with Sized, SchemaAndPair[_]] = for { + name <- Gen.string(Gen.alphaChar).map(TypeId.parse) schema <- anyStructure(anyTree(1)).map(fields => { val fieldSet = fields.foldRight[FieldSet](FieldSet.Empty)((field, acc) => field :*: acc) - Schema.GenericRecord(fieldSet) + Schema.GenericRecord(name, fieldSet) }) pair <- genOrderedPairRecord(schema) } yield pair @@ -222,12 +223,13 @@ object OrderingSpec extends DefaultRunnableSpec { equalFields <- genEqualFields(fields, 0, diffInd) orderedFields <- genOrderedField(fields(diffInd)) randomFields <- genRandomFields(fields, diffInd + 1) + name <- Gen.string(Gen.alphaChar).map(TypeId.parse) } yield { val allFields = (equalFields :+ orderedFields) ++ randomFields val xFields = allFields.map { case (label, value, _) => (label, value) } val yFields = allFields.map { case (label, _, value) => (label, value) } - val x = DynamicValue.Record(ListMap(xFields: _*)).toTypedValue(schema).toOption.get - val y = DynamicValue.Record(ListMap(yFields: _*)).toTypedValue(schema).toOption.get + val x = DynamicValue.Record(name, ListMap(xFields: _*)).toTypedValue(schema).toOption.get + val y = DynamicValue.Record(name, ListMap(yFields: _*)).toTypedValue(schema).toOption.get (schema, x, y) } } @@ -285,8 +287,9 @@ object OrderingSpec extends DefaultRunnableSpec { for { (label, caseSchema) <- Gen.elements(schema.structure.toList: _*) (smallCase, largeCase) <- genOrderedDynamicPair(caseSchema) - small = DynamicValue.Enumeration((label, smallCase)).toTypedValue(schema).toOption.get - large = DynamicValue.Enumeration((label, largeCase)).toTypedValue(schema).toOption.get + id <- Gen.string(Gen.alphaChar).map(TypeId.parse) + small = DynamicValue.Enumeration(id, (label, smallCase)).toTypedValue(schema).toOption.get + large = DynamicValue.Enumeration(id, (label, largeCase)).toTypedValue(schema).toOption.get } yield (schema, small, large) def genOrderedPairEnumDiffCase[A](schema: Schema.Enum[A]): Gen[Random with Sized, SchemaAndPair[A]] = { @@ -301,10 +304,10 @@ object OrderingSpec extends DefaultRunnableSpec { } yield (schema, small, large) } - def genElemOfCase[A, B](enumSchema: Schema[A], label: String, caseSchema: Schema[B]): Gen[Random with Sized, A] = + def genElemOfCase[A, B](enumSchema: Schema.Enum[A], label: String, caseSchema: Schema[B]): Gen[Random with Sized, A] = genFromSchema(caseSchema).map(b => { val innerValue = caseSchema.toDynamic(b) - val enumValue = DynamicValue.Enumeration((label, innerValue)) + val enumValue = DynamicValue.Enumeration(enumSchema.id, (label, innerValue)) enumValue.toTypedValue(enumSchema).toOption.get }) diff --git a/tests/shared/src/test/scala-2/zio/schema/SchemaAstSpec.scala b/tests/shared/src/test/scala-2/zio/schema/SchemaAstSpec.scala index 8f39da288..e2b9de18e 100644 --- a/tests/shared/src/test/scala-2/zio/schema/SchemaAstSpec.scala +++ b/tests/shared/src/test/scala-2/zio/schema/SchemaAstSpec.scala @@ -40,6 +40,7 @@ object SchemaAstSpec extends DefaultRunnableSpec { test("generic") { val schema = Schema.record( + TypeId.parse("zio.schema.SchemaAst.Product"), Chunk( Schema.Field("a", Schema[String]), Schema.Field("b", Schema[Int]) @@ -47,6 +48,7 @@ object SchemaAstSpec extends DefaultRunnableSpec { ) val expectedAst = SchemaAst.Product( + id = TypeId.parse("zio.schema.SchemaAst.Product"), path = NodePath.root, fields = Chunk( ("a", SchemaAst.Value(StandardType.StringType, NodePath.root / "a")), @@ -59,10 +61,12 @@ object SchemaAstSpec extends DefaultRunnableSpec { val schema = Schema[SchemaGen.Arity2] val expectedAst = SchemaAst.Product( + id = TypeId.parse("zio.schema.SchemaGen.Arity2"), path = NodePath.root, fields = Chunk( "value1" -> SchemaAst.Value(StandardType.StringType, NodePath.root / "value1"), "value2" -> SchemaAst.Product( + id = TypeId.parse("zio.schema.SchemaGen.Arity1"), path = NodePath.root / "value2", fields = Chunk( "value" -> SchemaAst.Value(StandardType.IntType, NodePath.root / "value2" / "value") @@ -78,7 +82,7 @@ object SchemaAstSpec extends DefaultRunnableSpec { val ast = SchemaAst.fromSchema(schema) val recursiveRef: Option[SchemaAst] = ast match { - case SchemaAst.Product(_, elements, _) => + case SchemaAst.Product(_, _, elements, _) => elements.find { case ("r", _) => true case _ => false @@ -97,25 +101,30 @@ object SchemaAstSpec extends DefaultRunnableSpec { test("generic") { val schema = Schema.enumeration[Any, CaseSet.Aux[Any]]( + TypeId.Structural, caseOf[SchemaGen.Arity1, Any]("type1")(_.asInstanceOf[SchemaGen.Arity1]) ++ caseOf[SchemaGen.Arity2, Any]( "type2" )(_.asInstanceOf[SchemaGen.Arity2]) ) val expectedAst = SchemaAst.Sum( + TypeId.Structural, path = NodePath.root, cases = Chunk( "type1" -> SchemaAst.Product( + id = TypeId.parse("zio.schema.SchemaGen.Arity1"), path = NodePath.root / "type1", fields = Chunk( "value" -> SchemaAst.Value(StandardType.IntType, NodePath.root / "type1" / "value") ) ), "type2" -> SchemaAst.Product( + id = TypeId.parse("zio.schema.SchemaGen.Arity2"), path = NodePath.root / "type2", fields = Chunk( "value1" -> SchemaAst.Value(StandardType.StringType, NodePath.root / "type2" / "value1"), "value2" -> SchemaAst.Product( + id = TypeId.parse("zio.schema.SchemaGen.Arity1"), path = NodePath.root / "type2" / "value2", fields = Chunk( "value" -> SchemaAst @@ -131,14 +140,17 @@ object SchemaAstSpec extends DefaultRunnableSpec { test("sealed trait") { val schema = Schema[Pet] val expectedAst = SchemaAst.Sum( + TypeId.parse("zio.schema.SchemaAstSpec.Pet"), path = NodePath.root, cases = Chunk( "Rock" -> SchemaAst.Value(StandardType.UnitType, NodePath.root / "Rock"), "Dog" -> SchemaAst.Product( + id = TypeId.parse("zio.schema.SchemaAstSpec.Dog"), path = NodePath.root / "Dog", fields = Chunk("name" -> SchemaAst.Value(StandardType.StringType, NodePath.root / "Dog" / "name")) ), "Cat" -> SchemaAst.Product( + id = TypeId.parse("zio.schema.SchemaAstSpec.Cat"), path = NodePath.root / "Cat", fields = Chunk( "name" -> SchemaAst.Value(StandardType.StringType, NodePath.root / "Cat" / "name"), diff --git a/tests/shared/src/test/scala-2/zio/schema/SchemaGen.scala b/tests/shared/src/test/scala-2/zio/schema/SchemaGen.scala index df55e73ba..15a83517c 100644 --- a/tests/shared/src/test/scala-2/zio/schema/SchemaGen.scala +++ b/tests/shared/src/test/scala-2/zio/schema/SchemaGen.scala @@ -6,6 +6,7 @@ import scala.collection.immutable.ListMap import zio.Chunk import zio.random.Random +import zio.schema.TypeId import zio.test.{ Gen, Sized } object SchemaGen { @@ -183,7 +184,10 @@ object SchemaGen { } yield schema -> value val anyEnumeration: Gen[Random with Sized, Schema[Any]] = - anyEnumeration(anySchema).map(toCaseSet).map(Schema.enumeration[Any, CaseSet.Aux[Any]](_)) + for { + caseSet <- anyEnumeration(anySchema).map(toCaseSet) + id <- Gen.string(Gen.alphaChar).map(TypeId.parse) + } yield Schema.enumeration[Any, CaseSet.Aux[Any]](id, caseSet) type EnumerationAndGen = (Schema[Any], Gen[Random with Sized, Any]) @@ -192,9 +196,10 @@ object SchemaGen { primitiveAndGen <- anyPrimitiveAndGen structure <- anyEnumeration(primitiveAndGen._1) primitiveValue <- primitiveAndGen._2 + id <- Gen.string(Gen.alphaChar).map(TypeId.parse) } yield { val gen = Gen.oneOf(structure.keys.map(Gen.const(_)).toSeq: _*).map(_ => primitiveValue) - Schema.enumeration[Any, CaseSet.Aux[Any]](toCaseSet(structure)) -> gen + Schema.enumeration[Any, CaseSet.Aux[Any]](id, toCaseSet(structure)) -> gen } type EnumerationAndValue = (Schema[Any], Any) @@ -206,13 +211,17 @@ object SchemaGen { } yield schema -> value val anyRecord: Gen[Random with Sized, Schema[ListMap[String, _]]] = - anyStructure(anySchema).map(Schema.record) + for { + name <- Gen.string(Gen.alphaChar).map(TypeId.parse) + fields <- anyStructure(anySchema) + } yield Schema.record(name, fields: _*) type GenericRecordAndGen = (Schema[ListMap[String, _]], Gen[Random with Sized, ListMap[String, _]]) val anyGenericRecordAndGen: Gen[Random with Sized, GenericRecordAndGen] = for { (schema, gen) <- anyPrimitiveAndGen + name <- Gen.string(Gen.alphaChar).map(TypeId.parse) structure <- anyStructure(schema) } yield { val valueGen = Gen @@ -224,7 +233,7 @@ object SchemaGen { } .map(ListMap.empty ++ _) - Schema.record(structure: _*) -> valueGen + Schema.record(name, structure: _*) -> valueGen } type RecordAndValue = (Schema[ListMap[String, _]], ListMap[String, _]) @@ -240,11 +249,12 @@ object SchemaGen { (schema1, gen1) <- anyGenericRecordAndGen (schema2, gen2) <- anyGenericRecordAndGen (schema3, gen3) <- anyGenericRecordAndGen + name <- Gen.string(Gen.alphaChar).map(TypeId.parse) keys <- Gen.setOfN(3)(anyLabel).map(_.toSeq) (key1, value1) <- Gen.const(keys(0)).zip(gen1) (key2, value2) <- Gen.const(keys(1)).zip(gen2) (key3, value3) <- Gen.const(keys(2)).zip(gen3) - } yield Schema.record(Schema.Field(key1, schema1), Schema.Field(key2, schema2), Schema.Field(key3, schema3)) -> ListMap( + } yield Schema.record(name, Schema.Field(key1, schema1), Schema.Field(key2, schema2), Schema.Field(key3, schema3)) -> ListMap( (key1, value1), (key2, value2), (key3, value3) @@ -483,10 +493,10 @@ object SchemaGen { val anyCaseClassAndGen: Gen[Random with Sized, CaseClassAndGen[_]] = anyCaseClassSchema.map { - case s @ Schema.CaseClass1(_, _, _, _) => (s -> anyArity1).asInstanceOf[CaseClassAndGen[Any]] - case s @ Schema.CaseClass2(_, _, _, _, _, _) => (s -> anyArity2).asInstanceOf[CaseClassAndGen[Any]] - case s @ Schema.CaseClass3(_, _, _, _, _, _, _, _) => (s -> anyArity3).asInstanceOf[CaseClassAndGen[Any]] - case s => (s -> anyArity24).asInstanceOf[CaseClassAndGen[Any]] + case s @ Schema.CaseClass1(_, _, _, _, _) => (s -> anyArity1).asInstanceOf[CaseClassAndGen[Any]] + case s @ Schema.CaseClass2(_, _, _, _, _, _, _) => (s -> anyArity2).asInstanceOf[CaseClassAndGen[Any]] + case s @ Schema.CaseClass3(_, _, _, _, _, _, _, _, _) => (s -> anyArity3).asInstanceOf[CaseClassAndGen[Any]] + case s => (s -> anyArity24).asInstanceOf[CaseClassAndGen[Any]] } val anyCaseClassAndValue: Gen[Random with Sized, CaseClassAndValue[_]] = @@ -517,7 +527,9 @@ object SchemaGen { anyPrimitive.map(_.optional), anyPrimitive.zip(anyPrimitive).map { case (l, r) => Schema.either(l, r) }, anyPrimitive.zip(anyPrimitive).map { case (l, r) => Schema.tuple2(l, r) }, - anyStructure(anyPrimitive).map(fields => Schema.record(fields: _*)), + anyStructure(anyPrimitive) + .zip(Gen.string(Gen.alphaChar).map(TypeId.parse)) + .map(z => Schema.record(z._2, z._1: _*)), Gen.const(Schema[Json]), // anyEnumeration(anyPrimitive).map(toCaseSet).map(Schema.enumeration[Any, CaseSet.Aux[Any]](_)), anyCaseClassSchema, @@ -537,7 +549,9 @@ object SchemaGen { }, anyTree(depth - 1).zip(anyTree(depth - 1)).map { case (l, r) => Schema.either(l, r) }, anyTree(depth - 1).zip(anyTree(depth - 1)).map { case (l, r) => Schema.tuple2(l, r) }, - anyStructure(anyTree(depth - 1)).map(fields => Schema.record(fields: _*)), + anyStructure(anyTree(depth - 1)) + .zip(Gen.string(Gen.alphaChar).map(TypeId.parse)) + .map(z => Schema.record(z._2, z._1: _*)), Gen.const(Schema[Json]) // anyEnumeration(anyTree(depth - 1)).map(toCaseSet).map(Schema.enumeration[Any, CaseSet.Aux[Any]](_)) ) diff --git a/tests/shared/src/test/scala/zio/schema/DefaultValueSpec.scala b/tests/shared/src/test/scala/zio/schema/DefaultValueSpec.scala index 8b5cea2a4..517871a54 100644 --- a/tests/shared/src/test/scala/zio/schema/DefaultValueSpec.scala +++ b/tests/shared/src/test/scala/zio/schema/DefaultValueSpec.scala @@ -149,6 +149,7 @@ object DefaultValueSpec extends DefaultRunnableSpec { test("basic") { val schema: Schema[UserId] = Schema.CaseClass1( + TypeId.parse("zio.schema.DefaultValueSpec.UserId"), field = Schema.Field("id", Schema.Primitive(StandardType.StringType)), UserId.apply, (uid: UserId) => uid.id @@ -158,9 +159,11 @@ object DefaultValueSpec extends DefaultRunnableSpec { test("recursive") { val expected: Schema[User] = Schema.CaseClass3( + TypeId.parse("zio.schema.DefaultValueSpec.User"), field1 = Schema.Field( "id", Schema.CaseClass1( + TypeId.parse("zio.schema.DefaultValueSpec.UserId"), field = Schema.Field("id", Schema.Primitive(StandardType.StringType)), UserId.apply, (uid: UserId) => uid.id @@ -187,6 +190,7 @@ object DefaultValueSpec extends DefaultRunnableSpec { suite("Enumeration")( test("defaults to first case") { val schema = Schema.enumeration[Any, CaseSet.Aux[Any]]( + TypeId.Structural, caseOf[Int, Any]("myInt")(_.asInstanceOf[Int]) ++ caseOf[String, Any]("myString")(_.asInstanceOf[String]) ) assert(schema.defaultValue)(isRight(equalTo(0))) @@ -229,6 +233,7 @@ object DefaultValueSpec extends DefaultRunnableSpec { val schema: Schema[Status] = Schema.Enum3( + TypeId.parse("zio.schema.DefaultValueSpec.Status"), Schema.Case("Failed", Schema[Failed], (s: Status) => s.asInstanceOf[Failed]), Schema.Case("Ok", Schema[Ok], (s: Status) => s.asInstanceOf[Ok]), Schema.Case( diff --git a/tests/shared/src/test/scala/zio/schema/MigrationSpec.scala b/tests/shared/src/test/scala/zio/schema/MigrationSpec.scala index 6b6d5f710..0d40f8a52 100644 --- a/tests/shared/src/test/scala/zio/schema/MigrationSpec.scala +++ b/tests/shared/src/test/scala/zio/schema/MigrationSpec.scala @@ -115,7 +115,10 @@ object MigrationSpec extends DefaultRunnableSpec { assert(Migration.DeleteNode(NodePath.root / "v2"))( transformsValueTo( Nested1(0, "foo"), - DynamicValue.Record(ListMap("v1" -> DynamicValue.Primitive(0, StandardType.IntType))) + DynamicValue.Record( + TypeId.parse("zio.schema.MigrationSpec.Nested1"), + ListMap("v1" -> DynamicValue.Primitive(0, StandardType.IntType)) + ) ) ) }, @@ -124,9 +127,11 @@ object MigrationSpec extends DefaultRunnableSpec { transformsValueTo( Outer1("foo", Nested1(0, "bar")), DynamicValue.Record( + TypeId.parse("zio.schema.MigrationSpec.Outer1"), ListMap( "v1" -> DynamicValue.Primitive("foo", StandardType.StringType), "v2" -> DynamicValue.Record( + TypeId.parse("zio.schema.MigrationSpec.Nested1"), ListMap( "v1" -> DynamicValue.Primitive(0, StandardType.IntType) ) @@ -141,15 +146,18 @@ object MigrationSpec extends DefaultRunnableSpec { transformsValueTo( Recursive1(0, "", Some(Recursive1(1, "", Some(Recursive1(2, "", None))))), DynamicValue.Record( + TypeId.parse("zio.schema.MigrationSpec.Recursive1"), ListMap( "v1" -> DynamicValue.Primitive(0, StandardType.IntType), "v2" -> DynamicValue.Primitive("", StandardType.StringType), "r" -> DynamicValue.SomeValue( DynamicValue.Record( + TypeId.parse("zio.schema.MigrationSpec.Recursive1"), ListMap( "v1" -> DynamicValue.Primitive(1, StandardType.IntType), "r" -> DynamicValue.SomeValue( DynamicValue.Record( + TypeId.parse("zio.schema.MigrationSpec.Recursive1"), ListMap( "v1" -> DynamicValue.Primitive(2, StandardType.IntType), "r" -> DynamicValue.NoneValue @@ -169,6 +177,7 @@ object MigrationSpec extends DefaultRunnableSpec { transformsValueTo( OptionalField(0, Some("foo")), DynamicValue.Record( + TypeId.parse("zio.schema.MigrationSpec.OptionalField"), ListMap( "v1" -> DynamicValue.Primitive(0, StandardType.IntType), "v2" -> DynamicValue.Primitive("foo", StandardType.StringType) @@ -185,6 +194,7 @@ object MigrationSpec extends DefaultRunnableSpec { transformsValueTo( Nested1(0, "foo"), DynamicValue.Record( + TypeId.parse("zio.schema.MigrationSpec.Nested1"), ListMap( "v1" -> DynamicValue.Primitive(0, StandardType.IntType), "v2" -> DynamicValue.SomeValue(DynamicValue.Primitive("foo", StandardType.StringType)) diff --git a/tests/shared/src/test/scala/zio/schema/SchemaSpec.scala b/tests/shared/src/test/scala/zio/schema/SchemaSpec.scala index 5d4791e47..384252bf1 100644 --- a/tests/shared/src/test/scala/zio/schema/SchemaSpec.scala +++ b/tests/shared/src/test/scala/zio/schema/SchemaSpec.scala @@ -49,10 +49,11 @@ object SchemaSpec extends DefaultRunnableSpec { def schemaUnit: Schema[Unit] = Schema[Unit] def schemaInt: Schema[Int] = Schema[Int] - def schemaRecord(key: String): Schema[ListMap[String, _]] = Schema.record(Schema.Field(key, schemaUnit)) + def schemaRecord(key: String): Schema[ListMap[String, _]] = + Schema.record(TypeId.Structural, Schema.Field(key, schemaUnit)) def schemaEnum(key: String): Schema[Any] = - Schema.enumeration[Any, CaseSet.Aux[Any]](caseOf[Unit, Any](key)(_ => ())) + Schema.enumeration[Any, CaseSet.Aux[Any]](TypeId.Structural, caseOf[Unit, Any](key)(_ => ())) val f: Unit => Either[String, Int] = _ => Right(0) val g: Int => Either[String, Unit] = _ => Right(()) diff --git a/tests/shared/src/test/scala/zio/schema/TestAccessorBuilder.scala b/tests/shared/src/test/scala/zio/schema/TestAccessorBuilder.scala index 15975b4f9..0dac5e7ad 100644 --- a/tests/shared/src/test/scala/zio/schema/TestAccessorBuilder.scala +++ b/tests/shared/src/test/scala/zio/schema/TestAccessorBuilder.scala @@ -2,14 +2,14 @@ package zio.schema import zio.schema class TestAccessorBuilder extends AccessorBuilder { - override type Lens[S, A] = TestAccessorBuilder.Lens[S, A] - override type Prism[S, A] = TestAccessorBuilder.Prism[S, A] + override type Lens[F, S, A] = TestAccessorBuilder.Lens[F, S, A] + override type Prism[F, S, A] = TestAccessorBuilder.Prism[F, S, A] override type Traversal[S, A] = TestAccessorBuilder.Traversal[S, A] - override def makeLens[S, A](product: Schema.Record[S], term: schema.Schema.Field[A]): Lens[S, A] = + override def makeLens[F, S, A](product: Schema.Record[S], term: schema.Schema.Field[A]): Lens[F, S, A] = TestAccessorBuilder.Lens(product, term) - override def makePrism[S, A](sum: Schema.Enum[S], term: schema.Schema.Case[A, S]): Prism[S, A] = + override def makePrism[F, S, A](sum: Schema.Enum[S], term: schema.Schema.Case[A, S]): Prism[F, S, A] = TestAccessorBuilder.Prism(sum, term) override def makeTraversal[S, A](collection: Schema.Collection[S, A], element: Schema[A]): Traversal[S, A] = @@ -18,9 +18,9 @@ class TestAccessorBuilder extends AccessorBuilder { object TestAccessorBuilder { - case class Lens[S, A](s: Schema.Record[S], a: Schema.Field[A]) + case class Lens[F, S, A](s: Schema.Record[S], a: Schema.Field[A]) - case class Prism[S, A](s: Schema.Enum[S], a: Schema.Case[A, S]) + case class Prism[F, S, A](s: Schema.Enum[S], a: Schema.Case[A, S]) case class Traversal[S, A](s: Schema.Collection[S, A], a: Schema[A]) } diff --git a/tests/shared/src/test/scala/zio/schema/TypeIdSpec.scala b/tests/shared/src/test/scala/zio/schema/TypeIdSpec.scala new file mode 100644 index 000000000..423b7b1e9 --- /dev/null +++ b/tests/shared/src/test/scala/zio/schema/TypeIdSpec.scala @@ -0,0 +1,54 @@ +package zio.schema + +import zio.Chunk +import zio.test.Assertion._ +import zio.test.{ DefaultRunnableSpec, ZSpec, _ } + +object TypeIdSpec extends DefaultRunnableSpec { + + def spec: ZSpec[Environment, Failure] = + suite("TypeId")( + test("parse class name in package") { + val expected = TypeId.Nominal(Chunk.fromIterable("foo" :: "bar" :: Nil), Chunk.empty, "Baz") + + assert(TypeId.parse("foo.bar.Baz"))(equalTo(expected)) + }, + test("parse inner class name in some object") { + val expected = TypeId.Nominal(Chunk.fromIterable("foo" :: "bar" :: Nil), Chunk("Baz"), "Random") + + assert(TypeId.parse("foo.bar.Baz.Random"))(equalTo(expected)) + }, + test("parse one string") { + val expected = TypeId.Nominal(Chunk.empty, Chunk.empty, "Foo") + + assert(TypeId.parse("Foo"))(equalTo(expected)) + }, + test("parse complex structure") { + val expected = TypeId.Nominal( + Chunk.fromIterable("dev" :: "zio" :: "schema" :: "example" :: "example2" :: Nil), + Chunk.fromIterable("Domain" :: "PaymentMethod" :: Nil), + "CreditCard" + ) + + assert(TypeId.parse("dev.zio.schema.example.example2.Domain.PaymentMethod.CreditCard"))(equalTo(expected)) + }, + test("fully qualified name of nominal structure") { + val expected = TypeId.Nominal( + Chunk.fromIterable("dev" :: "zio" :: "schema" :: "example" :: "example2" :: Nil), + Chunk.fromIterable("Domain" :: "PaymentMethod" :: Nil), + "CreditCard" + ) + + assert(expected.fullyQualified)(equalTo("dev.zio.schema.example.example2.Domain.PaymentMethod.CreditCard")) + }, + test("name of nominal structure") { + val expected = TypeId.Nominal( + Chunk.fromIterable("dev" :: "zio" :: "schema" :: "example" :: "example2" :: Nil), + Chunk.fromIterable("Domain" :: "PaymentMethod" :: Nil), + "CreditCard" + ) + + assert(expected.name)(equalTo("CreditCard")) + } + ) +} diff --git a/zio-schema-avro/shared/src/main/scala/zio/schema/codec/AvroCodec.scala b/zio-schema-avro/shared/src/main/scala/zio/schema/codec/AvroCodec.scala index 79187e9c8..dd68c4192 100644 --- a/zio-schema-avro/shared/src/main/scala/zio/schema/codec/AvroCodec.scala +++ b/zio-schema-avro/shared/src/main/scala/zio/schema/codec/AvroCodec.scala @@ -605,8 +605,12 @@ object AvroCodec extends AvroCodec { case Some(s) if validNameRegex.matches(s) => Right(s) case Some(s) => Left(s"Invalid Avro name: $s") case None => - Right(s"hashed_${schema.ast.toString.hashCode().toString.replaceFirst("-", "n")}") - //TODO: better way to generate a (maybe stable) name? + schema match { + case r: Record[_] => Right(r.id.name) + case e: Enum[_] => Right(e.id.name) + case _ => Right(s"hashed_${schema.ast.toString.hashCode().toString.replaceFirst("-", "n")}") + //TODO: better way to generate a (maybe stable) name? + } } } @@ -679,7 +683,7 @@ object AvroCodec extends AvroCodec { }.toEither.left.map(_.getMessage) case (left, _) => Left(left.mkString("\n")) } - caseSet.map(Schema.enumeration) + caseSet.map(cs => Schema.enumeration(TypeId.parse(avroSchema.getName), cs)) } private[codec] def toZioRecord(avroSchema: SchemaAvro): Either[String, Schema[_]] = @@ -742,7 +746,7 @@ object AvroCodec extends AvroCodec { val annotations = buildZioAnnotations(avroSchema) extractZioFields(avroSchema).map { fs => if (fs.isEmpty) Schema.Primitive(StandardType.UnitType).addAllAnnotations(annotations) - else Schema.record(fs: _*).addAllAnnotations(annotations) + else Schema.record(TypeId.parse(avroSchema.getName), fs: _*).addAllAnnotations(annotations) } } @@ -803,7 +807,7 @@ object AvroCodec extends AvroCodec { val cases = avroSchema.getEnumSymbols.asScala.map(s => Schema.Case[String, String](s, Schema[String], identity)).toSeq val caseSet = CaseSet[String](cases: _*).asInstanceOf[Aux[String]] - val enumeration: Schema[String] = Schema.enumeration(caseSet) + val enumeration: Schema[String] = Schema.enumeration(TypeId.parse("org.apache.avro.Schema"), caseSet) Right(enumeration.addAllAnnotations(buildZioAnnotations(avroSchema))) } diff --git a/zio-schema-derivation/shared/src/main/scala-2/zio/schema/macros.scala b/zio-schema-derivation/shared/src/main/scala-2/zio/schema/macros.scala index 21dc858e7..1d34148e0 100644 --- a/zio-schema-derivation/shared/src/main/scala-2/zio/schema/macros.scala +++ b/zio-schema-derivation/shared/src/main/scala-2/zio/schema/macros.scala @@ -187,6 +187,8 @@ object DeriveSchema { case p: TermSymbol if p.isCaseAccessor && p.isMethod => p.name } + val typeId = q"zio.schema.TypeId.parse(${tpe.toString()})" + @nowarn val typeAnnotations: List[Tree] = tpe.typeSymbol.annotations.collect { @@ -281,9 +283,10 @@ object DeriveSchema { if (typeAnnotations.isEmpty) Iterable(q"annotations = zio.Chunk.empty") else Iterable(q"annotations = zio.Chunk.apply(..$typeAnnotations)") - q"""zio.schema.Schema.GenericRecord(zio.schema.FieldSet(..$fields), ..$applyArgs).transformOrFail[$tpe]($fromMap,$toMap)""" + q"""zio.schema.Schema.GenericRecord($typeId, zio.schema.FieldSet(..$fields), ..$applyArgs).transformOrFail[$tpe]($fromMap,$toMap)""" } else { val schemaType = arity match { + case 0 => q"zio.schema.Schema.CaseClass0[..$typeArgs]" case 1 => q"zio.schema.Schema.CaseClass1[..$typeArgs]" case 2 => q"zio.schema.Schema.CaseClass2[..$typeArgs]" case 3 => q"zio.schema.Schema.CaseClass3[..$typeArgs]" @@ -345,11 +348,17 @@ object DeriveSchema { val applyArgs = if (typeAnnotations.isEmpty) - Iterable(q"annotations = zio.Chunk.empty") ++ fieldDefs ++ Iterable(constructExpr) ++ extractors + Iterable(q"annotations = zio.Chunk.empty") ++ Iterable(q"id = ${typeId}") ++ fieldDefs ++ Iterable( + constructExpr + ) ++ extractors else - Iterable(q"annotations = zio.Chunk.apply(..$typeAnnotations)") ++ fieldDefs ++ Iterable(constructExpr) ++ extractors + Iterable(q"annotations = zio.Chunk.apply(..$typeAnnotations)") ++ Iterable(q"id = ${typeId}") ++ fieldDefs ++ Iterable( + constructExpr + ) ++ extractors fieldTypes.size match { + case 0 => + q"{lazy val $selfRef: zio.schema.Schema.CaseClass0[..$typeArgs] = $schemaType(..$applyArgs); $selfRef}" case 1 => q"{lazy val $selfRef: zio.schema.Schema.CaseClass1[..$typeArgs] = $schemaType(..$applyArgs); $selfRef}" case 2 => @@ -404,6 +413,7 @@ object DeriveSchema { } def deriveEnum(tpe: Type, stack: List[Frame[c.type]]): Tree = { + val typeId = q"zio.schema.TypeId.parse(${tpe.toString()})" val appliedTypeArgs: Map[String, Type] = tpe.typeConstructor.typeParams.map(_.name.toString).zip(tpe.typeArgs).toMap @@ -508,9 +518,9 @@ object DeriveSchema { val applyArgs = if (typeAnnotations.isEmpty) - cases ++ Iterable(q"annotations = zio.Chunk.empty") + Iterable(q"id = ${typeId}") ++ cases ++ Iterable(q"annotations = zio.Chunk.empty") else - cases ++ Iterable(q"annotations = zio.Chunk.apply(..$typeAnnotations)") + Iterable(q"id = ${typeId}") ++ cases ++ Iterable(q"annotations = zio.Chunk.apply(..$typeAnnotations)") cases.size match { case 0 => c.abort(c.enclosingPosition, s"No subtypes found for ${show(tpe)}") @@ -562,24 +572,16 @@ object DeriveSchema { val caseSet = q"zio.schema.CaseSet.apply(..$cases).asInstanceOf[zio.schema.CaseSet.Aux[$tpe]]" if (typeAnnotations.isEmpty) - q"""{lazy val $selfRefIdent: zio.schema.Schema.EnumN[$tpe,zio.schema.CaseSet.Aux[$tpe]] = zio.schema.Schema.EnumN.apply[$tpe,zio.schema.CaseSet.Aux[$tpe]]($caseSet); $selfRefIdent}""" + q"""{lazy val $selfRefIdent: zio.schema.Schema.EnumN[$tpe,zio.schema.CaseSet.Aux[$tpe]] = zio.schema.Schema.EnumN.apply[$tpe,zio.schema.CaseSet.Aux[$tpe]]($typeId, $caseSet); $selfRefIdent}""" else { val annotationArg = q"zio.Chunk.apply(..$typeAnnotations)" - q"""{lazy val $selfRefIdent: zio.schema.Schema.EnumN[$tpe,zio.schema.CaseSet.Aux[$tpe]] = zio.schema.Schema.EnumN.apply[$tpe,zio.schema.CaseSet.Aux[$tpe]]($caseSet,$annotationArg); $selfRefIdent}""" + q"""{lazy val $selfRefIdent: zio.schema.Schema.EnumN[$tpe,zio.schema.CaseSet.Aux[$tpe]] = zio.schema.Schema.EnumN.apply[$tpe,zio.schema.CaseSet.Aux[$tpe]]($typeId, $caseSet, $annotationArg); $selfRefIdent}""" } } } - if (isCaseObject(tpe)) q"zio.schema.Schema.singleton(${tpe.typeSymbol.asClass.module})" - else if (isCaseClass(tpe)) deriveRecord(tpe, List.empty[Frame[c.type]]) - else if (isSealedTrait(tpe)) - deriveEnum(tpe, List.empty[Frame[c.type]]) - else - c.abort( - c.enclosingPosition, - s"Failed to derive schema for $tpe. Can only derive Schema for case class or sealed trait" - ) + recurse(tpe, List.empty[Frame[c.type]]) } case class Frame[C <: whitebox.Context](ctx: C, ref: String, tpe: C#Type) diff --git a/zio-schema-derivation/shared/src/main/scala-3/zio/schema/macros.scala b/zio-schema-derivation/shared/src/main/scala-3/zio/schema/macros.scala index 4b2524a93..612f67047 100644 --- a/zio-schema-derivation/shared/src/main/scala-3/zio/schema/macros.scala +++ b/zio-schema-derivation/shared/src/main/scala-3/zio/schema/macros.scala @@ -118,7 +118,8 @@ private case class DeriveSchema()(using val ctx: Quotes) extends ReflectionUtils val annotationExprs = TypeRepr.of[T].typeSymbol.annotations.filter(filterAnnotation).map(_.asExpr) val annotations = '{ zio.Chunk.fromIterable(${Expr.ofSeq(annotationExprs)}) } - val args = fields ++ Seq(constructor) ++ selects ++ Seq(annotations) + val typeInfo = '{TypeId.parse(${Expr(TypeRepr.of[T].show)})} + val args = List(typeInfo) ++ fields ++ Seq(constructor) ++ selects ++ Seq(annotations) val terms = Expr.ofTupleFromSeq(args) val typeArgs = @@ -182,7 +183,8 @@ private case class DeriveSchema()(using val ctx: Quotes) extends ReflectionUtils val annotationExprs = TypeRepr.of[T].typeSymbol.annotations.filter(filterAnnotation).map(_.asExpr) val annotations = '{ zio.Chunk.fromIterable(${Expr.ofSeq(annotationExprs)}) } - val args = cases :+ annotations + val typeInfo = '{TypeId.parse(${Expr(TypeRepr.of[T].show)})} + val args = List(typeInfo) ++ cases :+ annotations val terms = Expr.ofTupleFromSeq(args) val ctor = TypeRepr.of[Enum2[_, _, _]].typeSymbol.primaryConstructor diff --git a/zio-schema-derivation/shared/src/test/scala-2/zio/schema/DeriveSchemaSpec.scala b/zio-schema-derivation/shared/src/test/scala-2/zio/schema/DeriveSchemaSpec.scala index b3d4779fc..854567cb7 100644 --- a/zio-schema-derivation/shared/src/test/scala-2/zio/schema/DeriveSchemaSpec.scala +++ b/zio-schema-derivation/shared/src/test/scala-2/zio/schema/DeriveSchemaSpec.scala @@ -9,6 +9,7 @@ object DeriveSchemaSpec extends DefaultRunnableSpec { import Assertion._ import SchemaAssertions._ + final case class SimpleZero() final case class annotation1(value: String) extends Annotation final case class annotation2(value: String) extends Annotation final class annotation3 extends Annotation { @@ -232,6 +233,15 @@ object DeriveSchemaSpec extends DefaultRunnableSpec { override def spec: ZSpec[Environment, Failure] = suite("DeriveSchemaSpec")( suite("Derivation")( + test("correctly derives case class 0") { + val derived: Schema[SimpleZero] = DeriveSchema.gen[SimpleZero] + val expected: Schema[SimpleZero] = + Schema.CaseClass0( + TypeId.parse("zio.schema.DeriveSchemaSpec.SimpleZero"), + () => SimpleZero() + ) + assert(derived)(hasSameSchema(expected)) + }, test("correctly derives case class") { assert(Schema[User].toString)(not(containsString("null")) && not(equalTo("$Lazy$"))) }, @@ -253,6 +263,7 @@ object DeriveSchemaSpec extends DefaultRunnableSpec { val derived: Schema[UserId] = DeriveSchema.gen[UserId] val expected: Schema[UserId] = Schema.CaseClass1( + TypeId.parse("zio.schema.DeriveSchemaSpec.UserId"), field = Schema.Field("id", Schema.Primitive(StandardType.StringType)), UserId.apply, (uid: UserId) => uid.id @@ -270,10 +281,12 @@ object DeriveSchemaSpec extends DefaultRunnableSpec { val derived: Schema[User] = Schema[User] val expected: Schema[User] = { Schema.CaseClass2( + TypeId.parse("zio.schema.DeriveSchemaSpec.User"), field1 = Schema.Field("name", Schema.Primitive(StandardType.StringType)), field2 = Schema.Field( "id", Schema.CaseClass1( + TypeId.parse("zio.schema.DeriveSchemaSpec.UserId"), field = Schema.Field("id", Schema.Primitive(StandardType.StringType)), UserId.apply, (uid: UserId) => uid.id @@ -293,11 +306,11 @@ object DeriveSchemaSpec extends DefaultRunnableSpec { }, test("correctly derives Enum") { val derived: Schema[Status] = Schema[Status] - println(derived) val expected: Schema[Status] = Schema.Enum3( - Schema.Case("Ok", DeriveSchema.gen[Status.Ok], (s: Status) => s.asInstanceOf[Status.Ok]), + TypeId.parse("zio.schema.DeriveSchemaSpec.Status"), Schema.Case("Failed", DeriveSchema.gen[Status.Failed], (s: Status) => s.asInstanceOf[Status.Failed]), + Schema.Case("Ok", DeriveSchema.gen[Status.Ok], (s: Status) => s.asInstanceOf[Status.Ok]), Schema.Case( "Pending", DeriveSchema.gen[Status.Pending.type], @@ -305,7 +318,7 @@ object DeriveSchemaSpec extends DefaultRunnableSpec { ) ) - assert(derived)(hasSameAst(expected)) + assert(derived)(hasSameSchema(expected)) }, test("correctly capture annotations on Enum and cases") { val derived: Schema.Enum1[AnnotatedEnum.AnnotatedCase, AnnotatedEnum] = AnnotatedEnum.schema diff --git a/zio-schema-derivation/shared/src/test/scala-3/zio/schema/DeriveSchemaSpec.scala b/zio-schema-derivation/shared/src/test/scala-3/zio/schema/DeriveSchemaSpec.scala index b09f7b4bd..f77ad9f09 100644 --- a/zio-schema-derivation/shared/src/test/scala-3/zio/schema/DeriveSchemaSpec.scala +++ b/zio-schema-derivation/shared/src/test/scala-3/zio/schema/DeriveSchemaSpec.scala @@ -265,6 +265,7 @@ object DeriveSchemaSpec extends DefaultRunnableSpec { val derived: Schema[UserId] = DeriveSchema.gen[UserId] val expected: Schema[UserId] = Schema.CaseClass1( + id = TypeId.parse("zio.schema.DeriveSchemaSpec.UserId"), field = Schema.Field("id", Schema.Primitive(StandardType.StringType)), UserId.apply, (uid: UserId) => uid.id @@ -274,14 +275,14 @@ object DeriveSchemaSpec extends DefaultRunnableSpec { }, test("correctly derives for case object") { val derived: Schema[Singleton.type] = DeriveSchema.gen[Singleton.type] - val expected: Schema[Singleton.type] = Schema.CaseClass0(() => Singleton) + val expected: Schema[Singleton.type] = Schema.CaseClass0(TypeId.parse("zio.schema.DeriveSchemaSpec.Singleton"), () => Singleton) assert(derived)(hasSameSchema(expected)) }, test("correctly captures annotations on case class") { val derived: Schema[User] = Schema[User] derived match { - case Schema.CaseClass2(field1, field2, _, _, _, anns) => + case Schema.CaseClass2(id, field1, field2, _, _, _, anns) => assertTrue( anns.contains(new annotation3), field1.annotations.isEmpty, @@ -293,6 +294,7 @@ object DeriveSchemaSpec extends DefaultRunnableSpec { val derived: Schema[Status] = Schema[Status] val expected: Schema[Status] = Schema.Enum3( + TypeId.parse("zio.schema.DeriveSchemaSpec.Status"), Schema.Case("Failed", DeriveSchema.gen[Status.Failed], (s: Status) => s.asInstanceOf[Status.Failed]), Schema.Case("Ok", DeriveSchema.gen[Status.Ok], (s: Status) => s.asInstanceOf[Status.Ok]), Schema.Case( diff --git a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example1/Example1.scala b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example1/Example1.scala index 611942fdb..c2dacdee8 100644 --- a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example1/Example1.scala +++ b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example1/Example1.scala @@ -1,6 +1,6 @@ package dev.zio.schema.example.example1 -import zio.schema.{ DeriveSchema, Schema } +import zio.schema.{ DeriveSchema, Schema, TypeId } import zio.stream.ZTransducer import zio.{ Chunk, ExitCode, URIO, ZIO } @@ -34,6 +34,7 @@ object ManualConstruction { import zio.schema.Schema._ val schemaPerson: Schema[Person] = Schema.CaseClass2[String, Int, Person]( + TypeId.parse("dev.zio.schema.example.example1.Domain.Person"), field1 = Schema.Field[String]("name", Schema.primitive[String]), field2 = Schema.Field[Int]("age", Schema.primitive[Int]), construct = (name, age) => Person(name, age), @@ -42,6 +43,7 @@ object ManualConstruction { ) val schemaPaymentMethodWireTransfer: Schema[WireTransfer] = Schema.CaseClass2[String, String, WireTransfer]( + TypeId.parse("dev.zio.schema.example.example1.Domain.PaymentMethod.WireTransfer"), field1 = Schema.Field[String]("accountNumber", Schema.primitive[String]), field2 = Schema.Field[String]("bankCode", Schema.primitive[String]), construct = (number, bankCode) => PaymentMethod.WireTransfer(number, bankCode), @@ -50,6 +52,7 @@ object ManualConstruction { ) val schemaPaymentMethodCreditCard: Schema[CreditCard] = Schema.CaseClass3[String, Int, Int, CreditCard]( + TypeId.parse("dev.zio.schema.example.example1.Domain.PaymentMethod.CreditCard"), field1 = Schema.Field[String]("number", Schema.primitive[String]), field2 = Schema.Field[Int]("expirationMonth", Schema.primitive[Int]), field3 = Schema.Field[Int]("expirationYear", Schema.primitive[Int]), @@ -62,6 +65,7 @@ object ManualConstruction { val schemaPaymentMethod: Schema[PaymentMethod] = Schema.Enum2[PaymentMethod.CreditCard, PaymentMethod.WireTransfer, PaymentMethod]( + id = TypeId.parse("dev.zio.schema.example.example1.Domain.PaymentMethod"), case1 = Case[PaymentMethod.CreditCard, PaymentMethod]( id = "CreditCard", codec = schemaPaymentMethodCreditCard, @@ -78,6 +82,7 @@ object ManualConstruction { ) val schemaCustomer: Schema[Customer] = Schema.CaseClass2[Person, PaymentMethod, Customer]( + TypeId.parse("dev.zio.schema.example.example1.Domain.Customer"), field1 = Schema.Field[Person]("person", schemaPerson), field2 = Schema.Field[PaymentMethod]("paymentMethod", schemaPaymentMethod), construct = (person, paymentMethod) => Customer(person, paymentMethod), diff --git a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example2/Example2.scala b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example2/Example2.scala index 04dafb0f6..4510bebaa 100644 --- a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example2/Example2.scala +++ b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example2/Example2.scala @@ -1,7 +1,7 @@ package dev.zio.schema.example.example2 -import zio.schema.Schema import zio.schema.Schema._ +import zio.schema.{ DeriveSchema, Schema, TypeId } import zio.stream.ZTransducer import zio.{ Chunk, ExitCode, URIO, ZIO } @@ -24,6 +24,7 @@ object Domain { val age: Field[Int] = Schema.Field[Int]("age", Schema.primitive[Int]) val schema: Schema[Person] = Schema.CaseClass2[String, Int, Person]( + TypeId.parse("dev.zio.schema.example.example2.Domain.Person"), field1 = name, field2 = age, construct = (name, age) => Person(name, age), @@ -40,6 +41,7 @@ object Domain { val expirationMonth: Field[Int] = Schema.Field[Int]("expirationMonth", Schema.primitive[Int]) val expirationYear: Field[Int] = Schema.Field[Int]("expirationYear", Schema.primitive[Int]) implicit val schema: Schema[CreditCard] = Schema.CaseClass3[String, Int, Int, CreditCard]( + TypeId.parse("dev.zio.schema.example.example2.Domain.PaymentMethod.CreditCard"), field1 = number, field2 = expirationMonth, field3 = expirationYear, @@ -58,6 +60,7 @@ object Domain { val bankCode: Field[String] = Schema.Field[String]("bankCode", Schema.primitive[String]) implicit val schema: Schema[WireTransfer] = Schema.CaseClass2[String, String, WireTransfer]( + TypeId.parse("dev.zio.schema.example.example2.Domain.PaymentMethod.WireTransfer"), field1 = accountNumber, field2 = bankCode, construct = (number, bankCode) => PaymentMethod.WireTransfer(number, bankCode), @@ -67,6 +70,7 @@ object Domain { } val schemaPaymentMethod: Schema[PaymentMethod] = Schema.Enum2[CreditCard, WireTransfer, PaymentMethod]( + id = TypeId.parse("dev.zio.schema.example.example2.Domain.PaymentMethod"), case1 = Case[CreditCard, PaymentMethod]( id = "CreditCard", codec = CreditCard.schema, @@ -93,6 +97,7 @@ object Domain { Schema.Field[PaymentMethod]("paymentMethod", PaymentMethod.schemaPaymentMethod) implicit val schema: Schema[Customer] = Schema.CaseClass2[Person, PaymentMethod, Customer]( + TypeId.parse("dev.zio.schema.example.example2.Domain.Customer"), field1 = Customer.person, field2 = Customer.paymentMethod, construct = (person, paymentMethod) => Customer(person, paymentMethod), diff --git a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example3/Example3.scala b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example3/Example3.scala index a6311cd8b..8e8d9c7b6 100644 --- a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example3/Example3.scala +++ b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example3/Example3.scala @@ -19,6 +19,7 @@ private[example3] object Domain { val age: Field[Int] = Field[Int]("age", primitive[Int]) val schema: Schema[Person] = CaseClass2[String, Int, Person]( + TypeId.parse("dev.zio.example.example3.Domain.Person"), field1 = name, field2 = age, construct = (name, age) => Person(name, age), @@ -35,6 +36,7 @@ private[example3] object Domain { val years: Field[Int] = Field("years", primitive[Int]) val schema: Schema[PersonDTO] = CaseClass3[String, String, Int, PersonDTO]( + TypeId.parse("dev.zio.example.example3.Domain.PersonDTO"), field1 = firstname, field2 = lastname, field3 = years, diff --git a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example4/Example4Transformation.scala b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example4/Example4Transformation.scala index 7f6db1f07..391209c47 100644 --- a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example4/Example4Transformation.scala +++ b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example4/Example4Transformation.scala @@ -1,7 +1,7 @@ package dev.zio.schema.example.example4 import zio.schema.ast.{ Migration, NodePath, SchemaAst } -import zio.schema.{ DynamicValue, Schema } +import zio.schema.{ DynamicValue, Schema, TypeId } import zio.{ Chunk, ExitCode, URIO, ZIO } /** @@ -18,6 +18,7 @@ private[example4] object Domain { val age: Schema.Field[Int] = Schema.Field[Int]("age", Schema.primitive[Int]) val schema: Schema[WebPerson] = Schema.CaseClass2[String, Int, WebPerson]( + TypeId.parse("dev.zio.schema.example.example4.Domain.WebPerson"), field1 = name, field2 = age, construct = (name, age) => WebPerson(name, age), @@ -34,6 +35,7 @@ private[example4] object Domain { val years: Schema.Field[Int] = Schema.Field("years", Schema.primitive[Int]) val schema: Schema[DomainPerson] = Schema.CaseClass3[String, String, Int, DomainPerson]( + TypeId.parse("dev.zio.schema.example.example4.Domain.DomainPerson"), field1 = firstname, field2 = lastname, field3 = years, diff --git a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example5/Example5_Diffing.scala b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example5/Example5_Diffing.scala index 707aa9d95..8983793f0 100644 --- a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example5/Example5_Diffing.scala +++ b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example5/Example5_Diffing.scala @@ -1,7 +1,7 @@ package dev.zio.schema.example.example5 import zio.schema.Schema._ -import zio.schema.{ Diff, Schema } +import zio.schema.{ Diff, Schema, TypeId } import zio.{ ExitCode, URIO, ZIO } /** @@ -16,6 +16,7 @@ private[example5] object Domain { val age: Field[Int] = Field[Int]("age", primitive[Int]) val schema: Schema[Person] = CaseClass2[String, Int, Person]( + TypeId.parse("dev.zio.schema.example.example5.Domain.Person"), field1 = name, field2 = age, construct = (name, age) => Person(name, age), @@ -31,16 +32,16 @@ private[example5] object Domain { val lastname: Field[String] = Field("lastname", primitive[String]) val years: Field[Int] = Field("years", primitive[Int]) - val schema: Schema[PersonDTO] = - CaseClass3[String, String, Int, PersonDTO]( - field1 = firstname, - field2 = lastname, - field3 = years, - construct = (fn, ln, y) => PersonDTO(fn, ln, y), - extractField1 = _.firstname, - extractField2 = _.lastname, - extractField3 = _.years - ) + val schema: Schema[PersonDTO] = CaseClass3[String, String, Int, PersonDTO]( + TypeId.parse("dev.zio.schema.example.example5.Domain.PersonDTO"), + field1 = firstname, + field2 = lastname, + field3 = years, + construct = (fn, ln, y) => PersonDTO(fn, ln, y), + extractField1 = _.firstname, + extractField2 = _.lastname, + extractField3 = _.years + ) } } diff --git a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example6/Example6_ReifiedOptics.scala b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example6/Example6_ReifiedOptics.scala index ca28906cd..36c0f6b33 100644 --- a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example6/Example6_ReifiedOptics.scala +++ b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example6/Example6_ReifiedOptics.scala @@ -12,6 +12,7 @@ private[example6] object Domain { final case class Company(boss: User, employees: List[UserAddress]) implicit val userSchema: Schema.CaseClass2[String, Int, User] = Schema.CaseClass2[String, Int, User]( + TypeId.parse("dev.zio.schema.example.example6.Domain.User"), field1 = Field("name", Schema.primitive[String]), field2 = Field("age", Schema.primitive[Int]), construct = (name, years) => User(name, years), @@ -21,6 +22,7 @@ private[example6] object Domain { implicit val addressSchema: CaseClass3[String, String, String, Address] = Schema.CaseClass3[String, String, String, Address]( + TypeId.parse("dev.zio.schema.example.example6.Domain.Address"), field1 = Field("street", Schema.primitive[String]), field2 = Field("city", Schema.primitive[String]), field3 = Field("state", Schema.primitive[String]), @@ -32,6 +34,7 @@ private[example6] object Domain { implicit val userAddressSchema: CaseClass2[User, Address, UserAddress] = Schema.CaseClass2[User, Address, UserAddress]( + TypeId.parse("dev.zio.schema.example.example6.Domain.UserAddress"), field1 = Field("user", userSchema), field2 = Field("address", addressSchema), construct = (user, address) => UserAddress(user, address), @@ -41,6 +44,7 @@ private[example6] object Domain { implicit val companySchema: CaseClass2[User, List[UserAddress], Company] = Schema.CaseClass2[User, List[UserAddress], Company]( + TypeId.parse("dev.zio.schema.example.example6.Domain.Company"), field1 = Field("boss", userSchema), field2 = Field("employees", Schema.list(userAddressSchema)), construct = (boss, employees) => Company(boss, employees), diff --git a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example7/Problem.scala b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example7/Problem.scala index bb19df191..120462b87 100644 --- a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example7/Problem.scala +++ b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example7/Problem.scala @@ -4,7 +4,7 @@ import scala.collection.immutable.ListMap import scala.util.Try import zio.Chunk -import zio.schema.{ DeriveSchema, DynamicValue, Schema, StandardType } +import zio.schema.{ DeriveSchema, DynamicValue, Schema, StandardType, TypeId } /** This exercise is based on John DeGoes Spartan training on ZIO-Schema from 2021-11-04 */ @@ -82,7 +82,7 @@ private[example7] object Problem { } } } - .map(DynamicValue.Record) + .map(v => DynamicValue.Record(TypeId.Structural, v)) } val p: Either[String, Person] = decode[Person](Map("name" -> List("John"), "age" -> List("42"))) diff --git a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example8/Decoder.scala b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example8/Decoder.scala index 98ebf9864..f5136969b 100644 --- a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example8/Decoder.scala +++ b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example8/Decoder.scala @@ -37,9 +37,9 @@ object Decoder { case Json.JObj(map) => map.map { case (k, v) => k -> jsonToDynamicValue(v) - }.foldRight[Either[String, DynamicValue]](Right(DynamicValue.Record(ListMap.empty))) { - case ((key, Right(value)), Right(DynamicValue.Record(values))) => - Right(DynamicValue.Record(values + (key -> value))) + }.foldRight[Either[String, DynamicValue]](Right(DynamicValue.Record(TypeId.Structural, ListMap.empty))) { + case ((key, Right(value)), Right(DynamicValue.Record(_, values))) => + Right(DynamicValue.Record(TypeId.parse(key), values + (key -> value))) case ((_, Left(err)), _) => Left(err) case (_, Left(err)) => Left(err) } diff --git a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example8/Encoder.scala b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example8/Encoder.scala index b61ead3af..3ab79f3c7 100644 --- a/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example8/Encoder.scala +++ b/zio-schema-examples/shared/src/main/scala/dev/zio/schema/example/example8/Encoder.scala @@ -32,7 +32,7 @@ object Encoder { case DynamicValue.Sequence(chunk) => Json.JArr(chunk.map(toJson).toList) - case DynamicValue.Record(values) => + case DynamicValue.Record(_, values) => Json.JObj(values.map { case (k, v) => (k, toJson(v)) }) } } diff --git a/zio-schema-json/shared/src/main/scala/zio/schema/codec/JsonCodec.scala b/zio-schema-json/shared/src/main/scala/zio/schema/codec/JsonCodec.scala index e5a274471..4608c3eea 100644 --- a/zio-schema-json/shared/src/main/scala/zio/schema/codec/JsonCodec.scala +++ b/zio-schema-json/shared/src/main/scala/zio/schema/codec/JsonCodec.scala @@ -110,95 +110,95 @@ object JsonCodec extends Codec { JsonEncoder.chunk(schemaEncoder(ks).both(schemaEncoder(vs))).contramap(m => Chunk.fromIterable(m)) case Schema.SetSchema(s, _) => JsonEncoder.chunk(schemaEncoder(s)).contramap(m => Chunk.fromIterable(m)) - case Schema.Transform(c, _, g, _, _) => transformEncoder(c, g) - case Schema.Tuple(l, r, _) => JsonEncoder.tuple2(schemaEncoder(l), schemaEncoder(r)) - case Schema.Optional(schema, _) => JsonEncoder.option(schemaEncoder(schema)) - case Schema.Fail(_, _) => unitEncoder.contramap(_ => ()) - case Schema.GenericRecord(structure, _) => recordEncoder(structure.toChunk) - case EitherSchema(left, right, _) => JsonEncoder.either(schemaEncoder(left), schemaEncoder(right)) - case l @ Schema.Lazy(_) => schemaEncoder(l.schema) - case Schema.Meta(_, _) => astEncoder - case Schema.CaseClass0(_, _) => caseClassEncoder() - case Schema.CaseClass1(f, _, ext, _) => caseClassEncoder(f -> ext) - case Schema.CaseClass2(f1, f2, _, ext1, ext2, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2) - case Schema.CaseClass3(f1, f2, f3, _, ext1, ext2, ext3, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3) - case Schema.CaseClass4(f1, f2, f3, f4, _, ext1, ext2, ext3, ext4, _) => + case Schema.Transform(c, _, g, _, _) => transformEncoder(c, g) + case Schema.Tuple(l, r, _) => JsonEncoder.tuple2(schemaEncoder(l), schemaEncoder(r)) + case Schema.Optional(schema, _) => JsonEncoder.option(schemaEncoder(schema)) + case Schema.Fail(_, _) => unitEncoder.contramap(_ => ()) + case Schema.GenericRecord(_, structure, _) => recordEncoder(structure.toChunk) + case EitherSchema(left, right, _) => JsonEncoder.either(schemaEncoder(left), schemaEncoder(right)) + case l @ Schema.Lazy(_) => schemaEncoder(l.schema) + case Schema.Meta(_, _) => astEncoder + case Schema.CaseClass0(_, _, _) => caseClassEncoder() + case Schema.CaseClass1(_, f, _, ext, _) => caseClassEncoder(f -> ext) + case Schema.CaseClass2(_, f1, f2, _, ext1, ext2, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2) + case Schema.CaseClass3(_, f1, f2, f3, _, ext1, ext2, ext3, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3) + case Schema.CaseClass4(_, f1, f2, f3, f4, _, ext1, ext2, ext3, ext4, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4) - case Schema.CaseClass5(f1, f2, f3, f4, f5, _, ext1, ext2, ext3, ext4, ext5, _) => + case Schema.CaseClass5(_, f1, f2, f3, f4, f5, _, ext1, ext2, ext3, ext4, ext5, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5) - case Schema.CaseClass6(f1, f2, f3, f4, f5, f6, _, ext1, ext2, ext3, ext4, ext5, ext6, _) => + case Schema.CaseClass6(_, f1, f2, f3, f4, f5, f6, _, ext1, ext2, ext3, ext4, ext5, ext6, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6) - case Schema.CaseClass7(f1, f2, f3, f4, f5, f6, f7, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, _) => + case Schema.CaseClass7(_, f1, f2, f3, f4, f5, f6, f7, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7) - case Schema.CaseClass8(f1, f2, f3, f4, f5, f6, f7, f8, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, _) => + case Schema.CaseClass8(_, f1, f2, f3, f4, f5, f6, f7, f8, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8) case Schema - .CaseClass9(f1, f2, f3, f4, f5, f6, f7, f8, f9, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, _) => + .CaseClass9(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9) - case Schema.CaseClass10(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, _) => + case Schema.CaseClass10(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10) - case Schema.CaseClass11(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, _) => + case Schema.CaseClass11(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11) - case Schema.CaseClass12(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, _) => + case Schema.CaseClass12(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12) - case Schema.CaseClass13(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, _) => + case Schema.CaseClass13(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13) - case Schema.CaseClass14(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, _) => + case Schema.CaseClass14(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14) - case Schema.CaseClass15(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, _) => + case Schema.CaseClass15(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15) - case Schema.CaseClass16(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, _) => + case Schema.CaseClass16(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16) - case Schema.CaseClass17(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, _) => + case Schema.CaseClass17(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17) - case Schema.CaseClass18(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, _) => + case Schema.CaseClass18(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18) - case Schema.CaseClass19(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, _) => + case Schema.CaseClass19(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19) - case Schema.CaseClass20(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, _) => + case Schema.CaseClass20(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19, f20 -> ext20) - case Schema.CaseClass21(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, ext21, _) => + case Schema.CaseClass21(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, ext21, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19, f20 -> ext20, f21 -> ext21) - case Schema.CaseClass22(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, ext21, ext22, _) => + case Schema.CaseClass22(_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, ext21, ext22, _) => caseClassEncoder(f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19, f20 -> ext20, f21 -> ext21, f22 -> ext22) - case Schema.Enum1(c, _) => enumEncoder(c) - case Schema.Enum2(c1, c2, _) => enumEncoder(c1, c2) - case Schema.Enum3(c1, c2, c3, _) => enumEncoder(c1, c2, c3) - case Schema.Enum4(c1, c2, c3, c4, _) => enumEncoder(c1, c2, c3, c4) - case Schema.Enum5(c1, c2, c3, c4, c5, _) => enumEncoder(c1, c2, c3, c4, c5) - case Schema.Enum6(c1, c2, c3, c4, c5, c6, _) => enumEncoder(c1, c2, c3, c4, c5, c6) - case Schema.Enum7(c1, c2, c3, c4, c5, c6, c7, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7) - case Schema.Enum8(c1, c2, c3, c4, c5, c6, c7, c8, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8) - case Schema.Enum9(c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9) - case Schema.Enum10(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => + case Schema.Enum1(_, c, _) => enumEncoder(c) + case Schema.Enum2(_, c1, c2, _) => enumEncoder(c1, c2) + case Schema.Enum3(_, c1, c2, c3, _) => enumEncoder(c1, c2, c3) + case Schema.Enum4(_, c1, c2, c3, c4, _) => enumEncoder(c1, c2, c3, c4) + case Schema.Enum5(_, c1, c2, c3, c4, c5, _) => enumEncoder(c1, c2, c3, c4, c5) + case Schema.Enum6(_, c1, c2, c3, c4, c5, c6, _) => enumEncoder(c1, c2, c3, c4, c5, c6) + case Schema.Enum7(_, c1, c2, c3, c4, c5, c6, c7, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7) + case Schema.Enum8(_, c1, c2, c3, c4, c5, c6, c7, c8, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8) + case Schema.Enum9(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9) + case Schema.Enum10(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) - case Schema.Enum11(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => + case Schema.Enum11(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) - case Schema.Enum12(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => + case Schema.Enum12(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) - case Schema.Enum13(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => + case Schema.Enum13(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) - case Schema.Enum14(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => + case Schema.Enum14(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) - case Schema.Enum15(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => + case Schema.Enum15(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) - case Schema.Enum16(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => + case Schema.Enum16(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) - case Schema.Enum17(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => + case Schema.Enum17(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) - case Schema.Enum18(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => + case Schema.Enum18(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) - case Schema.Enum19(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => + case Schema.Enum19(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) case Schema - .Enum20(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => + .Enum20(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) case Schema - .Enum21(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => + .Enum21(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) - case Schema.Enum22(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => + case Schema.Enum22(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => enumEncoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) - case Schema.EnumN(cs, _) => enumEncoder(cs.toSeq: _*) + case Schema.EnumN(_, cs, _) => enumEncoder(cs.toSeq: _*) case Schema.Dynamic(_) => dynamicEncoder case Schema.SemiDynamic(_, _) => @@ -312,86 +312,86 @@ object JsonCodec extends Codec { case Schema.Sequence(codec, f, _, _, _) => JsonDecoder.chunk(schemaDecoder(codec)).map(f) case Schema.MapSchema(ks, vs, _) => JsonDecoder.chunk(schemaDecoder(ks) <*> schemaDecoder(vs)).map(entries => entries.toList.toMap) - case Schema.SetSchema(s, _) => JsonDecoder.chunk(schemaDecoder(s)).map(entries => entries.toSet) - case Schema.Fail(message, _) => failDecoder(message) - case Schema.GenericRecord(structure, _) => recordDecoder(structure.toChunk) - case Schema.EitherSchema(left, right, _) => JsonDecoder.either(schemaDecoder(left), schemaDecoder(right)) - case l @ Schema.Lazy(_) => schemaDecoder(l.schema) - case Schema.Meta(_, _) => astDecoder - case s @ Schema.CaseClass0(_, _) => caseClass0Decoder(s) - case s @ Schema.CaseClass1(_, _, _, _) => caseClass1Decoder(s) - case s @ Schema.CaseClass2(_, _, _, _, _, _) => caseClass2Decoder(s) - case s @ Schema.CaseClass3(_, _, _, _, _, _, _, _) => caseClass3Decoder(s) - case s @ Schema.CaseClass4(_, _, _, _, _, _, _, _, _, _) => caseClass4Decoder(s) - case s @ Schema.CaseClass5(_, _, _, _, _, _, _, _, _, _, _, _) => caseClass5Decoder(s) - case s @ Schema.CaseClass6(_, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass6Decoder(s) - case s @ Schema.CaseClass7(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass7Decoder(s) - case s @ Schema.CaseClass8(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass8Decoder(s) - case s @ Schema.CaseClass9(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass9Decoder(s) - case s @ Schema.CaseClass10(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass10Decoder(s) - case s @ Schema.CaseClass11(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case Schema.SetSchema(s, _) => JsonDecoder.chunk(schemaDecoder(s)).map(entries => entries.toSet) + case Schema.Fail(message, _) => failDecoder(message) + case Schema.GenericRecord(_, structure, _) => recordDecoder(structure.toChunk) + case Schema.EitherSchema(left, right, _) => JsonDecoder.either(schemaDecoder(left), schemaDecoder(right)) + case l @ Schema.Lazy(_) => schemaDecoder(l.schema) + case Schema.Meta(_, _) => astDecoder + case s @ Schema.CaseClass0(_, _, _) => caseClass0Decoder(s) + case s @ Schema.CaseClass1(_, _, _, _, _) => caseClass1Decoder(s) + case s @ Schema.CaseClass2(_, _, _, _, _, _, _) => caseClass2Decoder(s) + case s @ Schema.CaseClass3(_, _, _, _, _, _, _, _, _) => caseClass3Decoder(s) + case s @ Schema.CaseClass4(_, _, _, _, _, _, _, _, _, _, _) => caseClass4Decoder(s) + case s @ Schema.CaseClass5(_, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass5Decoder(s) + case s @ Schema.CaseClass6(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass6Decoder(s) + case s @ Schema.CaseClass7(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass7Decoder(s) + case s @ Schema.CaseClass8(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass8Decoder(s) + case s @ Schema.CaseClass9(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass9Decoder(s) + case s @ Schema.CaseClass10(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass10Decoder(s) + case s @ Schema.CaseClass11(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass11Decoder(s) - case s @ Schema.CaseClass12(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case s @ Schema.CaseClass12(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass12Decoder(s) - case s @ Schema.CaseClass13(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case s @ Schema.CaseClass13(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass13Decoder(s) case s @ Schema - .CaseClass14(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + .CaseClass14(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass14Decoder(s) case s @ Schema - .CaseClass15(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + .CaseClass15(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass15Decoder(s) - case s @ Schema.CaseClass16(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case s @ Schema.CaseClass16(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass16Decoder(s) - case s @ Schema.CaseClass17(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case s @ Schema.CaseClass17(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass17Decoder(s) - case s @ Schema.CaseClass18(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case s @ Schema.CaseClass18(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass18Decoder(s) - case s @ Schema.CaseClass19(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case s @ Schema.CaseClass19(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass19Decoder(s) - case s @ Schema.CaseClass20(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case s @ Schema.CaseClass20(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass20Decoder(s) - case s @ Schema.CaseClass21(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case s @ Schema.CaseClass21(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass21Decoder(s) - case s @ Schema.CaseClass22(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case s @ Schema.CaseClass22(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => caseClass22Decoder(s) - case Schema.Enum1(c, _) => enumDecoder(c) - case Schema.Enum2(c1, c2, _) => enumDecoder(c1, c2) - case Schema.Enum3(c1, c2, c3, _) => enumDecoder(c1, c2, c3) - case Schema.Enum4(c1, c2, c3, c4, _) => enumDecoder(c1, c2, c3, c4) - case Schema.Enum5(c1, c2, c3, c4, c5, _) => enumDecoder(c1, c2, c3, c4, c5) - case Schema.Enum6(c1, c2, c3, c4, c5, c6, _) => enumDecoder(c1, c2, c3, c4, c5, c6) - case Schema.Enum7(c1, c2, c3, c4, c5, c6, c7, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7) - case Schema.Enum8(c1, c2, c3, c4, c5, c6, c7, c8, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8) - case Schema.Enum9(c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9) - case Schema.Enum10(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => + case Schema.Enum1(_, c, _) => enumDecoder(c) + case Schema.Enum2(_, c1, c2, _) => enumDecoder(c1, c2) + case Schema.Enum3(_, c1, c2, c3, _) => enumDecoder(c1, c2, c3) + case Schema.Enum4(_, c1, c2, c3, c4, _) => enumDecoder(c1, c2, c3, c4) + case Schema.Enum5(_, c1, c2, c3, c4, c5, _) => enumDecoder(c1, c2, c3, c4, c5) + case Schema.Enum6(_, c1, c2, c3, c4, c5, c6, _) => enumDecoder(c1, c2, c3, c4, c5, c6) + case Schema.Enum7(_, c1, c2, c3, c4, c5, c6, c7, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7) + case Schema.Enum8(_, c1, c2, c3, c4, c5, c6, c7, c8, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8) + case Schema.Enum9(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9) + case Schema.Enum10(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) - case Schema.Enum11(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => + case Schema.Enum11(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) - case Schema.Enum12(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => + case Schema.Enum12(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) - case Schema.Enum13(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => + case Schema.Enum13(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) - case Schema.Enum14(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => + case Schema.Enum14(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) - case Schema.Enum15(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => + case Schema.Enum15(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) - case Schema.Enum16(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => + case Schema.Enum16(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) - case Schema.Enum17(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => + case Schema.Enum17(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) - case Schema.Enum18(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => + case Schema.Enum18(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) - case Schema.Enum19(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => + case Schema.Enum19(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) case Schema - .Enum20(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => + .Enum20(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) - case Schema.Enum21(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => + case Schema.Enum21(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) - case Schema.Enum22(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => + case Schema.Enum22(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) - case Schema.EnumN(cs, _) => enumDecoder(cs.toSeq: _*) + case Schema.EnumN(_, cs, _) => enumDecoder(cs.toSeq: _*) case Schema.Dynamic(_) => dynamicDecoder case Schema.SemiDynamic(_, _) => semiDynamicDecoder.asInstanceOf[JsonDecoder[A]] } diff --git a/zio-schema-json/shared/src/test/scala-2/zio/schema/codec/JsonCodecSpec.scala b/zio-schema-json/shared/src/test/scala-2/zio/schema/codec/JsonCodecSpec.scala index c10999e89..45a1ad459 100644 --- a/zio-schema-json/shared/src/test/scala-2/zio/schema/codec/JsonCodecSpec.scala +++ b/zio-schema-json/shared/src/test/scala-2/zio/schema/codec/JsonCodecSpec.scala @@ -1,6 +1,5 @@ package zio.schema.codec -// import java.time.Year import java.time.format.DateTimeFormatter import java.time.{ ZoneId, ZoneOffset } @@ -481,7 +480,7 @@ object JsonCodecSpec extends DefaultRunnableSpec { SchemaGen.anyRecordAndValue.runHead.flatMap { case Some((schema, value)) => val key = new String(Array('\u0007', '\n')) - val embedded = Schema.record(Schema.Field(key, schema)) + val embedded = Schema.record(TypeId.Structural, Schema.Field(key, schema)) assertEncodesThenDecodes(embedded, ListMap(key -> value)) case None => ZIO.fail("Should never happen!") } @@ -500,7 +499,10 @@ object JsonCodecSpec extends DefaultRunnableSpec { testM("of ZoneOffsets") { checkM(JavaTimeGen.anyZoneOffset) { zoneOffset => assertEncodesThenDecodes( - Schema.record(Schema.Field("zoneOffset", Schema.Primitive(StandardType.ZoneOffsetType))), + Schema.record( + TypeId.parse("java.time.ZoneOffset"), + Schema.Field("zoneOffset", Schema.Primitive(StandardType.ZoneOffsetType)) + ), ListMap[String, Any]("zoneOffset" -> zoneOffset) ) } @@ -776,16 +778,19 @@ object JsonCodecSpec extends DefaultRunnableSpec { val searchRequestSchema: Schema[SearchRequest] = DeriveSchema.gen[SearchRequest] val recordSchema: Schema[ListMap[String, _]] = Schema.record( + TypeId.Structural, Schema.Field("foo", Schema.Primitive(StandardType.StringType)), Schema.Field("bar", Schema.Primitive(StandardType.IntType)) ) val nestedRecordSchema: Schema[ListMap[String, _]] = Schema.record( + TypeId.Structural, Schema.Field("l1", Schema.Primitive(StandardType.StringType)), Schema.Field("l2", recordSchema) ) val enumSchema: Schema[Any] = Schema.enumeration[Any, CaseSet.Aux[Any]]( + TypeId.Structural, caseOf[String, Any]("string")(_.asInstanceOf[String]) ++ caseOf[Int, Any]("int")(_.asInstanceOf[Int]) ++ caseOf[ Boolean, Any diff --git a/zio-schema-optics/shared/src/main/scala/zio/schema/optics/ZioOpticsBuilder.scala b/zio-schema-optics/shared/src/main/scala/zio/schema/optics/ZioOpticsBuilder.scala index 159a2defc..3502978c1 100644 --- a/zio-schema-optics/shared/src/main/scala/zio/schema/optics/ZioOpticsBuilder.scala +++ b/zio-schema-optics/shared/src/main/scala/zio/schema/optics/ZioOpticsBuilder.scala @@ -15,11 +15,11 @@ import zio.{ Chunk, ChunkBuilder } */ object ZioOpticsBuilder extends AccessorBuilder { - type Lens[S, A] = Optic[S, S, A, OpticFailure, OpticFailure, A, S] - type Prism[S, A] = ZPrism[S, S, A, A] + type Lens[F, S, A] = Optic[S, S, A, OpticFailure, OpticFailure, A, S] + type Prism[F, S, A] = ZPrism[S, S, A, A] type Traversal[S, A] = ZTraversal[S, S, A, A] - override def makeLens[S, A]( + override def makeLens[F, S, A]( product: Schema.Record[S], term: Schema.Field[A] ): Optic[S, S, A, OpticFailure, OpticFailure, A, S] = @@ -28,7 +28,7 @@ object ZioOpticsBuilder extends AccessorBuilder { setOptic = ZioOpticsBuilder.makeLensSet(product, term) ) - override def makePrism[S, A]( + override def makePrism[F, S, A]( sum: Schema.Enum[S], term: Schema.Case[A, S] ): ZPrism[S, S, A, A] = @@ -64,7 +64,7 @@ object ZioOpticsBuilder extends AccessorBuilder { term: Schema.Field[A] ): S => Either[(OpticFailure, S), A] = { (whole: S) => product.toDynamic(whole) match { - case DynamicValue.Record(values) => + case DynamicValue.Record(_, values) => values .get(term.label) .map { dynamicField => @@ -83,9 +83,9 @@ object ZioOpticsBuilder extends AccessorBuilder { term: Schema.Field[A] ): A => S => Either[(OpticFailure, S), S] = { (piece: A) => (whole: S) => product.toDynamic(whole) match { - case DynamicValue.Record(values) => + case DynamicValue.Record(name, values) => val updated = spliceRecord(values, term.label, term.label -> term.schema.toDynamic(piece)) - product.fromDynamic(DynamicValue.Record(updated)) match { + product.fromDynamic(DynamicValue.Record(name, updated)) match { case Left(error) => Left(OpticFailure(error) -> whole) case Right(value) => Right(value) } diff --git a/zio-schema-optics/shared/src/test/scala/zio/schema/optics/LensSpec.scala b/zio-schema-optics/shared/src/test/scala/zio/schema/optics/LensSpec.scala index 9d7c9fa0f..af9166986 100644 --- a/zio-schema-optics/shared/src/test/scala/zio/schema/optics/LensSpec.scala +++ b/zio-schema-optics/shared/src/test/scala/zio/schema/optics/LensSpec.scala @@ -18,8 +18,8 @@ object LensSpec extends DefaultRunnableSpec { ) ) - def lensLaws[Env <: TestConfig, Whole, Piece](genWhole: Gen[Env, Whole], genPiece: Gen[Env, Piece])( - lens: ZioOpticsBuilder.Lens[Whole, Piece] + def lensLaws[F, Env <: TestConfig, Whole, Piece](genWhole: Gen[Env, Whole], genPiece: Gen[Env, Piece])( + lens: ZioOpticsBuilder.Lens[F, Whole, Piece] ): URIO[Env, TestResult] = for { getSetIdentity <- getSetIdentity(genWhole)(lens) @@ -27,24 +27,24 @@ object LensSpec extends DefaultRunnableSpec { setSetIdentity <- setSetIdentity(genWhole, genPiece)(lens) } yield setGetIdentity && getSetIdentity && setSetIdentity - def getSetIdentity[Env <: TestConfig, Whole, Piece](genWhole: Gen[Env, Whole])( - lens: ZioOpticsBuilder.Lens[Whole, Piece] + def getSetIdentity[F, Env <: TestConfig, Whole, Piece](genWhole: Gen[Env, Whole])( + lens: ZioOpticsBuilder.Lens[F, Whole, Piece] ): URIO[Env, TestResult] = check(genWhole) { wholeBefore => val wholeAfter = lens.get(wholeBefore).flatMap(lens.set(_)(wholeBefore)) assert(wholeAfter)(isRight(equalTo(wholeBefore))) } - def setGetIdentity[Env <: TestConfig, Whole, Piece](genWhole: Gen[Env, Whole], genPiece: Gen[Env, Piece])( - lens: ZioOpticsBuilder.Lens[Whole, Piece] + def setGetIdentity[F, Env <: TestConfig, Whole, Piece](genWhole: Gen[Env, Whole], genPiece: Gen[Env, Piece])( + lens: ZioOpticsBuilder.Lens[F, Whole, Piece] ): URIO[Env, TestResult] = check(genWhole, genPiece) { (whole, pieceBefore) => val pieceAfter = lens.set(pieceBefore)(whole).flatMap(lens.get) assert(pieceAfter)(isRight(equalTo(pieceBefore))) } - def setSetIdentity[Env <: TestConfig, Whole, Piece](genWhole: Gen[Env, Whole], genPiece: Gen[Env, Piece])( - lens: ZioOpticsBuilder.Lens[Whole, Piece] + def setSetIdentity[F, Env <: TestConfig, Whole, Piece](genWhole: Gen[Env, Whole], genPiece: Gen[Env, Piece])( + lens: ZioOpticsBuilder.Lens[F, Whole, Piece] ): URIO[Env, TestResult] = check(genWhole, genPiece) { (whole, piece) => val wholeBefore = lens.set(piece)(whole) diff --git a/zio-schema-protobuf/shared/src/main/scala/zio/schema/codec/ProtobufCodec.scala b/zio-schema-protobuf/shared/src/main/scala/zio/schema/codec/ProtobufCodec.scala index 626d09ff1..d2465af3a 100644 --- a/zio-schema-protobuf/shared/src/main/scala/zio/schema/codec/ProtobufCodec.scala +++ b/zio-schema-protobuf/shared/src/main/scala/zio/schema/codec/ProtobufCodec.scala @@ -46,12 +46,6 @@ object ProtobufCodec extends Codec { case object Bit32 extends WireType } - private[codec] def tupleSchema[A, B](first: Schema[A], second: Schema[B]): Schema[ListMap[String, _]] = - Schema.record(Schema.Field("first", first), Schema.Field("second", second)) - - private[codec] def singleSchema[A](codec: Schema[A]): Schema[ListMap[String, _]] = - Schema.record(Schema.Field("value", codec)) - private[codec] val bigDecimalStructure: Seq[Schema.Field[_]] = Seq( Schema.Field("unscaled", Schema.Primitive(StandardType.BigIntegerType)), @@ -141,7 +135,7 @@ object ProtobufCodec extends Codec { //scalafmt: { maxColumn = 400, optIn.configStyleArguments = false } def encode[A](fieldNumber: Option[Int], schema: Schema[A], value: A): Chunk[Byte] = (schema, value) match { - case (Schema.GenericRecord(structure, _), v: Map[String, _]) => + case (Schema.GenericRecord(_, structure, _), v: Map[String, _]) => encodeRecord(fieldNumber, structure.toChunk, v) case (Schema.Sequence(element, _, g, _, _), v) => encodeSequence(fieldNumber, element, g(v)) case (Schema.MapSchema(ks, vs, _), map) => encodeSequence(fieldNumber, ks <*> vs, Chunk.fromIterable(map)) @@ -153,74 +147,287 @@ object ProtobufCodec extends Codec { case (Schema.EitherSchema(left: Schema[a], right: Schema[b], _), v: Either[_, _]) => encodeEither(fieldNumber, left, right, v.asInstanceOf[Either[a, b]]) case (lzy @ Schema.Lazy(_), v) => encode(fieldNumber, lzy.schema, v) case (Schema.Meta(ast, _), _) => encode(fieldNumber, Schema[SchemaAst], ast) - case (Schema.CaseClass1(f, _, ext, _), v) => encodeCaseClass(v, f -> ext)(fieldNumber) - case (Schema.CaseClass2(f1, f2, _, ext1, ext2, _), v) => encodeCaseClass(v, f1 -> ext1, f2 -> ext2)(fieldNumber) - case (Schema.CaseClass3(f1, f2, f3, _, ext1, ext2, ext3, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3)(fieldNumber) - case (Schema.CaseClass4(f1, f2, f3, f4, _, ext1, ext2, ext3, ext4, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4)(fieldNumber) - case (Schema.CaseClass5(f1, f2, f3, f4, f5, _, ext1, ext2, ext3, ext4, ext5, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5)(fieldNumber) - case (Schema.CaseClass6(f1, f2, f3, f4, f5, f6, _, ext1, ext2, ext3, ext4, ext5, ext6, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6)(fieldNumber) - case (Schema.CaseClass7(f1, f2, f3, f4, f5, f6, f7, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7)(fieldNumber) - case (Schema.CaseClass8(f1, f2, f3, f4, f5, f6, f7, f8, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8)(fieldNumber) - case (Schema.CaseClass9(f1, f2, f3, f4, f5, f6, f7, f8, f9, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9)(fieldNumber) - case (Schema.CaseClass10(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10)(fieldNumber) - case (Schema.CaseClass11(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11)(fieldNumber) - case (Schema.CaseClass12(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12)(fieldNumber) - case (Schema.CaseClass13(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13)(fieldNumber) - case (Schema.CaseClass14(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14)(fieldNumber) - case (Schema.CaseClass15(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15)(fieldNumber) - case (Schema.CaseClass16(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16)(fieldNumber) - case (Schema.CaseClass17(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17)(fieldNumber) - case (Schema.CaseClass18(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18)(fieldNumber) - case (Schema.CaseClass19(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19)(fieldNumber) - case (Schema.CaseClass20(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19, f20 -> ext20)(fieldNumber) - case (Schema.CaseClass21(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, ext21, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19, f20 -> ext20, f21 -> ext21)(fieldNumber) - case (Schema.CaseClass22(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, ext21, ext22, _), v) => - encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19, f20 -> ext20, f21 -> ext21, f22 -> ext22)(fieldNumber) - case (Schema.Enum1(c, _), v) => encodeEnum(fieldNumber, v, c) - case (Schema.Enum2(c1, c2, _), v) => encodeEnum(fieldNumber, v, c1, c2) - case (Schema.Enum3(c1, c2, c3, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3) - case (Schema.Enum4(c1, c2, c3, c4, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4) - case (Schema.Enum5(c1, c2, c3, c4, c5, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5) - case (Schema.Enum6(c1, c2, c3, c4, c5, c6, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6) - case (Schema.Enum7(c1, c2, c3, c4, c5, c6, c7, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7) - case (Schema.Enum8(c1, c2, c3, c4, c5, c6, c7, c8, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8) - case (Schema.Enum9(c1, c2, c3, c4, c5, c6, c7, c8, c9, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9) - case (Schema.Enum10(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) - case (Schema.Enum11(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) - case (Schema.Enum12(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) - case (Schema.Enum13(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) - case (Schema.Enum14(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) - case (Schema.Enum15(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) - case (Schema.Enum16(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) - case (Schema.Enum17(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) - case (Schema.Enum18(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) - case (Schema.Enum19(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) - case (Schema.Enum20(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) - case (Schema.Enum21(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) - case (Schema.Enum22(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) - case (Schema.EnumN(cs, _), v) => encodeEnum(fieldNumber, v, cs.toSeq: _*) - case (Schema.Dynamic(_), v) => encode(fieldNumber, DynamicValueSchema.schema, v) - case (Schema.SemiDynamic(_, _), v) => encodeSemiDynamic[Any](fieldNumber, v.asInstanceOf[(Any, Schema[Any])]) - case (_, _) => Chunk.empty + case (_: Schema.CaseClass0[_], v) => + encodeCaseClass(v)(fieldNumber) + case (cc: Schema.CaseClass1[_, _], v) => + encodeCaseClass(v, cc.field -> cc.extractField)(fieldNumber) + case (cc: Schema.CaseClass2[_, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2)(fieldNumber) + case (cc: Schema.CaseClass3[_, _, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3)(fieldNumber) + case (cc: Schema.CaseClass4[_, _, _, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4)(fieldNumber) + case (cc: Schema.CaseClass5[_, _, _, _, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5)(fieldNumber) + case (cc: Schema.CaseClass6[_, _, _, _, _, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6)(fieldNumber) + case (cc: Schema.CaseClass7[_, _, _, _, _, _, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7)(fieldNumber) + case (cc: Schema.CaseClass8[_, _, _, _, _, _, _, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7, cc.field8 -> cc.extractField8)(fieldNumber) + case (cc: Schema.CaseClass9[_, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7, cc.field8 -> cc.extractField8, cc.field9 -> cc.extractField9)(fieldNumber) + case (cc: Schema.CaseClass10[_, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7, cc.field8 -> cc.extractField8, cc.field9 -> cc.extractField9, cc.field10 -> cc.extractField10)(fieldNumber) + case (cc: Schema.CaseClass11[_, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7, cc.field8 -> cc.extractField8, cc.field9 -> cc.extractField9, cc.field10 -> cc.extractField10, cc.field11 -> cc.extractField11)(fieldNumber) + case (cc: Schema.CaseClass12[_, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12 + )(fieldNumber) + case (cc: Schema.CaseClass13[_, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13 + )(fieldNumber) + case (cc: Schema.CaseClass14[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14 + )(fieldNumber) + case (cc: Schema.CaseClass15[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15 + )(fieldNumber) + case (cc: Schema.CaseClass16[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16 + )(fieldNumber) + case (cc: Schema.CaseClass17[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17 + )(fieldNumber) + case (cc: Schema.CaseClass18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18 + )(fieldNumber) + case (cc: Schema.CaseClass19[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18, + cc.field19 -> cc.extractField19 + )(fieldNumber) + case (cc: Schema.CaseClass20[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18, + cc.field19 -> cc.extractField19, + cc.field20 -> cc.extractField20 + )(fieldNumber) + case (cc: Schema.CaseClass21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18, + cc.field19 -> cc.extractField19, + cc.field20 -> cc.extractField20, + cc.field21 -> cc.extractField21 + )(fieldNumber) + case (cc: Schema.CaseClass22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18, + cc.field19 -> cc.extractField19, + cc.field20 -> cc.extractField20, + cc.field21 -> cc.extractField21, + cc.field22 -> cc.extractField22 + )(fieldNumber) + case (Schema.Enum1(_, c, _), v) => encodeEnum(fieldNumber, v, c) + case (Schema.Enum2(_, c1, c2, _), v) => encodeEnum(fieldNumber, v, c1, c2) + case (Schema.Enum3(_, c1, c2, c3, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3) + case (Schema.Enum4(_, c1, c2, c3, c4, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4) + case (Schema.Enum5(_, c1, c2, c3, c4, c5, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5) + case (Schema.Enum6(_, c1, c2, c3, c4, c5, c6, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6) + case (Schema.Enum7(_, c1, c2, c3, c4, c5, c6, c7, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7) + case (Schema.Enum8(_, c1, c2, c3, c4, c5, c6, c7, c8, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8) + case (Schema.Enum9(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9) + case (Schema.Enum10(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) + case (Schema.Enum11(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) + case (Schema.Enum12(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) + case (Schema.Enum13(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) + case (Schema.Enum14(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) + case (Schema.Enum15(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) + case (Schema.Enum16(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) + case (Schema.Enum17(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) + case (Schema.Enum18(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) + case (Schema.Enum19(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) + case (Schema.Enum20(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) + case (Schema.Enum21(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) + case (Schema.Enum22(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) + case (Schema.EnumN(_, cs, _), v) => encodeEnum(fieldNumber, v, cs.toSeq: _*) + case (Schema.Dynamic(_), v) => encode(fieldNumber, DynamicValueSchema.schema, v) + case (Schema.SemiDynamic(_, _), v) => encodeSemiDynamic[Any](fieldNumber, v.asInstanceOf[(Any, Schema[Any])]) + case (_, _) => Chunk.empty } //scalafmt: { maxColumn = 120, optIn.configStyleArguments = true } @@ -525,7 +732,7 @@ object ProtobufCodec extends Codec { private[codec] def decoder[A](schema: Schema[A]): Decoder[A] = //scalafmt: { maxColumn = 400, optIn.configStyleArguments = false } schema match { - case Schema.GenericRecord(structure, _) => recordDecoder(structure.toChunk) + case Schema.GenericRecord(_, structure, _) => recordDecoder(structure.toChunk) case Schema.Sequence(elementSchema, fromChunk, _, _, _) => if (canBePacked(elementSchema)) packedSequenceDecoder(elementSchema).map(fromChunk) else nonPackedSequenceDecoder(elementSchema).map(fromChunk) @@ -565,31 +772,31 @@ object ProtobufCodec extends Codec { caseClass21Decoder(s) case s: Schema.CaseClass22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, A] => caseClass22Decoder(s) - case Schema.Enum1(c, _) => enumDecoder(c) - case Schema.Enum2(c1, c2, _) => enumDecoder(c1, c2) - case Schema.Enum3(c1, c2, c3, _) => enumDecoder(c1, c2, c3) - case Schema.Enum4(c1, c2, c3, c4, _) => enumDecoder(c1, c2, c3, c4) - case Schema.Enum5(c1, c2, c3, c4, c5, _) => enumDecoder(c1, c2, c3, c4, c5) - case Schema.Enum6(c1, c2, c3, c4, c5, c6, _) => enumDecoder(c1, c2, c3, c4, c5, c6) - case Schema.Enum7(c1, c2, c3, c4, c5, c6, c7, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7) - case Schema.Enum8(c1, c2, c3, c4, c5, c6, c7, c8, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8) - case Schema.Enum9(c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9) - case Schema.Enum10(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) - case Schema.Enum11(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) - case Schema.Enum12(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) - case Schema.Enum13(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) - case Schema.Enum14(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) - case Schema.Enum15(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) - case Schema.Enum16(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) - case Schema.Enum17(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) - case Schema.Enum18(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) - case Schema.Enum19(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) - case Schema.Enum20(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) - case Schema.Enum21(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) - case Schema.Enum22(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) - case Schema.EnumN(cs, _) => enumDecoder(cs.toSeq: _*) - case Schema.Dynamic(_) => dynamicDecoder - case Schema.SemiDynamic(_, _) => semiDynamicDecoder.asInstanceOf[Decoder[A]] + case Schema.Enum1(_, c, _) => enumDecoder(c) + case Schema.Enum2(_, c1, c2, _) => enumDecoder(c1, c2) + case Schema.Enum3(_, c1, c2, c3, _) => enumDecoder(c1, c2, c3) + case Schema.Enum4(_, c1, c2, c3, c4, _) => enumDecoder(c1, c2, c3, c4) + case Schema.Enum5(_, c1, c2, c3, c4, c5, _) => enumDecoder(c1, c2, c3, c4, c5) + case Schema.Enum6(_, c1, c2, c3, c4, c5, c6, _) => enumDecoder(c1, c2, c3, c4, c5, c6) + case Schema.Enum7(_, c1, c2, c3, c4, c5, c6, c7, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7) + case Schema.Enum8(_, c1, c2, c3, c4, c5, c6, c7, c8, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8) + case Schema.Enum9(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9) + case Schema.Enum10(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) + case Schema.Enum11(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) + case Schema.Enum12(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) + case Schema.Enum13(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) + case Schema.Enum14(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) + case Schema.Enum15(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) + case Schema.Enum16(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) + case Schema.Enum17(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) + case Schema.Enum18(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) + case Schema.Enum19(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) + case Schema.Enum20(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) + case Schema.Enum21(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) + case Schema.Enum22(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => enumDecoder(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) + case Schema.EnumN(_, cs, _) => enumDecoder(cs.toSeq: _*) + case Schema.Dynamic(_) => dynamicDecoder + case Schema.SemiDynamic(_, _) => semiDynamicDecoder.asInstanceOf[Decoder[A]] } //scalafmt: { maxColumn = 120, optIn.configStyleArguments = true } diff --git a/zio-schema-protobuf/shared/src/test/scala-2/zio/schema/codec/ProtobufCodecSpec.scala b/zio-schema-protobuf/shared/src/test/scala-2/zio/schema/codec/ProtobufCodecSpec.scala index 0c6934663..13a810e7b 100644 --- a/zio-schema-protobuf/shared/src/test/scala-2/zio/schema/codec/ProtobufCodecSpec.scala +++ b/zio-schema-protobuf/shared/src/test/scala-2/zio/schema/codec/ProtobufCodecSpec.scala @@ -12,7 +12,7 @@ import zio.blocking.Blocking import zio.console._ import zio.random.Random import zio.schema.CaseSet._ -import zio.schema.{ CaseSet, DeriveSchema, DynamicValue, DynamicValueGen, Schema, SchemaGen, StandardType } +import zio.schema.{ CaseSet, DeriveSchema, DynamicValue, DynamicValueGen, Schema, SchemaGen, StandardType, TypeId } import zio.stream.{ ZSink, ZStream } import zio.test.Assertion._ import zio.test._ @@ -598,7 +598,10 @@ object ProtobufCodecSpec extends DefaultRunnableSpec { { case (str, schema) => Right(DynamicValue.fromSchemaAndValue(schema, str)) }, (v: DynamicValue) => v.toTypedValue(Schema[String]).map((_, Schema[String])) ) - val enumSchema = Schema.Enum1[DynamicValue, DynamicValue](Schema.Case("one", semiDynamicSchema, identity)) + val enumSchema = Schema.Enum1[DynamicValue, DynamicValue]( + TypeId.parse("zio.schema.DynamicValue"), + Schema.Case("one", semiDynamicSchema, identity) + ) assertM(encodeAndDecode(enumSchema, dynamicValue))(equalTo(Chunk(dynamicValue))) } }, @@ -612,7 +615,10 @@ object ProtobufCodecSpec extends DefaultRunnableSpec { { case (str, schema) => Right(DynamicValue.fromSchemaAndValue(schema, str)) }, (v: DynamicValue) => v.toTypedValue(Schema[Chunk[Int]]).map((_, Schema[Chunk[Int]])) ) - val enumSchema = Schema.Enum1[DynamicValue, DynamicValue](Schema.Case("one", semiDynamicSchema, identity)) + val enumSchema = Schema.Enum1[DynamicValue, DynamicValue]( + TypeId.parse("zio.schema.DynamicValue"), + Schema.Case("one", semiDynamicSchema, identity) + ) assertM(encodeAndDecode(enumSchema, dynamicValue))(equalTo(Chunk(dynamicValue))) } } @@ -733,6 +739,7 @@ object ProtobufCodecSpec extends DefaultRunnableSpec { }, testM("dynamic record example") { val dynamicValue = DynamicValue.Record( + TypeId.Structural, ListMap("0" -> DynamicValue.Primitive(new java.math.BigDecimal(0.0), StandardType[java.math.BigDecimal])) ) assertM(encodeAndDecodeNS(Schema.dynamicValue, dynamicValue))(equalTo(dynamicValue)) @@ -821,12 +828,14 @@ object ProtobufCodecSpec extends DefaultRunnableSpec { implicit val schemaRecord: Schema[Record] = DeriveSchema.gen[Record] val genericRecord: Schema[ListMap[String, _]] = Schema.record( + TypeId.Structural, Schema.Field("c", Schema.Primitive(StandardType.IntType)), Schema.Field("b", Schema.Primitive(StandardType.IntType)), Schema.Field("a", Schema.Primitive(StandardType.IntType)) ) val genericRecordSorted: Schema[ListMap[String, _]] = Schema.record( + TypeId.Structural, Schema.Field("a", Schema.Primitive(StandardType.IntType)), Schema.Field("b", Schema.Primitive(StandardType.IntType)), Schema.Field("c", Schema.Primitive(StandardType.IntType)) @@ -904,10 +913,12 @@ object ProtobufCodecSpec extends DefaultRunnableSpec { lazy val schemaEnumeration: Schema[Enumeration] = DeriveSchema.gen[Enumeration] lazy val schemaGenericEnumeration: Schema[Any] = Schema.enumeration[Any, CaseSet.Aux[Any]]( + TypeId.Structural, caseOf[String, Any]("string")(_.asInstanceOf[String]) ++ caseOf[Int, Any]("int")(_.asInstanceOf[Int]) ) lazy val schemaGenericEnumerationSorted: Schema[Any] = Schema.enumeration[Any, CaseSet.Aux[Any]]( + TypeId.Structural, caseOf[Int, Any]("int")(_.asInstanceOf[Int]) ++ caseOf[String, Any]("string")(_.asInstanceOf[String]) ) diff --git a/zio-schema-thrift/shared/src/main/scala/zio/schema/codec/ThriftCodec.scala b/zio-schema-thrift/shared/src/main/scala/zio/schema/codec/ThriftCodec.scala index ba2806bae..b50b4ebb0 100644 --- a/zio-schema-thrift/shared/src/main/scala/zio/schema/codec/ThriftCodec.scala +++ b/zio-schema-thrift/shared/src/main/scala/zio/schema/codec/ThriftCodec.scala @@ -1,4 +1,5 @@ package zio.schema.codec + import java.nio.ByteBuffer import java.time.{ DayOfWeek, @@ -312,7 +313,7 @@ object ThriftCodec extends Codec { //scalafmt: { maxColumn = 400, optIn.configStyleArguments = false } def encodeValue[A](fieldNumber: Option[Short], schema: Schema[A], value: A): Unit = (schema, value) match { - case (Schema.GenericRecord(structure, _), v) => encodeRecord(fieldNumber, structure.toChunk, v) + case (Schema.GenericRecord(_, structure, _), v) => encodeRecord(fieldNumber, structure.toChunk, v) case (Schema.Sequence(element, _, g, _, _), v) => encodeSequence(fieldNumber, element, g(v)) case (mapSchema @ Schema.MapSchema(_, _, _), map) => encodeMap(fieldNumber, mapSchema, map) case (Schema.SetSchema(s, _), set) => encodeSet(fieldNumber, s, set) @@ -326,44 +327,44 @@ object ThriftCodec extends Codec { case ProductEncoder(encode) => writeFieldBegin(fieldNumber, TType.STRUCT) encode() - case (Schema.Enum1(c, _), v) => encodeEnum(fieldNumber, v, c) - case (Schema.Enum2(c1, c2, _), v) => encodeEnum(fieldNumber, v, c1, c2) - case (Schema.Enum3(c1, c2, c3, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3) - case (Schema.Enum4(c1, c2, c3, c4, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4) - case (Schema.Enum5(c1, c2, c3, c4, c5, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5) - case (Schema.Enum6(c1, c2, c3, c4, c5, c6, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6) - case (Schema.Enum7(c1, c2, c3, c4, c5, c6, c7, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7) - case (Schema.Enum8(c1, c2, c3, c4, c5, c6, c7, c8, _), v) => + case (Schema.Enum1(_, c, _), v) => encodeEnum(fieldNumber, v, c) + case (Schema.Enum2(_, c1, c2, _), v) => encodeEnum(fieldNumber, v, c1, c2) + case (Schema.Enum3(_, c1, c2, c3, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3) + case (Schema.Enum4(_, c1, c2, c3, c4, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4) + case (Schema.Enum5(_, c1, c2, c3, c4, c5, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5) + case (Schema.Enum6(_, c1, c2, c3, c4, c5, c6, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6) + case (Schema.Enum7(_, c1, c2, c3, c4, c5, c6, c7, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7) + case (Schema.Enum8(_, c1, c2, c3, c4, c5, c6, c7, c8, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8) - case (Schema.Enum9(c1, c2, c3, c4, c5, c6, c7, c8, c9, _), v) => + case (Schema.Enum9(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9) - case (Schema.Enum10(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _), v) => + case (Schema.Enum10(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) - case (Schema.Enum11(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _), v) => + case (Schema.Enum11(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) - case (Schema.Enum12(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _), v) => + case (Schema.Enum12(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) - case (Schema.Enum13(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _), v) => + case (Schema.Enum13(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) - case (Schema.Enum14(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _), v) => + case (Schema.Enum14(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) - case (Schema.Enum15(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _), v) => + case (Schema.Enum15(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) - case (Schema.Enum16(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _), v) => + case (Schema.Enum16(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) - case (Schema.Enum17(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _), v) => + case (Schema.Enum17(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) - case (Schema.Enum18(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _), v) => + case (Schema.Enum18(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) - case (Schema.Enum19(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _), v) => + case (Schema.Enum19(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) - case (Schema.Enum20(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _), v) => + case (Schema.Enum20(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) - case (Schema.Enum21(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _), v) => + case (Schema.Enum21(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) - case (Schema.Enum22(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _), v) => + case (Schema.Enum22(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _), v) => encodeEnum(fieldNumber, v, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) - case (Schema.EnumN(cs, _), v) => encodeEnum(fieldNumber, v, cs.toSeq: _*) + case (Schema.EnumN(_, cs, _), v) => encodeEnum(fieldNumber, v, cs.toSeq: _*) case (Schema.Dynamic(_), v) => encodeDynamic(fieldNumber, v) case (Schema.SemiDynamic(_, _), v) => encodeSemiDynamic[Any](fieldNumber, v.asInstanceOf[(Any, Schema[Any])]) case (_, _) => () @@ -414,48 +415,283 @@ object ThriftCodec extends Codec { private[codec] object ProductEncoder { def unapply[A](schemaAndValue: (Schema[A], A)): Option[() => Unit] = schemaAndValue match { - case (Schema.CaseClass1(f, _, ext, _), v) => Some(encodeCaseClass(v, f -> ext)) - case (Schema.CaseClass2(f1, f2, _, ext1, ext2, _), v) => Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2)) - case (Schema.CaseClass3(f1, f2, f3, _, ext1, ext2, ext3, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3)) - case (Schema.CaseClass4(f1, f2, f3, f4, _, ext1, ext2, ext3, ext4, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4)) - case (Schema.CaseClass5(f1, f2, f3, f4, f5, _, ext1, ext2, ext3, ext4, ext5, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5)) - case (Schema.CaseClass6(f1, f2, f3, f4, f5, f6, _, ext1, ext2, ext3, ext4, ext5, ext6, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6)) - case (Schema.CaseClass7(f1, f2, f3, f4, f5, f6, f7, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7)) - case (Schema.CaseClass8(f1, f2, f3, f4, f5, f6, f7, f8, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8)) - case (Schema.CaseClass9(f1, f2, f3, f4, f5, f6, f7, f8, f9, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9)) - case (Schema.CaseClass10(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10)) - case (Schema.CaseClass11(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11)) - case (Schema.CaseClass12(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12)) - case (Schema.CaseClass13(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13)) - case (Schema.CaseClass14(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14)) - case (Schema.CaseClass15(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15)) - case (Schema.CaseClass16(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16)) - case (Schema.CaseClass17(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17)) - case (Schema.CaseClass18(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18)) - case (Schema.CaseClass19(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19)) - case (Schema.CaseClass20(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19, f20 -> ext20)) - case (Schema.CaseClass21(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, ext21, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19, f20 -> ext20, f21 -> ext21)) - case (Schema.CaseClass22(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, ext9, ext10, ext11, ext12, ext13, ext14, ext15, ext16, ext17, ext18, ext19, ext20, ext21, ext22, _), v) => - Some(encodeCaseClass(v, f1 -> ext1, f2 -> ext2, f3 -> ext3, f4 -> ext4, f5 -> ext5, f6 -> ext6, f7 -> ext7, f8 -> ext8, f9 -> ext9, f10 -> ext10, f11 -> ext11, f12 -> ext12, f13 -> ext13, f14 -> ext14, f15 -> ext15, f16 -> ext16, f17 -> ext17, f18 -> ext18, f19 -> ext19, f20 -> ext20, f21 -> ext21, f22 -> ext22)) + case (_: Schema.CaseClass0[_], v) => + Some(encodeCaseClass(v)) + case (cc: Schema.CaseClass1[_, _], v) => + Some(encodeCaseClass(v, cc.field -> cc.extractField)) + case (cc: Schema.CaseClass2[_, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2)) + case (cc: Schema.CaseClass3[_, _, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3)) + case (cc: Schema.CaseClass4[_, _, _, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4)) + case (cc: Schema.CaseClass5[_, _, _, _, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5)) + case (cc: Schema.CaseClass6[_, _, _, _, _, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6)) + case (cc: Schema.CaseClass7[_, _, _, _, _, _, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7)) + case (cc: Schema.CaseClass8[_, _, _, _, _, _, _, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7, cc.field8 -> cc.extractField8)) + case (cc: Schema.CaseClass9[_, _, _, _, _, _, _, _, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7, cc.field8 -> cc.extractField8, cc.field9 -> cc.extractField9)) + case (cc: Schema.CaseClass10[_, _, _, _, _, _, _, _, _, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7, cc.field8 -> cc.extractField8, cc.field9 -> cc.extractField9, cc.field10 -> cc.extractField10)) + case (cc: Schema.CaseClass11[_, _, _, _, _, _, _, _, _, _, _, _], v) => + Some(encodeCaseClass(v, cc.field1 -> cc.extractField1, cc.field2 -> cc.extractField2, cc.field3 -> cc.extractField3, cc.field4 -> cc.extractField4, cc.field5 -> cc.extractField5, cc.field6 -> cc.extractField6, cc.field7 -> cc.extractField7, cc.field8 -> cc.extractField8, cc.field9 -> cc.extractField9, cc.field10 -> cc.extractField10, cc.field11 -> cc.extractField11)) + case (cc: Schema.CaseClass12[_, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12 + ) + ) + case (cc: Schema.CaseClass13[_, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13 + ) + ) + case (cc: Schema.CaseClass14[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14 + ) + ) + case (cc: Schema.CaseClass15[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15 + ) + ) + case (cc: Schema.CaseClass16[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16 + ) + ) + case (cc: Schema.CaseClass17[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17 + ) + ) + case (cc: Schema.CaseClass18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18 + ) + ) + case (cc: Schema.CaseClass19[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18, + cc.field19 -> cc.extractField19 + ) + ) + case (cc: Schema.CaseClass20[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18, + cc.field19 -> cc.extractField19, + cc.field20 -> cc.extractField20 + ) + ) + case (cc: Schema.CaseClass21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18, + cc.field19 -> cc.extractField19, + cc.field20 -> cc.extractField20, + cc.field21 -> cc.extractField21 + ) + ) + case (cc: Schema.CaseClass22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], v) => + Some( + encodeCaseClass( + v, + cc.field1 -> cc.extractField1, + cc.field2 -> cc.extractField2, + cc.field3 -> cc.extractField3, + cc.field4 -> cc.extractField4, + cc.field5 -> cc.extractField5, + cc.field6 -> cc.extractField6, + cc.field7 -> cc.extractField7, + cc.field8 -> cc.extractField8, + cc.field9 -> cc.extractField9, + cc.field10 -> cc.extractField10, + cc.field11 -> cc.extractField11, + cc.field12 -> cc.extractField12, + cc.field13 -> cc.extractField13, + cc.field14 -> cc.extractField14, + cc.field15 -> cc.extractField15, + cc.field16 -> cc.extractField16, + cc.field17 -> cc.extractField17, + cc.field18 -> cc.extractField18, + cc.field19 -> cc.extractField19, + cc.field20 -> cc.extractField20, + cc.field21 -> cc.extractField21, + cc.field22 -> cc.extractField22 + ) + ) case _ => None } @@ -480,7 +716,9 @@ object ThriftCodec extends Codec { class Decoder(chunk: Chunk[Byte]) { type Path = Chunk[String] + case class Error(path: Path, error: String) + type Result[A] = Either[Error, A] type PrimitiveResult[A] = Path => Result[A] @@ -529,48 +767,48 @@ object ThriftCodec extends Codec { def decode[A](path: Path, schema: Schema[A]): Result[A] = schema match { - case Schema.GenericRecord(structure, _) => { + case Schema.GenericRecord(_, structure, _) => { val fields = structure.toChunk decodeRecord(path, fields).map(_.map { case (index, value) => (fields(index - 1).label, value) }) } - case seqSchema @ Schema.Sequence(_, _, _, _, _) => decodeSequence(path, seqSchema) - case mapSchema @ Schema.MapSchema(_, _, _) => decodeMap(path, mapSchema) - case setSchema @ Schema.SetSchema(_, _) => decodeSet(path, setSchema) - case Schema.Transform(codec, f, _, _, _) => transformDecoder(path, codec, f) - case Schema.Primitive(standardType, _) => primitiveDecoder(path, standardType) - case Schema.Tuple(left, right, _) => tupleDecoder(path, left, right) - case optionalSchema @ Schema.Optional(_, _) => optionalDecoder(path, optionalSchema) - case Schema.Fail(message, _) => fail(path, message) - case Schema.EitherSchema(left, right, _) => eitherDecoder(path, left, right) - case lzy @ Schema.Lazy(_) => decode(path, lzy.schema) - case Schema.Meta(_, _) => decode(path, Schema[SchemaAst]).map(_.toSchema) - case ProductDecoder(decoder) => decoder(path) - case Schema.Enum1(c, _) => enumDecoder(path, c) - case Schema.Enum2(c1, c2, _) => enumDecoder(path, c1, c2) - case Schema.Enum3(c1, c2, c3, _) => enumDecoder(path, c1, c2, c3) - case Schema.Enum4(c1, c2, c3, c4, _) => enumDecoder(path, c1, c2, c3, c4) - case Schema.Enum5(c1, c2, c3, c4, c5, _) => enumDecoder(path, c1, c2, c3, c4, c5) - case Schema.Enum6(c1, c2, c3, c4, c5, c6, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6) - case Schema.Enum7(c1, c2, c3, c4, c5, c6, c7, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7) - case Schema.Enum8(c1, c2, c3, c4, c5, c6, c7, c8, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8) - case Schema.Enum9(c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9) - case Schema.Enum10(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) - case Schema.Enum11(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) - case Schema.Enum12(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) - case Schema.Enum13(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) - case Schema.Enum14(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) - case Schema.Enum15(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) - case Schema.Enum16(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) - case Schema.Enum17(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) - case Schema.Enum18(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) - case Schema.Enum19(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) - case Schema.Enum20(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) - case Schema.Enum21(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) - case Schema.Enum22(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) - case Schema.EnumN(cs, _) => enumDecoder(path, cs.toSeq: _*) - case Schema.Dynamic(_) => dynamicDecoder(path) - case Schema.SemiDynamic(_, _) => semiDynamicDecoder[Any](path).asInstanceOf[Decoder.this.Result[A]] - case _ => fail(path, s"Unknown schema ${schema.getClass.getName}") + case seqSchema @ Schema.Sequence(_, _, _, _, _) => decodeSequence(path, seqSchema) + case mapSchema @ Schema.MapSchema(_, _, _) => decodeMap(path, mapSchema) + case setSchema @ Schema.SetSchema(_, _) => decodeSet(path, setSchema) + case Schema.Transform(codec, f, _, _, _) => transformDecoder(path, codec, f) + case Schema.Primitive(standardType, _) => primitiveDecoder(path, standardType) + case Schema.Tuple(left, right, _) => tupleDecoder(path, left, right) + case optionalSchema @ Schema.Optional(_, _) => optionalDecoder(path, optionalSchema) + case Schema.Fail(message, _) => fail(path, message) + case Schema.EitherSchema(left, right, _) => eitherDecoder(path, left, right) + case lzy @ Schema.Lazy(_) => decode(path, lzy.schema) + case Schema.Meta(_, _) => decode(path, Schema[SchemaAst]).map(_.toSchema) + case ProductDecoder(decoder) => decoder(path) + case Schema.Enum1(_, c, _) => enumDecoder(path, c) + case Schema.Enum2(_, c1, c2, _) => enumDecoder(path, c1, c2) + case Schema.Enum3(_, c1, c2, c3, _) => enumDecoder(path, c1, c2, c3) + case Schema.Enum4(_, c1, c2, c3, c4, _) => enumDecoder(path, c1, c2, c3, c4) + case Schema.Enum5(_, c1, c2, c3, c4, c5, _) => enumDecoder(path, c1, c2, c3, c4, c5) + case Schema.Enum6(_, c1, c2, c3, c4, c5, c6, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6) + case Schema.Enum7(_, c1, c2, c3, c4, c5, c6, c7, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7) + case Schema.Enum8(_, c1, c2, c3, c4, c5, c6, c7, c8, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8) + case Schema.Enum9(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9) + case Schema.Enum10(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) + case Schema.Enum11(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) + case Schema.Enum12(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) + case Schema.Enum13(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) + case Schema.Enum14(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) + case Schema.Enum15(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) + case Schema.Enum16(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) + case Schema.Enum17(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) + case Schema.Enum18(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) + case Schema.Enum19(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) + case Schema.Enum20(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) + case Schema.Enum21(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) + case Schema.Enum22(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => enumDecoder(path, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) + case Schema.EnumN(_, cs, _) => enumDecoder(path, cs.toSeq: _*) + case Schema.Dynamic(_) => dynamicDecoder(path) + case Schema.SemiDynamic(_, _) => semiDynamicDecoder[Any](path).asInstanceOf[Decoder.this.Result[A]] + case _ => fail(path, s"Unknown schema ${schema.getClass.getName}") } @@ -738,7 +976,9 @@ object ThriftCodec extends Codec { @tailrec def readFields(m: ListMap[Short, Any]): Result[ListMap[Short, Any]] = - Try { p.readFieldBegin() } match { + Try { + p.readFieldBegin() + } match { case Failure(err) => fail(path, s"Error reading field begin: ${err.getMessage}") case Success(readField) => { if (readField.`type` == TType.STOP) @@ -771,7 +1011,9 @@ object ThriftCodec extends Codec { } else succeed(cb.result()) - Try { p.readListBegin() }.fold(_ => fail(path, "Can not decode Sequence begin"), begin => decodeElements(begin.size, ChunkBuilder.make[Elem]()).map(schema.fromChunk)) + Try { + p.readListBegin() + }.fold(_ => fail(path, "Can not decode Sequence begin"), begin => decodeElements(begin.size, ChunkBuilder.make[Elem]()).map(schema.fromChunk)) } def decodeMap[K, V](path: Path, schema: Schema.MapSchema[K, V]): Result[Map[K, V]] = { @@ -802,7 +1044,9 @@ object ThriftCodec extends Codec { } else succeed(cb.result()) - Try { p.readSetBegin() }.fold(_ => fail(path, "Can not decode Set begin"), begin => decodeElements(begin.size, ChunkBuilder.make[A]()).map(_.toSet)) + Try { + p.readSetBegin() + }.fold(_ => fail(path, "Can not decode Set begin"), begin => decodeElements(begin.size, ChunkBuilder.make[A]()).map(_.toSet)) } private[codec] object ProductDecoder { diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/ThriftCodecSpec.scala b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/ThriftCodecSpec.scala index 42b00de6d..1a661709e 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/ThriftCodecSpec.scala +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/ThriftCodecSpec.scala @@ -31,7 +31,7 @@ import org.apache.thrift.protocol.{ TBinaryProtocol, TField, TType } import zio.console.putStrLn import zio.schema.CaseSet.caseOf import zio.schema.codec.{ generated => g } -import zio.schema.{ CaseSet, DeriveSchema, DynamicValue, DynamicValueGen, Schema, SchemaGen, StandardType } +import zio.schema.{ CaseSet, DeriveSchema, DynamicValue, DynamicValueGen, Schema, SchemaGen, StandardType, TypeId } import zio.stream.{ ZSink, ZStream } import zio.test.Assertion._ import zio.test._ @@ -729,6 +729,7 @@ object ThriftCodecSpec extends DefaultRunnableSpec { }, testM("dynamic record example") { val dynamicValue: DynamicValue = DynamicValue.Record( + TypeId.Structural, ListMap("0" -> DynamicValue.Primitive(new java.math.BigDecimal(0.0), StandardType[java.math.BigDecimal])) ) for { @@ -986,10 +987,12 @@ object ThriftCodecSpec extends DefaultRunnableSpec { lazy val schemaEnumeration: Schema[Enumeration] = DeriveSchema.gen[Enumeration] lazy val schemaGenericEnumeration: Schema[Any] = Schema.enumeration[Any, CaseSet.Aux[Any]]( + TypeId.Structural, caseOf[String, Any]("string")(_.asInstanceOf[String]) ++ caseOf[Int, Any]("int")(_.asInstanceOf[Int]) ) lazy val schemaGenericEnumerationSorted: Schema[Any] = Schema.enumeration[Any, CaseSet.Aux[Any]]( + TypeId.Structural, caseOf[Int, Any]("int")(_.asInstanceOf[Int]) ++ caseOf[String, Any]("string")(_.asInstanceOf[String]) ) diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicDouble.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicDouble.java index e8c3524ab..fcf810231 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicDouble.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicDouble.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class BasicDouble implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BasicDouble"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicInt.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicInt.java index 2bc9258ff..6864e91e7 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicInt.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicInt.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class BasicInt implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BasicInt"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicString.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicString.java index 74f397b3c..3727f5dae 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicString.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BasicString.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class BasicString implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BasicString"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BoolValue.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BoolValue.java index 239d57657..ab08cfaf7 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BoolValue.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/BoolValue.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class BoolValue implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BoolValue"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Color.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Color.java index bcce83269..7ec4b4d92 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Color.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Color.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public enum Color implements org.apache.thrift.TEnum { RED(0), GREEN(1), diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Embedded.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Embedded.java index 2b2e9782e..6dabbc682 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Embedded.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Embedded.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class Embedded implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Embedded"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/EnumValue.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/EnumValue.java index cfff12411..6c0d5dec9 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/EnumValue.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/EnumValue.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class EnumValue implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("EnumValue"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Enumeration.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Enumeration.java index 2a0ba1387..96f4031a5 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Enumeration.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Enumeration.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class Enumeration implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Enumeration"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/HighArity.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/HighArity.java index 4e93ad9e6..162de0773 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/HighArity.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/HighArity.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class HighArity implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("HighArity"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/IntList.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/IntList.java index 03db63307..88db2cfba 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/IntList.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/IntList.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class IntList implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("IntList"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/IntValue.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/IntValue.java index f14780d29..8f7e8b123 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/IntValue.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/IntValue.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class IntValue implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("IntValue"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/MapValue.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/MapValue.java index 5d3c02c60..632126e0a 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/MapValue.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/MapValue.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class MapValue implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("MapValue"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/OneOf.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/OneOf.java index c148520e3..cea98e237 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/OneOf.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/OneOf.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class OneOf extends org.apache.thrift.TUnion { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("OneOf"); private static final org.apache.thrift.protocol.TField STRING_VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("stringValue", org.apache.thrift.protocol.TType.STRUCT, (short)1); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Record.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Record.java index 51c634b6f..6ece4a164 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Record.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/Record.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class Record implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Record"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/SetValue.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/SetValue.java index 68acac35a..7bae51e0f 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/SetValue.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/SetValue.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class SetValue implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SetValue"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/StringList.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/StringList.java index 7797c7669..964f5d919 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/StringList.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/StringList.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class StringList implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("StringList"); diff --git a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/StringValue.java b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/StringValue.java index 4f297822f..2170de5c1 100644 --- a/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/StringValue.java +++ b/zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/StringValue.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.15.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -7,7 +7,7 @@ package zio.schema.codec.generated; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.15.0)") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)") public class StringValue implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("StringValue"); diff --git a/zio-schema-zio-test/shared/src/main/scala/zio/schema/DeriveGen.scala b/zio-schema-zio-test/shared/src/main/scala/zio/schema/DeriveGen.scala index 69abd3d5f..b3e1a5376 100644 --- a/zio-schema-zio-test/shared/src/main/scala/zio/schema/DeriveGen.scala +++ b/zio-schema-zio-test/shared/src/main/scala/zio/schema/DeriveGen.scala @@ -14,66 +14,66 @@ object DeriveGen { // scalafmt: { maxColumn = 400 } def gen[A](implicit schema: Schema[A]): Gen[Random with Sized, A] = schema match { - case Schema.Enum1(c1, _) => genEnum(c1) - case Schema.Enum2(c1, c2, _) => genEnum(c1, c2) - case Schema.Enum3(c1, c2, c3, _) => genEnum(c1, c2, c3) - case Schema.Enum4(c1, c2, c3, c4, _) => genEnum(c1, c2, c3, c4) - case Schema.Enum5(c1, c2, c3, c4, c5, _) => genEnum(c1, c2, c3, c4, c5) - case Schema.Enum6(c1, c2, c3, c4, c5, c6, _) => genEnum(c1, c2, c3, c4, c5, c6) - case Schema.Enum7(c1, c2, c3, c4, c5, c6, c7, _) => genEnum(c1, c2, c3, c4, c5, c6, c7) - case Schema.Enum8(c1, c2, c3, c4, c5, c6, c7, c8, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8) - case Schema.Enum9(c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9) - case Schema.Enum10(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) - case Schema.Enum11(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) - case Schema.Enum12(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) - case Schema.Enum13(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) - case Schema.Enum14(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) - case Schema.Enum15(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) - case Schema.Enum16(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) - case Schema.Enum17(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) - case Schema.Enum18(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) - case Schema.Enum19(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) - case Schema.Enum20(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) - case Schema.Enum21(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) - case Schema.Enum22(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) - case Schema.EnumN(caseSet, _) => genEnum(caseSet.toSeq.asInstanceOf[Seq[Schema.Case[_, A]]]: _*) - case c @ Schema.CaseClass0(_, _) => genCaseClass0(c) - case c @ Schema.CaseClass1(_, _, _, _) => genCaseClass1(c) - case c @ Schema.CaseClass2(_, _, _, _, _, _) => genCaseClass2(c) - case c @ Schema.CaseClass3(_, _, _, _, _, _, _, _) => genCaseClass3(c) - case c @ Schema.CaseClass4(_, _, _, _, _, _, _, _, _, _) => genCaseClass4(c) - case c @ Schema.CaseClass5(_, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass5(c) - case c @ Schema.CaseClass6(_, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass6(c) - case c @ Schema.CaseClass7(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass7(c) - case c @ Schema.CaseClass8(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass8(c) - case c @ Schema.CaseClass9(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass9(c) - case c @ Schema.CaseClass10(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass10(c) - case c @ Schema.CaseClass11(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass11(c) - case c @ Schema.CaseClass12(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass12(c) - case c @ Schema.CaseClass13(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass13(c) - case c @ Schema.CaseClass14(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass14(c) - case c @ Schema.CaseClass15(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass15(c) - case c @ Schema.CaseClass16(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass16(c) - case c @ Schema.CaseClass17(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass17(c) - case c @ Schema.CaseClass18(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass18(c) - case c @ Schema.CaseClass19(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass19(c) - case c @ Schema.CaseClass20(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass20(c) - case c @ Schema.CaseClass21(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass21(c) - case c @ Schema.CaseClass22(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass22(c) - case generic @ Schema.GenericRecord(_, _) => genGenericRecord(generic).map(_.asInstanceOf[A]) - case seq @ Schema.Sequence(_, _, _, _, _) => genSequence(seq) - case map @ Schema.MapSchema(_, _, _) => genMap(map) - case set @ Schema.SetSchema(_, _) => genSet(set) - case transform @ Schema.Transform(_, _, _, _, _) => genTransform(transform) - case Schema.Primitive(standardType, _) => genPrimitive(standardType) - case optional @ Schema.Optional(_, _) => genOptional(optional) - case fail @ Schema.Fail(_, _) => genFail(fail) - case tuple @ Schema.Tuple(_, _, _) => genTuple(tuple) - case either @ Schema.EitherSchema(_, _, _) => genEither(either) - case lazzy @ Schema.Lazy(_) => genLazy(lazzy) - case Schema.Meta(ast, _) => genMeta(ast) - case Schema.Dynamic(_) => gen(DynamicValueSchema()) - case Schema.SemiDynamic(_, _) => genSemiDynamic + case Schema.Enum1(_, c1, _) => genEnum(c1) + case Schema.Enum2(_, c1, c2, _) => genEnum(c1, c2) + case Schema.Enum3(_, c1, c2, c3, _) => genEnum(c1, c2, c3) + case Schema.Enum4(_, c1, c2, c3, c4, _) => genEnum(c1, c2, c3, c4) + case Schema.Enum5(_, c1, c2, c3, c4, c5, _) => genEnum(c1, c2, c3, c4, c5) + case Schema.Enum6(_, c1, c2, c3, c4, c5, c6, _) => genEnum(c1, c2, c3, c4, c5, c6) + case Schema.Enum7(_, c1, c2, c3, c4, c5, c6, c7, _) => genEnum(c1, c2, c3, c4, c5, c6, c7) + case Schema.Enum8(_, c1, c2, c3, c4, c5, c6, c7, c8, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8) + case Schema.Enum9(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9) + case Schema.Enum10(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) + case Schema.Enum11(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) + case Schema.Enum12(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) + case Schema.Enum13(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) + case Schema.Enum14(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) + case Schema.Enum15(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) + case Schema.Enum16(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) + case Schema.Enum17(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) + case Schema.Enum18(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) + case Schema.Enum19(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) + case Schema.Enum20(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) + case Schema.Enum21(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) + case Schema.Enum22(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => genEnum(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) + case Schema.EnumN(_, caseSet, _) => genEnum(caseSet.toSeq.asInstanceOf[Seq[Schema.Case[_, A]]]: _*) + case c @ Schema.CaseClass0(_, _, _) => genCaseClass0(c) + case c @ Schema.CaseClass1(_, _, _, _, _) => genCaseClass1(c) + case c @ Schema.CaseClass2(_, _, _, _, _, _, _) => genCaseClass2(c) + case c @ Schema.CaseClass3(_, _, _, _, _, _, _, _, _) => genCaseClass3(c) + case c @ Schema.CaseClass4(_, _, _, _, _, _, _, _, _, _, _) => genCaseClass4(c) + case c @ Schema.CaseClass5(_, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass5(c) + case c @ Schema.CaseClass6(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass6(c) + case c @ Schema.CaseClass7(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass7(c) + case c @ Schema.CaseClass8(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass8(c) + case c @ Schema.CaseClass9(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass9(c) + case c @ Schema.CaseClass10(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass10(c) + case c @ Schema.CaseClass11(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass11(c) + case c @ Schema.CaseClass12(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass12(c) + case c @ Schema.CaseClass13(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass13(c) + case c @ Schema.CaseClass14(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass14(c) + case c @ Schema.CaseClass15(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass15(c) + case c @ Schema.CaseClass16(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass16(c) + case c @ Schema.CaseClass17(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass17(c) + case c @ Schema.CaseClass18(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass18(c) + case c @ Schema.CaseClass19(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass19(c) + case c @ Schema.CaseClass20(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass20(c) + case c @ Schema.CaseClass21(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass21(c) + case c @ Schema.CaseClass22(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => genCaseClass22(c) + case generic @ Schema.GenericRecord(_, _, _) => genGenericRecord(generic).map(_.asInstanceOf[A]) + case seq @ Schema.Sequence(_, _, _, _, _) => genSequence(seq) + case map @ Schema.MapSchema(_, _, _) => genMap(map) + case set @ Schema.SetSchema(_, _) => genSet(set) + case transform @ Schema.Transform(_, _, _, _, _) => genTransform(transform) + case Schema.Primitive(standardType, _) => genPrimitive(standardType) + case optional @ Schema.Optional(_, _) => genOptional(optional) + case fail @ Schema.Fail(_, _) => genFail(fail) + case tuple @ Schema.Tuple(_, _, _) => genTuple(tuple) + case either @ Schema.EitherSchema(_, _, _) => genEither(either) + case lazzy @ Schema.Lazy(_) => genLazy(lazzy) + case Schema.Meta(ast, _) => genMeta(ast) + case Schema.Dynamic(_) => gen(DynamicValueSchema()) + case Schema.SemiDynamic(_, _) => genSemiDynamic } // scalafmt: { maxColumn = 120 } private def genEnum[Z](cases: Schema.Case[_, Z]*): Gen[Random with Sized, Z] = @@ -546,22 +546,24 @@ object DeriveGen { private def genSchemaAstProduct(path: NodePath): Gen[Random with Sized, SchemaAst.Product] = for { optional <- Gen.boolean + id <- Gen.string(Gen.alphaChar).map(TypeId.parse) fields <- Gen.chunkOf( Gen .string1(Gen.anyASCIIChar) .flatMap(name => genAst(path / name).map(fieldSchema => (name, fieldSchema))) ) - } yield SchemaAst.Product(path, fields, optional) + } yield SchemaAst.Product(id, path, fields, optional) private def genSchemaAstSum(path: NodePath): Gen[Random with Sized, SchemaAst.Sum] = for { optional <- Gen.boolean + id <- Gen.string(Gen.alphaChar).map(TypeId.parse) fields <- Gen.chunkOf( Gen .string1(Gen.anyASCIIChar) .flatMap(name => genAst(path / name).map(fieldSchema => (name, fieldSchema))) ) - } yield SchemaAst.Sum(path, fields, optional) + } yield SchemaAst.Sum(id, path, fields, optional) private def genSchemaAstValue(path: NodePath): Gen[Random, SchemaAst.Value] = for { diff --git a/zio-schema/shared/src/main/scala/zio/schema/AccessorBuilder.scala b/zio-schema/shared/src/main/scala/zio/schema/AccessorBuilder.scala index 4fb9da2d1..feb018692 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/AccessorBuilder.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/AccessorBuilder.scala @@ -1,13 +1,13 @@ package zio.schema trait AccessorBuilder { - type Lens[S, A] - type Prism[S, A] + type Lens[F, S, A] + type Prism[F, S, A] type Traversal[S, A] - def makeLens[S, A](product: Schema.Record[S], term: Schema.Field[A]): Lens[S, A] + def makeLens[F, S, A](product: Schema.Record[S], term: Schema.Field[A]): Lens[F, S, A] - def makePrism[S, A](sum: Schema.Enum[S], term: Schema.Case[A, S]): Prism[S, A] + def makePrism[F, S, A](sum: Schema.Enum[S], term: Schema.Case[A, S]): Prism[F, S, A] def makeTraversal[S, A](collection: Schema.Collection[S, A], element: Schema[A]): Traversal[S, A] } diff --git a/zio-schema/shared/src/main/scala/zio/schema/CaseSet.scala b/zio-schema/shared/src/main/scala/zio/schema/CaseSet.scala index fa56fe23c..a06cb7dd7 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/CaseSet.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/CaseSet.scala @@ -11,7 +11,7 @@ sealed trait CaseSet { self => type EnumType - type Accessors[Whole, Lens[_, _], Prism[_, _], Traversal[_, _]] + type Accessors[Whole, Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] def :+:[A](head: Case[A, EnumType]): A :+: CaseSet.Aux[EnumType] @@ -31,7 +31,7 @@ object CaseSet { final case class Empty[Z]() extends CaseSet { self => type EnumType = Z - override type Accessors[Whole, Lens[_, _], Prism[_, _], Traversal[_, _]] = Unit + override type Accessors[Whole, Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Unit override def :+:[A](head: Case[A, EnumType]): A :+: Empty[EnumType] = Cons(head, self) @@ -61,8 +61,8 @@ object CaseSet { final case class Cons[A, +T <: CaseSet.Aux[Z], Z](head: Case[A, Z], tail: T) extends :+:[A, T] { self => type EnumType = Z - override type Accessors[Whole, Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Prism[Whole, A], tail.Accessors[Whole, Lens, Prism, Traversal]) + override type Accessors[Whole, Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + (Prism[head.id.type, Whole, A], tail.Accessors[Whole, Lens, Prism, Traversal]) override def :+:[B](head2: Case[B, Z]): Cons[B, Cons[A, T, Z], Z] = Cons(head2, self) diff --git a/zio-schema/shared/src/main/scala/zio/schema/Diff.scala b/zio-schema/shared/src/main/scala/zio/schema/Diff.scala index 5dba1a426..0ce583a96 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/Diff.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/Diff.scala @@ -269,7 +269,7 @@ object Differ { case s @ Schema.Lazy(_) => fromSchema(s.schema) case Schema.Transform(schema, g, f, _, _) => fromSchema(schema).transformOrFail(f, g) case Schema.Fail(_, _) => fail - case s @ Schema.GenericRecord(_, _) => record(s) + case s @ Schema.GenericRecord(_, _, _) => record(s) case s: Schema.CaseClass0[A] => product0(s) case s: Schema.CaseClass1[_, A] => product1(s) case s: Schema.CaseClass2[_, _, A] => product2(s) @@ -294,31 +294,31 @@ object Differ { case s: Schema.CaseClass21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, A] => product21(s) case s: Schema.CaseClass22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, A] => product22(s) - case Schema.Enum1(c, _) => enumN(c) - case Schema.Enum2(c1, c2, _) => enumN(c1, c2) - case Schema.Enum3(c1, c2, c3, _) => enumN(c1, c2, c3) - case Schema.Enum4(c1, c2, c3, c4, _) => enumN(c1, c2, c3, c4) - case Schema.Enum5(c1, c2, c3, c4, c5, _) => enumN(c1, c2, c3, c4, c5) - case Schema.Enum6(c1, c2, c3, c4, c5, c6, _) => enumN(c1, c2, c3, c4, c5, c6) - case Schema.Enum7(c1, c2, c3, c4, c5, c6, c7, _) => enumN(c1, c2, c3, c4, c5, c6, c7) - case Schema.Enum8(c1, c2, c3, c4, c5, c6, c7, c8, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8) - case Schema.Enum9(c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9) - case Schema.Enum10(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) - case Schema.Enum11(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) - case Schema.Enum12(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) - case Schema.Enum13(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) - case Schema.Enum14(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) - case Schema.Enum15(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) - case Schema.Enum16(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) - case Schema.Enum17(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) - case Schema.Enum18(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) - case Schema.Enum19(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) - case Schema.Enum20(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) - case Schema.Enum21(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) - case Schema.Enum22(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) - case Schema.EnumN(cs, _) => enumN(cs.toSeq: _*) - case Schema.Dynamic(_) => Differ.dynamicValue - case s @ Schema.SemiDynamic(_, _) => Differ.semiDynamic(s) + case Schema.Enum1(_, c, _) => enumN(c) + case Schema.Enum2(_, c1, c2, _) => enumN(c1, c2) + case Schema.Enum3(_, c1, c2, c3, _) => enumN(c1, c2, c3) + case Schema.Enum4(_, c1, c2, c3, c4, _) => enumN(c1, c2, c3, c4) + case Schema.Enum5(_, c1, c2, c3, c4, c5, _) => enumN(c1, c2, c3, c4, c5) + case Schema.Enum6(_, c1, c2, c3, c4, c5, c6, _) => enumN(c1, c2, c3, c4, c5, c6) + case Schema.Enum7(_, c1, c2, c3, c4, c5, c6, c7, _) => enumN(c1, c2, c3, c4, c5, c6, c7) + case Schema.Enum8(_, c1, c2, c3, c4, c5, c6, c7, c8, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8) + case Schema.Enum9(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9) + case Schema.Enum10(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) + case Schema.Enum11(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) + case Schema.Enum12(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) + case Schema.Enum13(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) + case Schema.Enum14(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) + case Schema.Enum15(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) + case Schema.Enum16(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16) + case Schema.Enum17(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17) + case Schema.Enum18(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18) + case Schema.Enum19(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19) + case Schema.Enum20(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20) + case Schema.Enum21(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21) + case Schema.Enum22(_, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, _) => enumN(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22) + case Schema.EnumN(_, cs, _) => enumN(cs.toSeq: _*) + case Schema.Dynamic(_) => Differ.dynamicValue + case s @ Schema.SemiDynamic(_, _) => Differ.semiDynamic(s) } //scalafmt: { maxColumn = 120, optIn.configStyleArguments = true } @@ -870,28 +870,33 @@ object Diff { val structure = schema.structure val patchedDynamicValue = schema.toDynamic(input) match { - case DynamicValue.Record(values) => - differences.foldLeft[Either[String, ListMap[String, DynamicValue]]](Right(values)) { - case (Right(record), (key, diff)) => - (structure.find(_.label == key).map(_.schema), values.get(key)) match { - case (Some(schema: Schema[b]), Some(oldValue)) => - val oldVal = oldValue.toTypedValue(schema) - oldVal - .flatMap(v => diff.asInstanceOf[Diff[Any]].patch(v)) - .map(v => schema.asInstanceOf[Schema[Any]].toDynamic(v)) match { - case Left(error) => Left(error) - case Right(newValue) => Right(record + (key -> newValue)) - } - case _ => - Left(s"Values=$values and structure=$structure have incompatible shape.") - } - case (Left(string), _) => Left(string) - } + case DynamicValue.Record(name, values) => { + differences + .foldLeft[Either[String, ListMap[String, DynamicValue]]](Right(values)) { + case (Right(record), (key, diff)) => + (structure.find(_.label == key).map(_.schema), values.get(key)) match { + case (Some(schema: Schema[b]), Some(oldValue)) => + val oldVal = oldValue.toTypedValue(schema) + oldVal + .flatMap(v => diff.asInstanceOf[Diff[Any]].patch(v)) + .map(v => schema.asInstanceOf[Schema[Any]].toDynamic(v)) match { + case Left(error) => Left(error) + case Right(newValue) => Right(record + (key -> newValue)) + } + case _ => + Left(s"Values=$values and structure=$structure have incompatible shape.") + } + case (Left(string), _) => Left(string) + } + .map(r => (name, r)) + + } + case dv => Left(s"Failed to apply record diff. Unexpected dynamic value for record: $dv") } patchedDynamicValue.flatMap { newValues => - schema.fromDynamic(DynamicValue.Record(newValues)) + schema.fromDynamic(DynamicValue.Record(newValues._1, newValues._2)) } } diff --git a/zio-schema/shared/src/main/scala/zio/schema/DynamicValue.scala b/zio-schema/shared/src/main/scala/zio/schema/DynamicValue.scala index ec05659f4..7e78d8966 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/DynamicValue.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/DynamicValue.scala @@ -10,7 +10,8 @@ import scala.collection.immutable.ListMap import zio.Chunk import zio.schema.ast.{ Migration, SchemaAst } -sealed trait DynamicValue { self => +sealed trait DynamicValue { + self => def transform(transforms: Chunk[Migration]): Either[String, DynamicValue] = transforms.foldRight[Either[String, DynamicValue]](Right(self)) { @@ -23,13 +24,13 @@ sealed trait DynamicValue { self => case (DynamicValue.Primitive(value, p), Schema.Primitive(p2, _)) if p == p2 => Right(value.asInstanceOf[A]) - case (DynamicValue.Record(values), Schema.GenericRecord(structure, _)) => + case (DynamicValue.Record(_, values), Schema.GenericRecord(_, structure, _)) => DynamicValue.decodeStructure(values, structure.toChunk).asInstanceOf[Either[String, A]] - case (DynamicValue.Record(values), s: Schema.Record[A]) => + case (DynamicValue.Record(_, values), s: Schema.Record[A]) => DynamicValue.decodeStructure(values, s.structure).map(m => Chunk.fromIterable(m.values)).flatMap(s.rawConstruct) - case (DynamicValue.Enumeration((key, value)), s: Schema.Enum[A]) => + case (DynamicValue.Enumeration(_, (key, value)), s: Schema.Enum[A]) => s.structure.get(key) match { case Some(schema) => value.toTypedValue(schema).asInstanceOf[Either[String, A]] case None => Left(s"Failed to find case $key in enumN $s") @@ -108,46 +109,47 @@ object DynamicValue { case Schema.Primitive(p, _) => DynamicValue.Primitive(value, p) - case Schema.GenericRecord(structure, _) => + case Schema.GenericRecord(id, structure, _) => val map: ListMap[String, _] = value DynamicValue.Record( + id, ListMap.empty ++ structure.toChunk.map { case Schema.Field(key, schema: Schema[a], _, _) => key -> fromSchemaAndValue(schema, map(key).asInstanceOf[a]) } ) - case Schema.Enum1(case1, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, case1.unsafeDeconstruct(value))) + case Schema.Enum1(id, case1, _) => + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, case1.unsafeDeconstruct(value))) - case Schema.Enum2(case1, case2, _) => + case Schema.Enum2(id, case1, case2, _) => (case1.deconstruct(value), case2.deconstruct(value)) match { - case (Some(v1), _) => DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) - case (_, Some(v2)) => DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + case (Some(v1), _) => DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) + case (_, Some(v2)) => DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum3(case1, case2, case3, _) => + case Schema.Enum3(id, case1, case2, case3, _) => (case1.deconstruct(value), case2.deconstruct(value), case3.deconstruct(value)) match { - case (Some(v1), _, _) => DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) - case (_, Some(v2), _) => DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) - case (_, _, Some(v3)) => DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + case (Some(v1), _, _) => DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) + case (_, Some(v2), _) => DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) + case (_, _, Some(v3)) => DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum4(case1, case2, case3, case4, _) => + case Schema.Enum4(id, case1, case2, case3, case4, _) => (case1.deconstruct(value), case2.deconstruct(value), case3.deconstruct(value), case4.deconstruct(value)) match { - case (Some(v1), _, _, _) => DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) - case (_, Some(v2), _, _) => DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) - case (_, _, Some(v3), _) => DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) - case (_, _, _, Some(v4)) => DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + case (Some(v1), _, _, _) => DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) + case (_, Some(v2), _, _) => DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) + case (_, _, Some(v3), _) => DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) + case (_, _, _, Some(v4)) => DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum5(case1, case2, case3, case4, case5, _) => + case Schema.Enum5(id, case1, case2, case3, case4, case5, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -155,16 +157,16 @@ object DynamicValue { case4.deconstruct(value), case5.deconstruct(value) ) match { - case (Some(v1), _, _, _, _) => DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) - case (_, Some(v2), _, _, _) => DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) - case (_, _, Some(v3), _, _) => DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) - case (_, _, _, Some(v4), _) => DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) - case (_, _, _, _, Some(v5)) => DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + case (Some(v1), _, _, _, _) => DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) + case (_, Some(v2), _, _, _) => DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) + case (_, _, Some(v3), _, _) => DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) + case (_, _, _, Some(v4), _) => DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) + case (_, _, _, _, Some(v5)) => DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum6(case1, case2, case3, case4, case5, case6, _) => + case Schema.Enum6(id, case1, case2, case3, case4, case5, case6, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -173,17 +175,17 @@ object DynamicValue { case5.deconstruct(value), case6.deconstruct(value) ) match { - case (Some(v1), _, _, _, _, _) => DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) - case (_, Some(v2), _, _, _, _) => DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) - case (_, _, Some(v3), _, _, _) => DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) - case (_, _, _, Some(v4), _, _) => DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) - case (_, _, _, _, Some(v5), _) => DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) - case (_, _, _, _, _, Some(v6)) => DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + case (Some(v1), _, _, _, _, _) => DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) + case (_, Some(v2), _, _, _, _) => DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) + case (_, _, Some(v3), _, _, _) => DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) + case (_, _, _, Some(v4), _, _) => DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) + case (_, _, _, _, Some(v5), _) => DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) + case (_, _, _, _, _, Some(v6)) => DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum7(case1, case2, case3, case4, case5, case6, case7, _) => + case Schema.Enum7(id, case1, case2, case3, case4, case5, case6, case7, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -193,18 +195,18 @@ object DynamicValue { case6.deconstruct(value), case7.deconstruct(value) ) match { - case (Some(v1), _, _, _, _, _, _) => DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) - case (_, Some(v2), _, _, _, _, _) => DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) - case (_, _, Some(v3), _, _, _, _) => DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) - case (_, _, _, Some(v4), _, _, _) => DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) - case (_, _, _, _, Some(v5), _, _) => DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) - case (_, _, _, _, _, Some(v6), _) => DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) - case (_, _, _, _, _, _, Some(v7)) => DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + case (Some(v1), _, _, _, _, _, _) => DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) + case (_, Some(v2), _, _, _, _, _) => DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) + case (_, _, Some(v3), _, _, _, _) => DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) + case (_, _, _, Some(v4), _, _, _) => DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) + case (_, _, _, _, Some(v5), _, _) => DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) + case (_, _, _, _, _, Some(v6), _) => DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) + case (_, _, _, _, _, _, Some(v7)) => DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum8(case1, case2, case3, case4, case5, case6, case7, case8, _) => + case Schema.Enum8(id, case1, case2, case3, case4, case5, case6, case7, case8, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -216,26 +218,26 @@ object DynamicValue { case8.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8)) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum9(case1, case2, case3, case4, case5, case6, case7, case8, case9, _) => + case Schema.Enum9(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -248,28 +250,28 @@ object DynamicValue { case9.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9)) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum10(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, _) => + case Schema.Enum10(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -283,30 +285,30 @@ object DynamicValue { case10.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10)) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum11(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, _) => + case Schema.Enum11(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -321,32 +323,32 @@ object DynamicValue { case11.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11)) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum12(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, _) => + case Schema.Enum12(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -362,100 +364,100 @@ object DynamicValue { case12.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12)) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum13(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, _) => + case Schema.Enum13(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, _) => (case1.deconstruct(value), case2.deconstruct(value), case3.deconstruct(value), case4.deconstruct(value), case5.deconstruct(value), case6.deconstruct(value), case7.deconstruct(value), case8.deconstruct(value), case9.deconstruct(value), case10.deconstruct(value), case11.deconstruct(value), case12.deconstruct(value), case13.deconstruct(value)) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13)) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum14(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, _) => + case Schema.Enum14(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, _) => (case1.deconstruct(value), case2.deconstruct(value), case3.deconstruct(value), case4.deconstruct(value), case5.deconstruct(value), case6.deconstruct(value), case7.deconstruct(value), case8.deconstruct(value), case9.deconstruct(value), case10.deconstruct(value), case11.deconstruct(value), case12.deconstruct(value), case13.deconstruct(value), case14.deconstruct(value)) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _, _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13), _) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, Some(v14)) => - DynamicValue.Enumeration(case14.id -> fromSchemaAndValue(case14.codec, v14)) + DynamicValue.Enumeration(id, case14.id -> fromSchemaAndValue(case14.codec, v14)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum15(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, _) => + case Schema.Enum15(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -474,40 +476,40 @@ object DynamicValue { case15.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _, _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _, _, _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13), _, _) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, Some(v14), _) => - DynamicValue.Enumeration(case14.id -> fromSchemaAndValue(case14.codec, v14)) + DynamicValue.Enumeration(id, case14.id -> fromSchemaAndValue(case14.codec, v14)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v15)) => - DynamicValue.Enumeration(case15.id -> fromSchemaAndValue(case15.codec, v15)) + DynamicValue.Enumeration(id, case15.id -> fromSchemaAndValue(case15.codec, v15)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum16(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, _) => + case Schema.Enum16(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -527,42 +529,42 @@ object DynamicValue { case16.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _, _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _, _, _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _, _, _, _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13), _, _, _) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, Some(v14), _, _) => - DynamicValue.Enumeration(case14.id -> fromSchemaAndValue(case14.codec, v14)) + DynamicValue.Enumeration(id, case14.id -> fromSchemaAndValue(case14.codec, v14)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v15), _) => - DynamicValue.Enumeration(case15.id -> fromSchemaAndValue(case15.codec, v15)) + DynamicValue.Enumeration(id, case15.id -> fromSchemaAndValue(case15.codec, v15)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v16)) => - DynamicValue.Enumeration(case16.id -> fromSchemaAndValue(case16.codec, v16)) + DynamicValue.Enumeration(id, case16.id -> fromSchemaAndValue(case16.codec, v16)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum17(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, _) => + case Schema.Enum17(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -583,44 +585,44 @@ object DynamicValue { case17.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _, _, _, _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _, _, _, _, _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13), _, _, _, _) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, Some(v14), _, _, _) => - DynamicValue.Enumeration(case14.id -> fromSchemaAndValue(case14.codec, v14)) + DynamicValue.Enumeration(id, case14.id -> fromSchemaAndValue(case14.codec, v14)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v15), _, _) => - DynamicValue.Enumeration(case15.id -> fromSchemaAndValue(case15.codec, v15)) + DynamicValue.Enumeration(id, case15.id -> fromSchemaAndValue(case15.codec, v15)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v16), _) => - DynamicValue.Enumeration(case16.id -> fromSchemaAndValue(case16.codec, v16)) + DynamicValue.Enumeration(id, case16.id -> fromSchemaAndValue(case16.codec, v16)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v17)) => - DynamicValue.Enumeration(case17.id -> fromSchemaAndValue(case17.codec, v17)) + DynamicValue.Enumeration(id, case17.id -> fromSchemaAndValue(case17.codec, v17)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum18(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, _) => + case Schema.Enum18(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -642,46 +644,46 @@ object DynamicValue { case18.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _, _, _, _, _, _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13), _, _, _, _, _) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, Some(v14), _, _, _, _) => - DynamicValue.Enumeration(case14.id -> fromSchemaAndValue(case14.codec, v14)) + DynamicValue.Enumeration(id, case14.id -> fromSchemaAndValue(case14.codec, v14)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v15), _, _, _) => - DynamicValue.Enumeration(case15.id -> fromSchemaAndValue(case15.codec, v15)) + DynamicValue.Enumeration(id, case15.id -> fromSchemaAndValue(case15.codec, v15)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v16), _, _) => - DynamicValue.Enumeration(case16.id -> fromSchemaAndValue(case16.codec, v16)) + DynamicValue.Enumeration(id, case16.id -> fromSchemaAndValue(case16.codec, v16)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v17), _) => - DynamicValue.Enumeration(case17.id -> fromSchemaAndValue(case17.codec, v17)) + DynamicValue.Enumeration(id, case17.id -> fromSchemaAndValue(case17.codec, v17)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v18)) => - DynamicValue.Enumeration(case18.id -> fromSchemaAndValue(case18.codec, v18)) + DynamicValue.Enumeration(id, case18.id -> fromSchemaAndValue(case18.codec, v18)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum19(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, _) => + case Schema.Enum19(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -704,48 +706,48 @@ object DynamicValue { case19.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13), _, _, _, _, _, _) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, Some(v14), _, _, _, _, _) => - DynamicValue.Enumeration(case14.id -> fromSchemaAndValue(case14.codec, v14)) + DynamicValue.Enumeration(id, case14.id -> fromSchemaAndValue(case14.codec, v14)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v15), _, _, _, _) => - DynamicValue.Enumeration(case15.id -> fromSchemaAndValue(case15.codec, v15)) + DynamicValue.Enumeration(id, case15.id -> fromSchemaAndValue(case15.codec, v15)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v16), _, _, _) => - DynamicValue.Enumeration(case16.id -> fromSchemaAndValue(case16.codec, v16)) + DynamicValue.Enumeration(id, case16.id -> fromSchemaAndValue(case16.codec, v16)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v17), _, _) => - DynamicValue.Enumeration(case17.id -> fromSchemaAndValue(case17.codec, v17)) + DynamicValue.Enumeration(id, case17.id -> fromSchemaAndValue(case17.codec, v17)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v18), _) => - DynamicValue.Enumeration(case18.id -> fromSchemaAndValue(case18.codec, v18)) + DynamicValue.Enumeration(id, case18.id -> fromSchemaAndValue(case18.codec, v18)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v19)) => - DynamicValue.Enumeration(case19.id -> fromSchemaAndValue(case19.codec, v19)) + DynamicValue.Enumeration(id, case19.id -> fromSchemaAndValue(case19.codec, v19)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum20(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, _) => + case Schema.Enum20(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -769,50 +771,50 @@ object DynamicValue { case20.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, Some(v14), _, _, _, _, _, _) => - DynamicValue.Enumeration(case14.id -> fromSchemaAndValue(case14.codec, v14)) + DynamicValue.Enumeration(id, case14.id -> fromSchemaAndValue(case14.codec, v14)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v15), _, _, _, _, _) => - DynamicValue.Enumeration(case15.id -> fromSchemaAndValue(case15.codec, v15)) + DynamicValue.Enumeration(id, case15.id -> fromSchemaAndValue(case15.codec, v15)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v16), _, _, _, _) => - DynamicValue.Enumeration(case16.id -> fromSchemaAndValue(case16.codec, v16)) + DynamicValue.Enumeration(id, case16.id -> fromSchemaAndValue(case16.codec, v16)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v17), _, _, _) => - DynamicValue.Enumeration(case17.id -> fromSchemaAndValue(case17.codec, v17)) + DynamicValue.Enumeration(id, case17.id -> fromSchemaAndValue(case17.codec, v17)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v18), _, _) => - DynamicValue.Enumeration(case18.id -> fromSchemaAndValue(case18.codec, v18)) + DynamicValue.Enumeration(id, case18.id -> fromSchemaAndValue(case18.codec, v18)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v19), _) => - DynamicValue.Enumeration(case19.id -> fromSchemaAndValue(case19.codec, v19)) + DynamicValue.Enumeration(id, case19.id -> fromSchemaAndValue(case19.codec, v19)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v20)) => - DynamicValue.Enumeration(case20.id -> fromSchemaAndValue(case20.codec, v20)) + DynamicValue.Enumeration(id, case20.id -> fromSchemaAndValue(case20.codec, v20)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum21(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, _) => + case Schema.Enum21(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -837,52 +839,52 @@ object DynamicValue { case21.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, Some(v14), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case14.id -> fromSchemaAndValue(case14.codec, v14)) + DynamicValue.Enumeration(id, case14.id -> fromSchemaAndValue(case14.codec, v14)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v15), _, _, _, _, _, _) => - DynamicValue.Enumeration(case15.id -> fromSchemaAndValue(case15.codec, v15)) + DynamicValue.Enumeration(id, case15.id -> fromSchemaAndValue(case15.codec, v15)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v16), _, _, _, _, _) => - DynamicValue.Enumeration(case16.id -> fromSchemaAndValue(case16.codec, v16)) + DynamicValue.Enumeration(id, case16.id -> fromSchemaAndValue(case16.codec, v16)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v17), _, _, _, _) => - DynamicValue.Enumeration(case17.id -> fromSchemaAndValue(case17.codec, v17)) + DynamicValue.Enumeration(id, case17.id -> fromSchemaAndValue(case17.codec, v17)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v18), _, _, _) => - DynamicValue.Enumeration(case18.id -> fromSchemaAndValue(case18.codec, v18)) + DynamicValue.Enumeration(id, case18.id -> fromSchemaAndValue(case18.codec, v18)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v19), _, _) => - DynamicValue.Enumeration(case19.id -> fromSchemaAndValue(case19.codec, v19)) + DynamicValue.Enumeration(id, case19.id -> fromSchemaAndValue(case19.codec, v19)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v20), _) => - DynamicValue.Enumeration(case20.id -> fromSchemaAndValue(case20.codec, v20)) + DynamicValue.Enumeration(id, case20.id -> fromSchemaAndValue(case20.codec, v20)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v21)) => - DynamicValue.Enumeration(case21.id -> fromSchemaAndValue(case21.codec, v21)) + DynamicValue.Enumeration(id, case21.id -> fromSchemaAndValue(case21.codec, v21)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } - case Schema.Enum22(case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, case22, _) => + case Schema.Enum22(id, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, case22, _) => ( case1.deconstruct(value), case2.deconstruct(value), @@ -908,59 +910,60 @@ object DynamicValue { case22.deconstruct(value) ) match { case (Some(v1), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case1.id -> fromSchemaAndValue(case1.codec, v1)) + DynamicValue.Enumeration(id, case1.id -> fromSchemaAndValue(case1.codec, v1)) case (_, Some(v2), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case2.id -> fromSchemaAndValue(case2.codec, v2)) + DynamicValue.Enumeration(id, case2.id -> fromSchemaAndValue(case2.codec, v2)) case (_, _, Some(v3), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case3.id -> fromSchemaAndValue(case3.codec, v3)) + DynamicValue.Enumeration(id, case3.id -> fromSchemaAndValue(case3.codec, v3)) case (_, _, _, Some(v4), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case4.id -> fromSchemaAndValue(case4.codec, v4)) + DynamicValue.Enumeration(id, case4.id -> fromSchemaAndValue(case4.codec, v4)) case (_, _, _, _, Some(v5), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case5.id -> fromSchemaAndValue(case5.codec, v5)) + DynamicValue.Enumeration(id, case5.id -> fromSchemaAndValue(case5.codec, v5)) case (_, _, _, _, _, Some(v6), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case6.id -> fromSchemaAndValue(case6.codec, v6)) + DynamicValue.Enumeration(id, case6.id -> fromSchemaAndValue(case6.codec, v6)) case (_, _, _, _, _, _, Some(v7), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case7.id -> fromSchemaAndValue(case7.codec, v7)) + DynamicValue.Enumeration(id, case7.id -> fromSchemaAndValue(case7.codec, v7)) case (_, _, _, _, _, _, _, Some(v8), _, _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case8.id -> fromSchemaAndValue(case8.codec, v8)) + DynamicValue.Enumeration(id, case8.id -> fromSchemaAndValue(case8.codec, v8)) case (_, _, _, _, _, _, _, _, Some(v9), _, _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case9.id -> fromSchemaAndValue(case9.codec, v9)) + DynamicValue.Enumeration(id, case9.id -> fromSchemaAndValue(case9.codec, v9)) case (_, _, _, _, _, _, _, _, _, Some(v10), _, _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case10.id -> fromSchemaAndValue(case10.codec, v10)) + DynamicValue.Enumeration(id, case10.id -> fromSchemaAndValue(case10.codec, v10)) case (_, _, _, _, _, _, _, _, _, _, Some(v11), _, _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case11.id -> fromSchemaAndValue(case11.codec, v11)) + DynamicValue.Enumeration(id, case11.id -> fromSchemaAndValue(case11.codec, v11)) case (_, _, _, _, _, _, _, _, _, _, _, Some(v12), _, _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case12.id -> fromSchemaAndValue(case12.codec, v12)) + DynamicValue.Enumeration(id, case12.id -> fromSchemaAndValue(case12.codec, v12)) case (_, _, _, _, _, _, _, _, _, _, _, _, Some(v13), _, _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case13.id -> fromSchemaAndValue(case13.codec, v13)) + DynamicValue.Enumeration(id, case13.id -> fromSchemaAndValue(case13.codec, v13)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, Some(v14), _, _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case14.id -> fromSchemaAndValue(case14.codec, v14)) + DynamicValue.Enumeration(id, case14.id -> fromSchemaAndValue(case14.codec, v14)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v15), _, _, _, _, _, _, _) => - DynamicValue.Enumeration(case15.id -> fromSchemaAndValue(case15.codec, v15)) + DynamicValue.Enumeration(id, case15.id -> fromSchemaAndValue(case15.codec, v15)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v16), _, _, _, _, _, _) => - DynamicValue.Enumeration(case16.id -> fromSchemaAndValue(case16.codec, v16)) + DynamicValue.Enumeration(id, case16.id -> fromSchemaAndValue(case16.codec, v16)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v17), _, _, _, _, _) => - DynamicValue.Enumeration(case17.id -> fromSchemaAndValue(case17.codec, v17)) + DynamicValue.Enumeration(id, case17.id -> fromSchemaAndValue(case17.codec, v17)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v18), _, _, _, _) => - DynamicValue.Enumeration(case18.id -> fromSchemaAndValue(case18.codec, v18)) + DynamicValue.Enumeration(id, case18.id -> fromSchemaAndValue(case18.codec, v18)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v19), _, _, _) => - DynamicValue.Enumeration(case19.id -> fromSchemaAndValue(case19.codec, v19)) + DynamicValue.Enumeration(id, case19.id -> fromSchemaAndValue(case19.codec, v19)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v20), _, _) => - DynamicValue.Enumeration(case20.id -> fromSchemaAndValue(case20.codec, v20)) + DynamicValue.Enumeration(id, case20.id -> fromSchemaAndValue(case20.codec, v20)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v21), _) => - DynamicValue.Enumeration(case21.id -> fromSchemaAndValue(case21.codec, v21)) + DynamicValue.Enumeration(id, case21.id -> fromSchemaAndValue(case21.codec, v21)) case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, Some(v22)) => - DynamicValue.Enumeration(case22.id -> fromSchemaAndValue(case22.codec, v22)) + DynamicValue.Enumeration(id, case22.id -> fromSchemaAndValue(case22.codec, v22)) //This should never happen unless someone manually builds an Enum and doesn't include all cases case _ => DynamicValue.NoneValue } //scalafmt: { maxColumn = 120 } - case Schema.EnumN(cases, _) => + case Schema.EnumN(id, cases, _) => cases.toSeq .find(_.deconstruct(value).isDefined) match { case Some(c) => DynamicValue.Enumeration( + id, c.id -> fromSchemaAndValue(c.codec.asInstanceOf[Schema[Any]], c.unsafeDeconstruct(value)) ) case None => DynamicValue.NoneValue @@ -1004,29 +1007,32 @@ object DynamicValue { case Schema.Meta(ast, _) => DynamicValue.DynamicAst(ast) - case Schema.CaseClass0(_, _) => - DynamicValue.Record(ListMap()) + case Schema.CaseClass0(id, _, _) => + DynamicValue.Record(id, ListMap()) - case Schema.CaseClass1(f, _, ext, _) => - DynamicValue.Record(ListMap(f.label -> fromSchemaAndValue(f.schema, ext(value)))) + case Schema.CaseClass1(id, f, _, ext, _) => + DynamicValue.Record(id, ListMap(f.label -> fromSchemaAndValue(f.schema, ext(value)))) - case Schema.CaseClass2(f1, f2, _, ext1, ext2, _) => + case Schema.CaseClass2(id, f1, f2, _, ext1, ext2, _) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)) ) ) - case Schema.CaseClass3(f1, f2, f3, _, ext1, ext2, ext3, _) => + case Schema.CaseClass3(id, f1, f2, f3, _, ext1, ext2, ext3, _) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), f3.label -> fromSchemaAndValue(f3.schema, ext3(value)) ) ) - case Schema.CaseClass4(f1, f2, f3, f4, _, ext1, ext2, ext3, ext4, _) => + case Schema.CaseClass4(id, f1, f2, f3, f4, _, ext1, ext2, ext3, ext4, _) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1034,8 +1040,9 @@ object DynamicValue { f4.label -> fromSchemaAndValue(f4.schema, ext4(value)) ) ) - case Schema.CaseClass5(f1, f2, f3, f4, f5, _, ext1, ext2, ext3, ext4, ext5, _) => + case Schema.CaseClass5(id, f1, f2, f3, f4, f5, _, ext1, ext2, ext3, ext4, ext5, _) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1044,8 +1051,9 @@ object DynamicValue { f5.label -> fromSchemaAndValue(f5.schema, ext5(value)) ) ) - case Schema.CaseClass6(f1, f2, f3, f4, f5, f6, _, ext1, ext2, ext3, ext4, ext5, ext6, _) => + case Schema.CaseClass6(id, f1, f2, f3, f4, f5, f6, _, ext1, ext2, ext3, ext4, ext5, ext6, _) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1055,8 +1063,9 @@ object DynamicValue { f6.label -> fromSchemaAndValue(f6.schema, ext6(value)) ) ) - case Schema.CaseClass7(f1, f2, f3, f4, f5, f6, f7, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, _) => + case Schema.CaseClass7(id, f1, f2, f3, f4, f5, f6, f7, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, _) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1067,8 +1076,29 @@ object DynamicValue { f7.label -> fromSchemaAndValue(f7.schema, ext7(value)) ) ) - case Schema.CaseClass8(f1, f2, f3, f4, f5, f6, f7, f8, _, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8, _) => + case Schema.CaseClass8( + id, + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, + _, + ext1, + ext2, + ext3, + ext4, + ext5, + ext6, + ext7, + ext8, + _ + ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1081,6 +1111,7 @@ object DynamicValue { ) ) case Schema.CaseClass9( + id, f1, f2, f3, @@ -1103,6 +1134,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1116,6 +1148,7 @@ object DynamicValue { ) ) case Schema.CaseClass10( + id, f1, f2, f3, @@ -1140,6 +1173,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1154,6 +1188,7 @@ object DynamicValue { ) ) case Schema.CaseClass11( + id, f1, f2, f3, @@ -1180,6 +1215,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1195,6 +1231,7 @@ object DynamicValue { ) ) case Schema.CaseClass12( + id, f1, f2, f3, @@ -1223,6 +1260,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1239,6 +1277,7 @@ object DynamicValue { ) ) case Schema.CaseClass13( + id, f1, f2, f3, @@ -1269,6 +1308,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1286,6 +1326,7 @@ object DynamicValue { ) ) case Schema.CaseClass14( + id, f1, f2, f3, @@ -1318,6 +1359,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1336,6 +1378,7 @@ object DynamicValue { ) ) case Schema.CaseClass15( + id, f1, f2, f3, @@ -1370,6 +1413,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1389,6 +1433,7 @@ object DynamicValue { ) ) case Schema.CaseClass16( + id, f1, f2, f3, @@ -1425,6 +1470,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1445,6 +1491,7 @@ object DynamicValue { ) ) case Schema.CaseClass17( + id, f1, f2, f3, @@ -1483,6 +1530,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1504,6 +1552,7 @@ object DynamicValue { ) ) case Schema.CaseClass18( + id, f1, f2, f3, @@ -1544,6 +1593,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1566,6 +1616,7 @@ object DynamicValue { ) ) case Schema.CaseClass19( + id, f1, f2, f3, @@ -1608,6 +1659,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1631,6 +1683,7 @@ object DynamicValue { ) ) case Schema.CaseClass20( + id, f1, f2, f3, @@ -1675,6 +1728,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1699,6 +1753,7 @@ object DynamicValue { ) ) case Schema.CaseClass21( + id, f1, f2, f3, @@ -1745,6 +1800,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1770,6 +1826,7 @@ object DynamicValue { ) ) case Schema.CaseClass22( + id, f1, f2, f3, @@ -1818,6 +1875,7 @@ object DynamicValue { _ ) => DynamicValue.Record( + id, ListMap( f1.label -> fromSchemaAndValue(f1.schema, ext1(value)), f2.label -> fromSchemaAndValue(f2.schema, ext2(value)), @@ -1870,9 +1928,9 @@ object DynamicValue { } } - final case class Record(values: ListMap[String, DynamicValue]) extends DynamicValue + final case class Record(id: TypeId, values: ListMap[String, DynamicValue]) extends DynamicValue - final case class Enumeration(value: (String, DynamicValue)) extends DynamicValue + final case class Enumeration(id: TypeId, value: (String, DynamicValue)) extends DynamicValue final case class Sequence(values: Chunk[DynamicValue]) extends DynamicValue @@ -1900,12 +1958,14 @@ object DynamicValue { } -private[schema] object DynamicValueSchema { self => +private[schema] object DynamicValueSchema { + self => def apply(): Schema[DynamicValue] = schema lazy val schema: Schema[DynamicValue] = Schema.EnumN( + TypeId.Structural, CaseSet .Cons(errorCase, CaseSet.Empty[DynamicValue]()) .:+:(noneValueCase) @@ -1975,6 +2035,7 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "Error", Schema.CaseClass1[String, DynamicValue.Error]( + TypeId.parse("zio.scheema.DynamicValue.Error"), Schema.Field("message", Schema.primitive[String]), message => DynamicValue.Error(message), error => error.message @@ -1994,6 +2055,7 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "RightValue", Schema.CaseClass1[DynamicValue, DynamicValue.RightValue]( + TypeId.parse("zio.scheema.DynamicValue.RightValue"), Schema.Field("value", Schema.defer(DynamicValueSchema())), dynamicValue => DynamicValue.RightValue(dynamicValue), rightValue => rightValue.value @@ -2005,6 +2067,7 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "LeftValue", Schema.CaseClass1[DynamicValue, DynamicValue.LeftValue]( + TypeId.parse("zio.scheema.DynamicValue.LeftValue"), Schema.Field("value", Schema.defer(DynamicValueSchema())), dynamicValue => DynamicValue.LeftValue(dynamicValue), leftValue => leftValue.value @@ -2016,6 +2079,7 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "Tuple", Schema.CaseClass2[DynamicValue, DynamicValue, DynamicValue.Tuple]( + TypeId.parse("zio.scheema.DynamicValue.Tuple"), Schema.Field("left", Schema.defer(DynamicValueSchema())), Schema.Field("right", Schema.defer(DynamicValueSchema())), (left, right) => DynamicValue.Tuple(left, right), @@ -2029,6 +2093,7 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "SomeValue", Schema.CaseClass1[DynamicValue, DynamicValue.SomeValue]( + TypeId.parse("zio.scheema.DynamicValue.SomeValue"), Schema.Field("value", Schema.defer(DynamicValueSchema())), dv => DynamicValue.SomeValue(dv), someValue => someValue.value @@ -2040,6 +2105,7 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "Dictionary", Schema.CaseClass1[Chunk[(DynamicValue, DynamicValue)], DynamicValue.Dictionary]( + TypeId.parse("zio.scheema.DynamicValue.Dictionary"), Schema.Field( "entries", Schema.defer(Schema.chunk(Schema.tuple2(DynamicValueSchema(), DynamicValueSchema()))) @@ -2054,6 +2120,7 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "Sequence", Schema.CaseClass1[Chunk[DynamicValue], DynamicValue.Sequence]( + TypeId.parse("zio.scheema.DynamicValue.Sequence"), Schema.Field("values", Schema.defer(Schema.chunk(DynamicValueSchema()))), chunk => DynamicValue.Sequence(chunk), seq => seq.values @@ -2065,8 +2132,9 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "Enumeration", Schema.CaseClass1[(String, DynamicValue), DynamicValue.Enumeration]( + TypeId.parse("zio.scheema.DynamicValue.Enumeration"), Schema.Field("value", Schema.defer(Schema.tuple2(Schema.primitive[String], DynamicValueSchema()))), - value => DynamicValue.Enumeration(value), + value => DynamicValue.Enumeration(TypeId.Structural, value), enumeration => enumeration.value ), _.asInstanceOf[DynamicValue.Enumeration] @@ -2076,8 +2144,9 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "Record", Schema.CaseClass1[Map[String, DynamicValue], DynamicValue.Record]( + TypeId.parse("zio.scheema.DynamicValue.Record"), Schema.Field("values", Schema.defer(Schema.map(Schema.primitive[String], DynamicValueSchema()))), - map => DynamicValue.Record(ListMap(map.toSeq: _*)), + map => DynamicValue.Record(TypeId.Structural, ListMap(map.toSeq: _*)), record => record.values ), _.asInstanceOf[DynamicValue.Record] @@ -2087,6 +2156,7 @@ private[schema] object DynamicValueSchema { self => Schema.Case( "DynamicAst", Schema.CaseClass1[SchemaAst, DynamicValue.DynamicAst]( + TypeId.parse("zio.scheema.DynamicValue.DynamicAst"), Schema.Field("ast", SchemaAst.schema), schemaAst => DynamicValue.DynamicAst(schemaAst), dynamicAst => dynamicAst.ast diff --git a/zio-schema/shared/src/main/scala/zio/schema/FieldSet.scala b/zio-schema/shared/src/main/scala/zio/schema/FieldSet.scala index f652a8d35..a18f5f130 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/FieldSet.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/FieldSet.scala @@ -4,7 +4,7 @@ import zio.Chunk import zio.schema.Schema._ sealed trait FieldSet { - type Accessors[Whole, Lens[_, _], Prism[_, _], Traversal[_, _]] + type Accessors[Whole, Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] type Append[That <: FieldSet] <: FieldSet def :*:[A](head: Field[A]): FieldSet.Cons[A, FieldSet] @@ -24,8 +24,8 @@ object FieldSet { val Cons = :*: case object Empty extends FieldSet { - override type Accessors[Whole, Lens[_, _], Prism[_, _], Traversal[_, _]] = Unit - override type Append[That <: FieldSet] = That + override type Accessors[Whole, Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Unit + override type Append[That <: FieldSet] = That override def :*:[A](head: Field[A]): FieldSet.Cons[A, Empty] = Cons(head, Empty) @@ -42,8 +42,8 @@ object FieldSet { } final case class :*:[A, +T <: FieldSet](head: Field[A], tail: T) extends FieldSet { self => - override type Accessors[Whole, Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Lens[Whole, A], tail.Accessors[Whole, Lens, Prism, Traversal]) + override type Accessors[Whole, Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + (Lens[head.label.type, Whole, A], tail.Accessors[Whole, Lens, Prism, Traversal]) override type Append[That <: FieldSet] = Cons[A, tail.Append[That]] override def :*:[B](head2: Field[B]): FieldSet.Cons[B, Cons[A, T]] = Cons(head2, self) diff --git a/zio-schema/shared/src/main/scala/zio/schema/Schema.scala b/zio-schema/shared/src/main/scala/zio/schema/Schema.scala index 77ca078e2..df7601860 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/Schema.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/Schema.scala @@ -31,7 +31,7 @@ import zio.schema.validation._ sealed trait Schema[A] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] /** * A symbolic operator for [[optional]]. @@ -162,16 +162,16 @@ object Schema extends SchemaEquality { def defer[A](schema: => Schema[A]): Schema[A] = Lazy(() => schema) - def enumeration[A, C <: CaseSet.Aux[A]](caseSet: C): Schema[A] = - EnumN(caseSet, Chunk.empty) + def enumeration[A, C <: CaseSet.Aux[A]](id: TypeId, caseSet: C): Schema[A] = + EnumN(id, caseSet, Chunk.empty) def fail[A](message: String): Schema[A] = Fail(message) def first[A](codec: Schema[(A, Unit)]): Schema[A] = codec.transform[A](_._1, a => (a, ())) - def record(fields: Field[_]*): Schema[ListMap[String, _]] = - GenericRecord(FieldSet(fields: _*)) + def record(id: TypeId, fields: Field[_]*): Schema[ListMap[String, _]] = + GenericRecord(id, FieldSet(fields: _*)) def second[A](codec: Schema[(Unit, A)]): Schema[A] = codec.transform[A](_._2, a => ((), a)) @@ -270,6 +270,7 @@ object Schema extends SchemaEquality { chunk(element).transform(_.toVector, Chunk.fromIterable(_)) sealed trait Enum[A] extends Schema[A] { + def id: TypeId def structure: ListMap[String, Schema[_]] = ListMap(structureWithAnnotations.map(kv => (kv._1, kv._2._1)).toList: _*) @@ -289,6 +290,8 @@ object Schema extends SchemaEquality { def structure: Chunk[Field[_]] def rawConstruct(values: Chunk[Any]): Either[String, R] + def id: TypeId + def defaultValue: Either[String, R] = self.structure .map(_.schema.defaultValue) @@ -309,7 +312,7 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty, identity: I ) extends Collection[Col, Elem] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Traversal[Col, Elem] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Traversal[Col, Elem] override def annotate(annotation: Any): Sequence[Col, Elem, I] = copy(annotations = annotations :+ annotation) @@ -327,7 +330,7 @@ object Schema extends SchemaEquality { annotations: Chunk[Any], identity: I ) extends Schema[B] { - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = codec.Accessors[Lens, Prism, Traversal] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = codec.Accessors[Lens, Prism, Traversal] def defaultValue: Either[String, B] = codec.defaultValue.flatMap(f) @@ -346,7 +349,7 @@ object Schema extends SchemaEquality { final case class Primitive[A](standardType: StandardType[A], annotations: Chunk[Any] = Chunk.empty) extends Schema[A] { - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Unit + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Unit override def annotate(annotation: Any): Primitive[A] = copy(annotations = annotations :+ annotation) @@ -358,15 +361,19 @@ object Schema extends SchemaEquality { final case class Optional[A](codec: Schema[A], annotations: Chunk[Any] = Chunk.empty) extends Schema[Option[A]] { self => + val some = "Some" + val none = "None" + private[schema] lazy val someCodec: Schema[Some[A]] = codec.transform(a => Some(a), _.get) override def annotate(annotation: Any): Optional[A] = copy(annotations = annotations :+ annotation) - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Prism[Option[A], Some[A]], Prism[Option[A], None.type]) + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + (Prism[some.type, Option[A], Some[A]], Prism[none.type, Option[A], None.type]) lazy val toEnum: Enum2[Some[A], None.type, Option[A]] = Enum2( + TypeId.parse("zio.schema.Schema.Optional"), Case[Some[A], Option[A]]("Some", someCodec, _.asInstanceOf[Some[A]], Chunk.empty), Case[None.type, Option[A]]("None", singleton(None), _.asInstanceOf[None.type], Chunk.empty), Chunk.empty @@ -374,13 +381,15 @@ object Schema extends SchemaEquality { def defaultValue: Either[String, Option[A]] = Right(None) - override def makeAccessors(b: AccessorBuilder): (b.Prism[Option[A], Some[A]], b.Prism[Option[A], None.type]) = + override def makeAccessors( + b: AccessorBuilder + ): (b.Prism[some.type, Option[A], Some[A]], b.Prism[none.type, Option[A], None.type]) = b.makePrism(toEnum, toEnum.case1) -> b.makePrism(toEnum, toEnum.case2) } final case class Fail[A](message: String, annotations: Chunk[Any] = Chunk.empty) extends Schema[A] { - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Unit + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Unit override def annotate(annotation: Any): Fail[A] = copy(annotations = annotations :+ annotation) @@ -391,11 +400,16 @@ object Schema extends SchemaEquality { final case class Tuple[A, B](left: Schema[A], right: Schema[B], annotations: Chunk[Any] = Chunk.empty) extends Schema[(A, B)] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = (Lens[(A, B), A], Lens[(A, B), B]) + + val first = "_1" + val second = "_2" + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + (Lens[first.type, (A, B), A], Lens[second.type, (A, B), B]) override def annotate(annotation: Any): Tuple[A, B] = copy(annotations = annotations :+ annotation) val toRecord: CaseClass2[A, B, (A, B)] = CaseClass2[A, B, (A, B)]( + id = TypeId.parse("zio.schema.Schena.Tuple"), field1 = Field[A]("_1", left), field2 = Field[B]("_2", right), construct = (a, b) => (a, b), @@ -407,15 +421,21 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, (A, B)] = left.defaultValue.flatMap(a => right.defaultValue.map(b => (a, b))) - override def makeAccessors(b: AccessorBuilder): (b.Lens[(A, B), A], b.Lens[(A, B), B]) = + override def makeAccessors(b: AccessorBuilder): (b.Lens[first.type, (A, B), A], b.Lens[second.type, (A, B), B]) = b.makeLens(toRecord, toRecord.field1) -> b.makeLens(toRecord, toRecord.field2) } final case class EitherSchema[A, B](left: Schema[A], right: Schema[B], annotations: Chunk[Any] = Chunk.empty) extends Schema[Either[A, B]] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Prism[Either[A, B], Right[Nothing, B]], Prism[Either[A, B], Left[A, Nothing]]) + + val leftSingleton = "Left" + val rightSingleton = "Right" + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + ( + Prism[rightSingleton.type, Either[A, B], Right[Nothing, B]], + Prism[leftSingleton.type, Either[A, B], Left[A, Nothing]] + ) override def annotate(annotation: Any): EitherSchema[A, B] = copy(annotations = annotations :+ annotation) @@ -423,6 +443,7 @@ object Schema extends SchemaEquality { val leftSchema: Schema[Left[A, Nothing]] = left.transform(a => Left(a), _.value) val toEnum: Enum2[Right[Nothing, B], Left[A, Nothing], Either[A, B]] = Enum2( + TypeId.parse("zio.schema.Schema.EitherSchema"), Case("Right", rightSchema, _.asInstanceOf[Right[Nothing, B]], Chunk.empty), Case("Left", leftSchema, _.asInstanceOf[Left[A, Nothing]], Chunk.empty), Chunk.empty @@ -440,13 +461,16 @@ object Schema extends SchemaEquality { override def makeAccessors( b: AccessorBuilder - ): (b.Prism[Either[A, B], Right[Nothing, B]], b.Prism[Either[A, B], Left[A, Nothing]]) = + ): ( + b.Prism[rightSingleton.type, Either[A, B], Right[Nothing, B]], + b.Prism[leftSingleton.type, Either[A, B], Left[A, Nothing]] + ) = b.makePrism(toEnum, toEnum.case1) -> b.makePrism(toEnum, toEnum.case2) } final case class Lazy[A](private val schema0: () => Schema[A]) extends Schema[A] { - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = schema.Accessors[Lens, Prism, Traversal] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = schema.Accessors[Lens, Prism, Traversal] override def annotate(annotation: Any): Lazy[A] = Lazy(() => schema0().annotate(annotation)) @@ -466,7 +490,7 @@ object Schema extends SchemaEquality { override def annotate(annotation: Any): Meta = copy(annotations = annotations :+ annotation) - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Unit + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Unit override def defaultValue: Either[String, Schema[_]] = ast.toSchema.defaultValue.asInstanceOf[Either[String, Schema[_]]] @@ -477,7 +501,7 @@ object Schema extends SchemaEquality { final case class MapSchema[K, V](ks: Schema[K], vs: Schema[V], override val annotations: Chunk[Any] = Chunk.empty) extends Collection[Map[K, V], (K, V)] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Traversal[Map[K, V], (K, V)] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Traversal[Map[K, V], (K, V)] override def annotate(annotation: Any): MapSchema[K, V] = copy(annotations = annotations :+ annotation) @@ -491,7 +515,7 @@ object Schema extends SchemaEquality { final case class SetSchema[A](as: Schema[A], override val annotations: Chunk[Any] = Chunk.empty) extends Collection[Set[A], A] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Traversal[Set[A], A] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Traversal[Set[A], A] override def annotate(annotation: Any): SetSchema[A] = copy(annotations = annotations :+ annotation) @@ -504,7 +528,7 @@ object Schema extends SchemaEquality { } final case class Dynamic(override val annotations: Chunk[Any] = Chunk.empty) extends Schema[DynamicValue] { - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Unit + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Unit /** * The default value for a `Schema` of type `A`. @@ -525,7 +549,7 @@ object Schema extends SchemaEquality { override val defaultValue: Either[String, (A, Schema[A])], override val annotations: Chunk[Any] = Chunk.empty ) extends Schema[(A, Schema[A])] { - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Unit + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Unit /** * Returns a new schema that with `annotation` @@ -553,31 +577,34 @@ object Schema extends SchemaEquality { override def toString: String = s"Case($id,$codec,$annotations)" } - sealed case class Enum1[A <: Z, Z](case1: Case[A, Z], annotations: Chunk[Any] = Chunk.empty) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Prism[Z, A] + sealed case class Enum1[A <: Z, Z](id: TypeId, case1: Case[A, Z], annotations: Chunk[Any] = Chunk.empty) + extends Enum[Z] { self => + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Prism[case1.id.type, Z, A] override def annotate(annotation: Any): Enum1[A, Z] = copy(annotations = annotations :+ annotation) override def defaultValue: Either[String, Z] = case1.codec.defaultValue - override def makeAccessors(b: AccessorBuilder): b.Prism[Z, A] = b.makePrism(self, case1) + override def makeAccessors(b: AccessorBuilder): b.Prism[case1.id.type, Z, A] = b.makePrism(self, case1) override def structureWithAnnotations: ListMap[String, (Schema[_], Chunk[Any])] = ListMap(case1.id -> (case1.codec -> case1.annotations)) } sealed case class Enum2[A1 <: Z, A2 <: Z, Z]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = (Prism[Z, A1], Prism[Z, A2]) + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + (Prism[case1.id.type, Z, A1], Prism[case2.id.type, Z, A2]) override def annotate(annotation: Any): Enum2[A1, A2, Z] = copy(annotations = annotations :+ annotation) override def defaultValue: Either[String, Z] = case1.codec.defaultValue - override def makeAccessors(b: AccessorBuilder): (b.Prism[Z, A1], b.Prism[Z, A2]) = + override def makeAccessors(b: AccessorBuilder): (b.Prism[case1.id.type, Z, A1], b.Prism[case2.id.type, Z, A2]) = (b.makePrism(self, case1), b.makePrism(self, case2)) override def structureWithAnnotations: ListMap[String, (Schema[_], Chunk[Any])] = @@ -585,18 +612,22 @@ object Schema extends SchemaEquality { } sealed case class Enum3[A1 <: Z, A2 <: Z, A3 <: Z, Z]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = (Prism[Z, A1], Prism[Z, A2], Prism[Z, A3]) + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + (Prism[case1.id.type, Z, A1], Prism[case2.id.type, Z, A2], Prism[case3.id.type, Z, A3]) override def annotate(annotation: Any): Enum3[A1, A2, A3, Z] = copy(annotations = annotations :+ annotation) override def defaultValue: Either[String, Z] = case1.codec.defaultValue - override def makeAccessors(b: AccessorBuilder): (b.Prism[Z, A1], b.Prism[Z, A2], b.Prism[Z, A3]) = + override def makeAccessors( + b: AccessorBuilder + ): (b.Prism[case1.id.type, Z, A1], b.Prism[case2.id.type, Z, A2], b.Prism[case3.id.type, Z, A3]) = (b.makePrism(self, case1), b.makePrism(self, case2), b.makePrism(self, case3)) override def structureWithAnnotations: ListMap[String, (Schema[_], Chunk[Any])] = @@ -608,20 +639,31 @@ object Schema extends SchemaEquality { } sealed case class Enum4[A1 <: Z, A2 <: Z, A3 <: Z, A4 <: Z, Z]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], case4: Case[A4, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Prism[Z, A1], Prism[Z, A2], Prism[Z, A3], Prism[Z, A4]) + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4] + ) override def annotate(annotation: Any): Enum4[A1, A2, A3, A4, Z] = copy(annotations = annotations :+ annotation) override def defaultValue: Either[String, Z] = case1.codec.defaultValue - override def makeAccessors(b: AccessorBuilder): (b.Prism[Z, A1], b.Prism[Z, A2], b.Prism[Z, A3], b.Prism[Z, A4]) = + override def makeAccessors(b: AccessorBuilder): ( + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4] + ) = (b.makePrism(self, case1), b.makePrism(self, case2), b.makePrism(self, case3), b.makePrism(self, case4)) override def structureWithAnnotations: ListMap[String, (Schema[_], Chunk[Any])] = @@ -634,6 +676,7 @@ object Schema extends SchemaEquality { } sealed case class Enum5[A1 <: Z, A2 <: Z, A3 <: Z, A4 <: Z, A5 <: Z, Z]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -641,8 +684,14 @@ object Schema extends SchemaEquality { case5: Case[A5, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Prism[Z, A1], Prism[Z, A2], Prism[Z, A3], Prism[Z, A4], Prism[Z, A5]) + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5] + ) override def annotate(annotation: Any): Enum5[A1, A2, A3, A4, A5, Z] = copy(annotations = annotations :+ annotation) @@ -650,7 +699,13 @@ object Schema extends SchemaEquality { override def makeAccessors( b: AccessorBuilder - ): (b.Prism[Z, A1], b.Prism[Z, A2], b.Prism[Z, A3], b.Prism[Z, A4], b.Prism[Z, A5]) = + ): ( + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5] + ) = ( b.makePrism(self, case1), b.makePrism(self, case2), @@ -670,6 +725,7 @@ object Schema extends SchemaEquality { } sealed case class Enum6[A1 <: Z, A2 <: Z, A3 <: Z, A4 <: Z, A5 <: Z, A6 <: Z, Z]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -678,8 +734,15 @@ object Schema extends SchemaEquality { case6: Case[A6, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Prism[Z, A1], Prism[Z, A2], Prism[Z, A3], Prism[Z, A4], Prism[Z, A5], Prism[Z, A6]) + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6] + ) override def annotate(annotation: Any): Enum6[A1, A2, A3, A4, A5, A6, Z] = copy(annotations = annotations :+ annotation) @@ -688,7 +751,14 @@ object Schema extends SchemaEquality { override def makeAccessors( b: AccessorBuilder - ): (b.Prism[Z, A1], b.Prism[Z, A2], b.Prism[Z, A3], b.Prism[Z, A4], b.Prism[Z, A5], b.Prism[Z, A6]) = + ): ( + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6] + ) = ( b.makePrism(self, case1), b.makePrism(self, case2), @@ -710,6 +780,7 @@ object Schema extends SchemaEquality { } sealed case class Enum7[A1 <: Z, A2 <: Z, A3 <: Z, A4 <: Z, A5 <: Z, A6 <: Z, A7 <: Z, Z]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -719,8 +790,16 @@ object Schema extends SchemaEquality { case7: Case[A7, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Prism[Z, A1], Prism[Z, A2], Prism[Z, A3], Prism[Z, A4], Prism[Z, A5], Prism[Z, A6], Prism[Z, A7]) + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7] + ) override def annotate(annotation: Any): Enum7[A1, A2, A3, A4, A5, A6, A7, Z] = copy(annotations = annotations :+ annotation) @@ -728,13 +807,13 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7] ) = ( b.makePrism(self, case1), @@ -759,6 +838,7 @@ object Schema extends SchemaEquality { } sealed case class Enum8[A1 <: Z, A2 <: Z, A3 <: Z, A4 <: Z, A5 <: Z, A6 <: Z, A7 <: Z, A8 <: Z, Z]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -769,8 +849,17 @@ object Schema extends SchemaEquality { case8: Case[A8, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Prism[Z, A1], Prism[Z, A2], Prism[Z, A3], Prism[Z, A4], Prism[Z, A5], Prism[Z, A6], Prism[Z, A7], Prism[Z, A8]) + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8] + ) override def annotate(annotation: Any): Enum8[A1, A2, A3, A4, A5, A6, A7, A8, Z] = copy(annotations = annotations :+ annotation) @@ -778,14 +867,14 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8] ) = ( b.makePrism(self, case1), @@ -812,6 +901,7 @@ object Schema extends SchemaEquality { } sealed case class Enum9[A1 <: Z, A2 <: Z, A3 <: Z, A4 <: Z, A5 <: Z, A6 <: Z, A7 <: Z, A8 <: Z, A9 <: Z, Z]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -823,16 +913,16 @@ object Schema extends SchemaEquality { case9: Case[A9, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9] ) override def annotate(annotation: Any): Enum9[A1, A2, A3, A4, A5, A6, A7, A8, A9, Z] = @@ -841,15 +931,15 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9] ) = ( b.makePrism(self, case1), @@ -877,6 +967,7 @@ object Schema extends SchemaEquality { ) } sealed case class Enum10[A1 <: Z, A2 <: Z, A3 <: Z, A4 <: Z, A5 <: Z, A6 <: Z, A7 <: Z, A8 <: Z, A9 <: Z, A10 <: Z, Z]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -889,17 +980,17 @@ object Schema extends SchemaEquality { case10: Case[A10, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10] ) override def annotate(annotation: Any): Enum10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Z] = @@ -908,16 +999,16 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10] ) = ( b.makePrism(self, case1), @@ -960,6 +1051,7 @@ object Schema extends SchemaEquality { A11 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -973,18 +1065,18 @@ object Schema extends SchemaEquality { case11: Case[A11, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11] ) override def annotate(annotation: Any): Enum11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Z] = @@ -993,17 +1085,17 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11] ) = ( b.makePrism(self, case1), @@ -1049,6 +1141,7 @@ object Schema extends SchemaEquality { A12 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -1063,19 +1156,19 @@ object Schema extends SchemaEquality { case12: Case[A12, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12] ) override def annotate(annotation: Any): Enum12[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Z] = @@ -1084,18 +1177,18 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12] ) = ( b.makePrism(self, case1), @@ -1144,6 +1237,7 @@ object Schema extends SchemaEquality { A13 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -1159,20 +1253,20 @@ object Schema extends SchemaEquality { case13: Case[A13, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13] ) override def annotate(annotation: Any): Enum13[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Z] = @@ -1181,19 +1275,19 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13] ) = ( b.makePrism(self, case1), @@ -1246,6 +1340,7 @@ object Schema extends SchemaEquality { A14 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -1262,21 +1357,21 @@ object Schema extends SchemaEquality { case14: Case[A14, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13], - Prism[Z, A14] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13], + Prism[case14.id.type, Z, A14] ) override def annotate(annotation: Any): Enum14[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Z] = @@ -1285,20 +1380,20 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13], - b.Prism[Z, A14] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13], + b.Prism[case14.id.type, Z, A14] ) = ( b.makePrism(self, case1), @@ -1353,6 +1448,7 @@ object Schema extends SchemaEquality { A15 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -1370,22 +1466,22 @@ object Schema extends SchemaEquality { case15: Case[A15, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13], - Prism[Z, A14], - Prism[Z, A15] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13], + Prism[case14.id.type, Z, A14], + Prism[case15.id.type, Z, A15] ) override def annotate( @@ -1396,21 +1492,21 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13], - b.Prism[Z, A14], - b.Prism[Z, A15] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13], + b.Prism[case14.id.type, Z, A14], + b.Prism[case15.id.type, Z, A15] ) = ( b.makePrism(self, case1), @@ -1468,6 +1564,7 @@ object Schema extends SchemaEquality { A16 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -1486,23 +1583,23 @@ object Schema extends SchemaEquality { case16: Case[A16, Z], override val annotations: Chunk[Any] ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13], - Prism[Z, A14], - Prism[Z, A15], - Prism[Z, A16] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13], + Prism[case14.id.type, Z, A14], + Prism[case15.id.type, Z, A15], + Prism[case16.id.type, Z, A16] ) override def annotate( @@ -1513,22 +1610,22 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13], - b.Prism[Z, A14], - b.Prism[Z, A15], - b.Prism[Z, A16] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13], + b.Prism[case14.id.type, Z, A14], + b.Prism[case15.id.type, Z, A15], + b.Prism[case16.id.type, Z, A16] ) = ( b.makePrism(self, case1), @@ -1589,6 +1686,7 @@ object Schema extends SchemaEquality { A17 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -1608,24 +1706,24 @@ object Schema extends SchemaEquality { case17: Case[A17, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13], - Prism[Z, A14], - Prism[Z, A15], - Prism[Z, A16], - Prism[Z, A17] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13], + Prism[case14.id.type, Z, A14], + Prism[case15.id.type, Z, A15], + Prism[case16.id.type, Z, A16], + Prism[case17.id.type, Z, A17] ) override def annotate( @@ -1636,23 +1734,23 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13], - b.Prism[Z, A14], - b.Prism[Z, A15], - b.Prism[Z, A16], - b.Prism[Z, A17] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13], + b.Prism[case14.id.type, Z, A14], + b.Prism[case15.id.type, Z, A15], + b.Prism[case16.id.type, Z, A16], + b.Prism[case17.id.type, Z, A17] ) = ( b.makePrism(self, case1), @@ -1716,6 +1814,7 @@ object Schema extends SchemaEquality { A18 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -1736,25 +1835,25 @@ object Schema extends SchemaEquality { case18: Case[A18, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13], - Prism[Z, A14], - Prism[Z, A15], - Prism[Z, A16], - Prism[Z, A17], - Prism[Z, A18] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13], + Prism[case14.id.type, Z, A14], + Prism[case15.id.type, Z, A15], + Prism[case16.id.type, Z, A16], + Prism[case17.id.type, Z, A17], + Prism[case18.id.type, Z, A18] ) override def annotate( @@ -1765,24 +1864,24 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13], - b.Prism[Z, A14], - b.Prism[Z, A15], - b.Prism[Z, A16], - b.Prism[Z, A17], - b.Prism[Z, A18] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13], + b.Prism[case14.id.type, Z, A14], + b.Prism[case15.id.type, Z, A15], + b.Prism[case16.id.type, Z, A16], + b.Prism[case17.id.type, Z, A17], + b.Prism[case18.id.type, Z, A18] ) = ( b.makePrism(self, case1), @@ -1849,6 +1948,7 @@ object Schema extends SchemaEquality { A19 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -1870,26 +1970,26 @@ object Schema extends SchemaEquality { case19: Case[A19, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13], - Prism[Z, A14], - Prism[Z, A15], - Prism[Z, A16], - Prism[Z, A17], - Prism[Z, A18], - Prism[Z, A19] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13], + Prism[case14.id.type, Z, A14], + Prism[case15.id.type, Z, A15], + Prism[case16.id.type, Z, A16], + Prism[case17.id.type, Z, A17], + Prism[case18.id.type, Z, A18], + Prism[case19.id.type, Z, A19] ) override def annotate( @@ -1900,25 +2000,25 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13], - b.Prism[Z, A14], - b.Prism[Z, A15], - b.Prism[Z, A16], - b.Prism[Z, A17], - b.Prism[Z, A18], - b.Prism[Z, A19] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13], + b.Prism[case14.id.type, Z, A14], + b.Prism[case15.id.type, Z, A15], + b.Prism[case16.id.type, Z, A16], + b.Prism[case17.id.type, Z, A17], + b.Prism[case18.id.type, Z, A18], + b.Prism[case19.id.type, Z, A19] ) = ( b.makePrism(self, case1), @@ -1988,6 +2088,7 @@ object Schema extends SchemaEquality { A20 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -2010,27 +2111,27 @@ object Schema extends SchemaEquality { case20: Case[A20, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13], - Prism[Z, A14], - Prism[Z, A15], - Prism[Z, A16], - Prism[Z, A17], - Prism[Z, A18], - Prism[Z, A19], - Prism[Z, A20] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13], + Prism[case14.id.type, Z, A14], + Prism[case15.id.type, Z, A15], + Prism[case16.id.type, Z, A16], + Prism[case17.id.type, Z, A17], + Prism[case18.id.type, Z, A18], + Prism[case19.id.type, Z, A19], + Prism[case20.id.type, Z, A20] ) override def annotate( @@ -2041,26 +2142,26 @@ object Schema extends SchemaEquality { override def defaultValue: Either[String, Z] = case1.codec.defaultValue override def makeAccessors(b: AccessorBuilder): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13], - b.Prism[Z, A14], - b.Prism[Z, A15], - b.Prism[Z, A16], - b.Prism[Z, A17], - b.Prism[Z, A18], - b.Prism[Z, A19], - b.Prism[Z, A20] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13], + b.Prism[case14.id.type, Z, A14], + b.Prism[case15.id.type, Z, A15], + b.Prism[case16.id.type, Z, A16], + b.Prism[case17.id.type, Z, A17], + b.Prism[case18.id.type, Z, A18], + b.Prism[case19.id.type, Z, A19], + b.Prism[case20.id.type, Z, A20] ) = ( b.makePrism(self, case1), @@ -2133,6 +2234,7 @@ object Schema extends SchemaEquality { A21 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -2156,28 +2258,28 @@ object Schema extends SchemaEquality { case21: Case[A21, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13], - Prism[Z, A14], - Prism[Z, A15], - Prism[Z, A16], - Prism[Z, A17], - Prism[Z, A18], - Prism[Z, A19], - Prism[Z, A20], - Prism[Z, A21] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13], + Prism[case14.id.type, Z, A14], + Prism[case15.id.type, Z, A15], + Prism[case16.id.type, Z, A16], + Prism[case17.id.type, Z, A17], + Prism[case18.id.type, Z, A18], + Prism[case19.id.type, Z, A19], + Prism[case20.id.type, Z, A20], + Prism[case21.id.type, Z, A21] ) override def annotate( @@ -2190,27 +2292,27 @@ object Schema extends SchemaEquality { override def makeAccessors( b: AccessorBuilder ): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13], - b.Prism[Z, A14], - b.Prism[Z, A15], - b.Prism[Z, A16], - b.Prism[Z, A17], - b.Prism[Z, A18], - b.Prism[Z, A19], - b.Prism[Z, A20], - b.Prism[Z, A21] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13], + b.Prism[case14.id.type, Z, A14], + b.Prism[case15.id.type, Z, A15], + b.Prism[case16.id.type, Z, A16], + b.Prism[case17.id.type, Z, A17], + b.Prism[case18.id.type, Z, A18], + b.Prism[case19.id.type, Z, A19], + b.Prism[case20.id.type, Z, A20], + b.Prism[case21.id.type, Z, A21] ) = ( b.makePrism(self, case1), @@ -2286,6 +2388,7 @@ object Schema extends SchemaEquality { A22 <: Z, Z ]( + id: TypeId, case1: Case[A1, Z], case2: Case[A2, Z], case3: Case[A3, Z], @@ -2310,29 +2413,29 @@ object Schema extends SchemaEquality { case22: Case[A22, Z], annotations: Chunk[Any] = Chunk.empty ) extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Prism[Z, A1], - Prism[Z, A2], - Prism[Z, A3], - Prism[Z, A4], - Prism[Z, A5], - Prism[Z, A6], - Prism[Z, A7], - Prism[Z, A8], - Prism[Z, A9], - Prism[Z, A10], - Prism[Z, A11], - Prism[Z, A12], - Prism[Z, A13], - Prism[Z, A14], - Prism[Z, A15], - Prism[Z, A16], - Prism[Z, A17], - Prism[Z, A18], - Prism[Z, A19], - Prism[Z, A20], - Prism[Z, A21], - Prism[Z, A22] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Prism[case1.id.type, Z, A1], + Prism[case2.id.type, Z, A2], + Prism[case3.id.type, Z, A3], + Prism[case4.id.type, Z, A4], + Prism[case5.id.type, Z, A5], + Prism[case6.id.type, Z, A6], + Prism[case7.id.type, Z, A7], + Prism[case8.id.type, Z, A8], + Prism[case9.id.type, Z, A9], + Prism[case10.id.type, Z, A10], + Prism[case11.id.type, Z, A11], + Prism[case12.id.type, Z, A12], + Prism[case13.id.type, Z, A13], + Prism[case14.id.type, Z, A14], + Prism[case15.id.type, Z, A15], + Prism[case16.id.type, Z, A16], + Prism[case17.id.type, Z, A17], + Prism[case18.id.type, Z, A18], + Prism[case19.id.type, Z, A19], + Prism[case20.id.type, Z, A20], + Prism[case21.id.type, Z, A21], + Prism[case22.id.type, Z, A22] ) override def annotate( @@ -2345,28 +2448,28 @@ object Schema extends SchemaEquality { override def makeAccessors( b: AccessorBuilder ): ( - b.Prism[Z, A1], - b.Prism[Z, A2], - b.Prism[Z, A3], - b.Prism[Z, A4], - b.Prism[Z, A5], - b.Prism[Z, A6], - b.Prism[Z, A7], - b.Prism[Z, A8], - b.Prism[Z, A9], - b.Prism[Z, A10], - b.Prism[Z, A11], - b.Prism[Z, A12], - b.Prism[Z, A13], - b.Prism[Z, A14], - b.Prism[Z, A15], - b.Prism[Z, A16], - b.Prism[Z, A17], - b.Prism[Z, A18], - b.Prism[Z, A19], - b.Prism[Z, A20], - b.Prism[Z, A21], - b.Prism[Z, A22] + b.Prism[case1.id.type, Z, A1], + b.Prism[case2.id.type, Z, A2], + b.Prism[case3.id.type, Z, A3], + b.Prism[case4.id.type, Z, A4], + b.Prism[case5.id.type, Z, A5], + b.Prism[case6.id.type, Z, A6], + b.Prism[case7.id.type, Z, A7], + b.Prism[case8.id.type, Z, A8], + b.Prism[case9.id.type, Z, A9], + b.Prism[case10.id.type, Z, A10], + b.Prism[case11.id.type, Z, A11], + b.Prism[case12.id.type, Z, A12], + b.Prism[case13.id.type, Z, A13], + b.Prism[case14.id.type, Z, A14], + b.Prism[case15.id.type, Z, A15], + b.Prism[case16.id.type, Z, A16], + b.Prism[case17.id.type, Z, A17], + b.Prism[case18.id.type, Z, A18], + b.Prism[case19.id.type, Z, A19], + b.Prism[case20.id.type, Z, A20], + b.Prism[case21.id.type, Z, A21], + b.Prism[case22.id.type, Z, A22] ) = ( b.makePrism(self, case1), @@ -2419,9 +2522,11 @@ object Schema extends SchemaEquality { case22.id -> (case22.codec -> case22.annotations) ) } - sealed case class EnumN[Z, C <: CaseSet.Aux[Z]](caseSet: C, annotations: Chunk[Any] = Chunk.empty) extends Enum[Z] { + sealed case class EnumN[Z, C <: CaseSet.Aux[Z]](id: TypeId, caseSet: C, annotations: Chunk[Any] = Chunk.empty) + extends Enum[Z] { self => - override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = caseSet.Accessors[Z, Lens, Prism, Traversal] + override type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + caseSet.Accessors[Z, Lens, Prism, Traversal] override def annotate(annotation: Any): EnumN[Z, C] = copy(annotations = annotations :+ annotation) @@ -3096,10 +3201,10 @@ object Schema extends SchemaEquality { // # RECORD SCHEMAS - sealed case class GenericRecord(fieldSet: FieldSet, override val annotations: Chunk[Any] = Chunk.empty) + sealed case class GenericRecord(id: TypeId, fieldSet: FieldSet, override val annotations: Chunk[Any] = Chunk.empty) extends Record[ListMap[String, _]] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = fieldSet.Accessors[ListMap[String, _], Lens, Prism, Traversal] override def makeAccessors(b: AccessorBuilder): Accessors[b.Lens, b.Prism, b.Traversal] = @@ -3120,10 +3225,10 @@ object Schema extends SchemaEquality { } - sealed case class CaseClass0[Z](construct: () => Z, override val annotations: Chunk[Any] = Chunk.empty) + sealed case class CaseClass0[Z](id: TypeId, construct: () => Z, override val annotations: Chunk[Any] = Chunk.empty) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Nothing + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Nothing override def annotate(annotation: Any): CaseClass0[Z] = copy(annotations = annotations :+ annotation) @@ -3144,17 +3249,18 @@ object Schema extends SchemaEquality { } sealed case class CaseClass1[A, Z]( + id: TypeId, field: Field[A], construct: A => Z, extractField: Z => A, override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = Lens[Z, A] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = Lens[field.label.type, Z, A] override def annotate(annotation: Any): CaseClass1[A, Z] = copy(annotations = annotations :+ annotation) - override def makeAccessors(b: AccessorBuilder): b.Lens[Z, A] = b.makeLens(self, field) + override def makeAccessors(b: AccessorBuilder): b.Lens[field.label.type, Z, A] = b.makeLens(self, field) override def structure: Chunk[Field[_]] = Chunk(field) @@ -3171,6 +3277,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass2[A1, A2, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], construct: (A1, A2) => Z, @@ -3179,11 +3286,14 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = (Lens[Z, A1], Lens[Z, A2]) + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + (Lens[field1.label.type, Z, A1], Lens[field2.label.type, Z, A2]) override def annotate(annotation: Any): CaseClass2[A1, A2, Z] = copy(annotations = annotations :+ annotation) - override def makeAccessors(b: AccessorBuilder): (b.Lens[Z, A1], b.Lens[Z, A2]) = + override def makeAccessors( + b: AccessorBuilder + ): (b.Lens[field1.label.type, Z, A1], b.Lens[field2.label.type, Z, A2]) = (b.makeLens(self, field1), b.makeLens(self, field2)) override def structure: Chunk[Field[_]] = Chunk(field1, field2) @@ -3201,6 +3311,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass3[A1, A2, A3, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3210,11 +3321,15 @@ object Schema extends SchemaEquality { extractField3: Z => A3, override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = (Lens[Z, A1], Lens[Z, A2], Lens[Z, A3]) + + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + (Lens[field1.label.type, Z, A1], Lens[field2.label.type, Z, A2], Lens[field3.label.type, Z, A3]) override def annotate(annotation: Any): CaseClass3[A1, A2, A3, Z] = copy(annotations = annotations :+ annotation) - override def makeAccessors(b: AccessorBuilder): (b.Lens[Z, A1], b.Lens[Z, A2], b.Lens[Z, A3]) = + override def makeAccessors( + b: AccessorBuilder + ): (b.Lens[field1.label.type, Z, A1], b.Lens[field2.label.type, Z, A2], b.Lens[field3.label.type, Z, A3]) = (b.makeLens(self, field1), b.makeLens(self, field2), b.makeLens(self, field3)) override def structure: Chunk[Field[_]] = Chunk(field1, field2, field3) @@ -3233,6 +3348,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass4[A1, A2, A3, A4, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3244,12 +3360,23 @@ object Schema extends SchemaEquality { extractField4: Z => A4, override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = (Lens[Z, A1], Lens[Z, A2], Lens[Z, A3], Lens[Z, A4]) + + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4] + ) override def annotate(annotation: Any): CaseClass4[A1, A2, A3, A4, Z] = copy(annotations = annotations :+ annotation) - override def makeAccessors(b: AccessorBuilder): (b.Lens[Z, A1], b.Lens[Z, A2], b.Lens[Z, A3], b.Lens[Z, A4]) = + override def makeAccessors(b: AccessorBuilder): ( + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4] + ) = (b.makeLens(self, field1), b.makeLens(self, field2), b.makeLens(self, field3), b.makeLens(self, field4)) override def structure: Chunk[Field[_]] = Chunk(field1, field2, field3, field4) @@ -3275,6 +3402,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass5[A1, A2, A3, A4, A5, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3289,15 +3417,24 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Lens[Z, A1], Lens[Z, A2], Lens[Z, A3], Lens[Z, A4], Lens[Z, A5]) + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5] + ) override def annotate(annotation: Any): CaseClass5[A1, A2, A3, A4, A5, Z] = copy(annotations = annotations :+ annotation) - override def makeAccessors( - b: AccessorBuilder - ): (b.Lens[Z, A1], b.Lens[Z, A2], b.Lens[Z, A3], b.Lens[Z, A4], b.Lens[Z, A5]) = + override def makeAccessors(b: AccessorBuilder): ( + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5] + ) = ( b.makeLens(self, field1), b.makeLens(self, field2), @@ -3329,6 +3466,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass6[A1, A2, A3, A4, A5, A6, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3345,15 +3483,26 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Lens[Z, A1], Lens[Z, A2], Lens[Z, A3], Lens[Z, A4], Lens[Z, A5], Lens[Z, A6]) + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6] + ) override def annotate(annotation: Any): CaseClass6[A1, A2, A3, A4, A5, A6, Z] = copy(annotations = annotations :+ annotation) - override def makeAccessors( - b: AccessorBuilder - ): (b.Lens[Z, A1], b.Lens[Z, A2], b.Lens[Z, A3], b.Lens[Z, A4], b.Lens[Z, A5], b.Lens[Z, A6]) = + override def makeAccessors(b: AccessorBuilder): ( + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6] + ) = ( b.makeLens(self, field1), b.makeLens(self, field2), @@ -3388,6 +3537,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass7[A1, A2, A3, A4, A5, A6, A7, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3406,15 +3556,28 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Lens[Z, A1], Lens[Z, A2], Lens[Z, A3], Lens[Z, A4], Lens[Z, A5], Lens[Z, A6], Lens[Z, A7]) + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7] + ) override def annotate(annotation: Any): CaseClass7[A1, A2, A3, A4, A5, A6, A7, Z] = copy(annotations = annotations :+ annotation) - override def makeAccessors( - b: AccessorBuilder - ): (b.Lens[Z, A1], b.Lens[Z, A2], b.Lens[Z, A3], b.Lens[Z, A4], b.Lens[Z, A5], b.Lens[Z, A6], b.Lens[Z, A7]) = + override def makeAccessors(b: AccessorBuilder): ( + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7] + ) = ( b.makeLens(self, field1), b.makeLens(self, field2), @@ -3451,6 +3614,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass8[A1, A2, A3, A4, A5, A6, A7, A8, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3471,21 +3635,29 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = - (Lens[Z, A1], Lens[Z, A2], Lens[Z, A3], Lens[Z, A4], Lens[Z, A5], Lens[Z, A6], Lens[Z, A7], Lens[Z, A8]) + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8] + ) override def annotate(annotation: Any): CaseClass8[A1, A2, A3, A4, A5, A6, A7, A8, Z] = copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8] ) = ( b.makeLens(self, field1), @@ -3525,6 +3697,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass9[A1, A2, A3, A4, A5, A6, A7, A8, A9, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3547,31 +3720,31 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9] ) override def annotate(annotation: Any): CaseClass9[A1, A2, A3, A4, A5, A6, A7, A8, A9, Z] = copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9] ) = ( b.makeLens(self, field1), @@ -3613,6 +3786,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3637,33 +3811,33 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10] ) override def annotate(annotation: Any): CaseClass10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Z] = copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10] ) = ( b.makeLens(self, field1), @@ -3707,6 +3881,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3733,35 +3908,38 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11] - ) + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11] + ) override def annotate(annotation: Any): CaseClass11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Z] = copy(annotations = annotations :+ annotation) - override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11] + override def makeAccessors( + b: AccessorBuilder + ): ( + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11] ) = ( b.makeLens(self, field1), @@ -3807,6 +3985,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass12[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3835,37 +4014,38 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12] - ) + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = + ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12] + ) override def annotate(annotation: Any): CaseClass12[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Z] = copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12] ) = ( b.makeLens(self, field1), @@ -3913,6 +4093,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass13[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -3943,39 +4124,39 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13] ) override def annotate(annotation: Any): CaseClass13[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Z] = copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13] ) = ( b.makeLens(self, field1), @@ -4025,6 +4206,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass14[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -4057,21 +4239,21 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13], - Lens[Z, A14] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13], + Lens[field14.label.type, Z, A14] ) override def annotate( @@ -4080,20 +4262,20 @@ object Schema extends SchemaEquality { copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13], - b.Lens[Z, A14] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13], + b.Lens[field14.label.type, Z, A14] ) = ( b.makeLens(self, field1), @@ -4161,6 +4343,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass15[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -4195,22 +4378,22 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13], - Lens[Z, A14], - Lens[Z, A15] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13], + Lens[field14.label.type, Z, A14], + Lens[field15.label.type, Z, A15] ) override def annotate( @@ -4219,21 +4402,21 @@ object Schema extends SchemaEquality { copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13], - b.Lens[Z, A14], - b.Lens[Z, A15] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13], + b.Lens[field14.label.type, Z, A14], + b.Lens[field15.label.type, Z, A15] ) = ( b.makeLens(self, field1), @@ -4304,6 +4487,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass16[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -4340,23 +4524,23 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13], - Lens[Z, A14], - Lens[Z, A15], - Lens[Z, A16] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13], + Lens[field14.label.type, Z, A14], + Lens[field15.label.type, Z, A15], + Lens[field16.label.type, Z, A16] ) override def annotate( @@ -4365,22 +4549,22 @@ object Schema extends SchemaEquality { copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13], - b.Lens[Z, A14], - b.Lens[Z, A15], - b.Lens[Z, A16] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13], + b.Lens[field14.label.type, Z, A14], + b.Lens[field15.label.type, Z, A15], + b.Lens[field16.label.type, Z, A16] ) = ( b.makeLens(self, field1), @@ -4454,6 +4638,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass17[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -4492,24 +4677,24 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13], - Lens[Z, A14], - Lens[Z, A15], - Lens[Z, A16], - Lens[Z, A17] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13], + Lens[field14.label.type, Z, A14], + Lens[field15.label.type, Z, A15], + Lens[field16.label.type, Z, A16], + Lens[field17.label.type, Z, A17] ) override def annotate( @@ -4518,23 +4703,23 @@ object Schema extends SchemaEquality { copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13], - b.Lens[Z, A14], - b.Lens[Z, A15], - b.Lens[Z, A16], - b.Lens[Z, A17] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13], + b.Lens[field14.label.type, Z, A14], + b.Lens[field15.label.type, Z, A15], + b.Lens[field16.label.type, Z, A16], + b.Lens[field17.label.type, Z, A17] ) = ( b.makeLens(self, field1), @@ -4611,6 +4796,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass18[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -4651,25 +4837,25 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13], - Lens[Z, A14], - Lens[Z, A15], - Lens[Z, A16], - Lens[Z, A17], - Lens[Z, A18] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13], + Lens[field14.label.type, Z, A14], + Lens[field15.label.type, Z, A15], + Lens[field16.label.type, Z, A16], + Lens[field17.label.type, Z, A17], + Lens[field18.label.type, Z, A18] ) override def annotate( @@ -4678,24 +4864,24 @@ object Schema extends SchemaEquality { copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13], - b.Lens[Z, A14], - b.Lens[Z, A15], - b.Lens[Z, A16], - b.Lens[Z, A17], - b.Lens[Z, A18] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13], + b.Lens[field14.label.type, Z, A14], + b.Lens[field15.label.type, Z, A15], + b.Lens[field16.label.type, Z, A16], + b.Lens[field17.label.type, Z, A17], + b.Lens[field18.label.type, Z, A18] ) = ( b.makeLens(self, field1), @@ -4775,6 +4961,7 @@ object Schema extends SchemaEquality { } sealed case class CaseClass19[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, Z]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -4817,26 +5004,26 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13], - Lens[Z, A14], - Lens[Z, A15], - Lens[Z, A16], - Lens[Z, A17], - Lens[Z, A18], - Lens[Z, A19] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13], + Lens[field14.label.type, Z, A14], + Lens[field15.label.type, Z, A15], + Lens[field16.label.type, Z, A16], + Lens[field17.label.type, Z, A17], + Lens[field18.label.type, Z, A18], + Lens[field19.label.type, Z, A19] ) override def annotate( @@ -4845,25 +5032,25 @@ object Schema extends SchemaEquality { copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13], - b.Lens[Z, A14], - b.Lens[Z, A15], - b.Lens[Z, A16], - b.Lens[Z, A17], - b.Lens[Z, A18], - b.Lens[Z, A19] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13], + b.Lens[field14.label.type, Z, A14], + b.Lens[field15.label.type, Z, A15], + b.Lens[field16.label.type, Z, A16], + b.Lens[field17.label.type, Z, A17], + b.Lens[field18.label.type, Z, A18], + b.Lens[field19.label.type, Z, A19] ) = ( b.makeLens(self, field1), @@ -4968,6 +5155,7 @@ object Schema extends SchemaEquality { A20, Z ]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -5012,27 +5200,27 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13], - Lens[Z, A14], - Lens[Z, A15], - Lens[Z, A16], - Lens[Z, A17], - Lens[Z, A18], - Lens[Z, A19], - Lens[Z, A20] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13], + Lens[field14.label.type, Z, A14], + Lens[field15.label.type, Z, A15], + Lens[field16.label.type, Z, A16], + Lens[field17.label.type, Z, A17], + Lens[field18.label.type, Z, A18], + Lens[field19.label.type, Z, A19], + Lens[field20.label.type, Z, A20] ) override def annotate( @@ -5041,26 +5229,26 @@ object Schema extends SchemaEquality { copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13], - b.Lens[Z, A14], - b.Lens[Z, A15], - b.Lens[Z, A16], - b.Lens[Z, A17], - b.Lens[Z, A18], - b.Lens[Z, A19], - b.Lens[Z, A20] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13], + b.Lens[field14.label.type, Z, A14], + b.Lens[field15.label.type, Z, A15], + b.Lens[field16.label.type, Z, A16], + b.Lens[field17.label.type, Z, A17], + b.Lens[field18.label.type, Z, A18], + b.Lens[field19.label.type, Z, A19], + b.Lens[field20.label.type, Z, A20] ) = ( b.makeLens(self, field1), @@ -5169,6 +5357,7 @@ object Schema extends SchemaEquality { A21, Z ]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -5215,28 +5404,28 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13], - Lens[Z, A14], - Lens[Z, A15], - Lens[Z, A16], - Lens[Z, A17], - Lens[Z, A18], - Lens[Z, A19], - Lens[Z, A20], - Lens[Z, A21] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13], + Lens[field14.label.type, Z, A14], + Lens[field15.label.type, Z, A15], + Lens[field16.label.type, Z, A16], + Lens[field17.label.type, Z, A17], + Lens[field18.label.type, Z, A18], + Lens[field19.label.type, Z, A19], + Lens[field20.label.type, Z, A20], + Lens[field21.label.type, Z, A21] ) override def annotate( @@ -5245,27 +5434,27 @@ object Schema extends SchemaEquality { copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13], - b.Lens[Z, A14], - b.Lens[Z, A15], - b.Lens[Z, A16], - b.Lens[Z, A17], - b.Lens[Z, A18], - b.Lens[Z, A19], - b.Lens[Z, A20], - b.Lens[Z, A21] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13], + b.Lens[field14.label.type, Z, A14], + b.Lens[field15.label.type, Z, A15], + b.Lens[field16.label.type, Z, A16], + b.Lens[field17.label.type, Z, A17], + b.Lens[field18.label.type, Z, A18], + b.Lens[field19.label.type, Z, A19], + b.Lens[field20.label.type, Z, A20], + b.Lens[field21.label.type, Z, A21] ) = ( b.makeLens(self, field1), @@ -5378,6 +5567,7 @@ object Schema extends SchemaEquality { A22, Z ]( + id: TypeId, field1: Field[A1], field2: Field[A2], field3: Field[A3], @@ -5449,29 +5639,29 @@ object Schema extends SchemaEquality { override val annotations: Chunk[Any] = Chunk.empty ) extends Record[Z] { self => - type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = ( - Lens[Z, A1], - Lens[Z, A2], - Lens[Z, A3], - Lens[Z, A4], - Lens[Z, A5], - Lens[Z, A6], - Lens[Z, A7], - Lens[Z, A8], - Lens[Z, A9], - Lens[Z, A10], - Lens[Z, A11], - Lens[Z, A12], - Lens[Z, A13], - Lens[Z, A14], - Lens[Z, A15], - Lens[Z, A16], - Lens[Z, A17], - Lens[Z, A18], - Lens[Z, A19], - Lens[Z, A20], - Lens[Z, A21], - Lens[Z, A22] + type Accessors[Lens[_, _, _], Prism[_, _, _], Traversal[_, _]] = ( + Lens[field1.label.type, Z, A1], + Lens[field2.label.type, Z, A2], + Lens[field3.label.type, Z, A3], + Lens[field4.label.type, Z, A4], + Lens[field5.label.type, Z, A5], + Lens[field6.label.type, Z, A6], + Lens[field7.label.type, Z, A7], + Lens[field8.label.type, Z, A8], + Lens[field9.label.type, Z, A9], + Lens[field10.label.type, Z, A10], + Lens[field11.label.type, Z, A11], + Lens[field12.label.type, Z, A12], + Lens[field13.label.type, Z, A13], + Lens[field14.label.type, Z, A14], + Lens[field15.label.type, Z, A15], + Lens[field16.label.type, Z, A16], + Lens[field17.label.type, Z, A17], + Lens[field18.label.type, Z, A18], + Lens[field19.label.type, Z, A19], + Lens[field20.label.type, Z, A20], + Lens[field21.label.type, Z, A21], + Lens[field22.label.type, Z, A22] ) override def annotate(annotation: Any): CaseClass22[ @@ -5501,28 +5691,28 @@ object Schema extends SchemaEquality { ] = copy(annotations = annotations :+ annotation) override def makeAccessors(b: AccessorBuilder): ( - b.Lens[Z, A1], - b.Lens[Z, A2], - b.Lens[Z, A3], - b.Lens[Z, A4], - b.Lens[Z, A5], - b.Lens[Z, A6], - b.Lens[Z, A7], - b.Lens[Z, A8], - b.Lens[Z, A9], - b.Lens[Z, A10], - b.Lens[Z, A11], - b.Lens[Z, A12], - b.Lens[Z, A13], - b.Lens[Z, A14], - b.Lens[Z, A15], - b.Lens[Z, A16], - b.Lens[Z, A17], - b.Lens[Z, A18], - b.Lens[Z, A19], - b.Lens[Z, A20], - b.Lens[Z, A21], - b.Lens[Z, A22] + b.Lens[field1.label.type, Z, A1], + b.Lens[field2.label.type, Z, A2], + b.Lens[field3.label.type, Z, A3], + b.Lens[field4.label.type, Z, A4], + b.Lens[field5.label.type, Z, A5], + b.Lens[field6.label.type, Z, A6], + b.Lens[field7.label.type, Z, A7], + b.Lens[field8.label.type, Z, A8], + b.Lens[field9.label.type, Z, A9], + b.Lens[field10.label.type, Z, A10], + b.Lens[field11.label.type, Z, A11], + b.Lens[field12.label.type, Z, A12], + b.Lens[field13.label.type, Z, A13], + b.Lens[field14.label.type, Z, A14], + b.Lens[field15.label.type, Z, A15], + b.Lens[field16.label.type, Z, A16], + b.Lens[field17.label.type, Z, A17], + b.Lens[field18.label.type, Z, A18], + b.Lens[field19.label.type, Z, A19], + b.Lens[field20.label.type, Z, A20], + b.Lens[field21.label.type, Z, A21], + b.Lens[field22.label.type, Z, A22] ) = ( b.makeLens(self, field1), diff --git a/zio-schema/shared/src/main/scala/zio/schema/SchemaOrdering.scala b/zio-schema/shared/src/main/scala/zio/schema/SchemaOrdering.scala index ea7bfcb21..4254fcc5f 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/SchemaOrdering.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/SchemaOrdering.scala @@ -44,13 +44,14 @@ object SchemaOrdering { case (Schema.Transform(_, _, _, _, _), _, Error(_)) => 1 case (Schema.Transform(schemaA, _, _, _, _), lVal, rVal) => compareBySchema(schemaA)(lVal, rVal) - case (e: Schema.Enum[_], Enumeration((lField, lVal)), Enumeration((rField, rVal))) if lField == rField => + case (e: Schema.Enum[_], Enumeration(_, (lField, lVal)), Enumeration(_, (rField, rVal))) if lField == rField => compareBySchema(e.structure(lField))(lVal, rVal) - case (e: Schema.Enum[_], Enumeration((lField, _)), Enumeration((rField, _))) => { + case (e: Schema.Enum[_], Enumeration(_, (lField, _)), Enumeration(_, (rField, _))) => { val fields = e.structure.keys.toList fields.indexOf(lField).compareTo(fields.indexOf(rField)) } - case (r: Schema.Record[_], Record(lVals), Record(rVals)) => + //are two record with the different name equal? + case (r: Schema.Record[_], Record(_, lVals), Record(_, rVals)) => compareRecords(r, lVals, rVals) case (Schema.SemiDynamic(_, _), Tuple(l, DynamicAst(ast)), Tuple(r, DynamicAst(_))) => compareBySchema(ast.toSchema)(l, r) diff --git a/zio-schema/shared/src/main/scala/zio/schema/TypeId.scala b/zio-schema/shared/src/main/scala/zio/schema/TypeId.scala new file mode 100644 index 000000000..ed2cbeb1d --- /dev/null +++ b/zio-schema/shared/src/main/scala/zio/schema/TypeId.scala @@ -0,0 +1,32 @@ +package zio.schema + +import zio.Chunk + +sealed trait TypeId { self => + + def name: String = self match { + case TypeId.Structural => "Structural" + case TypeId.Nominal(_, _, typeName) => typeName + } +} + +object TypeId { + case object Structural extends TypeId + final case class Nominal(packageName: Chunk[String], objectNames: Chunk[String], typeName: String) extends TypeId { + def fullyQualified: String = (packageName ++ objectNames ++ Chunk(typeName)).mkString(".") + } + + def fromTypeName(typeName: String): TypeId = Nominal(Chunk.empty, Chunk.empty, typeName) + + def parse(s: String): TypeId = + if (s.isEmpty) Structural + else + s.split("\\.").toList.reverse match { + case first :: remainder => + val objectNames = remainder.takeWhile(_.headOption.fold(false)(_.isUpper)).reverse + val packageNames = remainder.drop(objectNames.size).reverse + Nominal(Chunk.fromIterable(packageNames), Chunk.fromIterable(objectNames), first) + + case Nil => Structural + } +} diff --git a/zio-schema/shared/src/main/scala/zio/schema/ast/Migration.scala b/zio-schema/shared/src/main/scala/zio/schema/ast/Migration.scala index 2188f275b..c314fc11d 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/ast/Migration.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/ast/Migration.scala @@ -118,16 +118,16 @@ object Migration { else transformShape(path, f, t) :+ UpdateFail(path, t.message) ) - case (f @ SchemaAst.Product(_, ffields, _), t @ SchemaAst.Product(_, tfields, _)) => + case (f @ SchemaAst.Product(_, _, ffields, _), t @ SchemaAst.Product(_, _, tfields, _)) => goProduct(f, t, ffields, tfields) case (f @ SchemaAst.Tuple(_, fleft, fright, _), t @ SchemaAst.Tuple(_, tleft, tright, _)) => val ffields = Chunk("left" -> fleft, "right" -> fright) val tfields = Chunk("left" -> tleft, "right" -> tright) goProduct(f, t, ffields, tfields) - case (f @ SchemaAst.Product(_, ffields, _), t @ SchemaAst.Tuple(_, tleft, tright, _)) => + case (f @ SchemaAst.Product(_, _, ffields, _), t @ SchemaAst.Tuple(_, tleft, tright, _)) => val tfields = Chunk("left" -> tleft, "right" -> tright) goProduct(f, t, ffields, tfields) - case (f @ SchemaAst.Tuple(_, fleft, fright, _), t @ SchemaAst.Product(_, tfields, _)) => + case (f @ SchemaAst.Tuple(_, fleft, fright, _), t @ SchemaAst.Product(_, _, tfields, _)) => val ffields = Chunk("left" -> fleft, "right" -> fright) goProduct(f, t, ffields, tfields) case (f @ SchemaAst.ListNode(fitem, _, _), t @ SchemaAst.ListNode(titem, _, _)) => @@ -142,16 +142,16 @@ object Migration { val ffields = Chunk("keys" -> fkeys, "values" -> fvalues) val tfields = Chunk("keys" -> tkeys, "values" -> tvalues) goProduct(f, t, ffields, tfields) - case (f @ SchemaAst.Sum(_, fcases, _), t @ SchemaAst.Sum(_, tcases, _)) => + case (f @ SchemaAst.Sum(_, _, fcases, _), t @ SchemaAst.Sum(_, _, tcases, _)) => goSum(f, t, fcases, tcases) case (f @ SchemaAst.Either(_, fleft, fright, _), t @ SchemaAst.Either(_, tleft, tright, _)) => val fcases = Chunk("left" -> fleft, "right" -> fright) val tcases = Chunk("left" -> tleft, "right" -> tright) goSum(f, t, fcases, tcases) - case (f @ SchemaAst.Sum(_, fcases, _), t @ SchemaAst.Either(_, tleft, tright, _)) => + case (f @ SchemaAst.Sum(_, _, fcases, _), t @ SchemaAst.Either(_, tleft, tright, _)) => val tcases = Chunk("left" -> tleft, "right" -> tright) goSum(f, t, fcases, tcases) - case (f @ SchemaAst.Either(_, fleft, fright, _), t @ SchemaAst.Sum(_, tcases, _)) => + case (f @ SchemaAst.Either(_, fleft, fright, _), t @ SchemaAst.Sum(_, _, tcases, _)) => val fcases = Chunk("left" -> fleft, "right" -> fright) goSum(f, t, fcases, tcases) case (f @ SchemaAst.Value(ftype, _, _), t @ SchemaAst.Value(ttype, _, _)) if ttype != ftype => @@ -298,31 +298,31 @@ object Migration { updateLeaf(r, remainder, trace :+ "right")(op).map(DynamicValue.RightValue(_)) case (value @ DynamicValue.RightValue(_), "left" :: _) => Right(value) - case (DynamicValue.Record(values), leafLabel :: Nil) if values.keySet.contains(leafLabel) => + case (DynamicValue.Record(name, values), leafLabel :: Nil) if values.keySet.contains(leafLabel) => op(leafLabel, values(leafLabel)).map { case Some((newLeafLabel, newLeafValue)) => - DynamicValue.Record(spliceRecord(values, leafLabel, newLeafLabel -> newLeafValue)) - case None => DynamicValue.Record(values - leafLabel) + DynamicValue.Record(name, spliceRecord(values, leafLabel, newLeafLabel -> newLeafValue)) + case None => DynamicValue.Record(name, values - leafLabel) } - case (DynamicValue.Record(values), nextLabel :: remainder) if values.keySet.contains(nextLabel) => + case (DynamicValue.Record(name, values), nextLabel :: remainder) if values.keySet.contains(nextLabel) => updateLeaf(values(nextLabel), remainder, trace :+ nextLabel)(op).map { updatedValue => - DynamicValue.Record(spliceRecord(values, nextLabel, nextLabel -> updatedValue)) + DynamicValue.Record(name, spliceRecord(values, nextLabel, nextLabel -> updatedValue)) } - case (DynamicValue.Record(_), nextLabel :: _) => + case (DynamicValue.Record(_, _), nextLabel :: _) => Left(s"Expected label $nextLabel not found at path ${renderPath(trace)}") - case (v @ DynamicValue.Enumeration((caseLabel, _)), nextLabel :: _) if caseLabel != nextLabel => + case (v @ DynamicValue.Enumeration(_, (caseLabel, _)), nextLabel :: _) if caseLabel != nextLabel => Right(v) - case (DynamicValue.Enumeration((caseLabel, caseValue)), nextLabel :: Nil) if caseLabel == nextLabel => + case (DynamicValue.Enumeration(id, (caseLabel, caseValue)), nextLabel :: Nil) if caseLabel == nextLabel => op(caseLabel, caseValue).flatMap { - case Some(newCase) => Right(DynamicValue.Enumeration(newCase)) + case Some(newCase) => Right(DynamicValue.Enumeration(id, newCase)) case None => Left( s"Failed to update leaf node at path ${renderPath(trace :+ nextLabel)}: Cannot remove instantiated case" ) } - case (DynamicValue.Enumeration((caseLabel, caseValue)), nextLabel :: remainder) if caseLabel == nextLabel => + case (DynamicValue.Enumeration(id, (caseLabel, caseValue)), nextLabel :: remainder) if caseLabel == nextLabel => updateLeaf(caseValue, remainder, trace :+ nextLabel)(op).map { updatedValue => - DynamicValue.Enumeration(nextLabel -> updatedValue) + DynamicValue.Enumeration(id, nextLabel -> updatedValue) } case (DynamicValue.Dictionary(entries), "keys" :: Nil) => entries diff --git a/zio-schema/shared/src/main/scala/zio/schema/ast/SchemaAst.scala b/zio-schema/shared/src/main/scala/zio/schema/ast/SchemaAst.scala index 8dfca5178..97a168c4d 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/ast/SchemaAst.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/ast/SchemaAst.scala @@ -30,6 +30,7 @@ object SchemaAst { .transform(NodePath(_), NodePath.unwrap) final case class Product( + id: TypeId, override val path: NodePath, fields: Chunk[Labelled] = Chunk.empty, override val optional: Boolean = false @@ -38,10 +39,12 @@ object SchemaAst { object Product { implicit val schema: Schema[Product] = { Schema.CaseClass3( + TypeId.parse("zio.scheema.ast.SchemaAst.Product"), field1 = Schema.Field("path", Schema[String].repeated), field2 = Schema.Field("fields", Schema[Labelled].repeated), field3 = Schema.Field("optional", Schema[Boolean]), - (path: Chunk[String], fields: Chunk[Labelled], optional: Boolean) => Product(NodePath(path), fields, optional), + (path: Chunk[String], fields: Chunk[Labelled], optional: Boolean) => + Product(TypeId.Structural, NodePath(path), fields, optional), _.path, _.fields, _.optional @@ -59,6 +62,7 @@ object SchemaAst { object Tuple { implicit val schema: Schema[Tuple] = { Schema.CaseClass4( + TypeId.parse("zio.scheema.ast.SchemaAst.Tuple"), field1 = Schema.Field("path", Schema[String].repeated), field2 = Schema.Field("left", Schema[SchemaAst]), field3 = Schema.Field("right", Schema[SchemaAst]), @@ -74,6 +78,7 @@ object SchemaAst { } final case class Sum( + id: TypeId, override val path: NodePath, cases: Chunk[Labelled] = Chunk.empty, override val optional: Boolean = false @@ -82,10 +87,12 @@ object SchemaAst { object Sum { implicit lazy val schema: Schema[Sum] = Schema.CaseClass3( + TypeId.parse("zio.scheema.ast.SchemaAst.Sum"), field1 = Schema.Field("path", Schema[String].repeated), field2 = Schema.Field("cases", Schema[Labelled].repeated), field3 = Schema.Field("optional", Schema[Boolean]), - (path: Chunk[String], fields: Chunk[Labelled], optional: Boolean) => Sum(NodePath(path), fields, optional), + (path: Chunk[String], fields: Chunk[Labelled], optional: Boolean) => + Sum(TypeId.Structural, NodePath(path), fields, optional), _.path, _.cases, _.optional @@ -102,6 +109,7 @@ object SchemaAst { object Either { implicit val schema: Schema[Either] = { Schema.CaseClass4( + TypeId.parse("zio.scheema.ast.SchemaAst.Either"), field1 = Schema.Field("path", Schema[String].repeated), field2 = Schema.Field("left", Schema[SchemaAst]), field3 = Schema.Field("right", Schema[SchemaAst]), @@ -124,6 +132,7 @@ object SchemaAst { object FailNode { implicit val schema: Schema[FailNode] = Schema.CaseClass3( + TypeId.parse("zio.scheema.ast.SchemaAst.FailNode"), field1 = Schema.Field("message", Schema[String]), field2 = Schema.Field("path", Schema[String].repeated), field3 = Schema.Field("optional", Schema[Boolean]), @@ -142,6 +151,7 @@ object SchemaAst { object ListNode { implicit val schema: Schema[ListNode] = Schema.CaseClass3( + TypeId.parse("zio.scheema.ast.SchemaAst.ListNode"), field1 = Schema.Field("item", Schema[SchemaAst]), field2 = Schema.Field("path", Schema[String].repeated), field3 = Schema.Field("optional", Schema[Boolean]), @@ -161,6 +171,7 @@ object SchemaAst { object Dictionary { implicit val schema: Schema[Dictionary] = Schema.CaseClass4( + TypeId.parse("zio.scheema.ast.SchemaAst.Dictionary"), field1 = Schema.Field("keys", Schema[SchemaAst]), field2 = Schema.Field("values", Schema[SchemaAst]), field3 = Schema.Field("path", Schema[String].repeated), @@ -184,6 +195,7 @@ object SchemaAst { implicit val schema: Schema[Value] = Schema .CaseClass3[String, Chunk[String], Boolean, (String, Chunk[String], Boolean)]( + TypeId.parse("zio.scheema.ast.SchemaAst.Value"), field1 = Schema.Field("valueType", Schema[String]), field2 = Schema.Field("path", Schema[String].repeated), field3 = Schema.Field("optional", Schema[Boolean]), @@ -214,6 +226,7 @@ object SchemaAst { object Ref { implicit val schema: Schema[Ref] = Schema.CaseClass3( + TypeId.parse("zio.scheema.ast.SchemaAst.Ref"), field1 = Schema.Field("refPath", Schema[String].repeated), field2 = Schema.Field("path", Schema[String].repeated), field3 = Schema.Field("optional", Schema[Boolean]), @@ -234,6 +247,7 @@ object SchemaAst { object Dynamic { implicit val schema: Schema[Dynamic] = Schema.CaseClass3( + TypeId.parse("zio.scheema.ast.SchemaAst.Dynamic"), field1 = Schema.Field("withSchema", Schema[Boolean]), field2 = Schema.Field("path", Schema[String].repeated), field3 = Schema.Field("optional", Schema[Boolean]), @@ -256,9 +270,9 @@ object SchemaAst { self } - def buildProduct(): Product = Product(path, children.result(), optional) + def buildProduct(id: TypeId): Product = Product(id, path, children.result(), optional) - def buildSum(): Sum = Sum(path, children.result(), optional) + def buildSum(id: TypeId): Sum = Sum(id, path, children.result(), optional) } @tailrec @@ -295,14 +309,14 @@ object SchemaAst { .foldLeft(NodeBuilder(NodePath.root, Chunk(s.hashCode() -> NodePath.root))) { (node, field) => node.addLabelledSubtree(field.label, field.schema) } - .buildProduct() + .buildProduct(s.id) case s: Schema.Enum[A] => s.structure .foldLeft(NodeBuilder(NodePath.root, Chunk(s.hashCode() -> NodePath.root))) { case (node, (id, schema)) => node.addLabelledSubtree(id, schema) } - .buildSum() + .buildSum(s.id) case Schema.Meta(ast, _) => ast case Schema.Dynamic(_) => Dynamic(withSchema = false, NodePath.root) case Schema.SemiDynamic(_, _) => Dynamic(withSchema = true, NodePath.root) @@ -356,14 +370,14 @@ object SchemaAst { .foldLeft(NodeBuilder(path, lineage :+ (s.hashCode() -> path), optional)) { (node, field) => node.addLabelledSubtree(field.label, field.schema) } - .buildProduct() + .buildProduct(s.id) case s: Schema.Enum[_] => s.structure .foldLeft(NodeBuilder(path, lineage :+ (s.hashCode() -> path), optional)) { case (node, (id, schema)) => node.addLabelledSubtree(id, schema) } - .buildSum() + .buildSum(s.id) case Schema.Fail(message, _) => FailNode(message, path) case Schema.Meta(ast, _) => ast case Schema.Dynamic(_) => Dynamic(withSchema = false, path, optional) @@ -380,8 +394,9 @@ object SchemaAst { Schema.defer( refs.getOrElse(refPath, Schema.Fail(s"invalid ref path $refPath")) ) - case SchemaAst.Product(_, elems, _) => + case SchemaAst.Product(id, _, elems, _) => Schema.record( + id, elems.map { case (label, ast) => Schema.Field(label, materialize(ast, refs)) @@ -392,8 +407,9 @@ object SchemaAst { materialize(left, refs), materialize(right, refs) ) - case SchemaAst.Sum(_, elems, _) => + case SchemaAst.Sum(id, _, elems, _) => Schema.enumeration[Any, CaseSet.Aux[Any]]( + id, elems.foldRight[CaseSet.Aux[Any]](CaseSet.Empty[Any]()) { case ((label, ast), acc) => val _case: Schema.Case[Any, Any] = Schema @@ -429,6 +445,7 @@ object SchemaAst { implicit lazy val schema: Schema[SchemaAst] = Schema.Lazy { () => Schema.EnumN[SchemaAst, CaseSet.Aux[SchemaAst]]( + TypeId.parse("zio.scheema.ast.SchemaAst"), caseOf[Value, SchemaAst]("Value")(_.asInstanceOf[Value]) ++ caseOf[Sum, SchemaAst]("Sum")(_.asInstanceOf[Sum]) ++ caseOf[Either, SchemaAst]("Either")(_.asInstanceOf[Either]) ++ @@ -450,7 +467,7 @@ private[schema] object AstRenderer { def render(ast: SchemaAst): String = ast match { case v @ SchemaAst.Value(_, _, _) => renderValue(v, 0, None) case f @ SchemaAst.FailNode(_, _, _) => renderFail(f, 0, None) - case SchemaAst.Product(_, fields, optional) => + case SchemaAst.Product(_, _, fields, optional) => val buffer = new StringBuffer() buffer.append(s"product") if (optional) buffer.append("?") @@ -463,7 +480,7 @@ private[schema] object AstRenderer { .append("\n") .append(Chunk("left" -> left, "right" -> right).map(renderField(_, INDENT_STEP)).mkString("\n")) .toString - case SchemaAst.Sum(_, cases, optional) => + case SchemaAst.Sum(_, _, cases, optional) => val buffer = new StringBuffer() buffer.append(s"enum") if (optional) buffer.append("?") @@ -511,7 +528,7 @@ private[schema] object AstRenderer { renderValue(value, indent, Some(label)) case (label, fail @ SchemaAst.FailNode(_, _, _)) => renderFail(fail, indent, Some(label)) - case (label, SchemaAst.Product(_, fields, optional)) => + case (label, SchemaAst.Product(_, _, fields, optional)) => pad(buffer, indent) buffer.append(s"$label: record") if (optional) buffer.append("?") @@ -524,7 +541,7 @@ private[schema] object AstRenderer { .append("\n") .append(Chunk("left" -> left, "right" -> right).map(renderField(_, indent + INDENT_STEP)).mkString("\n")) .toString - case (label, SchemaAst.Sum(_, cases, optional)) => + case (label, SchemaAst.Sum(_, _, cases, optional)) => pad(buffer, indent) buffer.append(s"$label: enum") if (optional) buffer.append("?") diff --git a/zio-schema/shared/src/test/scala/zio/schema/SchemaAssertions.scala b/zio-schema/shared/src/test/scala/zio/schema/SchemaAssertions.scala index 9ab6b0b38..d4b5c3082 100644 --- a/zio-schema/shared/src/test/scala/zio/schema/SchemaAssertions.scala +++ b/zio-schema/shared/src/test/scala/zio/schema/SchemaAssertions.scala @@ -63,7 +63,7 @@ object SchemaAssertions { case (Schema.Optional(expected, _), Schema.Optional(actual, _)) => equalsAst(expected, actual, depth) case (Schema.Tuple(expectedLeft, expectedRight, _), Schema.Tuple(actualLeft, actualRight, _)) => equalsAst(expectedLeft, actualLeft, depth) && equalsAst(expectedRight, actualRight, depth) - case (Schema.Tuple(expectedLeft, expectedRight, _), Schema.GenericRecord(structure, _)) => + case (Schema.Tuple(expectedLeft, expectedRight, _), Schema.GenericRecord(_, structure, _)) => structure.toChunk.size == 2 && structure.toChunk.find(_.label == "left").exists(f => equalsAst(expectedLeft, f.schema, depth)) && structure.toChunk.find(_.label == "right").exists(f => equalsAst(expectedRight, f.schema, depth))