From a6c51a2d79885d1e2d09c6ca08aa4927fa02dd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Thu, 12 Sep 2024 17:20:16 +0200 Subject: [PATCH] feat(dsl): Create the DangerousMongoApi annotation --- .../commonMain/kotlin/DangerousMongoApi.kt | 32 +++++++++++++++++++ prototype/dsl/src/main/kotlin/LowLevelApi.kt | 16 ---------- 2 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 dsl/src/commonMain/kotlin/DangerousMongoApi.kt delete mode 100644 prototype/dsl/src/main/kotlin/LowLevelApi.kt diff --git a/dsl/src/commonMain/kotlin/DangerousMongoApi.kt b/dsl/src/commonMain/kotlin/DangerousMongoApi.kt new file mode 100644 index 00000000..8e05eb6b --- /dev/null +++ b/dsl/src/commonMain/kotlin/DangerousMongoApi.kt @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024, OpenSavvy, 4SH and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package opensavvy.ktmongo.dsl + +/** + * Annotation to mark parts of the library that are not meant to be used by end-users. + * + * They are still public because they may be needed by driver implementations, + * or to in case some functionality is missing in the high-level API + * (which is everything *not* annotated by this annotation). + * + * Users should be cautious about using functionality from the low-level API, as it may + * not protect against incorrect usage. This could leak to injection attacks, memory leaks, or + * other unwanted consequences. + */ +@RequiresOptIn("This is a declaration from the low-level API which is used internally. We recommend against using it when possible, because it has less safety features and can easily create situations in which injections are possible. Behavior may also change between versions without warnings.", RequiresOptIn.Level.ERROR) +@MustBeDocumented +annotation class DangerousMongoApi diff --git a/prototype/dsl/src/main/kotlin/LowLevelApi.kt b/prototype/dsl/src/main/kotlin/LowLevelApi.kt deleted file mode 100644 index ee0324d1..00000000 --- a/prototype/dsl/src/main/kotlin/LowLevelApi.kt +++ /dev/null @@ -1,16 +0,0 @@ -package fr.qsh.ktmongo.dsl - -/** - * Annotation to mark parts of the library that are not meant to be used by end-users. - * - * They are still public because they may be needed by driver implementations, - * or to in case some functionality is missing in the high-level API - * (which is everything *not* annotated by this annotation). - * - * Users should be cautious about using functionality from the low-level API, as it may - * not protect against incorrect usage. This could leak to injection attacks, memory leaks, or - * other unwanted consequences. - */ -@RequiresOptIn("This is a declaration from the low-level API which is used internally. We recommend against using it when possible, because it has less safety features and is thus easy to misuse.") -@MustBeDocumented -annotation class LowLevelApi -- 2.51.2