-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from SwissDataScienceCenter/move-model-classes
chore: Move name and id to a common namespace
- Loading branch information
Showing
32 changed files
with
328 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
rules = [ | ||
OrganizeImports | ||
] | ||
OrganizeImports { | ||
coalesceToWildcardImportThreshold = 3 | ||
expandRelative = true | ||
groupedImports = Keep | ||
importsOrder = Ascii | ||
groups = ["re:javax?\\.", "scala.", "re:(cats|fs2)\\.", "*"] | ||
importSelectorsOrder = Ascii | ||
removeUnused = false | ||
targetDialect = Scala3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
modules/commons/src/main/scala/io/renku/search/model/Id.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2024 Swiss Data Science Center (SDSC) | ||
* A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and | ||
* Eidgenössische Technische Hochschule Zürich (ETHZ). | ||
* | ||
* 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 io.renku.search.model | ||
|
||
import io.bullet.borer.Codec | ||
import io.github.arainko.ducktape.Transformer | ||
|
||
opaque type Id = String | ||
object Id: | ||
def apply(v: String): Id = v | ||
extension (self: Id) def value: String = self | ||
given Transformer[String, Id] = apply | ||
given Codec[Id] = Codec.of[String] |
29 changes: 29 additions & 0 deletions
29
modules/commons/src/main/scala/io/renku/search/model/Name.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2024 Swiss Data Science Center (SDSC) | ||
* A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and | ||
* Eidgenössische Technische Hochschule Zürich (ETHZ). | ||
* | ||
* 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 io.renku.search.model | ||
|
||
import io.bullet.borer.Codec | ||
import io.github.arainko.ducktape.Transformer | ||
|
||
opaque type Name = String | ||
object Name: | ||
def apply(v: String): Name = v | ||
extension (self: Name) def value: String = self | ||
given Transformer[String, Name] = apply | ||
given Codec[Name] = Codec.of[String] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,23 +18,23 @@ | |
|
||
package io.renku.search.api.data | ||
|
||
import io.bullet.borer.* | ||
import java.time.Instant | ||
|
||
import io.bullet.borer.NullOptions.given | ||
import io.bullet.borer.* | ||
import io.bullet.borer.derivation.MapBasedCodecs.{deriveAllCodecs, deriveCodec} | ||
import io.renku.search.model.* | ||
import io.renku.search.api.tapir.SchemaSyntax.* | ||
import io.renku.search.model.* | ||
import sttp.tapir.Schema.SName | ||
import sttp.tapir.SchemaType.{SCoproduct, SDateTime, SProductField, SRef} | ||
import sttp.tapir.SchemaType._ | ||
import sttp.tapir.generic.Configuration | ||
import sttp.tapir.{FieldName, Schema, SchemaType} | ||
|
||
import java.time.Instant | ||
|
||
sealed trait SearchEntity | ||
|
||
final case class Project( | ||
id: projects.Id, | ||
name: projects.Name, | ||
id: Id, | ||
name: Name, | ||
slug: projects.Slug, | ||
repositories: Seq[projects.Repository], | ||
visibility: projects.Visibility, | ||
|
@@ -45,8 +45,8 @@ final case class Project( | |
) extends SearchEntity | ||
|
||
object Project: | ||
private given Schema[projects.Id] = Schema.string[projects.Id] | ||
private given Schema[projects.Name] = Schema.string[projects.Name] | ||
private given Schema[Id] = Schema.string[Id] | ||
private given Schema[Name] = Schema.string[Name] | ||
private given Schema[projects.Slug] = Schema.string[projects.Slug] | ||
private given Schema[projects.Repository] = Schema.string[projects.Repository] | ||
private given Schema[projects.Visibility] = | ||
|
@@ -57,45 +57,45 @@ object Project: | |
.derived[Project] | ||
.jsonExample( | ||
Project( | ||
projects.Id("01HRA7AZ2Q234CDQWGA052F8MK"), | ||
projects.Name("renku"), | ||
Id("01HRA7AZ2Q234CDQWGA052F8MK"), | ||
Name("renku"), | ||
projects.Slug("renku"), | ||
Seq(projects.Repository("https://github.com/renku")), | ||
projects.Visibility.Public, | ||
Some(projects.Description("Renku project")), | ||
UserId(users.Id("1CAF4C73F50D4514A041C9EDDB025A36")), | ||
UserId(Id("1CAF4C73F50D4514A041C9EDDB025A36")), | ||
projects.CreationDate(Instant.now), | ||
Some(1.0) | ||
): SearchEntity | ||
) | ||
|
||
final case class UserId(id: users.Id) | ||
final case class UserId(id: Id) | ||
object UserId: | ||
given Codec[UserId] = deriveCodec[UserId] | ||
|
||
private given Schema[users.Id] = Schema.string[users.Id] | ||
private given Schema[Id] = Schema.string[Id] | ||
given Schema[UserId] = Schema | ||
.derived[UserId] | ||
.jsonExample(UserId(users.Id("01HRA7AZ2Q234CDQWGA052F8MK"))) | ||
.jsonExample(UserId(Id("01HRA7AZ2Q234CDQWGA052F8MK"))) | ||
|
||
final case class User( | ||
id: users.Id, | ||
id: Id, | ||
firstName: Option[users.FirstName] = None, | ||
lastName: Option[users.LastName] = None, | ||
email: Option[users.Email] = None, | ||
score: Option[Double] = None | ||
) extends SearchEntity | ||
|
||
object User: | ||
private given Schema[users.Id] = Schema.string[users.Id] | ||
private given Schema[Id] = Schema.string[Id] | ||
private given Schema[users.FirstName] = Schema.string[users.FirstName] | ||
private given Schema[users.LastName] = Schema.string[users.LastName] | ||
private given Schema[users.Email] = Schema.string[users.Email] | ||
given Schema[User] = Schema | ||
.derived[User] | ||
.jsonExample( | ||
User( | ||
users.Id("1CAF4C73F50D4514A041C9EDDB025A36"), | ||
Id("1CAF4C73F50D4514A041C9EDDB025A36"), | ||
Some(users.FirstName("Albert")), | ||
Some(users.LastName("Einstein")), | ||
Some(users.Email("[email protected]")), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.