diff --git a/hll/build.gradle.kts b/hll/build.gradle.kts index 257a2d7f9a0..ddd1bdcee90 100644 --- a/hll/build.gradle.kts +++ b/hll/build.gradle.kts @@ -28,6 +28,7 @@ val sdkVersion: String by project val libraries = libs val optinAnnotations = listOf( + "aws.smithy.kotlin.runtime.ExperimentalApi", "aws.smithy.kotlin.runtime.InternalApi", "aws.sdk.kotlin.runtime.InternalSdkApi", "kotlin.RequiresOptIn", diff --git a/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/DataTypeGenerator.kt b/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/DataTypeGenerator.kt index c1106bdfd14..1e636f6fe4b 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/DataTypeGenerator.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/DataTypeGenerator.kt @@ -60,7 +60,9 @@ internal class DataTypeGenerator( private val structure: Structure, ) : CodeGenerator by generator { fun generate() { + write("@#T", Types.Smithy.ExperimentalApi) withBlock("public interface #T {", "}", structure.type) { + write("@#T", Types.Smithy.ExperimentalApi) write("public companion object { }") // leave room for future expansion blankLine() members { write("public val #L: #T", name, type) } @@ -83,6 +85,7 @@ internal class DataTypeGenerator( BuilderRenderer(this, structure.type, implType, structure.members, builderCtx).render() blankLine() + write("@#T", Types.Smithy.ExperimentalApi) withBlock( "public fun #1L#2T.toBuilder(): #3L#4L = #3L#4L().apply {", "}", @@ -95,6 +98,7 @@ internal class DataTypeGenerator( } blankLine() + write("@#T", Types.Smithy.ExperimentalApi) withBlock( "public fun #1L#2T.copy(block: #3L#4L.() -> Unit): #2T =", "", @@ -107,6 +111,7 @@ internal class DataTypeGenerator( } blankLine() + write("@#T", Types.Smithy.ExperimentalApi) withBlock( "public fun #L#L(block: #L#L.() -> Unit): #T =", "", diff --git a/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/OperationsTypeRenderer.kt b/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/OperationsTypeRenderer.kt index 2a6834763a9..1b6b4a428ef 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/OperationsTypeRenderer.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/OperationsTypeRenderer.kt @@ -105,7 +105,7 @@ internal class OperationsTypeRenderer( write("operations after mapping objects to items and vice versa") write("@param T The type of objects which will be read from and/or written to this #L", entityName) } - + write("@#T", Types.Smithy.ExperimentalApi) writeInline("public interface #T ", interfaceType) parentType?.let { writeInline(": #T ", parentType) } diff --git a/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/PaginatorRenderer.kt b/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/PaginatorRenderer.kt index e4fc8f6097a..b719ca75006 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/PaginatorRenderer.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/PaginatorRenderer.kt @@ -112,6 +112,7 @@ internal class PaginatorRenderer( private fun renderItemsPaginator() { val jvmName = "${op.methodName}${paginationInfo.items.name.capitalizeFirstChar}" + write("@#T", Types.Smithy.ExperimentalApi) write("@#T(#S)", Types.Kotlin.Jvm.JvmName, jvmName) withBlock("public fun #T.items(): #T =", "", pageFlowType, itemFlowType) { withBlock("#T { page ->", "}", Types.Kotlinx.Coroutines.Flow.transform) { @@ -123,6 +124,7 @@ internal class PaginatorRenderer( } private fun renderPaginatorWithDsl() { + write("@#T", Types.Smithy.ExperimentalApi) writeInline("public inline fun ") extensionOf?.let { writeInline("#T.", extensionOf) } @@ -139,6 +141,7 @@ internal class PaginatorRenderer( } private fun renderPaginatorWithRequest() { + write("@#T", Types.Smithy.ExperimentalApi) writeInline("public fun ") extensionOf?.let { writeInline("#T.", extensionOf) } diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/annotations/rendering/SchemaRenderer.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/annotations/rendering/SchemaRenderer.kt index d3a2a49d9c3..81dca0d50a6 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/annotations/rendering/SchemaRenderer.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/annotations/rendering/SchemaRenderer.kt @@ -103,6 +103,7 @@ internal class SchemaRenderer( } private fun renderItemConverter() { + write("@#T", Types.Smithy.ExperimentalApi) withBlock("#Lobject #L : #T by #T(", ")", ctx.attributes.visibility, converterName, MapperTypes.Items.itemConverter(classType), MapperTypes.Items.SimpleItemConverter) { if (shouldRenderBuilder) { write("builderFactory = ::#L,", builderName) @@ -127,6 +128,7 @@ internal class SchemaRenderer( */ private fun renderValueConverter() { // TODO Offer alternate serialization options besides AttributeValue.M? + write("@#T", Types.Smithy.ExperimentalApi) write( "#Lval #L : #T = #T.#T(#T)", ctx.attributes.visibility, @@ -275,6 +277,7 @@ internal class SchemaRenderer( MapperTypes.Items.itemSchemaPartitionKey(classType, partitionKeyProp.typeRef) } + write("@#T", Types.Smithy.ExperimentalApi) withBlock("#Lobject #L : #T {", "}", ctx.attributes.visibility, schemaName, schemaType) { write("override val converter : #1T = #1T", itemConverter) write("override val partitionKey: #T = #T(#S)", MapperTypes.Items.keySpec(partitionKeyProp.keySpec), partitionKeyProp.keySpecType, partitionKeyProp.name) @@ -305,6 +308,7 @@ internal class SchemaRenderer( docs("Returns a reference to a table named [name] containing items representing [#T]", classType) val fnName = "get${className}Table" + write("@#T", Types.Smithy.ExperimentalApi) write( "#Lfun #T.#L(name: String): #T = #L(name, #L)", ctx.attributes.visibility, diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPlugin.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPlugin.kt index fd50cafe600..93fdeb18312 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPlugin.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPlugin.kt @@ -6,12 +6,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.plugins import aws.sdk.kotlin.hll.codegen.rendering.RenderOptions import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.AnnotationsProcessorOptions +import aws.smithy.kotlin.runtime.ExperimentalApi import com.google.devtools.ksp.gradle.KspExtension import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.create +@ExperimentalApi public class SchemaGeneratorPlugin : Plugin { override fun apply(project: Project): Unit = project.run { val extension = createExtension() diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginExtension.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginExtension.kt index a0a53649f6d..5e9df6b7239 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginExtension.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginExtension.kt @@ -1,12 +1,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.plugins import aws.sdk.kotlin.hll.codegen.rendering.Visibility -import aws.sdk.kotlin.hll.codegen.rendering.Visibility.PUBLIC import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.DestinationPackage import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.GenerateBuilderClasses +import aws.smithy.kotlin.runtime.ExperimentalApi internal const val SCHEMA_GENERATOR_PLUGIN_EXTENSION = "dynamoDbMapper" +@ExperimentalApi public open class SchemaGeneratorPluginExtension { /** * Determines when a builder class should be generated for user classes. Defaults to "WHEN_REQUIRED". diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginTest.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginTest.kt index d538ea69608..9df663251e4 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginTest.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginTest.kt @@ -203,6 +203,9 @@ class SchemaGeneratorPluginTest { fun testGenerateBuilderOption() { val pluginConfiguration = """ import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.GenerateBuilderClasses + import aws.smithy.kotlin.runtime.ExperimentalApi + + @OptIn(ExperimentalApi::class) dynamoDbMapper { generateBuilderClasses = GenerateBuilderClasses.ALWAYS } @@ -233,6 +236,9 @@ class SchemaGeneratorPluginTest { fun testVisibilityOption() { val pluginConfiguration = """ import aws.sdk.kotlin.hll.codegen.rendering.Visibility + import aws.smithy.kotlin.runtime.ExperimentalApi + + @OptIn(ExperimentalApi::class) dynamoDbMapper { visibility = Visibility.INTERNAL } @@ -260,6 +266,9 @@ class SchemaGeneratorPluginTest { @Test fun testGenerateGetTableFunctionOption() { val pluginConfiguration = """ + import aws.smithy.kotlin.runtime.ExperimentalApi + + @OptIn(ExperimentalApi::class) dynamoDbMapper { generateGetTableExtension = false } @@ -288,6 +297,9 @@ class SchemaGeneratorPluginTest { fun testRelativeDestinationPackage() { val pluginConfiguration = """ import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.DestinationPackage + import aws.smithy.kotlin.runtime.ExperimentalApi + + @OptIn(ExperimentalApi::class) dynamoDbMapper { destinationPackage = DestinationPackage.Relative("hello.moto") } @@ -312,6 +324,9 @@ class SchemaGeneratorPluginTest { fun testAbsoluteDestinationPackage() { val pluginConfiguration = """ import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.DestinationPackage + import aws.smithy.kotlin.runtime.ExperimentalApi + + @OptIn(ExperimentalApi::class) dynamoDbMapper { destinationPackage = DestinationPackage.Absolute("absolutely.my.`package`") } diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/custom-item-converter/CustomItemConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/custom-item-converter/CustomItemConverter.kt index 6c9f12cde5d..abe58305992 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/custom-item-converter/CustomItemConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/custom-item-converter/CustomItemConverter.kt @@ -5,8 +5,10 @@ import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemConverter import aws.sdk.kotlin.hll.dynamodbmapper.items.SimpleItemConverter import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.IntConverter import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.StringConverter +import aws.smithy.kotlin.runtime.ExperimentalApi import org.example.CustomUser +@OptIn(ExperimentalApi::class) public object MyCustomUserConverter : ItemConverter by SimpleItemConverter( builderFactory = { CustomUser() }, build = { this }, diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/ListsTest.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/ListsTest.kt index 646da3942d7..eb68e343e9b 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/ListsTest.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/ListsTest.kt @@ -4,10 +4,12 @@ */ package org.example +import aws.smithy.kotlin.runtime.ExperimentalApi import org.example.dynamodbmapper.generatedschemas.ListsConverter import kotlin.test.Test import kotlin.test.assertEquals +@OptIn(ExperimentalApi::class) public class ListsTest { @Test fun converterTest() { diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/MapsTest.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/MapsTest.kt index 68148262c0f..3136f21deed 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/MapsTest.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/MapsTest.kt @@ -4,10 +4,12 @@ */ package org.example +import aws.smithy.kotlin.runtime.ExperimentalApi import org.example.dynamodbmapper.generatedschemas.MapsConverter import kotlin.test.Test import kotlin.test.assertEquals +@OptIn(ExperimentalApi::class) public class MapsTest { @Test fun converterTest() { diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/PrimitivesTest.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/PrimitivesTest.kt index 6566b72677a..7c62575deef 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/PrimitivesTest.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/PrimitivesTest.kt @@ -4,6 +4,7 @@ */ package org.example +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.smithy.kotlin.runtime.content.Document import aws.smithy.kotlin.runtime.net.url.Url import aws.smithy.kotlin.runtime.time.Instant @@ -11,6 +12,7 @@ import org.example.dynamodbmapper.generatedschemas.PrimitivesConverter import kotlin.test.Test import kotlin.test.assertEquals +@OptIn(ExperimentalApi::class) public class PrimitivesTest { @Test fun converterTest() { diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/SetsTest.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/SetsTest.kt index 6465f1cbe5c..124de3405c8 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/SetsTest.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/standard-item-converters/test/SetsTest.kt @@ -4,10 +4,12 @@ */ package org.example +import aws.smithy.kotlin.runtime.ExperimentalApi import org.example.dynamodbmapper.generatedschemas.SetsConverter import kotlin.test.Test import kotlin.test.assertEquals +@OptIn(ExperimentalApi::class) public class SetsTest { @Test fun converterTest() { diff --git a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/tests/UserTest.kt b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/tests/UserTest.kt index 7a11c1e660a..bead735690a 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/tests/UserTest.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/tests/UserTest.kt @@ -6,10 +6,12 @@ package org.example import aws.sdk.kotlin.hll.dynamodbmapper.model.itemOf import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi import org.example.dynamodbmapper.generatedschemas.UserConverter import kotlin.test.Test import kotlin.test.assertEquals +@OptIn(ExperimentalApi::class) class UserTest { @Test fun testConversion() { diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/DynamoDbMapper.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/DynamoDbMapper.kt index 81466f87d17..2a7f590862b 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/DynamoDbMapper.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/DynamoDbMapper.kt @@ -11,11 +11,14 @@ import aws.sdk.kotlin.hll.dynamodbmapper.model.Table import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.Interceptor import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.InterceptorAny import aws.sdk.kotlin.services.dynamodb.DynamoDbClient +import aws.smithy.kotlin.runtime.ExperimentalApi /** * A high-level client for DynamoDB which maps custom data types into DynamoDB attributes and vice versa. */ +@ExperimentalApi public interface DynamoDbMapper { + @ExperimentalApi public companion object { /** * Instantiate a new [Config] object @@ -109,6 +112,7 @@ public interface DynamoDbMapper { * @param client The low-level DynamoDB client to use for underlying calls to the service * @param config A DSL configuration block */ +@ExperimentalApi public fun DynamoDbMapper( client: DynamoDbClient, config: DynamoDbMapper.Config.Builder.() -> Unit = { }, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/annotations/ManualPagination.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/annotations/ManualPagination.kt index dad2142839d..3f0583a1dd8 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/annotations/ManualPagination.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/annotations/ManualPagination.kt @@ -4,9 +4,12 @@ */ package aws.sdk.kotlin.hll.dynamodbmapper.annotations +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Indicates that an operation invocation method (e.g., `query`) does not provide automatic pagination. While desirable * in advanced scenarios, the typical use case should favor the paginated equivalent (e.g., `queryPaginated`). */ +@ExperimentalApi @RequiresOptIn(message = "This method does not provide automatic pagination over results and should only be used in advanced scenarios. Where possible, consider using the paginated equivalent. To explicitly opt into using this method, annotate the call site with `@OptIn(ManualPagination::class)`.") public annotation class ManualPagination(val paginatedEquivalent: String) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AndExpr.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AndExpr.kt index 92265ad7838..f19a5bdef39 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AndExpr.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AndExpr.kt @@ -5,12 +5,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.AndExprImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents an `AND` expression as described in * [DynamoDB's **logical evaluations** documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations). * This expression will be true if `(operand[0] && operand[1] && ... && operand[n - 1])`. */ +@ExperimentalApi public interface AndExpr : BooleanExpr { /** * A list of 2 or more [BooleanExpr] conditions which are ANDed together @@ -24,4 +26,5 @@ public interface AndExpr : BooleanExpr { * Creates a new [AndExpr] with the given [operands] * @param operands A list of 2 or more [BooleanExpr] conditions which are ANDed together */ +@ExperimentalApi public fun AndExpr(operands: List): AndExpr = AndExprImpl(operands) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AttributePath.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AttributePath.kt index e57468ee847..7c6c3cff2d5 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AttributePath.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AttributePath.kt @@ -7,14 +7,17 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.AttrPathIndexImpl import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.AttrPathNameImpl import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.AttributePathImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents an element in an [AttributePath] */ +@ExperimentalApi public sealed interface AttrPathElement { /** * Represents the name of a top-level attribute or a key in a map */ + @ExperimentalApi public interface Name : AttrPathElement { /** * The name or key of this element @@ -25,6 +28,7 @@ public sealed interface AttrPathElement { /** * Represents an index into a list/set */ + @ExperimentalApi public interface Index : AttrPathElement { /** * The index (starting at `0`) @@ -42,6 +46,7 @@ public sealed interface AttrPathElement { * * See [Filter] for more information about creating references to attributes. */ +@ExperimentalApi public interface AttributePath : Expression { /** * The [AttrPathElement] for this path @@ -63,6 +68,7 @@ public interface AttributePath : Expression { * @param parent The parent [AttributePath] (if any) of this element. If [parent] is `null` then this instance * represents a top-level attribute. */ +@ExperimentalApi public fun AttributePath(name: String, parent: AttributePath? = null): AttributePath = AttributePathImpl(AttrPathNameImpl(name), parent) @@ -71,5 +77,6 @@ public fun AttributePath(name: String, parent: AttributePath? = null): Attribute * @param index The index (starting at `0`) of this element * @param parent The parent [AttributePath] of this element */ +@ExperimentalApi public fun AttributePath(index: Int, parent: AttributePath): AttributePath = AttributePathImpl(AttrPathIndexImpl(index), parent) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AttributeType.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AttributeType.kt index eec2c1b4152..b183cc71b05 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AttributeType.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/AttributeType.kt @@ -4,11 +4,14 @@ */ package aws.sdk.kotlin.hll.dynamodbmapper.expressions +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Represents a * [DynamoDB attribute data type](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes) * @param abbreviation The DynamoDB type name */ +@ExperimentalApi public enum class AttributeType(public val abbreviation: kotlin.String) { /** * Binary data type, denoted in DynamoDB as `B` diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BetweenExpr.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BetweenExpr.kt index 676937cf780..2c7f3554b2f 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BetweenExpr.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BetweenExpr.kt @@ -5,12 +5,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.BetweenExprImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents a `BETWEEN` expression as described in * [DynamoDB's **making comparisons** documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators). * This expression will be true if `value >= min && value <= max`. */ +@ExperimentalApi public interface BetweenExpr : BooleanExpr, SortKeyExpr { @@ -38,5 +40,6 @@ public interface BetweenExpr : * @param min The minimum bound for the comparison * @param max The maximum bound for the comparison */ +@ExperimentalApi public fun BetweenExpr(value: Expression, min: Expression, max: Expression): BetweenExpr = BetweenExprImpl(value, min, max) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BooleanFunc.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BooleanFunc.kt index 1b6e222fd6a..306384770b9 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BooleanFunc.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BooleanFunc.kt @@ -4,12 +4,15 @@ */ package aws.sdk.kotlin.hll.dynamodbmapper.expressions +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Identifies a * [DynamoDB expression function](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions) * which returns a boolean value * @param exprString The literal name of the function to use in expression strings */ +@ExperimentalApi public enum class BooleanFunc(public val exprString: String) { /** * The `attribute_exist` function diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BooleanFuncExpr.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BooleanFuncExpr.kt index 8d466256cda..3c02bc1f294 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BooleanFuncExpr.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/BooleanFuncExpr.kt @@ -5,11 +5,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.BooleanFuncExprImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents a function expression that yields a boolean result as described in * [DynamoDB's **function** documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions) */ +@ExperimentalApi public interface BooleanFuncExpr : BooleanExpr, SortKeyExpr { @@ -37,6 +39,7 @@ public interface BooleanFuncExpr : * @param path The attribute path to pass as the function's first argument * @param additionalOperands Any additional arguments used by the function */ +@ExperimentalApi public fun BooleanFuncExpr( func: BooleanFunc, path: AttributePath, @@ -49,6 +52,7 @@ public fun BooleanFuncExpr( * @param path The attribute path to pass as the function's first argument * @param additionalOperands Any additional arguments used by the function */ +@ExperimentalApi public fun BooleanFuncExpr( func: BooleanFunc, path: AttributePath, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Comparator.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Comparator.kt index d93b5d61093..d6af9ab2426 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Comparator.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Comparator.kt @@ -4,10 +4,13 @@ */ package aws.sdk.kotlin.hll.dynamodbmapper.expressions +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Identifies a comparison operator to use in an expression * @param exprString The literal value of the operator to use in an expression string */ +@ExperimentalApi public enum class Comparator(public val exprString: String) { /** * An equality comparison, equivalent to `==` in Kotlin and to `=` in DynamoDB diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ComparisonExpr.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ComparisonExpr.kt index c6d4772db80..4c428f6893a 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ComparisonExpr.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ComparisonExpr.kt @@ -5,12 +5,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.ComparisonExprImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents a comparison expression as described in * [DynamoDB's **making comparisons** documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators). * The specific type of comparison is identified by the [comparator] field. */ +@ExperimentalApi public interface ComparisonExpr : BooleanExpr, SortKeyExpr { @@ -38,5 +40,6 @@ public interface ComparisonExpr : * @param left The left value being compared * @param right The right value being compared */ +@ExperimentalApi public fun ComparisonExpr(comparator: Comparator, left: Expression, right: Expression): ComparisonExpr = ComparisonExprImpl(comparator, left, right) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ExpressionVisitor.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ExpressionVisitor.kt index 2ed03f5b845..7619089b85b 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ExpressionVisitor.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ExpressionVisitor.kt @@ -4,10 +4,13 @@ */ package aws.sdk.kotlin.hll.dynamodbmapper.expressions +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * A [visitor](https://en.wikipedia.org/wiki/Visitor_pattern) that can traverse an [Expression] * @param T The type of value used for state tracking by this visitor */ +@ExperimentalApi public interface ExpressionVisitor { /** * Visit an [AndExpr] diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Expressions.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Expressions.kt index f11025da72b..f212d18e1ac 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Expressions.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Expressions.kt @@ -4,6 +4,8 @@ */ package aws.sdk.kotlin.hll.dynamodbmapper.expressions +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Represents any kind of expression. This is an abstract top-level interface and describes no details about an * expression on its own. Expressions may be of various specific types (e.g., [AttributePath], [ComparisonExpr], @@ -12,6 +14,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions * [Expression] and its derivatives support the [visitor design pattern](https://en.wikipedia.org/wiki/Visitor_pattern) * by way of an [accept] method. */ +@ExperimentalApi public sealed interface Expression { /** * Accepts a visitor that is traversing an expression tree by dispatching to a subtype implementation. Subtype @@ -27,6 +30,7 @@ public sealed interface Expression { * items. This is a [marker interface](https://en.wikipedia.org/wiki/Marker_interface_pattern) which adds no additional * declarations. */ +@ExperimentalApi public sealed interface BooleanExpr : Expression /** @@ -34,4 +38,5 @@ public sealed interface BooleanExpr : Expression * key. This is a [marker interface](https://en.wikipedia.org/wiki/Marker_interface_pattern) which adds no additional * declarations. */ +@ExperimentalApi public sealed interface SortKeyExpr : Expression diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Filter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Filter.kt index 9261dda9cb8..98c966b0199 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Filter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Filter.kt @@ -5,6 +5,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.util.dynamicAttr +import aws.smithy.kotlin.runtime.ExperimentalApi /** * A DSL interface providing support for "low-level" filter expressions. Implementations of this interface provide @@ -179,6 +180,7 @@ import aws.sdk.kotlin.hll.dynamodbmapper.util.dynamicAttr * attr("bar").exists() // Checks whether any value exists for `bar` (including `null`) * ``` */ +@ExperimentalApi public interface Filter { // ATTRIBUTES diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/InExpr.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/InExpr.kt index ed4f320e4af..6c2d009f6d8 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/InExpr.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/InExpr.kt @@ -5,12 +5,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.InExprImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents an `IN` expression as described in * [DynamoDB's **making comparisons** documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators). * This expression will be true if `value in set` (or, equivalently, if `set.contains(value)`). */ +@ExperimentalApi public interface InExpr : BooleanExpr { /** * The value to check for in [set] @@ -30,4 +32,5 @@ public interface InExpr : BooleanExpr { * @param value The value to check for in [set] * @param set The set of values to compare against [value] */ +@ExperimentalApi public fun InExpr(value: Expression, set: Collection): InExpr = InExprImpl(value, set) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/KeyFilter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/KeyFilter.kt index ad10c72d76c..b807ac912e3 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/KeyFilter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/KeyFilter.kt @@ -6,11 +6,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.KeyFilterImpl import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.SortKeyFilterImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents a filter which limits a Query operation to a specific partition key and optional sort key criteria (if * applicable) */ +@ExperimentalApi public interface KeyFilter { /** * The required value of the partition key @@ -28,6 +30,7 @@ public interface KeyFilter { * @param partitionKey The value required for the partition key. This must be set to a byte array, string, or number * (including unsigned numbers). */ +@ExperimentalApi public fun KeyFilter(partitionKey: Any): KeyFilter = KeyFilterImpl(partitionKey, null) /** @@ -37,5 +40,6 @@ public fun KeyFilter(partitionKey: Any): KeyFilter = KeyFilterImpl(partitionKey, * (including unsigned numbers). * @param sortKey A DSL block that sets the condition for the sort key. See [SortKeyFilter] for more details. */ +@ExperimentalApi public fun KeyFilter(partitionKey: Any, sortKey: SortKeyFilter.() -> SortKeyExpr): KeyFilter = KeyFilterImpl(partitionKey, SortKeyFilterImpl.run(sortKey)) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/LiteralExpr.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/LiteralExpr.kt index 6dd2854e38a..62ceda9e122 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/LiteralExpr.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/LiteralExpr.kt @@ -7,10 +7,12 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.LiteralExprImpl import aws.sdk.kotlin.hll.dynamodbmapper.util.attr import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents an expression that consists of a single literal value */ +@ExperimentalApi public interface LiteralExpr : Expression { /** * The low-level DynamoDB representation of the literal value @@ -24,37 +26,44 @@ public interface LiteralExpr : Expression { * Creates a new literal expression * @param value The low-level DynamoDB representation of the literal value */ +@ExperimentalApi public fun LiteralExpr(value: AttributeValue): LiteralExpr = LiteralExprImpl(value) + private val NULL_LITERAL = LiteralExpr(attr(null)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: Boolean?): LiteralExpr = LiteralExpr(attr(value)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: ByteArray?): LiteralExpr = LiteralExpr(attr(value)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: List?): LiteralExpr = LiteralExpr(attr(value)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: Map?): LiteralExpr = LiteralExpr(attr(value)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi @Suppress("UNUSED_PARAMETER") public fun LiteralExpr(value: Nothing?): LiteralExpr = NULL_LITERAL @@ -62,12 +71,14 @@ public fun LiteralExpr(value: Nothing?): LiteralExpr = NULL_LITERAL * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: Number?): LiteralExpr = LiteralExpr(attr(value)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi @JvmName("LiteralExprSetByteArray") public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value)) @@ -75,6 +86,7 @@ public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(v * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi @JvmName("LiteralExprSetNumber") public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value)) @@ -82,6 +94,7 @@ public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(valu * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi @JvmName("LiteralExprSetString") public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value)) @@ -89,6 +102,7 @@ public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(valu * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi @JvmName("LiteralExprSetUByte") public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value)) @@ -96,6 +110,7 @@ public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi @JvmName("LiteralExprSetUInt") public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value)) @@ -103,6 +118,7 @@ public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value) * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi @JvmName("LiteralExprSetULong") public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value)) @@ -110,6 +126,7 @@ public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi @JvmName("LiteralExprSetUShort") public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(value)) @@ -117,28 +134,33 @@ public fun LiteralExpr(value: Set?): LiteralExpr = LiteralExpr(attr(valu * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: String?): LiteralExpr = LiteralExpr(attr(value)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: UByte?): LiteralExpr = LiteralExpr(attr(value)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: UInt?): LiteralExpr = LiteralExpr(attr(value)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: ULong?): LiteralExpr = LiteralExpr(attr(value)) /** * Creates a new literal expression * @param value The literal value which will be converted to an [AttributeValue] */ +@ExperimentalApi public fun LiteralExpr(value: UShort?): LiteralExpr = LiteralExpr(attr(value)) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/NotExpr.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/NotExpr.kt index c0591e2ae2c..fce372ff7f5 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/NotExpr.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/NotExpr.kt @@ -5,12 +5,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.NotExprImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents a `NOT` expression as described in * [DynamoDB's **logical evaluations** documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations). * This expression will be true if `!operand` (i.e., `operand` evaluates to `false`). */ +@ExperimentalApi public interface NotExpr : BooleanExpr { /** * The condition to negate @@ -24,4 +26,5 @@ public interface NotExpr : BooleanExpr { * Creates a new `NOT` expression * @param operand The condition to negate */ +@ExperimentalApi public fun NotExpr(operand: BooleanExpr): NotExpr = NotExprImpl(operand) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/OrExpr.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/OrExpr.kt index 6192e4d90b3..a7b9705dab8 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/OrExpr.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/OrExpr.kt @@ -5,12 +5,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.OrExprImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents an `OR` expression as described in * [DynamoDB's **logical evaluations** documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations). * This expression will be true if `(operand[0] || operand[1] || ... || operand[n - 1])`. */ +@ExperimentalApi public interface OrExpr : BooleanExpr { /** * A list of 2 or more [BooleanExpr] conditions which are ANDed together @@ -24,4 +26,5 @@ public interface OrExpr : BooleanExpr { * Creates a new [OrExpr] with the given [operands] * @param operands A list of 2 or more [BooleanExpr] conditions which are ORed together */ +@ExperimentalApi public fun OrExpr(operands: List): OrExpr = OrExprImpl(operands) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ScalarFunc.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ScalarFunc.kt index 5a713db6601..e1a32b09f17 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ScalarFunc.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ScalarFunc.kt @@ -4,12 +4,15 @@ */ package aws.sdk.kotlin.hll.dynamodbmapper.expressions +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Identifies a * [DynamoDB expression function](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions) * which returns a non-boolean value * @param exprString The literal name of the function to use in expression strings */ +@ExperimentalApi public enum class ScalarFunc(public val exprString: String) { /** * The `size` function diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ScalarFuncExpr.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ScalarFuncExpr.kt index c835078916b..b700c19391b 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ScalarFuncExpr.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/ScalarFuncExpr.kt @@ -5,11 +5,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.ScalarFuncExprImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents a function expression that yields a non-boolean result as described in * [DynamoDB's **function** documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions) */ +@ExperimentalApi public interface ScalarFuncExpr : BooleanExpr { /** * The specific non-boolean function to use @@ -35,6 +37,7 @@ public interface ScalarFuncExpr : BooleanExpr { * @param path The attribute path to pass as the function's first argument * @param additionalOperands Any additional arguments used by the function */ +@ExperimentalApi public fun ScalarFuncExpr( func: ScalarFunc, path: AttributePath, @@ -47,6 +50,7 @@ public fun ScalarFuncExpr( * @param path The attribute path to pass as the function's first argument * @param additionalOperands Any additional arguments used by the function */ +@ExperimentalApi public fun ScalarFuncExpr( func: ScalarFunc, path: AttributePath, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/SortKeyFilter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/SortKeyFilter.kt index 9b1a98fc0fd..5e8b2b2a01d 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/SortKeyFilter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/SortKeyFilter.kt @@ -4,9 +4,12 @@ */ package aws.sdk.kotlin.hll.dynamodbmapper.expressions +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Represents a sort key independent of schema */ +@ExperimentalApi public interface SortKey /** @@ -71,6 +74,7 @@ public interface SortKey * sortKey startsWith "abc" // Checks whether the value of the sort key starts with `"abc"` * ``` */ +@ExperimentalApi public interface SortKeyFilter { /** * Gets an attribute reference to the sort key diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/AttributeDescriptor.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/AttributeDescriptor.kt index 3d412837d0f..4ffd08ec55c 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/AttributeDescriptor.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/AttributeDescriptor.kt @@ -6,6 +6,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.items import aws.sdk.kotlin.hll.dynamodbmapper.items.internal.AttributeDescriptorImpl import aws.sdk.kotlin.hll.dynamodbmapper.values.ValueConverter +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Describes a single item attribute and how it is converted from an object of type [T] and to a build object of type @@ -14,6 +15,7 @@ import aws.sdk.kotlin.hll.dynamodbmapper.values.ValueConverter * @param T The type of object from which values are extracted * @param B The type of builder object in which values are mutated */ +@ExperimentalApi public interface AttributeDescriptor { /** * The name of the attribute @@ -47,6 +49,7 @@ public interface AttributeDescriptor { * @param converter A [ValueConverter] which defines how an object value is converted to an attribute value and vice * versa */ +@ExperimentalApi public fun AttributeDescriptor( name: String, getter: (T) -> A, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/DocumentConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/DocumentConverter.kt index 141ce49105f..b5ae1f3699c 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/DocumentConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/DocumentConverter.kt @@ -8,11 +8,13 @@ import aws.sdk.kotlin.hll.dynamodbmapper.model.Item import aws.sdk.kotlin.hll.dynamodbmapper.model.toItem import aws.sdk.kotlin.hll.dynamodbmapper.util.NULL_ATTR import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.smithy.kotlin.runtime.InternalApi import aws.smithy.kotlin.runtime.content.Document import aws.smithy.kotlin.runtime.util.toNumber // FIXME Combine with DocumentValueConverter or refactor to commonize as much code as possible +@ExperimentalApi public object DocumentConverter : ItemConverter { override fun convertFrom(to: Item): Document = to .mapValues { (_, attr) -> fromAttributeValue(attr) } diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/HeterogeneousItemConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/HeterogeneousItemConverter.kt index 2caf7f3f32d..39bfbbf9801 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/HeterogeneousItemConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/HeterogeneousItemConverter.kt @@ -7,7 +7,95 @@ package aws.sdk.kotlin.hll.dynamodbmapper.items import aws.sdk.kotlin.hll.dynamodbmapper.model.Item import aws.sdk.kotlin.hll.dynamodbmapper.model.buildItem import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi +/** + * An item converter which handles heterogeneous (i.e., incongruent) data types by way of a string discriminator + * attribute identified by [typeAttribute]. The given [typeMapper] function must return a string type name for an object + * which will be used for the [typeAttribute] attribute. Finally, the given [subConverters] map identifies the delegate + * converters for each type. + * + * This converter is particularly (although not _solely_) useful for mapping polymorphic structures. For example, given + * a class hierarchy: + * + * ```kotlin + * sealed interface Vehicle + * + * @DynamoDbItem + * data class Car( + * @DynamoDbPartitionKey val id: Int, + * val manufacturer: String, + * val model: String, + * val year: Int, + * ) : Vehicle + * + * @DynamoDbItem + * data class Bike( + * @DynamoDbPartitionKey val id: Int, + * val manufacturer: String + * val gears: Int, + * val isElectric: Boolean, + * ) : Vehicle + * ``` + * + * A heterogeneous item converter can be constructed: + * + * ```kotlin + * fun vehicleType(obj: Vehicle) = when (obj) { + * is Car -> "car" + * is Bike -> "bike" + * } + * + * val vehicleConverter = HeterogeneousItemConverter( + * typeMapper = ::vehicleType, + * typeAttribute = "type", + * subConverters = mapOf( + * "car" to CarConverter, + * "bike" to BikeConverter, + * ), + * ) + * ``` + * + * Objects mapped in this manner will use only the attributes relevant to their specific type, plus the [typeAttribute]. + * For example, given the following items and PutItem calls: + * + * ```kotlin + * val vehicles = listOf( + * Car(1, "Ford", "Model T", 1928), + * Bike(2, "Schwinn", 10, false), + * Car(3, "Edsel", "Corsair", 1958), + * Bike(4, "Kuwahara", 1, false), + * ) + * + * val table = ... // some table which uses the vehicleConverter from above in its schema + * + * vehicles.forEach { vehicle -> + * table.putItem { item = vehicle } + * } + * ``` + * + * Items would be persisted in the table as: + * + * | **id** | **type** | **manufacturer** | **model** | **year** | **gears** | **isElectric** | + * |-------:|----------|------------------|-----------|---------:|----------:|----------------| + * | 1 | car | Ford | Model T | 1928 | | | + * | 2 | bike | Schwinn | | | 10 | false | + * | 3 | car | Edsel | Corsair | 1958 | | | + * | 4 | bike | Kuwahara | | | 1 | false | + * + * @param T The common type ancestor for all subtypes handled by this converter. This may be a base class, interface, or + * even [Any]. + * @param typeMapper A function which accepts an instance of the common type [T] and returns the string identifier for + * the type. This identifier is written/read from the attribute identified by [typeAttribute] and used as a lookup key + * in [subConverters]. + * @param typeAttribute The name of the attribute in which to store/read type information. This attribute will be + * present for every item persisted via this converter. It should ideally be an attribute which doesn't conflict with + * other attributes used by subconverters. + * @param subConverters A map of type names (the same returned by [typeMapper]) to [ItemConverter] instances. If the + * [typeMapper] function returns a type name which does not exist in this map, or if an item is read containing a type + * attribute value which does not exist in this map, an exception will be thrown. + */ +@ExperimentalApi public class HeterogeneousItemConverter( public val typeMapper: (T) -> String, public val typeAttribute: String, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/ItemConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/ItemConverter.kt index 0eb13f4794f..be343fc4ae0 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/ItemConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/ItemConverter.kt @@ -6,11 +6,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.items import aws.sdk.kotlin.hll.dynamodbmapper.model.Item import aws.sdk.kotlin.hll.mapping.core.converters.Converter +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Defines the logic for converting between objects and DynamoDB items * @param T The type of objects which will be converted */ +@ExperimentalApi public interface ItemConverter : Converter { public fun convertTo(from: T, onlyAttributes: Set? = null): Item public override fun convertTo(from: T): Item = convertTo(from, null) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/ItemSchema.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/ItemSchema.kt index 3df886bdf77..a5c42b46acc 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/ItemSchema.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/ItemSchema.kt @@ -6,12 +6,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.items import aws.sdk.kotlin.hll.dynamodbmapper.items.internal.ItemSchemaCompositeKeyImpl import aws.sdk.kotlin.hll.dynamodbmapper.items.internal.ItemSchemaPartitionKeyImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Defines a schema for handling objects of a certain type, including an [ItemConverter] for converting between objects * items and a [KeySpec] for identifying primary keys. * @param T The type of objects described by this schema */ +@ExperimentalApi public interface ItemSchema { /** * The [ItemConverter] used to convert between objects and items @@ -28,6 +30,7 @@ public interface ItemSchema { * @param T The type of objects described by this schema * @param PK The type of the partition key property, either [String], [Number], or [ByteArray] */ + @ExperimentalApi public interface PartitionKey : ItemSchema { /** * The [KeySpec] for the partition key @@ -44,6 +47,7 @@ public interface ItemSchema { * @param PK The type of the partition key property, either [String], [Number], or [ByteArray] * @param SK The type of the sort key property, either [String], [Number], or [ByteArray] */ + @ExperimentalApi public interface CompositeKey : PartitionKey { /** * The [KeySpec] for the sort key @@ -62,6 +66,7 @@ public interface ItemSchema { * @param converter The [ItemConverter] used to convert between objects and items * @param partitionKey The [KeySpec] for the partition key */ +@ExperimentalApi @Suppress("FunctionName") public fun ItemSchema(converter: ItemConverter, partitionKey: KeySpec): ItemSchema.PartitionKey = ItemSchemaPartitionKeyImpl(converter, partitionKey) @@ -75,6 +80,7 @@ public fun ItemSchema(converter: ItemConverter, partitionKey: KeySpec * @param partitionKey The [KeySpec] for the partition key * @param sortKey The [KeySpec] for the sort key */ +@ExperimentalApi @Suppress("FunctionName") public fun ItemSchema( converter: ItemConverter, @@ -88,6 +94,7 @@ public fun ItemSchema( * @param PK The type of the partition key property, either [String], [Number], or [ByteArray] * @param partitionKey The [KeySpec] that describes the partition key */ +@ExperimentalApi public fun ItemConverter.withKeySpec(partitionKey: KeySpec): ItemSchema.PartitionKey = ItemSchema(this, partitionKey) @@ -99,6 +106,7 @@ public fun ItemConverter.withKeySpec(partitionKey: KeySpec): Item * @param partitionKey The [KeySpec] that describes the partition key * @param sortKey The [KeySpec] that describes the sort key */ +@ExperimentalApi public fun ItemConverter.withKeySpec( partitionKey: KeySpec, sortKey: KeySpec, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/KeySpec.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/KeySpec.kt index e403a56a51e..9cf119b4fc7 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/KeySpec.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/KeySpec.kt @@ -5,27 +5,33 @@ package aws.sdk.kotlin.hll.dynamodbmapper.items import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Defines a specification for a single key attribute * @param K The type of the key property, either [kotlin.String], [kotlin.Number], or [kotlin.ByteArray] */ +@ExperimentalApi public sealed interface KeySpec { /** * A [KeySpec] for a [kotlin.ByteArray]-typed field */ + @ExperimentalApi public interface ByteArray : KeySpec /** * A [KeySpec] for a [kotlin.Number]-typed field */ + @ExperimentalApi public interface Number : KeySpec /** * A [KeySpec] for a [kotlin.String]-typed field */ + @ExperimentalApi public interface String : KeySpec + @ExperimentalApi public companion object { /** * Creates a new [ByteArray] key specification diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/SimpleItemConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/SimpleItemConverter.kt index 3b768e9fef8..9e4d0fb457d 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/SimpleItemConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/items/SimpleItemConverter.kt @@ -7,6 +7,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.items import aws.sdk.kotlin.hll.dynamodbmapper.model.Item import aws.sdk.kotlin.hll.dynamodbmapper.model.buildItem import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * An item converter which uses attribute descriptors to convert objects to items and vice versa. This converter @@ -21,6 +22,7 @@ import aws.sdk.kotlin.services.dynamodb.model.AttributeValue * [T] are the same type, this may be an identity function. * @param descriptors A collection of [AttributeDescriptor] which describe how to construct and parse attributes */ +@ExperimentalApi public class SimpleItemConverter( private val builderFactory: () -> B, private val build: B.() -> T, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Index.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Index.kt index c297940e477..6d652224b69 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Index.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Index.kt @@ -5,12 +5,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.model import aws.sdk.kotlin.hll.dynamodbmapper.operations.IndexOperations +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents a secondary index on a table in DynamoDB and an associated item schema. Operations on this index will * invoke low-level operations and map items to objects. * @param T The type of objects which will be read from this index */ +@ExperimentalApi public interface Index : IndexSpec, IndexOperations, @@ -21,6 +23,7 @@ public interface Index : * @param T The type of objects which will be read from this index * @param PK The type of the partition key property, either [String], [Number], or [ByteArray] */ + @ExperimentalApi public interface PartitionKey : Index, PersistenceSpec.PartitionKey @@ -31,6 +34,7 @@ public interface Index : * @param PK The type of the partition key property, either [String], [Number], or [ByteArray] * @param SK The type of the sort key property, either [String], [Number], or [ByteArray] */ + @ExperimentalApi public interface CompositeKey : Index, PersistenceSpec.CompositeKey diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/IndexSpec.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/IndexSpec.kt index bd644f55c1d..b92b1bb3b36 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/IndexSpec.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/IndexSpec.kt @@ -5,11 +5,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.model import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Specifies how items can be read from a secondary index * @param T The type of objects which will be read from this index */ +@ExperimentalApi public interface IndexSpec : PersistenceSpec { /** * The name of the table @@ -24,6 +26,7 @@ public interface IndexSpec : PersistenceSpec { /** * Specifies how items can be read from a secondary index whose primary key consists of a single partition key */ + @ExperimentalApi public interface PartitionKey : IndexSpec { override val schema: ItemSchema.PartitionKey } @@ -32,6 +35,7 @@ public interface IndexSpec : PersistenceSpec { * Specifies how items can be read from a secondary index whose primary key consists of a composite of a partition * key and a sort key */ + @ExperimentalApi public interface CompositeKey : IndexSpec { override val schema: ItemSchema.CompositeKey } diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Item.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Item.kt index ce67991d2e7..0c2d4c97718 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Item.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Item.kt @@ -7,11 +7,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.model import aws.sdk.kotlin.hll.dynamodbmapper.model.internal.ItemImpl import aws.sdk.kotlin.hll.dynamodbmapper.util.dynamicAttr import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * An immutable representation of a low-level item in a DynamoDB table. Items consist of attributes, each of which have * a string name and a value. */ +@ExperimentalApi public interface Item : Map /** @@ -19,17 +21,20 @@ public interface Item : Map * of it. * @param block The block to apply to the [MutableItem] builder */ +@ExperimentalApi public inline fun buildItem(block: MutableItem.() -> Unit): Item = mutableMapOf().toMutableItem().apply(block).toItem() /** * Convert this [Item] into a [MutableItem]. Changes to the returned instance do not affect this instance. */ +@ExperimentalApi public fun Item.toMutableItem(): MutableItem = toMutableMap().toMutableItem() /** * Converts this map to an immutable [Item] */ +@ExperimentalApi public fun Map.toItem(): Item = ItemImpl(this) /** @@ -43,6 +48,7 @@ internal fun Map.toItem() = mapValues { (_, v) -> dynamicAttr(v) } * @param pairs A collection of [Pair]<[String], [AttributeValue]> where the first value is the attribute name and the * second is the attribute value. */ +@ExperimentalApi public fun itemOf(vararg pairs: Pair): Item = mapOf(*pairs).toItem() /** diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/ItemSource.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/ItemSource.kt index 4cac2295474..a9141c17c04 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/ItemSource.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/ItemSource.kt @@ -5,10 +5,12 @@ package aws.sdk.kotlin.hll.dynamodbmapper.model import aws.sdk.kotlin.hll.dynamodbmapper.operations.ItemSourceOperations +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents a source of DynamoDB items (such as a table or secondary index) */ +@ExperimentalApi public interface ItemSource : PersistenceSpec, ItemSourceOperations { @@ -19,6 +21,7 @@ public interface ItemSource : * @param T The type of objects which will be read from and/or written to this item source * @param PK The type of the partition key property, either [String], [Number], or [ByteArray] */ + @ExperimentalApi public interface PartitionKey : ItemSource, PersistenceSpec.PartitionKey @@ -30,6 +33,7 @@ public interface ItemSource : * @param PK The type of the partition key property, either [String], [Number], or [ByteArray] * @param SK The type of the sort key property, either [String], [Number], or [ByteArray] */ + @ExperimentalApi public interface CompositeKey : ItemSource, PersistenceSpec.CompositeKey diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/MutableItem.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/MutableItem.kt index d577a1e2dee..0b0bbd0e2c6 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/MutableItem.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/MutableItem.kt @@ -6,21 +6,25 @@ package aws.sdk.kotlin.hll.dynamodbmapper.model import aws.sdk.kotlin.hll.dynamodbmapper.model.internal.MutableItemImpl import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * A mutable representation of a low-level item in a DynamoDB table. Items consist of attributes, each of which have a * string name and a value. */ +@ExperimentalApi public interface MutableItem : MutableMap /** * Convert this [MutableItem] to an immutable [Item]. Changes to this instance do not affect the returned instance. */ +@ExperimentalApi public fun MutableItem.toItem(): Item = toMap().toItem() /** * Converts this map to a [MutableItem] */ +@ExperimentalApi public fun MutableMap.toMutableItem(): MutableItem = MutableItemImpl(this) /** @@ -28,5 +32,6 @@ public fun MutableMap.toMutableItem(): MutableItem = Mut * @param pairs A collection of [Pair]<[String], [AttributeValue]> where the first value is the attribute name and the * second is the attribute value. */ +@ExperimentalApi public fun mutableItemOf(vararg pairs: Pair): MutableItem = MutableItemImpl(mutableMapOf(*pairs)) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/PersistenceSpec.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/PersistenceSpec.kt index 640d36bd952..452b571040c 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/PersistenceSpec.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/PersistenceSpec.kt @@ -6,12 +6,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.model import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbMapper import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Specifies how items can be read from and written to a specific DynamoDB location (such as a table or a secondary * index) * @param T The type of objects which will be read from and/or written to this item source */ +@ExperimentalApi public interface PersistenceSpec { /** * The [DynamoDbMapper] which holds the underlying DynamoDB service client used to invoke operations @@ -27,6 +29,7 @@ public interface PersistenceSpec { * Specifies how items can be read from and written to a specific DynamoDB location (such as a table or a secondary * index) whose primary key consists of a single partition key */ + @ExperimentalApi public interface PartitionKey : PersistenceSpec { override val schema: ItemSchema.PartitionKey } @@ -35,6 +38,7 @@ public interface PersistenceSpec { * Specifies how items can be read from and written to a specific DynamoDB location (such as a table or a secondary * index) whose primary key consists of a composite of a partition key and a sort key */ + @ExperimentalApi public interface CompositeKey : PersistenceSpec { override val schema: ItemSchema.CompositeKey } diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Table.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Table.kt index 9ca08c1423d..fd96d1554cd 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Table.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/Table.kt @@ -6,12 +6,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.model import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema import aws.sdk.kotlin.hll.dynamodbmapper.operations.TableOperations +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Represents a table in DynamoDB and an associated item schema. Operations on this table will invoke low-level * operations after mapping objects to items and vice versa. * @param T The type of objects which will be read from and/or written to this table */ +@ExperimentalApi public interface Table : TableSpec, TableOperations, @@ -22,6 +24,7 @@ public interface Table : * @param T The type of objects which will be read from and/or written to this table * @param PK The type of the partition key property, either [String], [Number], or [ByteArray] */ + @ExperimentalApi public interface PartitionKey : Table, ItemSource.PartitionKey { @@ -35,6 +38,7 @@ public interface Table : * @param PK The type of the partition key property, either [String], [Number], or [ByteArray] * @param SK The type of the sort key property, either [String], [Number], or [ByteArray] */ + @ExperimentalApi public interface CompositeKey : Table, ItemSource.CompositeKey { diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/TableSpec.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/TableSpec.kt index 0c63ed3818a..a9d78371c70 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/TableSpec.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/model/TableSpec.kt @@ -5,11 +5,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.model import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Specifies how items can be read from and written to a table * @param T The type of objects which will be read from and/or written to this table */ +@ExperimentalApi public interface TableSpec : PersistenceSpec { /** * The name of the table @@ -19,6 +21,7 @@ public interface TableSpec : PersistenceSpec { /** * Specifies how items can be read from or written to a table whose primary key consists of a single partition key */ + @ExperimentalApi public interface PartitionKey : TableSpec { override val schema: ItemSchema.PartitionKey } @@ -27,6 +30,7 @@ public interface TableSpec : PersistenceSpec { * Specifies how items can be read from or written to a table whose primary key consists of a composite of a * partition key and a sort key */ + @ExperimentalApi public interface CompositeKey : TableSpec { override val schema: ItemSchema.CompositeKey } diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/DeserializeInput.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/DeserializeInput.kt index a6a409846f4..f572e15e1ae 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/DeserializeInput.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/DeserializeInput.kt @@ -6,6 +6,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.pipeline import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.DeserializeInputImpl +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.sdk.kotlin.services.dynamodb.model.GetItemResponse as LowLevelGetItemResponse /** @@ -13,6 +14,7 @@ import aws.sdk.kotlin.services.dynamodb.model.GetItemResponse as LowLevelGetItem * @param T The type of objects being converted to/from DynamoDB items * @param LRes The type of low-level response object (e.g., [LowLevelGetItemResponse]) */ +@ExperimentalApi public interface DeserializeInput { /** * The low-level response which is to be deserialized into a high-level response object @@ -32,6 +34,7 @@ public interface DeserializeInput { * @param lowLevelResponse The low-level response which is to be deserialized into a high-level response object * @param deserializeSchema The [ItemSchema] to use for deserializing items into objects */ +@ExperimentalApi public fun DeserializeInput( lowLevelResponse: LRes, deserializeSchema: ItemSchema, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/HReqContext.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/HReqContext.kt index 4482aaaf7c7..8c8abea9375 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/HReqContext.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/HReqContext.kt @@ -7,12 +7,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.pipeline import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema import aws.sdk.kotlin.hll.dynamodbmapper.operations.GetItemRequest import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.HReqContextImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Contextual data for stages in the pipeline dealing with high-level requests (i.e., before serialization) * @param T The type of objects being converted to/from DynamoDB items * @param HReq The type of high-level request object (e.g., [GetItemRequest]) */ +@ExperimentalApi public interface HReqContext : SerializeInput { /** @@ -37,6 +39,7 @@ public interface HReqContext : SerializeInput { * @param mapperContext Additional, generalized context which may be useful to interceptors * @param error The most recent error which occurred, if any. Defaults to null. */ +@ExperimentalApi public fun HReqContext( highLevelRequest: HReq, serializeSchema: ItemSchema, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/HResContext.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/HResContext.kt index 27c22e067f4..0a6334b8ee2 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/HResContext.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/HResContext.kt @@ -8,6 +8,7 @@ import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema import aws.sdk.kotlin.hll.dynamodbmapper.operations.GetItemRequest import aws.sdk.kotlin.hll.dynamodbmapper.operations.GetItemResponse import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.HResContextImpl +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.sdk.kotlin.services.dynamodb.model.GetItemRequest as LowLevelGetItemRequest import aws.sdk.kotlin.services.dynamodb.model.GetItemResponse as LowLevelGetItemResponse @@ -19,6 +20,7 @@ import aws.sdk.kotlin.services.dynamodb.model.GetItemResponse as LowLevelGetItem * @param LRes The type of low-level response object (e.g., [LowLevelGetItemResponse]) * @param HRes The type of high-level response object (e.g., [GetItemResponse]) */ +@ExperimentalApi public interface HResContext : LResContext { /** * The high-level response to return to the caller @@ -41,6 +43,7 @@ public interface HResContext : LResContext HResContext( highLevelRequest: HReq, serializeSchema: ItemSchema, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/Interceptor.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/Interceptor.kt index 86cc201956b..c5de8f1f978 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/Interceptor.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/Interceptor.kt @@ -9,6 +9,7 @@ import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema import aws.sdk.kotlin.hll.dynamodbmapper.operations.GetItemRequest import aws.sdk.kotlin.hll.dynamodbmapper.operations.GetItemResponse import aws.sdk.kotlin.services.dynamodb.DynamoDbClient +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.sdk.kotlin.services.dynamodb.model.GetItemRequest as LowLevelGetItemRequest import aws.sdk.kotlin.services.dynamodb.model.GetItemResponse as LowLevelGetItemResponse @@ -74,6 +75,7 @@ import aws.sdk.kotlin.services.dynamodb.model.GetItemResponse as LowLevelGetItem * @param LRes The type of low-level response object (e.g., [LowLevelGetItemResponse]) * @param HRes The type of high-level response object (e.g., [GetItemResponse]) */ +@ExperimentalApi public interface Interceptor { // Hooks functions are defined in the same order as pipeline execution below: @@ -180,4 +182,5 @@ public interface Interceptor { /** * A universal interceptor which acts on any type of high-level objects, requests, and responses */ +@ExperimentalApi public typealias InterceptorAny = Interceptor<*, *, *, *, *> diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/LReqContext.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/LReqContext.kt index 4d6a534a044..39cf25cc0d1 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/LReqContext.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/LReqContext.kt @@ -7,6 +7,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.pipeline import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema import aws.sdk.kotlin.hll.dynamodbmapper.operations.GetItemRequest import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.LReqContextImpl +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.sdk.kotlin.services.dynamodb.model.GetItemRequest as LowLevelGetItemRequest /** @@ -16,6 +17,7 @@ import aws.sdk.kotlin.services.dynamodb.model.GetItemRequest as LowLevelGetItemR * @param HReq The type of high-level request object (e.g., [GetItemRequest]) * @param LReq The type of low-level request object (e.g., [LowLevelGetItemRequest]) */ +@ExperimentalApi public interface LReqContext : HReqContext { /** * The low-level request object which is to be used in the low-level operation invocation @@ -34,6 +36,7 @@ public interface LReqContext : HReqContext { * @param lowLevelRequest The low-level request object which is to be used in the low-level operation invocation * @param error The most recent error which occurred, if any. Defaults to null. */ +@ExperimentalApi public fun LReqContext( highLevelRequest: HReq, serializeSchema: ItemSchema, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/LResContext.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/LResContext.kt index c612d5da3b9..f1e4f9bb065 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/LResContext.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/LResContext.kt @@ -7,6 +7,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.pipeline import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema import aws.sdk.kotlin.hll.dynamodbmapper.operations.GetItemRequest import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.LResContextImpl +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.sdk.kotlin.services.dynamodb.model.GetItemRequest as LowLevelGetItemRequest import aws.sdk.kotlin.services.dynamodb.model.GetItemResponse as LowLevelGetItemResponse @@ -18,6 +19,7 @@ import aws.sdk.kotlin.services.dynamodb.model.GetItemResponse as LowLevelGetItem * @param LReq The type of low-level request object (e.g., [LowLevelGetItemRequest]) * @param LRes The type of low-level response object (e.g., [LowLevelGetItemResponse]) */ +@ExperimentalApi public interface LResContext : LReqContext, DeserializeInput @@ -36,6 +38,7 @@ public interface LResContext : * @param deserializeSchema The [ItemSchema] to use for deserializing items into objects * @param error The most recent error which occurred, if any. Defaults to null. */ +@ExperimentalApi public fun LResContext( highLevelRequest: HReq, serializeSchema: ItemSchema, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/MapperContext.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/MapperContext.kt index 42a241e83d3..3115ff7d90b 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/MapperContext.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/MapperContext.kt @@ -6,11 +6,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.pipeline import aws.sdk.kotlin.hll.dynamodbmapper.model.PersistenceSpec import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.MapperContextImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Holds generalized context which may be useful to interceptors * @param T The type of objects being converted to/from DynamoDB items */ +@ExperimentalApi public interface MapperContext { // TODO what other fields would be useful in here? @@ -31,5 +33,6 @@ public interface MapperContext { * @param persistenceSpec The metadata about an operation invocation * @param operation The name of the high-level operation being invoked */ +@ExperimentalApi public fun MapperContext(persistenceSpec: PersistenceSpec, operation: String): MapperContext = MapperContextImpl(persistenceSpec, operation) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/SerializeInput.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/SerializeInput.kt index b780c2a8b5b..b5f644cb098 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/SerializeInput.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/pipeline/SerializeInput.kt @@ -7,12 +7,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.pipeline import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema import aws.sdk.kotlin.hll.dynamodbmapper.operations.GetItemRequest import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.SerializeInputImpl +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Defines input to the serialization step of the pipeline * @param T The type of objects being converted to/from DynamoDB items * @param HReq The type of high-level request object (e.g., [GetItemRequest]) */ +@ExperimentalApi public interface SerializeInput { /** * The high-level request object which is to be serialized into a low-level request object @@ -32,5 +34,6 @@ public interface SerializeInput { * @param highLevelRequest The high-level request object which is to be serialized into a low-level request object * @param serializeSchema The [ItemSchema] to use for serializing objects into items */ +@ExperimentalApi public fun SerializeInput(highLevelRequest: HReq, serializeSchema: ItemSchema): SerializeInput = SerializeInputImpl(highLevelRequest, serializeSchema) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/ItemToValueConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/ItemToValueConverter.kt index 578269f064f..c2adda57125 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/ItemToValueConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/ItemToValueConverter.kt @@ -7,11 +7,13 @@ package aws.sdk.kotlin.hll.dynamodbmapper.values import aws.sdk.kotlin.hll.dynamodbmapper.model.Item import aws.sdk.kotlin.hll.dynamodbmapper.model.toItem import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Converts between [Item] and [AttributeValue]. * This converter is typically chained following an [ItemConverter] using the [andThenTo] extension function. */ +@ExperimentalApi public object ItemToValueConverter : ValueConverter { /** * Convert from [AttributeValue] to [Item] diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/NullableConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/NullableConverter.kt index 44da31ecf64..90a22dfa670 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/NullableConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/NullableConverter.kt @@ -10,6 +10,7 @@ import aws.sdk.kotlin.hll.mapping.core.converters.SplittingConverter import aws.sdk.kotlin.hll.mapping.core.converters.mergeBy import aws.sdk.kotlin.hll.mapping.core.util.Either import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi import kotlin.reflect.KClass /** @@ -19,6 +20,7 @@ import kotlin.reflect.KClass * Thus, it is typically used in conjunction with the [NullableConverter] factory function or via [mergeBy]. * @param V The non-nullable type */ +@ExperimentalApi public class NullableConverter(klass: KClass) : SplittingConverter { override fun convertTo(from: V?): Either = when (from) { null -> Either.Left(NULL_ATTR) @@ -34,8 +36,10 @@ public class NullableConverter(klass: KClass) : SplittingConverter NullableConverter(): NullableConverter = NullableConverter(V::class) +@ExperimentalApi @Suppress("ktlint:standard:function-naming") public inline fun NullableConverter( delegate: Converter, diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/ValueConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/ValueConverter.kt index ac955d89f5c..3f403387563 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/ValueConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/ValueConverter.kt @@ -6,6 +6,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.values import aws.sdk.kotlin.hll.mapping.core.converters.Converter import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Defines the logic for converting individual values between a high-level type [V] (e.g., [String], [Boolean], [Map]) @@ -13,4 +14,5 @@ import aws.sdk.kotlin.services.dynamodb.model.AttributeValue * [DynamoDB data types](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes) * @param V The type of high-level values which will be converted to low-level DynamoDB attribute values */ +@ExperimentalApi public typealias ValueConverter = Converter diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/ListConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/ListConverter.kt index df254b87133..d5003c9c011 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/ListConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/ListConverter.kt @@ -8,6 +8,7 @@ import aws.sdk.kotlin.hll.dynamodbmapper.values.ValueConverter import aws.sdk.kotlin.hll.mapping.core.converters.Converter import aws.sdk.kotlin.hll.mapping.core.converters.collections.mapFrom import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Converts between [List] and @@ -23,6 +24,7 @@ import aws.sdk.kotlin.services.dynamodb.model.AttributeValue * val intListConv2 = ListConverter.mapFrom(IntConverter) // same as above * ``` */ +@ExperimentalApi public val ListConverter: ValueConverter> = Converter(AttributeValue::L, AttributeValue::asL) /** @@ -30,6 +32,7 @@ public val ListConverter: ValueConverter> = Converter(Attri * @param F The type of elements in the list * @param elementConverter A converter for transforming between values of [F] and [AttributeValue] */ +@ExperimentalApi @Suppress("ktlint:standard:function-naming") public fun ListConverter(elementConverter: Converter): ValueConverter> = ListConverter.mapFrom(elementConverter) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/MapConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/MapConverter.kt index 9e0c1856f16..ef0b62d2b14 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/MapConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/MapConverter.kt @@ -10,6 +10,7 @@ import aws.sdk.kotlin.hll.mapping.core.converters.collections.mapFrom import aws.sdk.kotlin.hll.mapping.core.converters.collections.mapKeysFrom import aws.sdk.kotlin.hll.mapping.core.converters.collections.mapValuesFrom import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Converts between [Map] and @@ -23,6 +24,7 @@ import aws.sdk.kotlin.services.dynamodb.model.AttributeValue * val instantMapConv2 = MapConverter.mapValuesFrom(InstantConverter.Default) // same as above * ``` */ +@ExperimentalApi public val MapConverter: ValueConverter> = Converter(AttributeValue::M, AttributeValue::asM) /** @@ -32,6 +34,7 @@ public val MapConverter: ValueConverter> = Converter * @param keyConverter A converter for transforming between [K] keys and [String] keys * @param valueConverter A converter for transforming between [V] values and [AttributeValue] */ +@ExperimentalApi @Suppress("ktlint:standard:function-naming") public fun MapConverter( keyConverter: Converter, @@ -43,6 +46,7 @@ public fun MapConverter( * @param V The type of values in the map * @param valueConverter A converter for transforming between [V] values and [AttributeValue] */ +@ExperimentalApi @Suppress("ktlint:standard:function-naming") public fun MapConverter(valueConverter: ValueConverter): ValueConverter> = MapConverter.mapValuesFrom(valueConverter) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/NumberSetConverters.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/NumberSetConverters.kt index 385415c35c2..f65098c46f1 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/NumberSetConverters.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/NumberSetConverters.kt @@ -11,10 +11,12 @@ import aws.sdk.kotlin.hll.mapping.core.converters.andThenFrom import aws.sdk.kotlin.hll.mapping.core.converters.collections.CollectionTypeConverters import aws.sdk.kotlin.hll.mapping.core.converters.collections.mapFrom import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Namespace for containing various conversion utilities dealing with numerical set conversion */ +@ExperimentalApi public object NumberSetConverters { /** * Converts between a [List] of [String] elements and @@ -35,7 +37,6 @@ public object NumberSetConverters { * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) * @param N The type of high-level values which will be converted */ - public fun of(numberToStringConverter: Converter): ValueConverter> = StringSetToAttributeValueNumberSetConverter.mapFrom(numberToStringConverter) } @@ -44,12 +45,14 @@ public object NumberSetConverters { * Converts between a [Set] of [Byte] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val ByteSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.ByteToStringConverter) /** * Converts between a [Set] of [Double] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val DoubleSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.DoubleToStringConverter) @@ -57,6 +60,7 @@ public val DoubleSetConverter: ValueConverter> = * Converts between a [Set] of [Float] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val FloatSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.FloatToStringConverter) @@ -64,18 +68,21 @@ public val FloatSetConverter: ValueConverter> = * Converts between a [Set] of [Int] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val IntSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.IntToStringConverter) /** * Converts between a [Set] of [Long] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val LongSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.LongToStringConverter) /** * Converts between a [Set] of [Short] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val ShortSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.ShortToStringConverter) @@ -83,6 +90,7 @@ public val ShortSetConverter: ValueConverter> = * Converts between a [Set] of [UByte] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val UByteSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.UByteToStringConverter) @@ -90,12 +98,14 @@ public val UByteSetConverter: ValueConverter> = * Converts between a [Set] of [UInt] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val UIntSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.UIntToStringConverter) /** * Converts between a [Set] of [ULong] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val ULongSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.ULongToStringConverter) @@ -103,5 +113,6 @@ public val ULongSetConverter: ValueConverter> = * Converts between a [Set] of [UShort] elements and * [DynamoDB `NS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val UShortSetConverter: ValueConverter> = NumberSetConverters.of(NumberConverters.UShortToStringConverter) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/PrimitiveSetConverters.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/PrimitiveSetConverters.kt index d5805c5a7f5..3ff20e92b81 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/PrimitiveSetConverters.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/collections/PrimitiveSetConverters.kt @@ -11,11 +11,13 @@ import aws.sdk.kotlin.hll.mapping.core.converters.andThenFrom import aws.sdk.kotlin.hll.mapping.core.converters.collections.CollectionTypeConverters import aws.sdk.kotlin.hll.mapping.core.converters.collections.mapFrom import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Converts between a [Set] of [ByteArray] elements and * [DynamoDB `BS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val ByteArraySetConverter: ValueConverter> = Converter( convertTo = { from: Set -> AttributeValue.Bs(from.toList()) }, convertFrom = { to: AttributeValue -> to.asBs().toSet() }, @@ -25,6 +27,7 @@ public val ByteArraySetConverter: ValueConverter> = Converter( * Converts between a [List] of [String] elements and * [DynamoDB `SS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val StringListToAttributeValueStringSetConverter: ValueConverter> = Converter(AttributeValue::Ss, AttributeValue::asSs) @@ -32,6 +35,7 @@ public val StringListToAttributeValueStringSetConverter: ValueConverter> = StringListToAttributeValueStringSetConverter.andThenFrom(CollectionTypeConverters.SetToListConverter()) @@ -39,6 +43,7 @@ public val StringSetConverter: ValueConverter> = * Converts between a [Set] of [CharArray] elements and * [DynamoDB `SS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val CharArraySetConverter: ValueConverter> = StringSetConverter.mapFrom(TextConverters.CharArrayToStringConverter) @@ -46,5 +51,6 @@ public val CharArraySetConverter: ValueConverter> = * Converts between a [Set] of [Char] elements and * [DynamoDB `SS` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes) */ +@ExperimentalApi public val CharSetConverter: ValueConverter> = StringSetConverter.mapFrom(TextConverters.CharToStringConverter) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/BooleanConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/BooleanConverter.kt index cf86a72407c..1b663b12344 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/BooleanConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/BooleanConverter.kt @@ -7,14 +7,17 @@ package aws.sdk.kotlin.hll.dynamodbmapper.values.scalars import aws.sdk.kotlin.hll.dynamodbmapper.values.ValueConverter import aws.sdk.kotlin.hll.mapping.core.converters.Converter import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Converts between [Boolean] and * [DynamoDB `BOOL` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Boolean) */ +@ExperimentalApi public val BooleanConverter: ValueConverter = Converter(AttributeValue::Bool, AttributeValue::asBool) /** * Converts between [Boolean] and [String] */ +@ExperimentalApi public val BooleanToStringConverter: Converter = Converter({ it.toString() }, { it.toBoolean() }) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/ByteArrayConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/ByteArrayConverter.kt index 631bb203a22..a0e49973d81 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/ByteArrayConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/ByteArrayConverter.kt @@ -7,9 +7,11 @@ package aws.sdk.kotlin.hll.dynamodbmapper.values.scalars import aws.sdk.kotlin.hll.dynamodbmapper.values.ValueConverter import aws.sdk.kotlin.hll.mapping.core.converters.Converter import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Converts between [ByteArray] and * [DynamoDB `B` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Binary) */ +@ExperimentalApi public val ByteArrayConverter: ValueConverter = Converter(AttributeValue::B, AttributeValue::asB) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/EnumConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/EnumConverter.kt index 1a2d4665619..2dc2897c11e 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/EnumConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/EnumConverter.kt @@ -7,12 +7,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.values.scalars import aws.sdk.kotlin.hll.dynamodbmapper.values.ValueConverter import aws.sdk.kotlin.hll.mapping.core.converters.Converter import aws.sdk.kotlin.hll.mapping.core.converters.andThenFrom +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Converts between [Enum] and * [DynamoDB `S` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.String) * @param E The [Enum] type to convert */ +@ExperimentalApi public class EnumConverter>( private val enumToStringConverter: Converter, ) : ValueConverter by StringConverter.andThenFrom(enumToStringConverter) @@ -21,6 +23,7 @@ public class EnumConverter>( * Instantiates a new [ValueConverter] for enums of type [E] * @param E The [Enum] type for which to create a [ValueConverter] */ +@ExperimentalApi public inline fun > EnumConverter(): EnumConverter = EnumConverter( enumToStringConverter = Converter( diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/NumberConverters.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/NumberConverters.kt index 0c872e74cd7..865ffea0ea2 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/NumberConverters.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/NumberConverters.kt @@ -9,10 +9,12 @@ import aws.sdk.kotlin.hll.mapping.core.converters.Converter import aws.sdk.kotlin.hll.mapping.core.converters.andThenTo import aws.sdk.kotlin.hll.mapping.core.converters.validatingFrom import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Namespace for containing various conversion utilities dealing with number conversion */ +@ExperimentalApi public object NumberConverters { /** * Converts between [String] instances which contains numbers and @@ -115,6 +117,7 @@ public object NumberConverters { * * [Int] — If the number is in the range of [Int.MIN_VALUE] and [Int.MAX_VALUE] (inclusive) * * [Long] — Anything else */ +@ExperimentalApi public val AutoNumberConverter: ValueConverter = NumberConverters.of(NumberConverters.AutoNumberToStringConverter) @@ -122,58 +125,68 @@ public val AutoNumberConverter: ValueConverter = * Converts between [Byte] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val ByteConverter: ValueConverter = NumberConverters.of(NumberConverters.ByteToStringConverter) /** * Converts between [Double] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val DoubleConverter: ValueConverter = NumberConverters.of(NumberConverters.DoubleToStringConverter) /** * Converts between [Float] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val FloatConverter: ValueConverter = NumberConverters.of(NumberConverters.FloatToStringConverter) /** * Converts between [Int] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val IntConverter: ValueConverter = NumberConverters.of(NumberConverters.IntToStringConverter) /** * Converts between [Long] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val LongConverter: ValueConverter = NumberConverters.of(NumberConverters.LongToStringConverter) /** * Converts between [Short] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val ShortConverter: ValueConverter = NumberConverters.of(NumberConverters.ShortToStringConverter) /** * Converts between [UByte] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val UByteConverter: ValueConverter = NumberConverters.of(NumberConverters.UByteToStringConverter) /** * Converts between [UInt] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val UIntConverter: ValueConverter = NumberConverters.of(NumberConverters.UIntToStringConverter) /** * Converts between [ULong] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val ULongConverter: ValueConverter = NumberConverters.of(NumberConverters.ULongToStringConverter) /** * Converts between [UShort] and * [DynamoDB `N` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Number) */ +@ExperimentalApi public val UShortConverter: ValueConverter = NumberConverters.of(NumberConverters.UShortToStringConverter) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/TextConverters.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/TextConverters.kt index 06a24101ab0..0baea144585 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/TextConverters.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/scalars/TextConverters.kt @@ -8,10 +8,12 @@ import aws.sdk.kotlin.hll.dynamodbmapper.values.ValueConverter import aws.sdk.kotlin.hll.mapping.core.converters.Converter import aws.sdk.kotlin.hll.mapping.core.converters.andThenTo import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Namespace for containing various conversion utilities dealing with text conversion */ +@ExperimentalApi public object TextConverters { /** * Converts between [CharArray] and [String] @@ -33,12 +35,14 @@ public object TextConverters { * Converts between [String] and * [DynamoDB `S` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.String) */ +@ExperimentalApi public val StringConverter: ValueConverter = Converter(AttributeValue::S, AttributeValue::asS) /** * Converts between [CharArray] and * [DynamoDB `S` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.String) */ +@ExperimentalApi public val CharArrayConverter: ValueConverter = TextConverters.CharArrayToStringConverter.andThenTo(StringConverter) @@ -46,4 +50,5 @@ public val CharArrayConverter: ValueConverter = * Converts between [Char] and * [DynamoDB `S` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.String) */ +@ExperimentalApi public val CharConverter: ValueConverter = TextConverters.CharToStringConverter.andThenTo(StringConverter) diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/DocumentConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/DocumentConverter.kt index cf1c577e04e..1d36c8383ae 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/DocumentConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/DocumentConverter.kt @@ -15,6 +15,7 @@ import aws.sdk.kotlin.hll.mapping.core.converters.collections.mapFrom import aws.sdk.kotlin.hll.mapping.core.converters.collections.mapValuesFrom import aws.sdk.kotlin.hll.mapping.core.converters.mergeBy import aws.sdk.kotlin.services.dynamodb.model.AttributeValue +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.smithy.kotlin.runtime.content.Document /** @@ -26,6 +27,7 @@ import aws.smithy.kotlin.runtime.content.Document * * [Document.List] ↔ [DynamoDB `L` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Document.List) * * [Document.Map] ↔ [DynamoDB `M` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.Document.Map) */ +@ExperimentalApi public class DocumentConverter( private val numberConverter: ValueConverter = AutoNumberConverter, private val stringConverter: ValueConverter = StringConverter, @@ -38,6 +40,7 @@ public class DocumentConverter( private val listConverter = listConverter.mapFrom(this.nullableConverter) private val mapConverter = mapConverter.mapValuesFrom(this.nullableConverter) + @ExperimentalApi public companion object { /** * The default instance of [DocumentConverter] diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/InstantConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/InstantConverter.kt index fbcac84d692..9513032b386 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/InstantConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/InstantConverter.kt @@ -9,6 +9,7 @@ import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.LongConverter import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.StringConverter import aws.sdk.kotlin.hll.mapping.core.converters.Converter import aws.sdk.kotlin.hll.mapping.core.converters.andThenTo +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.smithy.kotlin.runtime.time.Instant import aws.smithy.kotlin.runtime.time.TimestampFormat import aws.smithy.kotlin.runtime.time.epochMilliseconds @@ -17,6 +18,7 @@ import aws.smithy.kotlin.runtime.time.fromEpochMilliseconds /** * Provides access to [ValueConverter] types for various [Instant] representations */ +@ExperimentalApi public object InstantConverter { /** * Converts between [Instant] and diff --git a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/UrlConverter.kt b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/UrlConverter.kt index 6d12de6e35b..a727fda3283 100644 --- a/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/UrlConverter.kt +++ b/hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/values/smithytypes/UrlConverter.kt @@ -8,15 +8,18 @@ import aws.sdk.kotlin.hll.dynamodbmapper.values.ValueConverter import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.StringConverter import aws.sdk.kotlin.hll.mapping.core.converters.Converter import aws.sdk.kotlin.hll.mapping.core.converters.andThenTo +import aws.smithy.kotlin.runtime.ExperimentalApi import aws.smithy.kotlin.runtime.net.url.Url /** * Converts between [Url] and [String] types */ +@ExperimentalApi public val UrlToStringConverter: Converter = Converter(Url::toString, Url::parse) /** * Converts between [Url] and * [DynamoDB `S` values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.String) */ +@ExperimentalApi public val UrlConverter: ValueConverter = UrlToStringConverter.andThenTo(StringConverter) diff --git a/hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/model/Types.kt b/hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/model/Types.kt index 52bbb1faa0e..64400b17a79 100644 --- a/hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/model/Types.kt +++ b/hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/model/Types.kt @@ -9,6 +9,7 @@ import aws.sdk.kotlin.runtime.InternalSdkApi public object Types { @InternalSdkApi public object Smithy { + public val ExperimentalApi: TypeRef = TypeRef("aws.smithy.kotlin.runtime", "ExperimentalApi") public val Instant: TypeRef = TypeRef("aws.smithy.kotlin.runtime.time", "Instant") public val Url: TypeRef = TypeRef("aws.smithy.kotlin.runtime.net.url", "Url") public val Document: TypeRef = TypeRef("aws.smithy.kotlin.runtime.content", "Document") diff --git a/hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/rendering/BuilderRenderer.kt b/hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/rendering/BuilderRenderer.kt index 34f2b0bc069..d14733105f4 100644 --- a/hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/rendering/BuilderRenderer.kt +++ b/hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/rendering/BuilderRenderer.kt @@ -38,6 +38,7 @@ public class BuilderRenderer( val genericParams = members.flatMap { it.type.genericVars() }.asParamsList() + write("@#T", Types.Smithy.ExperimentalApi) withBlock("#Lclass #L#L {", "}", ctx.attributes.visibility, builderName, genericParams) { members.forEach(::renderProperty) blankLine() diff --git a/hll/hll-mapping-core/build.gradle.kts b/hll/hll-mapping-core/build.gradle.kts index 5490add9a6a..b7c2dc41027 100644 --- a/hll/hll-mapping-core/build.gradle.kts +++ b/hll/hll-mapping-core/build.gradle.kts @@ -1,3 +1,5 @@ +import aws.sdk.kotlin.gradle.kmp.kotlin + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 @@ -6,3 +8,13 @@ description = "Common data mapping utilities used by AWS SDK for Kotlin's high level libraries" extra["displayName"] = "AWS :: SDK :: Kotlin :: HLL :: Mapping" extra["moduleName"] = "aws.sdk.kotlin.hll.mapping.core" + +kotlin { + sourceSets { + commonMain { + dependencies { + implementation(libs.smithy.kotlin.runtime.core) + } + } + } +} diff --git a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/Converter.kt b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/Converter.kt index 65af4456255..cbb024960e6 100644 --- a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/Converter.kt +++ b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/Converter.kt @@ -4,11 +4,14 @@ */ package aws.sdk.kotlin.hll.mapping.core.converters +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Models two-way conversion between a type [T] and a type [F] * @param F The type being converted from * @param T The type being converted to */ +@ExperimentalApi public interface Converter : ConvertsTo, ConvertsFrom @@ -20,6 +23,7 @@ public interface Converter : * @param convertTo A converter instance for converting one-way from [F] to [T] * @param convertFrom A converter instance for converting one-way from [T] to [F] */ +@ExperimentalApi public fun Converter(convertTo: ConvertsTo, convertFrom: ConvertsFrom): Converter = object : Converter, ConvertsTo by convertTo, ConvertsFrom by convertFrom { } @@ -33,6 +37,7 @@ public fun Converter(convertTo: ConvertsTo, convertFrom: ConvertsFr * @param converter The converter to chain together with this converter. Note that the source type of the given * [converter] must be the same as the target type of this converter. */ +@ExperimentalApi public fun Converter.andThenTo(converter: Converter): Converter = Converter(this.andThenConvertsTo(converter), converter.andThenConvertsFrom(this)) @@ -46,6 +51,7 @@ public fun Converter.andThenTo(converter: Converter): Co * @param converter The converter to chain together with this converter. Note that the target type of the given * [converter] must be the same as the source type of this converter. */ +@ExperimentalApi public fun Converter.andThenFrom(converter: Converter): Converter = Converter(converter.andThenConvertsTo(this), this.andThenConvertsFrom(converter)) @@ -57,6 +63,7 @@ public fun Converter.andThenFrom(converter: Converter): * @param validate A function which accepts an [F] value and throws an exception if the expected condition is not * met */ +@ExperimentalApi public fun Converter.validatingFrom(validate: (F) -> Unit): Converter = Converter(this.firstValidatingFrom(validate), this) @@ -68,5 +75,6 @@ public fun Converter.validatingFrom(validate: (F) -> Unit): Convert * @param validate A function which accepts a [T] value and throws an exception if the expected condition is not * met */ +@ExperimentalApi public fun Converter.validatingTo(validate: (T) -> Unit): Converter = Converter(this, this.firstValidatingTo(validate)) diff --git a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/ConvertsFrom.kt b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/ConvertsFrom.kt index b21c2495516..7f81d9aee9f 100644 --- a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/ConvertsFrom.kt +++ b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/ConvertsFrom.kt @@ -4,12 +4,15 @@ */ package aws.sdk.kotlin.hll.mapping.core.converters +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Models one-way conversion from a type [T] to a type [F]. This type is similar to [ConvertsTo] but models conversion * in the opposite direction. * @param F The type being converted to * @param T The type being converted from */ +@ExperimentalApi public fun interface ConvertsFrom { /** * Converts a single value from type [T] to type [F] @@ -28,6 +31,7 @@ public fun interface ConvertsFrom { * @param converter The converter to chain together with this converter. Note that the target type of the given * [converter] must be the same as the source type of this converter. */ +@ExperimentalApi public fun ConvertsFrom.andThenConvertsFrom(converter: ConvertsFrom): ConvertsFrom = ConvertsFrom { to: T -> converter.convertFrom(this.convertFrom(to)) } @@ -38,6 +42,7 @@ public fun ConvertsFrom.andThenConvertsFrom(converter: Converts * @param T The type being converted from * @param validate A function which accepts a [T] value and throws an exception if the expected condition is not met */ +@ExperimentalApi public fun ConvertsFrom.firstValidatingTo(validate: (T) -> Unit): ConvertsFrom = ConvertsFrom { to: T -> validate(to) diff --git a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/ConvertsTo.kt b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/ConvertsTo.kt index d3f40e0832e..b7c4e02eb85 100644 --- a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/ConvertsTo.kt +++ b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/ConvertsTo.kt @@ -4,11 +4,14 @@ */ package aws.sdk.kotlin.hll.mapping.core.converters +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Models one-way conversion from a type [F] to a type [T] * @param F The type being converted from * @param T The type being converted to */ +@ExperimentalApi public fun interface ConvertsTo { /** * Converts a single value from type [F] to type [T] @@ -27,6 +30,7 @@ public fun interface ConvertsTo { * @param converter The converter to chain together with this converter. Note that the source type of the given * [converter] must be the same as the target type of this converter. */ +@ExperimentalApi public fun ConvertsTo.andThenConvertsTo(converter: ConvertsTo): ConvertsTo = ConvertsTo { from: F -> converter.convertTo(this.convertTo(from)) } @@ -37,6 +41,7 @@ public fun ConvertsTo.andThenConvertsTo(converter: ConvertsTo ConvertsTo.firstValidatingFrom(validate: (F) -> Unit): ConvertsTo = ConvertsTo { from: F -> validate(from) diff --git a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/SplittingConverter.kt b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/SplittingConverter.kt index c6469d7f430..6bdce1186e6 100644 --- a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/SplittingConverter.kt +++ b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/SplittingConverter.kt @@ -7,6 +7,7 @@ package aws.sdk.kotlin.hll.mapping.core.converters import aws.sdk.kotlin.hll.mapping.core.util.Either import aws.sdk.kotlin.hll.mapping.core.util.map import aws.sdk.kotlin.hll.mapping.core.util.merge +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Models partial, asymmetrical conversion between a type [F] and a type [T], where some condition internal to the @@ -26,6 +27,7 @@ import aws.sdk.kotlin.hll.mapping.core.util.merge * @param T2 The intermediate type being converted to on the complex branch * @param T The overall type being converted to */ +@ExperimentalApi public interface SplittingConverter : ConvertsTo>, ConvertsFrom, T> @@ -41,6 +43,7 @@ public interface SplittingConverter : * @param T The overall type being converted to * @param converter A [Converter] between types [F2] and [T2] */ +@ExperimentalApi public fun SplittingConverter.mergeBy( converter: Converter, ): Converter = diff --git a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/CollectionTypeConverters.kt b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/CollectionTypeConverters.kt index e1b4dc55f23..5c9cb9b288e 100644 --- a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/CollectionTypeConverters.kt +++ b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/CollectionTypeConverters.kt @@ -5,11 +5,13 @@ package aws.sdk.kotlin.hll.mapping.core.converters.collections import aws.sdk.kotlin.hll.mapping.core.converters.Converter +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Namespace for containing various conversion utilities dealing with mapping between collection types (e.g., [Set] to * [List]) */ +@ExperimentalApi public object CollectionTypeConverters { /** * Creates a [Converter] which transforms between [Set] and [List] instances (both of some type [T]) diff --git a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/ListMappingConverters.kt b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/ListMappingConverters.kt index 3a333b29185..addfd5aa23e 100644 --- a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/ListMappingConverters.kt +++ b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/ListMappingConverters.kt @@ -5,10 +5,12 @@ package aws.sdk.kotlin.hll.mapping.core.converters.collections import aws.sdk.kotlin.hll.mapping.core.converters.* +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Namespace for containing various conversion utilities dealing with [List] mapping */ +@ExperimentalApi public object ListMappingConverters { /** * Creates a one-way converter for transforming [List] with elements of type [T] to [List] with elements of type [F] @@ -77,6 +79,7 @@ public object ListMappingConverters { * @param elementConverter The element converter to chain together with this list converter. Note that the target type * of the given [elementConverter] must be the same as the source element type of this converter. */ +@ExperimentalApi public fun Converter, T>.mapFrom(elementConverter: Converter): Converter, T> = this.andThenFrom(ListMappingConverters.of(elementConverter)) @@ -90,5 +93,6 @@ public fun Converter, T>.mapFrom(elementConverter: Converter< * @param elementConverter The element converter to chain together with this list converter. Note that the source type * of the given [elementConverter] must be the same as the target element type of this converter. */ +@ExperimentalApi public fun Converter>.mapTo(elementConverter: Converter): Converter> = this.andThenTo(ListMappingConverters.of(elementConverter)) diff --git a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/MapMappingConverters.kt b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/MapMappingConverters.kt index 515a99182c2..9e65fb5bba5 100644 --- a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/MapMappingConverters.kt +++ b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/MapMappingConverters.kt @@ -5,10 +5,12 @@ package aws.sdk.kotlin.hll.mapping.core.converters.collections import aws.sdk.kotlin.hll.mapping.core.converters.* +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Namespace for containing various conversion utilities dealing with [Map] mapping */ +@ExperimentalApi public object MapMappingConverters { /** * Creates a one-way converter for transforming [Map] with keys of type [TK] to [Map] with keys of type [FK]. The @@ -246,6 +248,7 @@ public object MapMappingConverters { * @param keyConverter The key converter to chain together with this map converter. Note that the target key type of the * given [keyConverter] must be the same as the source key type of this converter. */ +@ExperimentalApi public fun Converter, T>.mapKeysFrom( keyConverter: Converter, ): Converter, T> = this.andThenFrom(MapMappingConverters.ofKeys(keyConverter)) @@ -261,6 +264,7 @@ public fun Converter, T>.mapKeysFrom( * @param keyConverter The key converter to chain together with this map converter. Note that the source key type of the * given [keyConverter] must be the same as the target key type of this converter. */ +@ExperimentalApi public fun Converter>.mapKeysTo( keyConverter: Converter, ): Converter> = this.andThenTo(MapMappingConverters.ofKeys(keyConverter)) @@ -276,6 +280,7 @@ public fun Converter>.mapKeysTo( * @param valueConverter The value converter to chain together with this map converter. Note that the target value type * of the given [valueConverter] must be the same as the source value type of this converter. */ +@ExperimentalApi public fun Converter, T>.mapValuesFrom( valueConverter: Converter, ): Converter, T> = this.andThenFrom(MapMappingConverters.ofValues(valueConverter)) @@ -291,6 +296,7 @@ public fun Converter, T>.mapValuesFrom( * @param valueConverter The value converter to chain together with this map converter. Note that the source value type * of the given [valueConverter] must be the same as the target value type of this converter. */ +@ExperimentalApi public fun Converter>.mapValuesTo( valueConverter: Converter, ): Converter> = this.andThenTo(MapMappingConverters.ofValues(valueConverter)) @@ -321,6 +327,7 @@ private fun Converter.zip(other: Converter) = C * @param entryConverter The entry converter to chain together with this map converter. Note that the target types of * the given [entryConverter] must be the same as the source types of this converter. */ +@ExperimentalApi public fun Converter, T>.mapFrom( entryConverter: Converter, Pair>, ): Converter, T> = this.andThenFrom(MapMappingConverters.of(entryConverter)) @@ -339,6 +346,7 @@ public fun Converter, T>.mapFrom( * @param valueConverter The value converter to chain together with this map converter. Note that the target value type * of the given [valueConverter] must be the same as the source value type of this converter. */ +@ExperimentalApi public fun Converter, T>.mapFrom( keyConverter: Converter, valueConverter: Converter, @@ -356,6 +364,7 @@ public fun Converter, T>.mapFrom( * @param entryConverter The entry converter to chain together with this map converter. Note that the source types of * the given [entryConverter] must be the same as the target types of this converter. */ +@ExperimentalApi public fun Converter>.mapTo( entryConverter: Converter, Pair>, ): Converter> = this.andThenTo(MapMappingConverters.of(entryConverter)) @@ -374,6 +383,7 @@ public fun Converter>.mapTo( * @param valueConverter The value converter to chain together with this map converter. Note that the source value type * of the given [valueConverter] must be the same as the target value type of this converter. */ +@ExperimentalApi public fun Converter>.mapTo( keyConverter: Converter, valueConverter: Converter, diff --git a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/SetMappingConverters.kt b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/SetMappingConverters.kt index 585f8b54544..b97585779bd 100644 --- a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/SetMappingConverters.kt +++ b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/converters/collections/SetMappingConverters.kt @@ -5,10 +5,12 @@ package aws.sdk.kotlin.hll.mapping.core.converters.collections import aws.sdk.kotlin.hll.mapping.core.converters.* +import aws.smithy.kotlin.runtime.ExperimentalApi /** * Namespace for containing various conversion utilities dealing with [Set] mapping */ +@ExperimentalApi public object SetMappingConverters { /** * Creates a one-way converter for transforming [Set] with elements of type [T] to [Set] with elements of type [F] @@ -77,6 +79,7 @@ public object SetMappingConverters { * @param elementConverter The element converter to chain together with this set converter. Note that the target type * of the given [elementConverter] must be the same as the source element type of this converter. */ +@ExperimentalApi public fun Converter, T>.mapFrom(elementConverter: Converter): Converter, T> = this.andThenFrom(SetMappingConverters.of(elementConverter)) @@ -90,5 +93,6 @@ public fun Converter, T>.mapFrom(elementConverter: Converter Converter>.mapTo(elementConverter: Converter): Converter> = this.andThenTo(SetMappingConverters.of(elementConverter)) diff --git a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/util/Either.kt b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/util/Either.kt index 2d0669b282f..b6b79d2ec81 100644 --- a/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/util/Either.kt +++ b/hll/hll-mapping-core/common/src/aws/sdk/kotlin/hll/mapping/core/util/Either.kt @@ -4,6 +4,8 @@ */ package aws.sdk.kotlin.hll.mapping.core.util +import aws.smithy.kotlin.runtime.ExperimentalApi + /** * Represents a value which may be one of two possible types: [L] or [R]. An instance of this type will be either [Left] * or [Right]. @@ -15,11 +17,13 @@ package aws.sdk.kotlin.hll.mapping.core.util * @param L The type of [Left] values * @param R The type of [Right] values */ +@ExperimentalApi public sealed interface Either { /** * The left side of an [Either] * @param L The type of values held in this class */ + @ExperimentalApi public interface Left : Either { /** * An [L] value @@ -31,6 +35,7 @@ public sealed interface Either { * The right side of an [Either] * @param R The type of values held in this class */ + @ExperimentalApi public interface Right : Either { /** * An [R] value @@ -38,6 +43,7 @@ public sealed interface Either { public val value: R } + @ExperimentalApi public companion object { /** * Creates a new [Left] with the given [value] @@ -66,6 +72,7 @@ private data class RightImpl(override val value: R) : Either.Right * @param R2 The new type of right value * @param func A mapping function which turns an [R] into an [R2] */ +@ExperimentalApi public inline fun Either.map(func: (right: R) -> R2): Either = when (this) { is Either.Left -> this is Either.Right -> Either.Right(func(value)) @@ -79,6 +86,7 @@ public inline fun Either.map(func: (right: R) -> R2): Either Either.fold(ifLeft: (left: L) -> T, ifRight: (right: R) -> T): T = when (this) { is Either.Left -> ifLeft(value) is Either.Right -> ifRight(value) @@ -88,4 +96,5 @@ public inline fun Either.fold(ifLeft: (left: L) -> T, ifRight: ( * Returns the left value or right value * @param T The type of values in left/right */ +@ExperimentalApi public fun Either.merge(): T = fold({ it }, { it })