├── .github ├── actions │ └── gradle-cache │ │ └── action.yml ├── dependabot.yml └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── CODE-OF-CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── benchmarks ├── benchmarks-util │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── benchmarks │ │ └── BenchmarkUtils.kt ├── build.gradle.kts ├── protobuf-java-benchmarks │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── benchmarks │ │ └── ProtobufBenchmarks.kt ├── protokt-benchmarks │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── benchmarks │ │ ├── FixtureGenerator.kt │ │ └── ProtoktBenchmarks.kt ├── schema │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── resources │ │ └── schema │ │ ├── benchmarks.proto │ │ └── generic_message.proto └── wire-benchmarks │ ├── build.gradle.kts │ └── src │ └── main │ └── kotlin │ └── protokt │ └── v1 │ └── benchmarks │ └── WireBenchmarks.kt ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts ├── semantic-build-versioning.gradle ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ ├── AndroidCompatibility.kt │ ├── DependencyUtils.kt │ ├── JavaBasedProjectConventions.kt │ ├── KotlinApiCompatibility.kt │ ├── KotlinConfiguration.kt │ ├── LocalProtoktBuild.kt │ ├── RemotePublishing.kt │ ├── protokt.android-conventions.gradle.kts │ ├── protokt.benchmarks-conventions.gradle.kts │ ├── protokt.common-conventions.gradle.kts │ ├── protokt.grpc-examples-conventions.gradle.kts │ ├── protokt.jvm-conventions.gradle.kts │ ├── protokt.multiplatform-conventions.gradle.kts │ ├── protokt.multiplatform-published-conventions.gradle.kts │ ├── protokt.spotless-conventions.gradle.kts │ └── protokt.third-party-conventions.gradle.kts ├── examples ├── README.md ├── grpc-java-lite │ └── build.gradle.kts ├── grpc-java │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ ├── animals │ │ ├── AnimalsClient.kt │ │ └── AnimalsServer.kt │ │ ├── helloworld │ │ ├── HelloWorldClient.kt │ │ └── HelloWorldServer.kt │ │ └── io │ │ └── grpc │ │ └── examples │ │ └── routeguide │ │ ├── RouteGuideClient.kt │ │ └── RouteGuideServer.kt ├── grpc-kotlin-lite │ └── build.gradle.kts ├── grpc-kotlin │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── protokt │ │ │ └── v1 │ │ │ ├── animals │ │ │ ├── AnimalsClient.kt │ │ │ └── AnimalsServer.kt │ │ │ ├── helloworld │ │ │ ├── HelloWorldClient.kt │ │ │ └── HelloWorldServer.kt │ │ │ └── io │ │ │ └── grpc │ │ │ └── examples │ │ │ └── routeguide │ │ │ ├── RouteGuideClient.kt │ │ │ └── RouteGuideServer.kt │ │ └── test │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ ├── animals │ │ └── AnimalsServerTest.kt │ │ ├── helloworld │ │ └── HelloWorldServerTest.kt │ │ └── io │ │ └── grpc │ │ └── examples │ │ └── routeguide │ │ └── RouteGuideServerTest.kt ├── grpc-node │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── kotlin │ │ │ ├── App.kt │ │ │ └── protokt │ │ │ └── v1 │ │ │ ├── animals │ │ │ ├── AnimalsClient.kt │ │ │ └── AnimalsServer.kt │ │ │ ├── helloworld │ │ │ ├── HelloWorldClient.kt │ │ │ └── HelloWorldServer.kt │ │ │ └── io │ │ │ └── grpc │ │ │ └── examples │ │ │ └── routeguide │ │ │ ├── RouteGuideClient.kt │ │ │ └── RouteGuideServer.kt │ │ └── test │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ ├── animals │ │ └── AnimalsServerTest.kt │ │ ├── helloworld │ │ └── HelloWorldServerTest.kt │ │ └── io │ │ └── grpc │ │ └── examples │ │ └── routeguide │ │ └── RouteGuideServerTest.kt └── protos │ ├── build.gradle.kts │ └── src │ ├── commonMain │ ├── kotlin │ │ └── protokt │ │ │ └── v1 │ │ │ └── io │ │ │ └── grpc │ │ │ └── examples │ │ │ └── routeguide │ │ │ ├── Database.kt │ │ │ ├── Durations.kt │ │ │ └── Points.kt │ └── resources │ │ └── protokt │ │ └── v1 │ │ └── io │ │ └── grpc │ │ └── examples │ │ └── routeguide │ │ └── route_guide_db.json │ ├── jsMain │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── io │ │ └── grpc │ │ └── examples │ │ └── routeguide │ │ └── Database.kt │ ├── jvmMain │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── io │ │ └── grpc │ │ └── examples │ │ └── routeguide │ │ └── Database.kt │ └── main │ └── proto │ ├── animals │ ├── dog.proto │ ├── pig.proto │ └── sheep.proto │ ├── helloworld │ └── hello_world.proto │ └── io │ └── grpc │ └── examples │ └── route_guide.proto ├── expediter └── expediter.json ├── extensions ├── build.gradle.kts ├── protokt-extensions-api │ ├── api │ │ └── protokt-extensions-api.api │ ├── build.gradle.kts │ └── src │ │ ├── commonMain │ │ └── kotlin │ │ │ └── protokt │ │ │ └── v1 │ │ │ ├── Converter.kt │ │ │ └── OptimizedSizeOfConverter.kt │ │ └── jvmMain │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── AbstractConverter.kt ├── protokt-extensions-lite │ ├── api │ │ └── protokt-extensions-lite.api │ ├── build.gradle.kts │ └── src │ │ ├── extensions-proto │ │ └── protokt │ │ │ └── v1 │ │ │ └── protokt.proto │ │ ├── jvmMain │ │ ├── kotlin │ │ │ └── protokt │ │ │ │ └── v1 │ │ │ │ ├── DurationConverter.kt │ │ │ │ ├── InetAddressBytesConverter.kt │ │ │ │ ├── InetAddressBytesValueConverter.kt │ │ │ │ ├── InetSocketAddressConverter.kt │ │ │ │ ├── InstantConverter.kt │ │ │ │ ├── LocalDateStringConverter.kt │ │ │ │ ├── LocalDateStringValueConverter.kt │ │ │ │ ├── UuidBytesConverter.kt │ │ │ │ └── UuidBytesValueConverter.kt │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ └── protokt.v1.Converter │ │ ├── jvmTest │ │ └── kotlin │ │ │ └── protokt │ │ │ └── v1 │ │ │ ├── InetAddressBytesConverterTest.kt │ │ │ ├── InetSocketAddressConverterTest.kt │ │ │ ├── InstantConverterTest.kt │ │ │ └── UuidBytesConverterTest.kt │ │ └── main │ │ └── proto │ │ └── protokt │ │ └── v1 │ │ └── inet_socket_address.proto └── protokt-extensions │ ├── api │ └── protokt-extensions.api │ └── build.gradle.kts ├── gradle-plugin-integration-test ├── README.md ├── build.gradle.kts ├── gradle ├── gradle.properties ├── gradlew ├── gradlew.bat ├── jvm-lite │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── proto │ │ └── testing │ │ └── wrapper_test.proto ├── jvm-regular │ └── build.gradle.kts ├── kotlin-js-store │ └── yarn.lock ├── multiplatform │ ├── build.gradle.kts │ └── src │ │ ├── commonTest │ │ └── kotlin │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ └── TestMessageTest.kt │ │ ├── jsTest │ │ └── kotlin │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ └── BasicSerializationTest.kt │ │ ├── jvmTest │ │ └── kotlin │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ └── VersionTest.kt │ │ └── main │ │ └── proto │ │ └── testing │ │ └── test.proto ├── semantic-build-versioning.gradle ├── settings.gradle.kts └── wrapper-types │ ├── build.gradle.kts │ └── src │ └── main │ └── kotlin │ └── protokt │ └── v1 │ └── testing │ └── Id.kt ├── gradle.properties ├── gradle ├── libs.versions.toml ├── license-header-c-style └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── grpc-kotlin-shim └── build.gradle.kts ├── kotlin-js-store └── yarn.lock ├── protokt-codegen ├── build.gradle.kts └── src │ ├── main │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── codegen │ │ ├── Main.kt │ │ ├── generate │ │ ├── BuilderGenerator.kt │ │ ├── CodeGenerator.kt │ │ ├── Deprecation.kt │ │ ├── DeserializerGenerator.kt │ │ ├── DeserializerSupport.kt │ │ ├── EnumGenerator.kt │ │ ├── FileDescriptorEncoding.kt │ │ ├── FileDescriptorResolver.kt │ │ ├── FileGenerator.kt │ │ ├── Implements.kt │ │ ├── KotlinPoetUtil.kt │ │ ├── MapEntryGenerator.kt │ │ ├── MessageDocumentationAnnotator.kt │ │ ├── MessageGenerator.kt │ │ ├── MessageSizeGenerator.kt │ │ ├── Nullability.kt │ │ ├── OneofGenerator.kt │ │ ├── PropertyAnnotator.kt │ │ ├── PropertyDocumentationAnnotator.kt │ │ ├── SerializeAndSizeSupport.kt │ │ ├── SerializerGenerator.kt │ │ ├── ServiceGenerator.kt │ │ └── Wrapper.kt │ │ └── util │ │ ├── ClassNames.kt │ │ ├── EnumParser.kt │ │ ├── ErrorContext.kt │ │ ├── FieldParser.kt │ │ ├── FieldTypeExt.kt │ │ ├── FileContentParser.kt │ │ ├── GeneratedCodeCleanup.kt │ │ ├── GeneratorContext.kt │ │ ├── GrpcKotlinGeneratorSupport.kt │ │ ├── MessageParser.kt │ │ ├── PackageResolution.kt │ │ ├── PluginParams.kt │ │ ├── ServiceParser.kt │ │ └── Types.kt │ └── test │ ├── kotlin │ └── protokt │ │ └── v1 │ │ └── codegen │ │ ├── AbstractProtoktCodegenTest.kt │ │ ├── ImplementDelegationTest.kt │ │ ├── NonNullValidationTest.kt │ │ ├── ProtoktCodegenTest.kt │ │ └── generate │ │ ├── DeserializerGeneratorTest.kt │ │ └── SerializerGeneratorTest.kt │ └── resources │ ├── META-INF │ └── services │ │ └── protokt.v1.Converter │ ├── implement_by_delegate_with_non_null_property.proto │ ├── non_null.proto │ ├── non_null_nested.proto │ ├── non_null_oneof.proto │ ├── non_null_optional.proto │ ├── protokt │ └── v1 │ │ └── codegen │ │ └── bin-generator │ └── test.proto ├── protokt-core-lite ├── api │ └── protokt-core-lite.api ├── build.gradle.kts └── src │ ├── commonMain │ ├── kotlin │ │ └── protokt │ │ │ └── v1 │ │ │ └── google │ │ │ └── protobuf │ │ │ ├── BoolValueConverter.kt │ │ │ ├── BytesValueConverter.kt │ │ │ ├── DoubleValueConverter.kt │ │ │ ├── FloatValueConverter.kt │ │ │ ├── Int32ValueConverter.kt │ │ │ ├── Int64ValueConverter.kt │ │ │ ├── StringValueConverter.kt │ │ │ ├── UInt32ValueConverter.kt │ │ │ └── UInt64ValueConverter.kt │ └── resources │ │ └── META-INF │ │ └── services │ │ └── protokt.v1.Converter │ └── jvmTest │ └── kotlin │ └── protokt │ └── v1 │ └── SerializationTest.kt ├── protokt-core ├── api │ └── protokt-core.api ├── build.gradle.kts └── src │ ├── commonMain │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── google │ │ └── protobuf │ │ └── Descriptors.kt │ └── jvmMain │ └── kotlin │ └── protokt │ └── v1 │ └── google │ └── protobuf │ └── Anies.kt ├── protokt-gradle-plugin ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── protokt │ └── v1 │ └── gradle │ ├── BinaryInstaller.kt │ └── ProtoktPlugin.kt ├── protokt-protovalidate ├── api │ └── protokt-protovalidate.api ├── build.gradle.kts └── src │ └── main │ └── kotlin │ ├── build │ └── buf │ │ └── protovalidate │ │ └── PackageHacks.kt │ └── protokt │ └── v1 │ └── buf │ └── validate │ └── Validator.kt ├── protokt-reflect ├── api │ └── protokt-reflect.api ├── build.gradle.kts └── src │ └── jvmMain │ └── kotlin │ └── protokt │ └── v1 │ └── google │ └── protobuf │ ├── Messages.kt │ ├── ProtoktReflect.kt │ └── RuntimeContext.kt ├── protokt-runtime-grpc-lite ├── api │ └── protokt-runtime-grpc-lite.api ├── build.gradle.kts └── src │ ├── jsMain │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── grpc │ │ ├── AbstractCoroutineServerImpl.kt │ │ ├── AbstractCoroutineStub.kt │ │ ├── BindableService.kt │ │ ├── ClientCalls.kt │ │ ├── GrpcJs.kt │ │ ├── GrpcJsAdapters.kt │ │ ├── Marshaller.kt │ │ ├── MethodDescriptor.kt │ │ ├── NodeRuntime.kt │ │ ├── ServerCalls.kt │ │ ├── ServerMethodDefinition.kt │ │ ├── ServerServiceDefinition.kt │ │ ├── Servers.kt │ │ ├── ServiceDescriptor.kt │ │ ├── Status.kt │ │ ├── StatusException.kt │ │ └── Stream.kt │ └── jvmMain │ └── kotlin │ └── protokt │ └── v1 │ └── grpc │ ├── Marshaller.kt │ └── SchemaDescriptor.kt ├── protokt-runtime-grpc ├── api │ └── protokt-runtime-grpc.api ├── build.gradle.kts └── src │ └── jvmMain │ └── kotlin │ └── protokt │ └── v1 │ └── grpc │ └── SchemaDescriptors.kt ├── protokt-runtime ├── api │ └── protokt-runtime.api ├── build.gradle.kts └── src │ ├── commonMain │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ ├── AbstractBytes.kt │ │ ├── AbstractDeserializer.kt │ │ ├── AbstractMessage.kt │ │ ├── Beta.kt │ │ ├── BuilderDsl.kt │ │ ├── Bytes.kt │ │ ├── BytesSlice.kt │ │ ├── Collections.kt │ │ ├── Deserializer.kt │ │ ├── Enum.kt │ │ ├── EnumReader.kt │ │ ├── GeneratedFileDescriptor.kt │ │ ├── GeneratedMessage.kt │ │ ├── GeneratedProperty.kt │ │ ├── Message.kt │ │ ├── Reader.kt │ │ ├── SizeCodecs.kt │ │ ├── UnknownField.kt │ │ ├── UnknownFieldSet.kt │ │ └── Writer.kt │ ├── commonTest │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── BytesSliceTest.kt │ ├── jsMain │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ ├── AbstractDeserializer.kt │ │ ├── AbstractMessage.kt │ │ ├── Bytes.kt │ │ ├── Collections.kt │ │ ├── Deserializer.kt │ │ ├── JsReader.kt │ │ ├── JsUtil.kt │ │ ├── JsWriter.kt │ │ ├── Message.kt │ │ └── ProtobufJs.kt │ ├── jvmMain │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ ├── AbstractDeserializer.kt │ │ ├── AbstractMessage.kt │ │ ├── Bytes.kt │ │ ├── Collections.kt │ │ ├── Deserializer.kt │ │ ├── JvmReader.kt │ │ ├── JvmWriter.kt │ │ └── Message.kt │ └── jvmTest │ └── kotlin │ └── protokt │ └── v1 │ └── BytesTest.kt ├── semantic-build-versioning.gradle ├── settings.gradle.kts ├── shared-src ├── codegen │ └── protokt │ │ └── v1 │ │ └── gradle │ │ ├── PluginConfig.kt │ │ └── ProtoktExtension.kt ├── gradle-plugin │ ├── com │ │ └── google │ │ │ └── protobuf │ │ │ └── gradle │ │ │ └── GenerateProtoTaskExt.kt │ └── protokt │ │ └── v1 │ │ └── gradle │ │ ├── DslExtensions.kt │ │ ├── KotlinPlugins.kt │ │ ├── Os.kt │ │ ├── ProtobufBuild.kt │ │ └── ProtoktBuild.kt ├── lite-util │ └── protokt │ │ └── v1 │ │ └── util │ │ └── ProtoktExtentions.kt └── reflect │ └── protokt │ └── v1 │ └── reflect │ ├── ClassLookup.kt │ ├── ClassNames.kt │ ├── FieldType.kt │ ├── PackageNames.kt │ └── WellKnownTypes.kt ├── testing ├── android-test-configurations │ ├── build.gradle.kts │ └── src │ │ └── test │ │ └── proto │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ └── android │ │ └── test.proto ├── android │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── proto │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ └── android │ │ │ └── test.proto │ │ └── test │ │ └── java │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ └── android │ │ └── AndroidProtobufTest.kt ├── conformance │ ├── driver │ │ ├── build.gradle.kts │ │ └── src │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── protokt │ │ │ │ └── v1 │ │ │ │ └── conformance │ │ │ │ ├── Main.kt │ │ │ │ └── Platform.kt │ │ │ ├── jsMain │ │ │ └── kotlin │ │ │ │ └── protokt │ │ │ │ └── v1 │ │ │ │ └── conformance │ │ │ │ └── Platform.kt │ │ │ ├── jvmMain │ │ │ └── kotlin │ │ │ │ └── protokt │ │ │ │ └── v1 │ │ │ │ └── conformance │ │ │ │ └── Platform.kt │ │ │ └── main │ │ │ └── proto │ │ │ ├── conformance │ │ │ └── conformance.proto │ │ │ └── protobuf_test_messages │ │ │ ├── editions │ │ │ ├── proto3 │ │ │ │ └── test_messages_proto3_editions.proto │ │ │ └── test_messages_edition2023.proto │ │ │ └── proto3 │ │ │ └── test_messages_proto3.proto │ ├── js-ir │ │ ├── build.gradle.kts │ │ ├── failure_list_kt.txt │ │ ├── run.sh │ │ └── src │ │ │ └── jsMain │ │ │ └── kotlin │ │ │ └── App.kt │ ├── jvm │ │ ├── build.gradle.kts │ │ ├── failure_list_kt.txt │ │ └── src │ │ │ └── test │ │ │ └── java │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── conformance │ │ │ └── ParseConformanceOctal.kt │ └── runner │ │ ├── README.md │ │ ├── build.gradle.kts │ │ └── src │ │ └── test │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── conformance │ │ └── ConformanceTest.kt ├── interop │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── proto │ │ │ ├── google │ │ │ └── protobuf │ │ │ │ ├── unittest_import.proto │ │ │ │ ├── unittest_import_public.proto │ │ │ │ └── unittest_proto3.proto │ │ │ ├── protokt │ │ │ └── v1 │ │ │ │ └── testing │ │ │ │ ├── deeply_nested.proto │ │ │ │ ├── has_a_service.proto │ │ │ │ ├── test.proto │ │ │ │ └── wrappers_dynamic.proto │ │ │ └── tutorial │ │ │ └── addressbook.proto │ │ └── test │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ ├── CollectionsJavaInteropTest.kt │ │ ├── CopyTest.kt │ │ ├── DynamicMessageTest.kt │ │ ├── FileDescriptorEncodingTest.kt │ │ ├── MessageJavaInteropTest.kt │ │ ├── ProtoktReflectTest.kt │ │ ├── RuntimeContextUtil.kt │ │ ├── TestUtil.kt │ │ └── UnknownFieldsInteropTest.kt ├── multiplatform-testing │ ├── build.gradle.kts │ └── src │ │ ├── jsTest │ │ └── kotlin │ │ │ └── protokt.v1.testing │ │ │ └── MultiplatformGenerationTest.kt │ │ ├── jvmTest │ │ └── kotlin │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ └── MultiplatformGenerationTest.kt │ │ └── main │ │ └── proto │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ └── mp_test.proto ├── options-api │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ ├── CachingId.kt │ │ ├── Duration.kt │ │ ├── IModel.kt │ │ ├── IModel2.kt │ │ ├── IModel3.kt │ │ ├── IModel4.kt │ │ ├── Id.kt │ │ ├── ModelWithString.kt │ │ ├── OneofModel.kt │ │ └── PrimitiveConverters.kt ├── options-test-configurations │ └── build.gradle.kts ├── options │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ ├── kotlin │ │ │ └── protokt │ │ │ │ └── v1 │ │ │ │ └── testing │ │ │ │ └── Marshallers.kt │ │ └── proto │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ ├── custom_file_descriptor_object_name.proto │ │ │ ├── custom_marshallers.proto │ │ │ ├── message_implements.proto │ │ │ ├── non_null_property_and_oneof.proto │ │ │ ├── nullable_wrappers_example.proto │ │ │ ├── oneof_exercises.proto │ │ │ ├── oneof_implements.proto │ │ │ ├── pkg │ │ │ └── shared_simple_names_alternate_package.proto │ │ │ ├── primitive_wrapped_types.proto │ │ │ ├── proto_deprecation.proto │ │ │ ├── shared_simple_names.proto │ │ │ ├── test_proto3_optional.proto │ │ │ ├── uses_bytes_slice.proto │ │ │ └── wrapper_types.proto │ │ └── test │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ ├── BytesSliceTest.kt │ │ ├── CustomFileDescriptorObjectNameTest.kt │ │ ├── CustomMarshallersTest.kt │ │ ├── DeprecatedTest.kt │ │ ├── MessageImplementsTest.kt │ │ ├── NonNullableTest.kt │ │ ├── NullableWrappersExampleTest.kt │ │ ├── OneofImplementsTest.kt │ │ ├── Proto3OptionalWrapperTypeTest.kt │ │ ├── ProtoktExtensionsTest.kt │ │ ├── SharedSimpleNamesTest.kt │ │ ├── WrapperTypesTest.kt │ │ └── pkg │ │ └── SharedSimpleNamesAlternativePackageTest.kt ├── plugin-options │ └── lite │ │ ├── build.gradle.kts │ │ └── src │ │ └── test │ │ ├── kotlin │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ ├── lite │ │ │ └── LiteOptionTest.kt │ │ │ └── pluginoptions │ │ │ └── LiteOptionTest.kt │ │ └── proto │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ └── lite_test.proto ├── protobuf-java │ └── build.gradle.kts ├── protobufjs │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── proto │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ └── js_test.proto │ │ └── test │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ ├── BasicSerializationTest.kt │ │ └── JavaScriptGenerationTest.kt ├── protokt-generation-2 │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── proto │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ └── file_descriptor_name_collision.proto │ │ └── test │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ └── FileDescriptorNameCollisionTest.kt ├── protokt-generation │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ ├── kotlin │ │ │ └── protokt │ │ │ │ └── v1 │ │ │ │ └── testing │ │ │ │ └── PropertyUtils.kt │ │ └── proto │ │ │ ├── no_package.proto │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── testing │ │ │ ├── basic_enums.proto │ │ │ ├── data │ │ │ ├── evil_names.proto │ │ │ └── import_evil_names.proto │ │ │ ├── defines_nested_enum.proto │ │ │ ├── documentation_test.proto │ │ │ ├── edition_2023_presence_default.proto │ │ │ ├── edition_2023_presence_file_explicit.proto │ │ │ ├── edition_2023_presence_file_implicit.proto │ │ │ ├── edition_2023_presence_file_legacy_required.proto │ │ │ ├── enum_names_with_shared_prefix.proto │ │ │ ├── enum_oneof_name_conflict.proto │ │ │ ├── enumconflicts │ │ │ └── enum_conflicts.proto │ │ │ ├── enums_across_packages.proto │ │ │ ├── file_descriptor_name_collision1.proto │ │ │ ├── import_nested_enums.proto │ │ │ ├── json_serialization.proto │ │ │ ├── messageconflicts │ │ │ └── message_conflicts.proto │ │ │ ├── name_conflicts.proto │ │ │ ├── nested_message_used_as_field.proto │ │ │ ├── oneof │ │ │ ├── child │ │ │ │ └── child_package.proto │ │ │ ├── oneof_exercises.proto │ │ │ ├── oneof_packages.proto │ │ │ └── shared_name.proto │ │ │ ├── other │ │ │ ├── file_descriptor_name_collision1.proto │ │ │ ├── model.proto │ │ │ └── other_package.proto │ │ │ ├── poor_naming_conventions.proto │ │ │ ├── proto2_maps.proto │ │ │ ├── proto3_optional.proto │ │ │ ├── service_package.proto │ │ │ ├── service_with_java_multiple_files_false.proto │ │ │ ├── service_with_java_multiple_files_true.proto │ │ │ ├── to_string_test.proto │ │ │ ├── uses_null.proto │ │ │ └── wkt_test.proto │ │ └── test │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── testing │ │ ├── AnyTest.kt │ │ ├── Edition2023PresenceTest.kt │ │ ├── EnumTest.kt │ │ ├── EnumsWithSharedPrefixTest.kt │ │ ├── EvilNamesTest.kt │ │ ├── JsonDeserializationTest.kt │ │ ├── PoorNamingConventionsTest.kt │ │ ├── Proto3OptionalTest.kt │ │ ├── SchemaDescriptorTest.kt │ │ ├── ServicePackageTest.kt │ │ ├── ToStringTest.kt │ │ ├── WellKnownTypesTest.kt │ │ ├── enumconflicts │ │ └── EnumConflictsTest.kt │ │ └── messageconflicts │ │ └── MessageConflictsTest.kt ├── protovalidate-conformance │ ├── build.gradle.kts │ ├── expected_failures.yaml │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── protokt │ │ │ └── v1 │ │ │ └── buf │ │ │ └── validate │ │ │ └── conformance │ │ │ ├── DynamicConcreteMessageDeserializer.kt │ │ │ ├── FileDescriptorUtil.kt │ │ │ └── Main.kt │ │ └── test │ │ └── kotlin │ │ └── protokt │ │ └── v1 │ │ └── buf │ │ └── validate │ │ └── ValidatorTest.kt └── testing-util │ ├── build.gradle.kts │ └── src │ └── main │ └── kotlin │ └── protokt │ └── v1 │ └── testing │ └── ProcessUtils.kt └── third-party ├── proto-google-common-protos-extensions-lite ├── api │ └── proto-google-common-protos-extensions-lite.api ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── protokt │ └── v1 │ └── google │ └── type │ └── LocalDateConverter.kt ├── proto-google-common-protos-extensions ├── api │ └── proto-google-common-protos-extensions.api └── build.gradle.kts ├── proto-google-common-protos-grpc-kotlin ├── api │ └── proto-google-common-protos-grpc-kotlin.api ├── build.gradle.kts └── src │ └── test │ └── kotlin │ └── protokt │ └── v1 │ └── google │ └── longrunning │ └── ExistenceTest.kt ├── proto-google-common-protos-grpc ├── api │ └── proto-google-common-protos-grpc.api ├── build.gradle.kts └── src │ └── test │ └── kotlin │ └── protokt │ └── v1 │ └── google │ └── longrunning │ └── ExistenceTest.kt ├── proto-google-common-protos-lite ├── api │ └── proto-google-common-protos-lite.api ├── build.gradle.kts └── src │ └── commonTest │ └── kotlin │ └── protokt │ └── v1 │ └── google │ └── api │ └── ExistenceTest.kt └── proto-google-common-protos ├── api └── proto-google-common-protos.api ├── build.gradle.kts └── src └── commonTest └── kotlin └── protokt └── v1 └── google └── api └── ExistenceTest.kt /.github/actions/gradle-cache/action.yml: -------------------------------------------------------------------------------- 1 | name: Gradle cache 2 | description: Gradle caching logic shared across builds 3 | runs: 4 | using: composite 5 | steps: 6 | - uses: actions/cache@v4 7 | with: 8 | path: | 9 | ~/.gradle/caches 10 | ~/.gradle/wrapper 11 | key: gradle-${{ hashFiles('gradle/libs.versions.toml', 'gradle/wrapper/gradle-wrapper.properties') }} 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "gradle" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "weekly" 11 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '[0-9]+.[0-9]+.*' 7 | 8 | jobs: 9 | release: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | with: 14 | fetch-depth: 0 15 | - uses: ./.github/actions/gradle-cache 16 | - name: Set up java 17 | uses: actions/setup-java@v4 18 | with: 19 | distribution: corretto 20 | java-version: 17 21 | - name: Publish 22 | run: ./gradlew publishAllPublicationsToMavenCentral publishPlugins --no-configuration-cache --stacktrace --no-daemon 23 | env: 24 | PGP_KEY: ${{ secrets.PGP_KEY }} 25 | PGP_PASSWORD: ${{ secrets.PGP_PASSWORD }} 26 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} 27 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} 28 | GRADLE_PORTAL_PUBLISH_KEY: ${{ secrets.GRADLE_PORTAL_PUBLISH_KEY }} 29 | GRADLE_PORTAL_PUBLISH_SECRET: ${{ secrets.GRADLE_PORTAL_PUBLISH_SECRET }} 30 | GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.internal.http.socketTimeout=120000 -Dorg.gradle.internal.network.retry.max.attempts=1 -Dorg.gradle.internal.publish.checksums.insecure=true" 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | 3 | .kotlin 4 | .gradle 5 | /**/build/* 6 | !/**/src/**/build/* 7 | out 8 | .DS_Store 9 | 10 | .idea 11 | *.iml 12 | 13 | testing/conformance/runner/failing_tests.txt 14 | protokt-codegen/src/test/resources/protokt/v1/codegen/test-proto-bin-request.bin 15 | node_modules/ 16 | package-lock.json 17 | package.json 18 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Before contributing to this repository please first discuss the change you wish 4 | to make via issue or any other method with the owners of this repository. 5 | 6 | Please note that we have a [code of conduct](CODE-OF-CONDUCT.md). Please follow 7 | it in all your interactions with the project. 8 | 9 | ## Pull Request Process 10 | 11 | https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork 12 | -------------------------------------------------------------------------------- /benchmarks/benchmarks-util/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.benchmarks-conventions") 18 | } 19 | -------------------------------------------------------------------------------- /benchmarks/protobuf-java-benchmarks/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.benchmarks-conventions") 18 | id("com.google.protobuf") 19 | application 20 | } 21 | 22 | defaultProtoc() 23 | 24 | configure { 25 | mainClass.set("com.toasttab.protokt.benchmarks.ProtobufBenchmarksKt") 26 | executableDir = ".." 27 | } 28 | 29 | dependencies { 30 | implementation(project(":benchmarks:benchmarks-util")) 31 | implementation(libs.protobuf.java) 32 | 33 | protobuf(project(":benchmarks:schema")) 34 | } 35 | 36 | tasks.named("run") { 37 | dependsOn(":benchmarks:datasets") 38 | } 39 | -------------------------------------------------------------------------------- /benchmarks/protokt-benchmarks/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import com.google.protobuf.gradle.protobuf 17 | 18 | plugins { 19 | id("protokt.benchmarks-conventions") 20 | application 21 | } 22 | 23 | localProtokt() 24 | 25 | configure { 26 | mainClass.set("protokt.v1.benchmarks.ProtoktBenchmarksKt") 27 | executableDir = ".." 28 | } 29 | 30 | dependencies { 31 | protobuf(project(":benchmarks:schema")) 32 | 33 | implementation(kotlin("reflect")) 34 | implementation(project(":benchmarks:benchmarks-util")) 35 | 36 | runtimeOnly(libs.protobuf.java) 37 | } 38 | 39 | tasks.named("run") { 40 | dependsOn(":benchmarks:datasets") 41 | } 42 | -------------------------------------------------------------------------------- /benchmarks/schema/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.benchmarks-conventions") 18 | } 19 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.common-conventions") 18 | id("protokt.spotless-conventions") 19 | } 20 | -------------------------------------------------------------------------------- /buildSrc/semantic-build-versioning.gradle: -------------------------------------------------------------------------------- 1 | ../semantic-build-versioning.gradle -------------------------------------------------------------------------------- /buildSrc/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | buildscript { 17 | repositories { 18 | maven(url = "https://repo1.maven.org/maven2") 19 | gradlePluginPortal() 20 | } 21 | dependencies { 22 | classpath("gradle.plugin.net.vivin:gradle-semantic-build-versioning:4.0.0") 23 | } 24 | } 25 | 26 | apply(plugin = "net.vivin.gradle-semantic-build-versioning") 27 | 28 | dependencyResolutionManagement { 29 | versionCatalogs { 30 | create("libs") { 31 | from(files("../gradle/libs.versions.toml")) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/KotlinApiCompatibility.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import kotlinx.validation.ApiValidationExtension 17 | import org.gradle.api.Project 18 | import org.gradle.kotlin.dsl.apply 19 | import org.gradle.kotlin.dsl.configure 20 | 21 | fun Project.trackKotlinApiCompatibility(validate: Boolean = true) { 22 | apply(plugin = "binary-compatibility-validator") 23 | 24 | configure { 25 | validationDisabled = !validate 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/protokt.android-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.common-conventions") 18 | id("com.android.library") 19 | `kotlin-android` 20 | } 21 | 22 | javaBasedProjectConventions() 23 | 24 | repositories { 25 | google() 26 | } 27 | 28 | kotlin { 29 | jvmToolchain(libs.versions.java.get().toInt()) 30 | } 31 | 32 | // remove after AGP 8.1.0 33 | // https://issuetracker.google.com/issues/260059413 34 | android { 35 | compileOptions { 36 | sourceCompatibility = JavaVersion.valueOf("VERSION_${libs.versions.java.get().toInt()}") 37 | targetCompatibility = JavaVersion.valueOf("VERSION_${libs.versions.java.get().toInt()}") 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/protokt.benchmarks-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.jvm-conventions") 18 | `kotlin-kapt` 19 | } 20 | 21 | dependencies { 22 | implementation(libs.jmh.core) 23 | kapt(libs.jmh.generator) 24 | } 25 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/protokt.common-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import protokt.v1.gradle.BASE_GROUP_NAME 17 | 18 | plugins { idea } 19 | 20 | version = rootProject.version 21 | group = BASE_GROUP_NAME 22 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/protokt.jvm-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import org.jetbrains.kotlin.gradle.dsl.KotlinVersion 17 | 18 | plugins { 19 | id("protokt.common-conventions") 20 | kotlin 21 | } 22 | 23 | javaBasedProjectConventions() 24 | 25 | kotlin { 26 | jvmToolchain(libs.versions.java.get().toInt()) 27 | compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_8 28 | compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_8 29 | } 30 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/protokt.multiplatform-published-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.multiplatform-conventions") 18 | } 19 | 20 | enablePublishing() 21 | trackKotlinApiCompatibility() 22 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/protokt.third-party-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import protokt.v1.gradle.BASE_GROUP_NAME 17 | 18 | group = "$BASE_GROUP_NAME.thirdparty" 19 | -------------------------------------------------------------------------------- /examples/grpc-java/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import com.google.protobuf.gradle.protobuf 17 | import protokt.v1.gradle.protokt 18 | 19 | plugins { 20 | id("protokt.grpc-examples-conventions") 21 | } 22 | 23 | localProtokt() 24 | pureKotlin() 25 | 26 | protokt { 27 | generate { 28 | grpcDescriptors = true 29 | } 30 | } 31 | 32 | dependencies { 33 | protobuf(project(":examples:protos")) 34 | 35 | implementation(project(":examples:protos")) 36 | 37 | runtimeOnly(libs.protobuf.java) 38 | } 39 | -------------------------------------------------------------------------------- /examples/grpc-node/src/main/kotlin/protokt/v1/helloworld/HelloWorldClient.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.helloworld 17 | 18 | import protokt.v1.grpc.ChannelCredentials 19 | import protokt.v1.helloworld.GreeterGrpcKt.GreeterCoroutineStub 20 | 21 | class HelloWorldClient { 22 | private val stub = GreeterCoroutineStub("localhost:50051", ChannelCredentials.createInsecure()) 23 | 24 | suspend fun greet(name: String = "world"): HelloReply { 25 | val reply = stub.sayHello(HelloRequest { this.name = name }) 26 | println("Greeting: ${reply.message}") 27 | return reply 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/protos/src/commonMain/kotlin/protokt/v1/io/grpc/examples/routeguide/Database.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.io.grpc.examples.routeguide 17 | 18 | expect object Database { 19 | fun features(): List 20 | } 21 | -------------------------------------------------------------------------------- /examples/protos/src/commonMain/kotlin/protokt/v1/io/grpc/examples/routeguide/Durations.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.io.grpc.examples.routeguide 17 | 18 | import protokt.v1.google.protobuf.Duration 19 | 20 | private const val MICROS_PER_SECOND = 1000000 21 | private const val NANOS_PER_MICROSECOND = 1000 22 | 23 | object Durations { 24 | fun fromMicros(microseconds: Long) = 25 | Duration { 26 | seconds = microseconds / MICROS_PER_SECOND 27 | nanos = (microseconds % MICROS_PER_SECOND * NANOS_PER_MICROSECOND).toInt() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/protos/src/main/proto/animals/dog.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The gRPC Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | syntax = "proto3"; 15 | 16 | option java_multiple_files = true; 17 | option java_package = "io.grpc.examples.animals"; 18 | option java_outer_classname = "DogProto"; 19 | 20 | package animals; 21 | 22 | service Dog { 23 | rpc Bark (BarkRequest) returns (BarkReply) {} 24 | } 25 | 26 | message BarkRequest { 27 | } 28 | 29 | message BarkReply { 30 | string message = 1; 31 | } 32 | -------------------------------------------------------------------------------- /examples/protos/src/main/proto/animals/pig.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The gRPC Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | syntax = "proto3"; 15 | 16 | option java_multiple_files = true; 17 | option java_package = "io.grpc.examples.animals"; 18 | option java_outer_classname = "PigProto"; 19 | 20 | package animals; 21 | 22 | service Pig { 23 | rpc Oink (OinkRequest) returns (OinkReply) {} 24 | } 25 | 26 | message OinkRequest { 27 | } 28 | 29 | message OinkReply { 30 | string message = 1; 31 | } 32 | -------------------------------------------------------------------------------- /examples/protos/src/main/proto/animals/sheep.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The gRPC Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | syntax = "proto3"; 15 | 16 | option java_multiple_files = true; 17 | option java_package = "io.grpc.examples.animals"; 18 | option java_outer_classname = "SheepProto"; 19 | 20 | package animals; 21 | 22 | service Sheep { 23 | rpc Baa (BaaRequest) returns (BaaReply) {} 24 | } 25 | 26 | message BaaRequest { 27 | } 28 | 29 | message BaaReply { 30 | string message = 1; 31 | } 32 | -------------------------------------------------------------------------------- /examples/protos/src/main/proto/helloworld/hello_world.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The gRPC Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | syntax = "proto3"; 15 | 16 | option java_multiple_files = true; 17 | option java_package = "io.grpc.examples.helloworld"; 18 | option java_outer_classname = "HelloWorldProto"; 19 | 20 | package helloworld; 21 | 22 | // The greeting service definition. 23 | service Greeter { 24 | // Sends a greeting 25 | rpc SayHello (HelloRequest) returns (HelloReply) {} 26 | } 27 | 28 | // The request message containing the user's name. 29 | message HelloRequest { 30 | string name = 1; 31 | } 32 | 33 | // The response message containing the greetings 34 | message HelloReply { 35 | string message = 1; 36 | } 37 | -------------------------------------------------------------------------------- /extensions/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | spotless { 17 | kotlin { 18 | targetExclude( 19 | "protokt-extensions/src/jvmMain/kotlin/com/toasttab/protokt/ext/inet_socket_address.kt", 20 | "protokt-extensions/src/jvmMain/kotlin/com/toasttab/protokt/ext/protokt.kt", 21 | "protokt-extensions-lite/src/jvmMain/kotlin/com/toasttab/protokt/ext/inet_socket_address.kt", 22 | "protokt-extensions-lite/src/jvmMain/kotlin/com/toasttab/protokt/ext/protokt.kt" 23 | ) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-api/api/protokt-extensions-api.api: -------------------------------------------------------------------------------- 1 | public abstract class protokt/v1/AbstractConverter : protokt/v1/Converter { 2 | public fun ()V 3 | public final fun getWrapped ()Lkotlin/reflect/KClass; 4 | public final fun getWrapper ()Lkotlin/reflect/KClass; 5 | } 6 | 7 | public abstract interface class protokt/v1/Converter { 8 | public fun getAcceptsDefaultValue ()Z 9 | public abstract fun getWrapped ()Lkotlin/reflect/KClass; 10 | public abstract fun getWrapper ()Lkotlin/reflect/KClass; 11 | public abstract fun unwrap (Ljava/lang/Object;)Ljava/lang/Object; 12 | public abstract fun wrap (Ljava/lang/Object;)Ljava/lang/Object; 13 | } 14 | 15 | public abstract interface class protokt/v1/OptimizedSizeOfConverter : protokt/v1/Converter { 16 | public abstract fun sizeOf (Ljava/lang/Object;)I 17 | } 18 | 19 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.multiplatform-published-conventions") 18 | } 19 | 20 | compatibleWithAndroid() 21 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-api/src/commonMain/kotlin/protokt/v1/Converter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import kotlin.reflect.KClass 19 | 20 | interface Converter { 21 | val wrapper: KClass 22 | 23 | val wrapped: KClass 24 | 25 | val acceptsDefaultValue 26 | get() = true 27 | 28 | fun wrap(unwrapped: ProtobufT): KotlinT 29 | 30 | fun unwrap(wrapped: KotlinT): ProtobufT 31 | } 32 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-api/src/commonMain/kotlin/protokt/v1/OptimizedSizeOfConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | interface OptimizedSizeOfConverter : Converter { 19 | fun sizeOf(wrapped: KotlinT): Int 20 | } 21 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmMain/kotlin/protokt/v1/DurationConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | object DurationConverter : AbstractConverter() { 19 | override fun wrap(unwrapped: protokt.v1.google.protobuf.Duration): java.time.Duration = 20 | java.time.Duration.ofSeconds(unwrapped.seconds, unwrapped.nanos.toLong()) 21 | 22 | override fun unwrap(wrapped: java.time.Duration) = 23 | protokt.v1.google.protobuf.Duration { 24 | seconds = wrapped.seconds 25 | nanos = wrapped.nano 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmMain/kotlin/protokt/v1/InetAddressBytesConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import java.net.InetAddress 19 | 20 | object InetAddressBytesConverter : AbstractConverter() { 21 | override val acceptsDefaultValue = false 22 | 23 | override fun wrap(unwrapped: Bytes): InetAddress { 24 | require(unwrapped.isNotEmpty()) { 25 | "cannot unwrap absent InetAddress" 26 | } 27 | return InetAddress.getByAddress(unwrapped.bytes) 28 | } 29 | 30 | override fun unwrap(wrapped: InetAddress): Bytes = 31 | Bytes.from(wrapped.address) 32 | } 33 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmMain/kotlin/protokt/v1/InetAddressBytesValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import protokt.v1.google.protobuf.BytesValue 19 | import java.net.InetAddress 20 | 21 | object InetAddressBytesValueConverter : AbstractConverter() { 22 | override fun wrap(unwrapped: BytesValue) = 23 | InetAddressBytesConverter.wrap(unwrapped.value) 24 | 25 | override fun unwrap(wrapped: InetAddress) = 26 | BytesValue { value = InetAddressBytesConverter.unwrap(wrapped) } 27 | } 28 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmMain/kotlin/protokt/v1/InetSocketAddressConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | object InetSocketAddressConverter : AbstractConverter() { 19 | override fun wrap(unwrapped: InetSocketAddress) = 20 | java.net.InetSocketAddress( 21 | InetAddressBytesConverter.wrap(unwrapped.address), 22 | unwrapped.port 23 | ) 24 | 25 | override fun unwrap(wrapped: java.net.InetSocketAddress) = 26 | InetSocketAddress { 27 | address = InetAddressBytesConverter.unwrap(wrapped.address) 28 | port = wrapped.port 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmMain/kotlin/protokt/v1/InstantConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import protokt.v1.google.protobuf.Timestamp 19 | import java.time.Instant 20 | 21 | object InstantConverter : AbstractConverter() { 22 | override fun wrap(unwrapped: Timestamp): Instant = 23 | Instant.ofEpochSecond(unwrapped.seconds, unwrapped.nanos.toLong()) 24 | 25 | override fun unwrap(wrapped: Instant) = 26 | Timestamp { 27 | seconds = wrapped.epochSecond 28 | nanos = wrapped.nano 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmMain/kotlin/protokt/v1/LocalDateStringConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import java.time.LocalDate 19 | 20 | object LocalDateStringConverter : AbstractConverter() { 21 | override val acceptsDefaultValue = false 22 | 23 | override fun wrap(unwrapped: String): LocalDate = 24 | LocalDate.parse(unwrapped) 25 | 26 | override fun unwrap(wrapped: LocalDate) = 27 | wrapped.toString() 28 | } 29 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmMain/kotlin/protokt/v1/LocalDateStringValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import protokt.v1.google.protobuf.StringValue 19 | import java.time.LocalDate 20 | 21 | object LocalDateStringValueConverter : AbstractConverter() { 22 | override fun wrap(unwrapped: StringValue) = 23 | LocalDateStringConverter.wrap(unwrapped.value) 24 | 25 | override fun unwrap(wrapped: LocalDate) = 26 | StringValue { value = LocalDateStringConverter.unwrap(wrapped) } 27 | } 28 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmMain/resources/META-INF/services/protokt.v1.Converter: -------------------------------------------------------------------------------- 1 | protokt.v1.DurationConverter 2 | protokt.v1.InetAddressBytesConverter 3 | protokt.v1.InetAddressBytesValueConverter 4 | protokt.v1.InetSocketAddressConverter 5 | protokt.v1.InstantConverter 6 | protokt.v1.LocalDateStringConverter 7 | protokt.v1.LocalDateStringValueConverter 8 | protokt.v1.UuidBytesConverter 9 | protokt.v1.UuidBytesValueConverter 10 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmTest/kotlin/protokt/v1/InetAddressBytesConverterTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | import java.net.InetAddress 21 | 22 | class InetAddressBytesConverterTest { 23 | @Test 24 | fun `conversion works`() { 25 | val address = InetAddress.getLocalHost() 26 | 27 | assertThat( 28 | InetAddressBytesConverter.wrap(InetAddressBytesConverter.unwrap(address)) 29 | ).isEqualTo(address) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmTest/kotlin/protokt/v1/InetSocketAddressConverterTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | import java.net.InetAddress 21 | import java.net.InetSocketAddress 22 | 23 | class InetSocketAddressConverterTest { 24 | @Test 25 | fun `conversion works`() { 26 | val addr = InetSocketAddress(InetAddress.getLocalHost(), 8080) 27 | 28 | assertThat( 29 | InetSocketAddressConverter.wrap(InetSocketAddressConverter.unwrap(addr)) 30 | ).isEqualTo(addr) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/jvmTest/kotlin/protokt/v1/InstantConverterTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | import java.time.Instant 21 | 22 | class InstantConverterTest { 23 | @Test 24 | fun `conversion works`() { 25 | val instant = Instant.now() 26 | 27 | assertThat( 28 | InstantConverter.wrap(InstantConverter.unwrap(instant)) 29 | ).isEqualTo(instant) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /extensions/protokt-extensions-lite/src/main/proto/protokt/v1/inet_socket_address.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | option java_package = "com.toasttab.protokt.v1"; 23 | option java_outer_classname = "InetSocketAddressProto"; 24 | option (protokt.v1.file).file_descriptor_object_name = "InetSocketAddressProto"; 25 | 26 | message InetSocketAddress { 27 | bytes address = 1; 28 | int32 port = 2; 29 | } 30 | -------------------------------------------------------------------------------- /gradle-plugin-integration-test/README.md: -------------------------------------------------------------------------------- 1 | # Integration Tests 2 | 3 | To build first run `./gradlew publishToIntegrationRepository` from the root directory. 4 | -------------------------------------------------------------------------------- /gradle-plugin-integration-test/gradle: -------------------------------------------------------------------------------- 1 | ../gradle -------------------------------------------------------------------------------- /gradle-plugin-integration-test/gradle.properties: -------------------------------------------------------------------------------- 1 | ../gradle.properties -------------------------------------------------------------------------------- /gradle-plugin-integration-test/gradlew: -------------------------------------------------------------------------------- 1 | ../gradlew -------------------------------------------------------------------------------- /gradle-plugin-integration-test/gradlew.bat: -------------------------------------------------------------------------------- 1 | ../gradlew.bat -------------------------------------------------------------------------------- /gradle-plugin-integration-test/jvm-lite/src/main/proto/testing/wrapper_test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message WrapperTest { 23 | bytes foo = 1 [(protokt.v1.property).wrap = "Id"]; 24 | } 25 | -------------------------------------------------------------------------------- /gradle-plugin-integration-test/multiplatform/src/commonTest/kotlin/protokt/v1/testing/TestMessageTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import kotlin.test.Test 19 | import kotlin.test.assertEquals 20 | 21 | class TestMessageTest { 22 | @Test 23 | fun serialization_round_trip() { 24 | val message = TestMessage { baz = "2007-12-03T10:15:30.00Z" } 25 | 26 | assertEquals( 27 | message, 28 | TestMessage.deserialize(message.serialize()) 29 | ) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /gradle-plugin-integration-test/multiplatform/src/jvmTest/kotlin/protokt/v1/testing/VersionTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import protokt.v1.Message 19 | import kotlin.test.Test 20 | import kotlin.test.assertTrue 21 | 22 | class VersionTest { 23 | @Test 24 | fun `runtime version should match project version`() { 25 | val version = System.getenv("version") 26 | val runtimeJarPath = Message::class.java.protectionDomain.codeSource.location.toString() 27 | 28 | assertTrue(runtimeJarPath.endsWith("protokt-runtime-jvm-$version.jar")) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gradle-plugin-integration-test/multiplatform/src/main/proto/testing/test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package testing; 19 | 20 | import "google/protobuf/wrappers.proto"; 21 | import "protokt/v1/protokt.proto"; 22 | 23 | message TestMessage { 24 | string baz = 1; 25 | 26 | oneof bar { 27 | string foo = 2; 28 | } 29 | 30 | google.protobuf.BoolValue qux = 3; 31 | 32 | enum Foo { 33 | FOO_FIRST_UNSPECIFIED = 0; 34 | } 35 | 36 | message Submessage { 37 | TestMessage qux = 1 [(protokt.v1.property).generate_non_null_accessor = true]; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /gradle-plugin-integration-test/semantic-build-versioning.gradle: -------------------------------------------------------------------------------- 1 | ../semantic-build-versioning.gradle -------------------------------------------------------------------------------- /gradle-plugin-integration-test/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | buildscript { 17 | repositories { 18 | gradlePluginPortal() 19 | } 20 | dependencies { 21 | classpath("gradle.plugin.net.vivin:gradle-semantic-build-versioning:4.0.0") 22 | } 23 | } 24 | 25 | plugins { 26 | id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0" 27 | } 28 | 29 | apply(plugin = "net.vivin.gradle-semantic-build-versioning") 30 | 31 | rootProject.name = "gradle-plugin-integration-test" 32 | 33 | listOf( 34 | "jvm-regular", 35 | "jvm-lite", 36 | "multiplatform", 37 | "wrapper-types" 38 | ).forEach { include(it) } 39 | -------------------------------------------------------------------------------- /gradle-plugin-integration-test/wrapper-types/src/main/kotlin/protokt/v1/testing/Id.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.auto.service.AutoService 19 | import protokt.v1.Bytes 20 | import protokt.v1.Converter 21 | 22 | data class Id(val value: String) 23 | 24 | @SuppressWarnings("rawtypes") 25 | @AutoService(Converter::class) 26 | object IdConverter : Converter { 27 | override val wrapper = Id::class 28 | 29 | override val wrapped = Bytes::class 30 | 31 | override fun wrap(unwrapped: Bytes) = 32 | Id(String(unwrapped.bytes)) 33 | 34 | override fun unwrap(wrapped: Id) = 35 | Bytes.from(wrapped.value.toByteArray()) 36 | } 37 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4096M 2 | kotlin.mpp.stability.nowarn=true 3 | org.gradle.caching=true 4 | -------------------------------------------------------------------------------- /gradle/license-header-c-style: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) $YEAR Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-toast/protokt/0f255be579c15a14795778cbaa40d85c6ea208b9/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /grpc-kotlin-shim/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.jvm-conventions") 18 | } 19 | 20 | val grpcKotlinGenerator = configurations.create("grpcKotlinGenerator") 21 | 22 | dependencies { 23 | grpcKotlinGenerator(libs.grpc.kotlin.gen) { 24 | artifact { 25 | name = "protoc-gen-grpc-kotlin" 26 | classifier = "jdk8" 27 | type = "jar" 28 | extension = "jar" 29 | } 30 | } 31 | } 32 | 33 | tasks.withType { 34 | from( 35 | zipTree(grpcKotlinGenerator.singleFile) 36 | .matching { include("**/io/grpc/kotlin/**") } 37 | ) 38 | } 39 | -------------------------------------------------------------------------------- /protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/PackageResolution.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.codegen.util 17 | 18 | import com.google.protobuf.DescriptorProtos.FileDescriptorProto 19 | import protokt.v1.reflect.DOT_GOOGLE_PROTOBUF 20 | import protokt.v1.reflect.PROTOKT_V1 21 | import protokt.v1.reflect.resolvePackage 22 | 23 | val PROTOKT_V1_GOOGLE_PROTO = PROTOKT_V1 + DOT_GOOGLE_PROTOBUF 24 | 25 | fun packagesByFileName(protoFileList: List) = 26 | protoFileList.associate { it.name to resolvePackage(it.`package`) } 27 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/kotlin/protokt/v1/codegen/ImplementDelegationTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.codegen 17 | 18 | import org.junit.jupiter.api.Test 19 | 20 | class ImplementDelegationTest : AbstractProtoktCodegenTest() { 21 | @Test 22 | fun `delegate to interface with non-null property`() { 23 | runPlugin("implement_by_delegate_with_non_null_property.proto").orFail() 24 | } 25 | } 26 | 27 | @Suppress("UNUSED") 28 | interface Model { 29 | val id: String 30 | } 31 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/kotlin/protokt/v1/codegen/generate/DeserializerGeneratorTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.codegen.generate 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | 21 | class DeserializerGeneratorTest { 22 | @Test 23 | fun `reader is named correctly`() { 24 | assertThat(READER).isEqualTo("reader") 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/kotlin/protokt/v1/codegen/generate/SerializerGeneratorTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.codegen.generate 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | 21 | class SerializerGeneratorTest { 22 | @Test 23 | fun `writer is named correctly`() { 24 | assertThat(WRITER).isEqualTo("writer") 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/resources/META-INF/services/protokt.v1.Converter: -------------------------------------------------------------------------------- 1 | protokt.v1.codegen.UuidBytesConverter 2 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/resources/implement_by_delegate_with_non_null_property.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package toasttab.protokt.v1.codegen.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message ImplementsModel { 23 | option (.protokt.v1.class).implements = "protokt.v1.codegen.Model"; 24 | 25 | string id = 1; 26 | } 27 | 28 | message ImplementsWithDelegate { 29 | option (.protokt.v1.class).implements = "protokt.v1.codegen.Model by model"; 30 | 31 | ImplementsModel model = 1; 32 | } 33 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/resources/non_null.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package toasttab.protokt.v1.codegen.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message TestMessageWithBadNonNullField { 23 | REPLACE value = 1 [ 24 | (.protokt.v1.property).generate_non_null_accessor = true 25 | ]; 26 | } 27 | 28 | enum Foo { 29 | FOO = 0; 30 | } 31 | 32 | message Bar {} 33 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/resources/non_null_nested.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package toasttab.protokt.v1.codegen.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message Outer { 23 | message TestNestedMessageWithBadNonNullField { 24 | REPLACE value = 1 [ 25 | (.protokt.v1.property).generate_non_null_accessor = true 26 | ]; 27 | } 28 | } 29 | 30 | enum Foo { 31 | FOO = 0; 32 | } 33 | 34 | message Bar {} 35 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/resources/non_null_oneof.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package toasttab.protokt.v1.codegen.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message TestMessageWithBadNonNullOneof { 23 | oneof foo { 24 | REPLACE bar = 1 [(.protokt.v1.property).generate_non_null_accessor = true]; 25 | } 26 | } 27 | 28 | message Foo {} 29 | 30 | enum Bar { 31 | BAR = 0; 32 | } 33 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/resources/non_null_optional.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto2"; 17 | 18 | package toasttab.protokt.v1.codegen.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message TestMessageWithBadNonNullOptionalField { 23 | optional REPLACE value = 1 [ 24 | (.protokt.v1.property).generate_non_null_accessor = true 25 | ]; 26 | } 27 | 28 | enum Foo { 29 | FOO = 0; 30 | } 31 | 32 | message Bar {} 33 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/resources/protokt/v1/codegen/bin-generator: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | exec cat > protokt-codegen/src/test/resources/protokt/v1/codegen/test-proto-bin-request.bin 3 | -------------------------------------------------------------------------------- /protokt-codegen/src/test/resources/test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package toasttab.protokt.v1.codegen.testing; 19 | 20 | import "google/protobuf/empty.proto"; 21 | import "google/protobuf/wrappers.proto"; 22 | import "protokt/v1/protokt.proto"; 23 | 24 | message TestMessage { 25 | // google.protobuf.DoubleValue double = 1; 26 | map map = 1; 27 | 28 | /* 29 | map map_int_value_wrapped = 4 [ 30 | (.protokt.v1.property).value_wrap = "java.util.UUID" 31 | ]; 32 | */ 33 | } 34 | 35 | /* 36 | message Empty {} 37 | */ 38 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/kotlin/protokt/v1/google/protobuf/BoolValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.protobuf 17 | 18 | import protokt.v1.Converter 19 | 20 | object BoolValueConverter : Converter { 21 | override val wrapper = Boolean::class 22 | 23 | override val wrapped = BoolValue::class 24 | 25 | override fun wrap(unwrapped: BoolValue) = 26 | unwrapped.value 27 | 28 | override fun unwrap(wrapped: Boolean) = 29 | BoolValue { value = wrapped } 30 | } 31 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/kotlin/protokt/v1/google/protobuf/BytesValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.protobuf 17 | 18 | import protokt.v1.Bytes 19 | import protokt.v1.Converter 20 | 21 | object BytesValueConverter : Converter { 22 | override val wrapper = Bytes::class 23 | 24 | override val wrapped = BytesValue::class 25 | 26 | override fun wrap(unwrapped: BytesValue) = 27 | unwrapped.value 28 | 29 | override fun unwrap(wrapped: Bytes) = 30 | BytesValue { value = wrapped } 31 | } 32 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/kotlin/protokt/v1/google/protobuf/DoubleValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.protobuf 17 | 18 | import protokt.v1.Converter 19 | 20 | object DoubleValueConverter : Converter { 21 | override val wrapper = Double::class 22 | 23 | override val wrapped = DoubleValue::class 24 | 25 | override fun wrap(unwrapped: DoubleValue) = 26 | unwrapped.value 27 | 28 | override fun unwrap(wrapped: Double) = 29 | DoubleValue { value = wrapped } 30 | } 31 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/kotlin/protokt/v1/google/protobuf/FloatValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.protobuf 17 | 18 | import protokt.v1.Converter 19 | 20 | object FloatValueConverter : Converter { 21 | override val wrapper = Float::class 22 | 23 | override val wrapped = FloatValue::class 24 | 25 | override fun wrap(unwrapped: FloatValue) = 26 | unwrapped.value 27 | 28 | override fun unwrap(wrapped: Float) = 29 | FloatValue { value = wrapped } 30 | } 31 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/kotlin/protokt/v1/google/protobuf/Int32ValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.protobuf 17 | 18 | import protokt.v1.Converter 19 | 20 | object Int32ValueConverter : Converter { 21 | override val wrapper = Int::class 22 | 23 | override val wrapped = Int32Value::class 24 | 25 | override fun wrap(unwrapped: Int32Value) = 26 | unwrapped.value 27 | 28 | override fun unwrap(wrapped: Int) = 29 | Int32Value { value = wrapped } 30 | } 31 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/kotlin/protokt/v1/google/protobuf/Int64ValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.protobuf 17 | 18 | import protokt.v1.Converter 19 | 20 | object Int64ValueConverter : Converter { 21 | override val wrapper = Long::class 22 | 23 | override val wrapped = Int64Value::class 24 | 25 | override fun wrap(unwrapped: Int64Value) = 26 | unwrapped.value 27 | 28 | override fun unwrap(wrapped: Long) = 29 | Int64Value { value = wrapped } 30 | } 31 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/kotlin/protokt/v1/google/protobuf/StringValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.protobuf 17 | 18 | import protokt.v1.Converter 19 | 20 | object StringValueConverter : Converter { 21 | override val wrapper = String::class 22 | 23 | override val wrapped = StringValue::class 24 | 25 | override fun wrap(unwrapped: StringValue) = 26 | unwrapped.value 27 | 28 | override fun unwrap(wrapped: String) = 29 | StringValue { value = wrapped } 30 | } 31 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/kotlin/protokt/v1/google/protobuf/UInt32ValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.protobuf 17 | 18 | import protokt.v1.Converter 19 | 20 | object UInt32ValueConverter : Converter { 21 | override val wrapper = UInt::class 22 | 23 | override val wrapped = UInt32Value::class 24 | 25 | override fun wrap(unwrapped: UInt32Value) = 26 | unwrapped.value 27 | 28 | override fun unwrap(wrapped: UInt) = 29 | UInt32Value { value = wrapped } 30 | } 31 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/kotlin/protokt/v1/google/protobuf/UInt64ValueConverter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.protobuf 17 | 18 | import protokt.v1.Converter 19 | 20 | object UInt64ValueConverter : Converter { 21 | override val wrapper = ULong::class 22 | 23 | override val wrapped = UInt64Value::class 24 | 25 | override fun wrap(unwrapped: UInt64Value) = 26 | unwrapped.value 27 | 28 | override fun unwrap(wrapped: ULong) = 29 | UInt64Value { value = wrapped } 30 | } 31 | -------------------------------------------------------------------------------- /protokt-core-lite/src/commonMain/resources/META-INF/services/protokt.v1.Converter: -------------------------------------------------------------------------------- 1 | protokt.v1.google.protobuf.BoolValueConverter 2 | protokt.v1.google.protobuf.BytesValueConverter 3 | protokt.v1.google.protobuf.DoubleValueConverter 4 | protokt.v1.google.protobuf.FloatValueConverter 5 | protokt.v1.google.protobuf.Int32ValueConverter 6 | protokt.v1.google.protobuf.Int64ValueConverter 7 | protokt.v1.google.protobuf.StringValueConverter 8 | protokt.v1.google.protobuf.UInt32ValueConverter 9 | protokt.v1.google.protobuf.UInt64ValueConverter 10 | -------------------------------------------------------------------------------- /protokt-core-lite/src/jvmTest/kotlin/protokt/v1/SerializationTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | import protokt.v1.google.protobuf.Duration 21 | 22 | class SerializationTest { 23 | @Test 24 | fun `serialize and deserialize`() { 25 | assertThat( 26 | Duration.deserialize(Duration { seconds = 4 }.serialize()).seconds 27 | ).isEqualTo(4) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /protokt-gradle-plugin/src/main/kotlin/protokt/v1/gradle/ProtoktPlugin.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.gradle 17 | 18 | import org.gradle.api.Plugin 19 | import org.gradle.api.Project 20 | 21 | class ProtoktPlugin : Plugin { 22 | override fun apply(project: Project) { 23 | configureProtokt(project, PROTOKT_VERSION, true, binaryFromArtifact(project)) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /protokt-protovalidate/api/protokt-protovalidate.api: -------------------------------------------------------------------------------- 1 | public final class protokt/v1/buf/validate/Validator { 2 | public fun ()V 3 | public fun (Lbuild/buf/protovalidate/Config;)V 4 | public synthetic fun (Lbuild/buf/protovalidate/Config;ILkotlin/jvm/internal/DefaultConstructorMarker;)V 5 | public final fun load (Lcom/google/protobuf/Descriptors$Descriptor;)V 6 | public final fun validate (Lprotokt/v1/Message;)Lbuild/buf/protovalidate/ValidationResult; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /protokt-protovalidate/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.jvm-conventions") 18 | } 19 | 20 | enablePublishing() 21 | trackKotlinApiCompatibility() 22 | 23 | dependencies { 24 | implementation(project(":protokt-reflect")) 25 | implementation(kotlin("reflect")) 26 | implementation(libs.cel) 27 | implementation(libs.protovalidateJava) 28 | } 29 | -------------------------------------------------------------------------------- /protokt-runtime-grpc-lite/api/protokt-runtime-grpc-lite.api: -------------------------------------------------------------------------------- 1 | public final class protokt/v1/grpc/Marshaller : io/grpc/MethodDescriptor$Marshaller { 2 | public fun (Lprotokt/v1/Deserializer;)V 3 | public synthetic fun parse (Ljava/io/InputStream;)Ljava/lang/Object; 4 | public fun parse (Ljava/io/InputStream;)Lprotokt/v1/Message; 5 | public synthetic fun stream (Ljava/lang/Object;)Ljava/io/InputStream; 6 | public fun stream (Lprotokt/v1/Message;)Ljava/io/ByteArrayInputStream; 7 | } 8 | 9 | public final class protokt/v1/grpc/SchemaDescriptor { 10 | public fun (Ljava/lang/String;Ljava/lang/String;)V 11 | public final fun getFileDescriptorUntyped ()Ljava/lang/Object; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /protokt-runtime-grpc-lite/src/jsMain/kotlin/protokt/v1/grpc/AbstractCoroutineStub.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.grpc 17 | 18 | import protokt.v1.Beta 19 | 20 | @Beta 21 | abstract class AbstractCoroutineStub>( 22 | protected val client: Client 23 | ) { 24 | constructor( 25 | serviceDescriptor: ServiceDescriptor, 26 | address: String, 27 | credentials: ChannelCredentials 28 | ) : this(newClient(serviceDescriptor, address, credentials)) 29 | } 30 | -------------------------------------------------------------------------------- /protokt-runtime-grpc-lite/src/jsMain/kotlin/protokt/v1/grpc/BindableService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.grpc 17 | 18 | import protokt.v1.Beta 19 | 20 | @Beta 21 | interface BindableService { 22 | fun bindService(): ServerServiceDefinition 23 | } 24 | -------------------------------------------------------------------------------- /protokt-runtime-grpc-lite/src/jsMain/kotlin/protokt/v1/grpc/Marshaller.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.grpc 17 | 18 | import protokt.v1.Beta 19 | import protokt.v1.Deserializer 20 | import protokt.v1.Message 21 | 22 | @Beta 23 | class Marshaller( 24 | private val deserializer: Deserializer 25 | ) : MethodDescriptor.Marshaller { 26 | override fun parse(bytes: ByteArray) = 27 | deserializer.deserialize(bytes) 28 | 29 | override fun serialize(value: T): dynamic = 30 | value.serialize() 31 | } 32 | -------------------------------------------------------------------------------- /protokt-runtime-grpc-lite/src/jsMain/kotlin/protokt/v1/grpc/NodeRuntime.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | @file:Suppress("ktlint:standard:filename") 17 | 18 | package protokt.v1.grpc 19 | 20 | internal external class Buffer { 21 | companion object { 22 | fun from(obj: dynamic): Buffer 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /protokt-runtime-grpc-lite/src/jsMain/kotlin/protokt/v1/grpc/ServerMethodDefinition.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.grpc 17 | 18 | import protokt.v1.Beta 19 | 20 | @Beta 21 | class ServerMethodDefinition( 22 | internal val methodDescriptor: MethodDescriptor, 23 | internal val handler: dynamic 24 | ) 25 | -------------------------------------------------------------------------------- /protokt-runtime-grpc-lite/src/jsMain/kotlin/protokt/v1/grpc/StatusException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.grpc 17 | 18 | import protokt.v1.Beta 19 | 20 | @Beta 21 | class StatusException(@Suppress("UNUSED_PARAMETER") status: Status) : Exception() 22 | -------------------------------------------------------------------------------- /protokt-runtime-grpc-lite/src/jsMain/kotlin/protokt/v1/grpc/Stream.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | @file:JsModule("stream") 17 | @file:JsNonModule 18 | 19 | package protokt.v1.grpc 20 | 21 | import protokt.v1.Beta 22 | 23 | @Beta 24 | external interface Readable { 25 | fun on(event: String, callback: (dynamic) -> Unit) 26 | } 27 | 28 | @Beta 29 | external interface Writable 30 | -------------------------------------------------------------------------------- /protokt-runtime-grpc-lite/src/jvmMain/kotlin/protokt/v1/grpc/Marshaller.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.grpc 17 | 18 | import io.grpc.MethodDescriptor 19 | import protokt.v1.Deserializer 20 | import protokt.v1.Message 21 | import java.io.InputStream 22 | 23 | class Marshaller( 24 | private val deserializer: Deserializer 25 | ) : MethodDescriptor.Marshaller { 26 | override fun stream(value: T) = 27 | value.serialize().inputStream() 28 | 29 | override fun parse(stream: InputStream) = 30 | deserializer.deserialize(stream) 31 | } 32 | -------------------------------------------------------------------------------- /protokt-runtime-grpc/api/protokt-runtime-grpc.api: -------------------------------------------------------------------------------- 1 | public final class protokt/v1/grpc/SchemaDescriptors { 2 | public static final fun getFileDescriptor (Lprotokt/v1/grpc/SchemaDescriptor;)Lprotokt/v1/google/protobuf/FileDescriptor; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /protokt-runtime-grpc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.multiplatform-published-conventions") 18 | } 19 | 20 | compatibleWithAndroid() 21 | 22 | kotlin { 23 | sourceSets { 24 | val commonMain by getting { 25 | dependencies { 26 | api(project(":protokt-runtime-grpc-lite")) 27 | api(project(":protokt-core")) 28 | } 29 | } 30 | 31 | val jvmMain by getting { 32 | dependencies { 33 | implementation(libs.grpc.stub) 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /protokt-runtime-grpc/src/jvmMain/kotlin/protokt/v1/grpc/SchemaDescriptors.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | @file:JvmName("SchemaDescriptors") 17 | 18 | package protokt.v1.grpc 19 | 20 | import protokt.v1.google.protobuf.FileDescriptor 21 | 22 | @Suppress("DEPRECATION") 23 | val SchemaDescriptor.fileDescriptor: FileDescriptor 24 | get() = fileDescriptorUntyped as FileDescriptor 25 | -------------------------------------------------------------------------------- /protokt-runtime/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.multiplatform-published-conventions") 18 | } 19 | 20 | compatibleWithAndroid() 21 | 22 | kotlin { 23 | sourceSets { 24 | val jvmMain by getting { 25 | dependencies { 26 | compileOnly(libs.protobuf.java) 27 | } 28 | } 29 | 30 | val jsMain by getting { 31 | dependencies { 32 | api(npm("protobufjs", libs.versions.protobuf.js.get())) 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/AbstractDeserializer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | expect abstract class AbstractDeserializer() : Deserializer { 19 | abstract override fun deserialize(reader: Reader): T 20 | 21 | final override fun deserialize(bytes: Bytes): T 22 | 23 | final override fun deserialize(bytes: ByteArray): T 24 | 25 | final override fun deserialize(bytes: BytesSlice): T 26 | } 27 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/AbstractMessage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | expect abstract class AbstractMessage() : Message { 19 | final override fun serialize(): ByteArray 20 | } 21 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/Beta.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | /** 19 | * Signifies that a public API is subject to incompatible changes, or even removal, in a future release. 20 | * An API bearing this annotation is exempt from any compatibility guarantees and additionally may not 21 | * be suitable for production use. 22 | */ 23 | annotation class Beta 24 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/BuilderDsl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | @DslMarker 19 | annotation class BuilderDsl 20 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/Bytes.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import kotlin.jvm.JvmStatic 19 | 20 | expect class Bytes internal constructor( 21 | value: ByteArray 22 | ) : AbstractBytes { 23 | companion object { 24 | @JvmStatic 25 | fun empty(): Bytes 26 | 27 | @JvmStatic 28 | fun from(bytes: ByteArray): Bytes 29 | 30 | @JvmStatic 31 | fun from(message: Message): Bytes 32 | } 33 | } 34 | 35 | internal expect fun clone(bytes: ByteArray): ByteArray 36 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/Deserializer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | expect interface Deserializer { 19 | fun deserialize(reader: Reader): T 20 | 21 | fun deserialize(bytes: Bytes): T 22 | 23 | fun deserialize(bytes: ByteArray): T 24 | 25 | fun deserialize(bytes: BytesSlice): T 26 | } 27 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/Enum.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | abstract class Enum { 19 | abstract val value: Int 20 | abstract val name: String 21 | 22 | final override fun equals(other: Any?) = 23 | other != null && 24 | other::class == this::class && 25 | (other as Enum).value == value 26 | 27 | final override fun hashCode() = 28 | value 29 | 30 | final override fun toString() = 31 | name 32 | } 33 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/EnumReader.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | interface EnumReader { 19 | fun from(value: Int): E 20 | } 21 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/GeneratedFileDescriptor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | annotation class GeneratedFileDescriptor 19 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/GeneratedMessage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | @Target(AnnotationTarget.CLASS) 19 | annotation class GeneratedMessage( 20 | /** 21 | * The full protocol buffer type name of this message used for packing into an Any. 22 | */ 23 | val fullTypeName: String 24 | ) 25 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/GeneratedProperty.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | @Target(AnnotationTarget.PROPERTY) 19 | annotation class GeneratedProperty( 20 | /** 21 | * The property's Protobuf field number. 22 | */ 23 | val number: Int 24 | ) 25 | -------------------------------------------------------------------------------- /protokt-runtime/src/commonMain/kotlin/protokt/v1/Message.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | expect interface Message { 19 | fun messageSize(): Int 20 | 21 | fun serialize(writer: Writer) 22 | 23 | fun serialize(): ByteArray 24 | } 25 | -------------------------------------------------------------------------------- /protokt-runtime/src/jsMain/kotlin/protokt/v1/AbstractDeserializer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | actual abstract class AbstractDeserializer actual constructor() : Deserializer { 19 | actual abstract override fun deserialize(reader: Reader): T 20 | 21 | actual final override fun deserialize(bytes: Bytes) = 22 | deserialize(bytes.value) 23 | 24 | actual final override fun deserialize(bytes: ByteArray): T = 25 | deserialize(reader(ProtobufJsReader.create(bytes.asUint8Array()))) 26 | 27 | actual final override fun deserialize(bytes: BytesSlice): T = 28 | deserialize(reader(ProtobufJsReader.create(bytes.asUint8Array()))) 29 | } 30 | -------------------------------------------------------------------------------- /protokt-runtime/src/jsMain/kotlin/protokt/v1/AbstractMessage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import org.khronos.webgl.Int8Array 19 | 20 | actual abstract class AbstractMessage actual constructor() : Message { 21 | actual final override fun serialize(): ByteArray { 22 | val writer = ProtobufJsWriter.create() 23 | serialize(writer(writer)) 24 | val buf = writer.finish() 25 | val res = Int8Array(buf.buffer, buf.byteOffset, buf.length).unsafeCast() 26 | check(res.size == messageSize()) { "Expected ${messageSize()}, got ${res.size}" } 27 | return res 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /protokt-runtime/src/jsMain/kotlin/protokt/v1/Bytes.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | actual class Bytes internal actual constructor(value: ByteArray) : AbstractBytes(value) { 19 | // Annotation `@JvmStatic` is missing on actual declaration 20 | @Suppress("ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT") 21 | actual companion object { 22 | actual fun empty() = 23 | AbstractBytes.empty() 24 | 25 | actual fun from(bytes: ByteArray) = 26 | AbstractBytes.from(bytes) 27 | 28 | actual fun from(message: Message) = 29 | AbstractBytes.from(message) 30 | } 31 | } 32 | 33 | internal actual fun clone(bytes: ByteArray) = 34 | bytes.copyOf() 35 | -------------------------------------------------------------------------------- /protokt-runtime/src/jsMain/kotlin/protokt/v1/Deserializer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import org.khronos.webgl.Uint8Array 19 | 20 | actual interface Deserializer { 21 | actual fun deserialize(bytes: Bytes): T 22 | 23 | actual fun deserialize(bytes: ByteArray): T 24 | 25 | actual fun deserialize(bytes: BytesSlice): T 26 | 27 | actual fun deserialize(reader: Reader): T 28 | 29 | fun deserialize(bytes: Uint8Array): T = 30 | deserialize(reader(ProtobufJsReader.create(bytes))) 31 | } 32 | -------------------------------------------------------------------------------- /protokt-runtime/src/jsMain/kotlin/protokt/v1/Message.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | actual interface Message { 19 | actual fun messageSize(): Int 20 | 21 | actual fun serialize(writer: Writer) 22 | 23 | actual fun serialize(): ByteArray 24 | } 25 | -------------------------------------------------------------------------------- /protokt-runtime/src/jvmMain/kotlin/protokt/v1/AbstractMessage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import com.google.protobuf.CodedOutputStream 19 | 20 | actual abstract class AbstractMessage actual constructor() : Message { 21 | actual final override fun serialize(): ByteArray { 22 | val buf = ByteArray(messageSize()) 23 | serialize(writer(CodedOutputStream.newInstance(buf))) 24 | return buf 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /protokt-runtime/src/jvmMain/kotlin/protokt/v1/Message.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1 17 | 18 | import com.google.protobuf.CodedOutputStream 19 | import java.io.OutputStream 20 | 21 | actual interface Message { 22 | actual fun messageSize(): Int 23 | 24 | actual fun serialize(writer: Writer) 25 | 26 | actual fun serialize(): ByteArray 27 | 28 | fun serialize(outputStream: OutputStream) = 29 | CodedOutputStream.newInstance(outputStream).run { 30 | serialize(writer(this)) 31 | flush() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /semantic-build-versioning.gradle: -------------------------------------------------------------------------------- 1 | preRelease { 2 | startingVersion = 'alpha.0' 3 | 4 | bump = { 5 | // The bumping scheme is alpha.0 -> alpha.1 -> ... -> alpha.n 6 | // "alpha.${((it - ~/^alpha\./) as int) + 1}" 7 | "beta.${((it - ~/^beta\./) as int) + 1}" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /shared-src/gradle-plugin/com/google/protobuf/gradle/GenerateProtoTaskExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.google.protobuf.gradle 17 | 18 | internal val GenerateProtoTask.outputSourceDirectoriesHack 19 | get() = outputSourceDirectories 20 | -------------------------------------------------------------------------------- /shared-src/gradle-plugin/protokt/v1/gradle/KotlinPlugins.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.gradle 17 | 18 | internal object KotlinPlugins { 19 | const val MULTIPLATFORM = "org.jetbrains.kotlin.multiplatform" 20 | const val JVM = "org.jetbrains.kotlin.jvm" 21 | const val ANDROID = "org.jetbrains.kotlin.android" 22 | } 23 | -------------------------------------------------------------------------------- /shared-src/lite-util/protokt/v1/util/ProtoktExtentions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.util 17 | 18 | const val PROTOKT_EXTENSIONS_CLASS_NAME = "protokt.v1.protokt_file_descriptor" 19 | -------------------------------------------------------------------------------- /testing/android-test-configurations/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.android-conventions") 18 | } 19 | 20 | android { 21 | namespace = "com.toasttab.protokt.testing.android" 22 | compileSdk = 31 23 | namespace = "com.toasttab.protokt.v1.testing.android" 24 | 25 | sourceSets["test"].java.srcDir("../android/src/test/java") 26 | } 27 | 28 | localProtokt() 29 | pureKotlin() 30 | 31 | dependencies { 32 | testRuntimeOnly(libs.protobuf.lite) 33 | } 34 | -------------------------------------------------------------------------------- /testing/android-test-configurations/src/test/proto/protokt/v1/testing/android/test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing.android; 19 | 20 | option java_package = "com.toasttab.protokt.v1.testing.android"; 21 | 22 | message TestMessage { 23 | string foo = 1; 24 | } 25 | -------------------------------------------------------------------------------- /testing/android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.android-conventions") 18 | } 19 | 20 | android { 21 | namespace = "com.toasttab.protokt.testing.android" 22 | compileSdk = 31 23 | namespace = "com.toasttab.protokt.v1.testing.android" 24 | } 25 | 26 | localProtokt() 27 | 28 | dependencies { 29 | testRuntimeOnly(libs.protobuf.lite) 30 | } 31 | -------------------------------------------------------------------------------- /testing/android/src/main/proto/protokt/v1/testing/android/test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing.android; 19 | 20 | option java_package = "com.toasttab.protokt.v1.testing.android"; 21 | 22 | message TestMessage { 23 | string foo = 1; 24 | } 25 | -------------------------------------------------------------------------------- /testing/conformance/driver/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 17 | 18 | plugins { 19 | id("protokt.multiplatform-conventions") 20 | } 21 | 22 | localProtokt() 23 | 24 | kotlin { 25 | sourceSets { 26 | val commonMain by getting { 27 | dependencies { 28 | implementation(libs.kotlinx.coroutines.core) 29 | } 30 | } 31 | } 32 | } 33 | 34 | tasks.withType { 35 | compilerOptions { 36 | freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn") 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /testing/conformance/js-ir/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | `kotlin-multiplatform` 18 | } 19 | 20 | kotlin { 21 | js(IR) { 22 | binaries.executable() 23 | nodejs {} 24 | } 25 | 26 | sourceSets { 27 | val jsMain by getting { 28 | dependencies { 29 | implementation(project(":testing:conformance:driver")) 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /testing/conformance/js-ir/failure_list_kt.txt: -------------------------------------------------------------------------------- 1 | # proto3: protokt does not support 2 | Recommended.Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput 3 | Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.ProtobufOutput 4 | Required.Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput 5 | Required.Proto3.ProtobufInput.ValidDataOneof.MESSAGE.Merge.ProtobufOutput 6 | 7 | # editions: protokt does not support 8 | Recommended.Editions_Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput 9 | Required.Editions_Proto3.ProtobufInput.RepeatedScalarMessageMerge.ProtobufOutput 10 | Required.Editions_Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput 11 | Required.Editions_Proto3.ProtobufInput.ValidDataOneof.MESSAGE.Merge.ProtobufOutput 12 | Required.Editions.ProtobufInput.ValidDelimitedExtension.GroupLike.ProtobufOutput 13 | Required.Editions.ProtobufInput.ValidDelimitedExtension.NotGroupLike.ProtobufOutput 14 | Required.Editions.ProtobufInput.ValidDelimitedField.GroupLike.ProtobufOutput 15 | Required.Editions.ProtobufInput.ValidDelimitedField.NotGroupLike.ProtobufOutput 16 | -------------------------------------------------------------------------------- /testing/conformance/js-ir/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -o pipefail 5 | 6 | DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 7 | 8 | exec node $DIR/build/compileSync/js/main/productionExecutable/kotlin/protokt-testing-conformance-js-ir.js 2> $DIR/build/conformance-run 9 | -------------------------------------------------------------------------------- /testing/conformance/js-ir/src/jsMain/kotlin/App.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | fun main() { 17 | protokt.v1.configureLong() 18 | protokt.v1.conformance.main() 19 | } 20 | -------------------------------------------------------------------------------- /testing/conformance/jvm/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.jvm-conventions") 18 | application 19 | } 20 | 21 | application { 22 | applicationName = "protokt-conformance" 23 | mainClass.set("protokt.v1.conformance.MainKt") 24 | } 25 | 26 | dependencies { 27 | implementation(project(":testing:conformance:driver")) 28 | 29 | runtimeOnly(libs.protobuf.java) 30 | } 31 | -------------------------------------------------------------------------------- /testing/conformance/jvm/failure_list_kt.txt: -------------------------------------------------------------------------------- 1 | # proto3: protokt does not support 2 | Recommended.Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput 3 | Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.ProtobufOutput 4 | Required.Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput 5 | Required.Proto3.ProtobufInput.ValidDataOneof.MESSAGE.Merge.ProtobufOutput 6 | 7 | # editions: protokt does not support 8 | Recommended.Editions_Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput 9 | Required.Editions_Proto3.ProtobufInput.RepeatedScalarMessageMerge.ProtobufOutput 10 | Required.Editions_Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput 11 | Required.Editions_Proto3.ProtobufInput.ValidDataOneof.MESSAGE.Merge.ProtobufOutput 12 | Required.Editions.ProtobufInput.ValidDelimitedExtension.GroupLike.ProtobufOutput 13 | Required.Editions.ProtobufInput.ValidDelimitedExtension.NotGroupLike.ProtobufOutput 14 | Required.Editions.ProtobufInput.ValidDelimitedField.GroupLike.ProtobufOutput 15 | Required.Editions.ProtobufInput.ValidDelimitedField.NotGroupLike.ProtobufOutput 16 | -------------------------------------------------------------------------------- /testing/interop/src/main/proto/google/protobuf/unittest_import_public.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file or at 6 | // https://developers.google.com/open-source/licenses/bsd 7 | 8 | // Author: liujisi@google.com (Pherl Liu) 9 | 10 | syntax = "proto2"; 11 | 12 | package protobuf_unittest_import; 13 | 14 | option java_package = "com.google.protobuf.test"; 15 | 16 | message PublicImportMessage { 17 | optional int32 e = 1; 18 | } 19 | -------------------------------------------------------------------------------- /testing/interop/src/main/proto/protokt/v1/testing/deeply_nested.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | option java_package = "com.toasttab.protokt.v1.testing"; 21 | 22 | message DeeplyNested1 { 23 | message DeeplyNested2 { 24 | message DeeplyNested3 { 25 | message DeeplyNested4 {} 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testing/interop/src/main/proto/protokt/v1/testing/has_a_service.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/testing/test.proto"; 21 | 22 | option java_package = "com.toasttab.protokt.v1.testing"; 23 | 24 | service FooService { 25 | rpc GetFoo(Test) returns (Test2); 26 | } 27 | -------------------------------------------------------------------------------- /testing/multiplatform-testing/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import protokt.v1.gradle.protoktExtensions 17 | 18 | plugins { 19 | id("protokt.multiplatform-conventions") 20 | } 21 | 22 | localProtokt() 23 | 24 | kotlin { 25 | sourceSets { 26 | val jvmTest by getting { 27 | dependencies { 28 | runtimeOnly(libs.protobuf.java) 29 | } 30 | } 31 | } 32 | } 33 | 34 | dependencies { 35 | protoktExtensions(project(":extensions:protokt-extensions")) 36 | } 37 | -------------------------------------------------------------------------------- /testing/multiplatform-testing/src/jsTest/kotlin/protokt.v1.testing/MultiplatformGenerationTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import kotlin.test.Test 19 | import kotlin.test.assertEquals 20 | 21 | class MultiplatformGenerationTest { 22 | @Test 23 | fun test_mp_test_round_trip() { 24 | val mpTest = MpTest { foo = "1" } 25 | 26 | val deserialized = MpTest.deserialize(mpTest.serialize()) 27 | 28 | assertEquals(mpTest, deserialized) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /testing/multiplatform-testing/src/jvmTest/kotlin/protokt/v1/testing/MultiplatformGenerationTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | 21 | class MultiplatformGenerationTest { 22 | @Test 23 | fun `test multiplatform test round trip`() { 24 | val mpTest = MpTest { foo = "1" } 25 | 26 | val deserialized = MpTest.deserialize(mpTest.serialize()) 27 | 28 | assertThat(deserialized).isEqualTo(mpTest) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /testing/multiplatform-testing/src/main/proto/protokt/v1/testing/mp_test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message MpTest { 23 | string foo = 1; 24 | } 25 | -------------------------------------------------------------------------------- /testing/options-api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.jvm-conventions") 18 | kotlin("kapt") 19 | } 20 | 21 | dependencies { 22 | implementation(project(":protokt-core")) 23 | implementation(libs.autoServiceAnnotations) 24 | 25 | kapt(libs.autoService) 26 | } 27 | -------------------------------------------------------------------------------- /testing/options-api/src/main/kotlin/protokt/v1/testing/Duration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.auto.service.AutoService 19 | import protokt.v1.AbstractConverter 20 | import protokt.v1.Converter 21 | 22 | data class Duration(val value: protokt.v1.google.protobuf.Duration) 23 | 24 | @SuppressWarnings("rawtypes") 25 | @AutoService(Converter::class) 26 | object DurationConverter : AbstractConverter() { 27 | override fun wrap(unwrapped: protokt.v1.google.protobuf.Duration) = 28 | Duration(unwrapped) 29 | 30 | override fun unwrap(wrapped: Duration) = 31 | wrapped.value 32 | } 33 | -------------------------------------------------------------------------------- /testing/options-api/src/main/kotlin/protokt/v1/testing/IModel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | interface IModel { 19 | val id: Id 20 | } 21 | -------------------------------------------------------------------------------- /testing/options-api/src/main/kotlin/protokt/v1/testing/IModel2.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | interface IModel2 { 19 | val id: String? 20 | } 21 | -------------------------------------------------------------------------------- /testing/options-api/src/main/kotlin/protokt/v1/testing/IModel3.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import protokt.v1.Message 19 | 20 | interface IModel3 : Message { 21 | val id: String? 22 | } 23 | -------------------------------------------------------------------------------- /testing/options-api/src/main/kotlin/protokt/v1/testing/IModel4.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | interface IModel4 { 19 | val bar: IModel? 20 | } 21 | -------------------------------------------------------------------------------- /testing/options-api/src/main/kotlin/protokt/v1/testing/Id.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.auto.service.AutoService 19 | import protokt.v1.AbstractConverter 20 | import protokt.v1.Bytes 21 | import protokt.v1.Converter 22 | 23 | data class Id(val value: String) 24 | 25 | @SuppressWarnings("rawtypes") 26 | @AutoService(Converter::class) 27 | object IdConverter : AbstractConverter() { 28 | override fun wrap(unwrapped: Bytes) = 29 | Id(String(unwrapped.bytes)) 30 | 31 | override fun unwrap(wrapped: Id) = 32 | Bytes.from(wrapped.value.toByteArray().inputStream()) 33 | } 34 | -------------------------------------------------------------------------------- /testing/options-api/src/main/kotlin/protokt/v1/testing/ModelWithString.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | interface ModelWithString { 19 | val string: String 20 | } 21 | -------------------------------------------------------------------------------- /testing/options-api/src/main/kotlin/protokt/v1/testing/OneofModel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | interface OneofModel { 19 | val id: Id 20 | } 21 | -------------------------------------------------------------------------------- /testing/options-test-configurations/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import com.google.protobuf.gradle.testProtobuf 17 | import protokt.v1.gradle.testProtoktExtensions 18 | 19 | plugins { 20 | id("protokt.jvm-conventions") 21 | } 22 | 23 | localProtokt() 24 | pureKotlin() 25 | 26 | dependencies { 27 | testProtoktExtensions(project(":testing:options-api")) 28 | testProtoktExtensions(project(":third-party:proto-google-common-protos-extensions")) 29 | 30 | testProtobuf(project(":testing:options")) 31 | 32 | testRuntimeOnly(libs.protobuf.java) 33 | } 34 | -------------------------------------------------------------------------------- /testing/options/src/main/kotlin/protokt/v1/testing/Marshallers.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import io.grpc.MethodDescriptor 19 | import java.io.InputStream 20 | 21 | object InMarshaller : MethodDescriptor.Marshaller { 22 | override fun stream(value: In) = 23 | value.serialize().inputStream() 24 | 25 | override fun parse(stream: InputStream) = 26 | In.deserialize(stream) 27 | } 28 | 29 | object OutMarshaller : MethodDescriptor.Marshaller { 30 | override fun stream(value: Out) = 31 | value.serialize().inputStream() 32 | 33 | override fun parse(stream: InputStream) = 34 | Out.deserialize(stream) 35 | } 36 | -------------------------------------------------------------------------------- /testing/options/src/main/proto/protokt/v1/testing/custom_file_descriptor_object_name.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | option (.protokt.v1.file).file_descriptor_object_name = "SomeOtherObjectName"; 23 | 24 | message FileDescriptorObjectNameTest {} 25 | -------------------------------------------------------------------------------- /testing/options/src/main/proto/protokt/v1/testing/custom_marshallers.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | option java_package = "com.toasttab.protokt.v1.testing"; 23 | 24 | message In {} 25 | message Out {} 26 | 27 | service CustomMarshallerService { 28 | rpc CustomMarshallersMethod(In) returns (Out) { 29 | option (.protokt.v1.method).request_marshaller = "InMarshaller"; 30 | option (.protokt.v1.method).response_marshaller = "OutMarshaller"; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /testing/options/src/main/proto/protokt/v1/testing/oneof_exercises.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | option java_package = "com.toasttab.protokt.v1.testing"; 23 | 24 | // This file exercises oneofs whose names are the same as their 25 | // generated sealed class type names. If the code generator does 26 | // not handle them properly then compilation will fail. 27 | 28 | message OneofExerciseModelWithWrapper { 29 | oneof oneof { 30 | // Needs full qualification: com.toasttab.protokt.testing.options.CachingId 31 | bytes caching_id = 1 [ 32 | (.protokt.v1.property).wrap = "CachingId" 33 | ]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /testing/options/src/main/proto/protokt/v1/testing/test_proto3_optional.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message TestProto3OptionalWrapperType { 23 | optional string optional_local_date = 1 [ 24 | (.protokt.v1.property).wrap = "java.time.LocalDate" 25 | ]; 26 | } 27 | -------------------------------------------------------------------------------- /testing/options/src/main/proto/protokt/v1/testing/uses_bytes_slice.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message SliceModel { 23 | bytes slice = 1 [ 24 | (.protokt.v1.property).bytes_slice = true 25 | ]; 26 | } 27 | -------------------------------------------------------------------------------- /testing/options/src/test/kotlin/protokt/v1/testing/BytesSliceTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | import protokt.v1.BytesSlice 21 | 22 | class BytesSliceTest { 23 | private val model = 24 | SliceModel { 25 | slice = BytesSlice.from("asdf".toByteArray()) 26 | } 27 | 28 | @Test 29 | fun `slice contents are preserved`() { 30 | val deserialized = SliceModel.deserialize(model.serialize()) 31 | 32 | assertThat(deserialized.slice).isEqualTo(model.slice) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /testing/options/src/test/kotlin/protokt/v1/testing/CustomFileDescriptorObjectNameTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | 21 | class CustomFileDescriptorObjectNameTest { 22 | @Test 23 | fun `plugin should respect custom file descriptor object name`() { 24 | assertThat(SomeOtherObjectName.descriptor.messageTypes) 25 | .contains(FileDescriptorObjectNameTest.descriptor) 26 | 27 | assertThat(FileDescriptorObjectNameTest.descriptor.file) 28 | .isEqualTo(SomeOtherObjectName.descriptor) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /testing/options/src/test/kotlin/protokt/v1/testing/ProtoktExtensionsTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | import protokt.v1.protokt_file_descriptor 21 | import protokt.v1.util.PROTOKT_EXTENSIONS_CLASS_NAME 22 | 23 | class ProtoktExtensionsTest { 24 | @Test 25 | fun `protokt extensions class name is correct`() { 26 | assertThat(PROTOKT_EXTENSIONS_CLASS_NAME).isEqualTo(protokt_file_descriptor::class.qualifiedName) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testing/options/src/test/kotlin/protokt/v1/testing/SharedSimpleNamesTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import org.junit.jupiter.api.Test 19 | import protokt.v1.testing.pkg.checkDurationTypes 20 | 21 | class SharedSimpleNamesTest { 22 | @Test 23 | fun `check types of each duration`() { 24 | checkDurationTypes(ImportsWrapperModel::class) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testing/plugin-options/lite/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import protokt.v1.gradle.protokt 17 | import protokt.v1.gradle.protoktExtensions 18 | 19 | plugins { 20 | id("protokt.jvm-conventions") 21 | } 22 | 23 | localProtokt() 24 | pureKotlin() 25 | 26 | protokt { 27 | generate { 28 | lite() 29 | } 30 | } 31 | 32 | dependencies { 33 | protoktExtensions(project(":third-party:proto-google-common-protos-extensions-lite")) 34 | 35 | testImplementation(kotlin("reflect")) 36 | 37 | testRuntimeOnly(libs.protobuf.lite) 38 | } 39 | 40 | sourceSets { 41 | test { 42 | java { 43 | srcDir(rootProject.file("shared-src/lite-util")) 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /testing/plugin-options/lite/src/test/kotlin/protokt/v1/testing/lite/LiteOptionTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing.lite 17 | 18 | import org.junit.jupiter.api.Test 19 | import org.junit.jupiter.api.assertThrows 20 | import protokt.v1.util.PROTOKT_EXTENSIONS_CLASS_NAME 21 | 22 | class LiteOptionTest { 23 | @Test 24 | fun `protokt descriptor isn't available`() { 25 | assertThrows { 26 | Class.forName(PROTOKT_EXTENSIONS_CLASS_NAME) 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testing/plugin-options/lite/src/test/kotlin/protokt/v1/testing/pluginoptions/LiteOptionTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing.pluginoptions 17 | 18 | import org.junit.jupiter.api.Test 19 | import org.junit.jupiter.api.assertThrows 20 | 21 | class LiteOptionTest { 22 | @Test 23 | fun `descriptor object doesn't exist`() { 24 | assertThrows { 25 | Class.forName("toasttab.protokt.testing.lite.LiteTest") 26 | } 27 | } 28 | 29 | @Test 30 | fun `service descriptor doesn't exist`() { 31 | assertThrows { 32 | Class.forName("toasttab.protokt.testing.lite.LiteService") 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /testing/protobuf-java/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import com.google.protobuf.gradle.proto 17 | 18 | plugins { 19 | id("protokt.jvm-conventions") 20 | id("com.google.protobuf") 21 | } 22 | 23 | defaultProtoc() 24 | 25 | dependencies { 26 | compileOnly(libs.protobuf.java) 27 | protobuf(project(":extensions:protokt-extensions")) 28 | } 29 | 30 | sourceSets { 31 | main { 32 | proto { 33 | srcDir("${project.rootDir}/testing/interop/src/main/proto") 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /testing/protobufjs/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import protokt.v1.gradle.protoktExtensions 17 | 18 | plugins { 19 | `kotlin-multiplatform` 20 | } 21 | 22 | kotlin { 23 | js(IR) { configureJsTests() } 24 | 25 | sourceSets { 26 | val jsTest by getting { 27 | dependencies { 28 | api(kotlin("test")) 29 | } 30 | } 31 | } 32 | } 33 | 34 | localProtokt() 35 | 36 | dependencies { 37 | protoktExtensions(project(":extensions:protokt-extensions")) 38 | } 39 | -------------------------------------------------------------------------------- /testing/protobufjs/src/main/proto/protokt/v1/testing/js_test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/protokt.proto"; 21 | 22 | message JsTest { 23 | string foo = 1; 24 | } 25 | -------------------------------------------------------------------------------- /testing/protobufjs/src/test/kotlin/protokt/v1/testing/JavaScriptGenerationTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import kotlin.test.Test 19 | import kotlin.test.assertEquals 20 | 21 | class JavaScriptGenerationTest { 22 | @Test 23 | fun test_js_test_round_trip() { 24 | val jsTest = JsTest { foo = "1" } 25 | 26 | val deserialized = JsTest.deserialize(jsTest.serialize()) 27 | 28 | assertEquals(jsTest, deserialized) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /testing/protokt-generation-2/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import protokt.v1.gradle.protoktExtensions 17 | 18 | plugins { 19 | id("protokt.jvm-conventions") 20 | } 21 | 22 | localProtokt() 23 | pureKotlin() 24 | 25 | dependencies { 26 | runtimeOnly(libs.protobuf.java) 27 | 28 | protoktExtensions(project(":testing:protokt-generation")) 29 | } 30 | -------------------------------------------------------------------------------- /testing/protokt-generation-2/src/main/proto/protokt/v1/testing/file_descriptor_name_collision.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | edition = "2023"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/testing/other/file_descriptor_name_collision1.proto"; 21 | 22 | message CollisionBar { 23 | other.CollisionFoo foo = 1; 24 | } 25 | -------------------------------------------------------------------------------- /testing/protokt-generation/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import protokt.v1.gradle.protokt 17 | 18 | plugins { 19 | id("protokt.jvm-conventions") 20 | } 21 | 22 | localProtokt() 23 | pureKotlin() 24 | 25 | protokt { 26 | generate { 27 | types = true 28 | descriptors = true 29 | grpcDescriptors = true 30 | grpcKotlinStubs = true 31 | } 32 | } 33 | 34 | dependencies { 35 | implementation(kotlin("reflect")) 36 | implementation(project(":testing:protobuf-java")) 37 | implementation(libs.grpc.kotlin.stub) 38 | implementation(libs.grpc.stub) 39 | 40 | testImplementation(libs.jackson) 41 | 42 | testRuntimeOnly(libs.protobuf.java) 43 | } 44 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/kotlin/protokt/v1/testing/PropertyUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import kotlin.reflect.KClass 19 | import kotlin.reflect.full.declaredMemberProperties 20 | 21 | fun KClass<*>.propertyNamed(name: String) = 22 | declaredMemberProperties.single { it.name == name } 23 | 24 | fun KClass<*>.propertyType(name: String) = 25 | propertyNamed(name).returnType 26 | 27 | fun KClass<*>.propertyIsMarkedNullable(name: String) = 28 | propertyType(name).isMarkedNullable 29 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/no_package.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | message NoPackage {} 19 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/basic_enums.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | message HasAnEnum { 21 | SomeEnum enum = 1; 22 | } 23 | 24 | enum SomeEnum { 25 | VALUE = 0; 26 | VALUE_2 = 1; 27 | } 28 | 29 | message HasMoreEnum { 30 | MoreEnum enum = 1; 31 | } 32 | 33 | enum MoreEnum { 34 | MORE_VALUE = 0; 35 | MORE_VALUE_2 = 1; 36 | MORE_VALUE_3 = 2; 37 | } 38 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/data/evil_names.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | // This is in a different packages since the test was created because of a bug 19 | // that triggered with reserved keywords (specifically `data`) in the package name. 20 | package protokt.v1.testing.data; 21 | 22 | message Foo { 23 | bool data = 1; 24 | bool null = 2; 25 | bool abstract = 3; 26 | bool continue = 4; 27 | } 28 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/data/import_evil_names.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing.data; 19 | 20 | import "protokt/v1/testing/data/evil_names.proto"; 21 | 22 | message Bar { 23 | Foo foo = 1; 24 | } 25 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/defines_nested_enum.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | message DefinesNestedEnum { 21 | enum NestedEnum { 22 | ZEROTH = 0; 23 | FIRST = 1; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/edition_2023_presence_file_legacy_required.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | edition = "2023"; 17 | 18 | package protokt.v1.testing; 19 | 20 | // not allowed: option features.field_presence = LEGACY_REQUIRED; 21 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/enum_oneof_name_conflict.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | message NamesOneofFoo { 21 | Foo2 foo_field = 1; 22 | 23 | oneof Foo2 { 24 | Foo2 foo = 2; 25 | } 26 | } 27 | 28 | enum Foo2 { 29 | FOO = 0; 30 | } 31 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/enums_across_packages.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/testing/other/other_package.proto"; 21 | 22 | message UsesOtherPackageEnum { 23 | other.OtherPackageMessage.OtherPackageEnum enum = 1; 24 | } 25 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/file_descriptor_name_collision1.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | message CollisionFoo {} 21 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/import_nested_enums.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "protokt/v1/testing/defines_nested_enum.proto"; 21 | 22 | message UsesNestedEnumInDifferentFileSamePackage { 23 | DefinesNestedEnum.NestedEnum value = 1; 24 | } 25 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/json_serialization.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "google/protobuf/wrappers.proto"; 21 | 22 | message RootMessage { 23 | string field = 1; 24 | 25 | oneof oneof_field { 26 | string name = 3; 27 | } 28 | } 29 | 30 | enum AnEnum { 31 | FIRST = 0; 32 | } 33 | 34 | message ToDeserialize { 35 | google.protobuf.StringValue string_value = 1; 36 | 37 | RootMessage message = 2; 38 | 39 | AnEnum enum = 3; 40 | } 41 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/nested_message_used_as_field.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | message Foo1 { 21 | message Bar {} 22 | } 23 | 24 | message Baz1 { 25 | Foo1.Bar bar = 1; 26 | } 27 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/oneof/child/child_package.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing.oneof.child; 19 | 20 | message ChildPackageMessage {} 21 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/oneof/shared_name.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing.oneof; 19 | 20 | message MessageName { 21 | oneof message_name { 22 | string child = 1; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/other/file_descriptor_name_collision1.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing.other; 19 | 20 | message CollisionFoo {} 21 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/other/model.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing.other; 19 | 20 | message Model {} 21 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/other/other_package.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing.other; 19 | 20 | message OtherPackageMessage { 21 | enum OtherPackageEnum { 22 | FIRST = 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/poor_naming_conventions.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | import "google/protobuf/empty.proto"; 21 | 22 | service Greeter { 23 | // Lower case initial 's' 24 | rpc sayHello (google.protobuf.Empty) returns (google.protobuf.Empty) {} 25 | } 26 | 27 | message BadFieldName { 28 | string fooBar = 1; 29 | } 30 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/proto2_maps.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto2"; 17 | 18 | package protokt.v1.testing; 19 | 20 | message TestProto2Maps { 21 | map val = 1; 22 | } 23 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/proto3_optional.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | message TestProto3Optional { 21 | optional int32 optional_int32 = 1; 22 | optional string optional_string = 2; 23 | 24 | // doesn't do anything, but must be supported 25 | optional Foo optional_foo = 3; 26 | } 27 | 28 | message Foo {} 29 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/service_package.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | service TestService {} 21 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/service_with_java_multiple_files_false.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | service TestService2 { 21 | rpc SayHello (TestRequest2) returns (TestReply2) {} 22 | } 23 | 24 | message TestRequest2 { 25 | string message = 1; 26 | } 27 | 28 | message TestReply2 { 29 | string message = 1; 30 | } 31 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/service_with_java_multiple_files_true.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | 20 | package protokt.v1.testing; 21 | 22 | service TestService3 { 23 | rpc SayHello (TestRequest3) returns (TestReply3) {} 24 | } 25 | 26 | message TestRequest3 { 27 | string message = 1; 28 | } 29 | 30 | message TestReply3 { 31 | string message = 1; 32 | } 33 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/to_string_test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | message ToStringTestEmpty {} 21 | 22 | message ToStringTest2 { 23 | bytes val = 1; 24 | string extra = 2; 25 | } 26 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/main/proto/protokt/v1/testing/uses_null.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | syntax = "proto3"; 17 | 18 | package protokt.v1.testing; 19 | 20 | message MyMessage { 21 | oneof my_oneof { 22 | int32 something = 1; 23 | int32 null = 2; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/test/kotlin/protokt/v1/testing/EnumTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | 21 | class EnumTest { 22 | @Test 23 | fun `round trip preserves unknown enums`() { 24 | val with3 = HasMoreEnum { enum = MoreEnum.MORE_VALUE_3 } 25 | val as2 = HasAnEnum.deserialize(with3.serialize()) 26 | 27 | assertThat(as2.enum).isEqualTo(SomeEnum.from(2)) 28 | 29 | val as3From2 = HasMoreEnum.deserialize(as2.serialize()) 30 | 31 | assertThat(as3From2.enum).isEqualTo(MoreEnum.MORE_VALUE_3) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/test/kotlin/protokt/v1/testing/EvilNamesTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | import protokt.v1.testing.data.evil_names_file_descriptor 21 | import protokt.v1.testing.data.import_evil_names_file_descriptor 22 | 23 | class EvilNamesTest { 24 | @Test 25 | fun `ensure package has reserved word in package name`() { 26 | assertThat(evil_names_file_descriptor::class.qualifiedName).contains(".data.") 27 | assertThat(import_evil_names_file_descriptor::class.qualifiedName).contains(".data.") 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/test/kotlin/protokt/v1/testing/PoorNamingConventionsTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | 21 | class PoorNamingConventionsTest { 22 | @Test 23 | fun `camel case proto name matches protobuf-java convention`() { 24 | val foo = BadFieldName { fooBar = "foobar" } 25 | assertThat(foo.fooBar).isEqualTo("foobar") 26 | assertThat(BadFieldName::class.propertyNamed("fooBar")).isNotNull() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/test/kotlin/protokt/v1/testing/SchemaDescriptorTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | import protokt.v1.grpc.SchemaDescriptor 21 | import protokt.v1.grpc.fileDescriptor 22 | 23 | class SchemaDescriptorTest { 24 | @Test 25 | fun `schemaDescriptor has correct file descriptor`() { 26 | val schemaDescriptor = TestServiceGrpc.getServiceDescriptor().schemaDescriptor as SchemaDescriptor 27 | assertThat(schemaDescriptor.fileDescriptor.proto) 28 | .isEqualTo(service_package_file_descriptor.descriptor.proto) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /testing/protokt-generation/src/test/kotlin/protokt/v1/testing/ServicePackageTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.testing 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | 21 | class ServicePackageTest { 22 | @Test 23 | fun `service has protobuf package`() { 24 | assertThat(TestServiceGrpc.SERVICE_NAME.substringBeforeLast(".")) 25 | .isEqualTo("protokt.v1.testing") 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /testing/testing-util/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.jvm-conventions") 18 | } 19 | 20 | dependencies { 21 | implementation(libs.junit.jupiter) 22 | } 23 | -------------------------------------------------------------------------------- /third-party/proto-google-common-protos-extensions-lite/api/proto-google-common-protos-extensions-lite.api: -------------------------------------------------------------------------------- 1 | public final class protokt/v1/google/type/LocalDateConverter : protokt/v1/AbstractConverter { 2 | public static final field INSTANCE Lprotokt/v1/google/type/LocalDateConverter; 3 | public synthetic fun unwrap (Ljava/lang/Object;)Ljava/lang/Object; 4 | public fun unwrap (Ljava/time/LocalDate;)Lprotokt/v1/google/type/Date; 5 | public synthetic fun wrap (Ljava/lang/Object;)Ljava/lang/Object; 6 | public fun wrap (Lprotokt/v1/google/type/Date;)Ljava/time/LocalDate; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /third-party/proto-google-common-protos-extensions-lite/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.jvm-conventions") 18 | id("protokt.third-party-conventions") 19 | kotlin("kapt") 20 | } 21 | 22 | enablePublishing() 23 | trackKotlinApiCompatibility() 24 | 25 | dependencies { 26 | api(project(":extensions:protokt-extensions-lite")) 27 | api(project(":third-party:proto-google-common-protos-lite")) 28 | 29 | implementation(libs.autoServiceAnnotations) 30 | 31 | kapt(libs.autoService) 32 | } 33 | -------------------------------------------------------------------------------- /third-party/proto-google-common-protos-extensions/api/proto-google-common-protos-extensions.api: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-toast/protokt/0f255be579c15a14795778cbaa40d85c6ea208b9/third-party/proto-google-common-protos-extensions/api/proto-google-common-protos-extensions.api -------------------------------------------------------------------------------- /third-party/proto-google-common-protos-extensions/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | plugins { 17 | id("protokt.jvm-conventions") 18 | id("protokt.third-party-conventions") 19 | } 20 | 21 | enablePublishing() 22 | trackKotlinApiCompatibility() 23 | 24 | dependencies { 25 | api(project(":extensions:protokt-extensions")) 26 | api(project(":third-party:proto-google-common-protos")) 27 | api(project(":third-party:proto-google-common-protos-extensions-lite")) 28 | } 29 | -------------------------------------------------------------------------------- /third-party/proto-google-common-protos-grpc-kotlin/src/test/kotlin/protokt/v1/google/longrunning/ExistenceTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.longrunning 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | 21 | class ExistenceTest { 22 | @Test 23 | fun `stubs exist`() { 24 | assertThat(OperationsGrpcKt::class).isNotNull() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /third-party/proto-google-common-protos-grpc/api/proto-google-common-protos-grpc.api: -------------------------------------------------------------------------------- 1 | public final class protokt/v1/google/cloud/location/LocationsGrpc { 2 | public static final field INSTANCE Lprotokt/v1/google/cloud/location/LocationsGrpc; 3 | public static final field SERVICE_NAME Ljava/lang/String; 4 | public static final fun getGetLocationMethod ()Lio/grpc/MethodDescriptor; 5 | public static final fun getListLocationsMethod ()Lio/grpc/MethodDescriptor; 6 | public static final fun getServiceDescriptor ()Lio/grpc/ServiceDescriptor; 7 | } 8 | 9 | public final class protokt/v1/google/longrunning/OperationsGrpc { 10 | public static final field INSTANCE Lprotokt/v1/google/longrunning/OperationsGrpc; 11 | public static final field SERVICE_NAME Ljava/lang/String; 12 | public static final fun getCancelOperationMethod ()Lio/grpc/MethodDescriptor; 13 | public static final fun getDeleteOperationMethod ()Lio/grpc/MethodDescriptor; 14 | public static final fun getGetOperationMethod ()Lio/grpc/MethodDescriptor; 15 | public static final fun getListOperationsMethod ()Lio/grpc/MethodDescriptor; 16 | public static final fun getServiceDescriptor ()Lio/grpc/ServiceDescriptor; 17 | public static final fun getWaitOperationMethod ()Lio/grpc/MethodDescriptor; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /third-party/proto-google-common-protos-grpc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import protokt.v1.gradle.protokt 17 | 18 | plugins { 19 | id("protokt.jvm-conventions") 20 | id("protokt.third-party-conventions") 21 | } 22 | 23 | localProtokt() 24 | pureKotlin() 25 | enablePublishing() 26 | compatibleWithAndroid() 27 | trackKotlinApiCompatibility() 28 | 29 | protokt { 30 | generate { 31 | types = false 32 | descriptors = false 33 | grpcDescriptors = true 34 | } 35 | } 36 | 37 | dependencies { 38 | protobufExcludingProtobufJava(libs.protoGoogleCommonProtos) 39 | 40 | api(project(":third-party:proto-google-common-protos")) 41 | api(libs.grpc.stub) 42 | } 43 | -------------------------------------------------------------------------------- /third-party/proto-google-common-protos-grpc/src/test/kotlin/protokt/v1/google/longrunning/ExistenceTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.longrunning 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.jupiter.api.Test 20 | 21 | class ExistenceTest { 22 | @Test 23 | fun `descriptors exist`() { 24 | assertThat(OperationsGrpc::class).isNotNull() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /third-party/proto-google-common-protos-lite/src/commonTest/kotlin/protokt/v1/google/api/ExistenceTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.api 17 | 18 | import kotlin.test.Test 19 | import kotlin.test.assertNotNull 20 | 21 | class ExistenceTest { 22 | @Test 23 | fun generated_messages_exist() { 24 | assertNotNull(Authentication::class) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /third-party/proto-google-common-protos/src/commonTest/kotlin/protokt/v1/google/api/ExistenceTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Toast, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package protokt.v1.google.api 17 | 18 | import kotlin.test.Test 19 | import kotlin.test.assertNotNull 20 | 21 | class ExistenceTest { 22 | @Test 23 | fun descriptors_exist() { 24 | assertNotNull(auth_file_descriptor::class) 25 | } 26 | } 27 | --------------------------------------------------------------------------------