Skip to content

Commit

Permalink
merge: Split the core module
Browse files Browse the repository at this point in the history
Split the core module into:
- `core-data`: data types used throughout the application
- `core-users`: authentication and user management
- `core-domain`: schema and workflow

This change will make the build faster by making it more parallel.

Closes #303

See merge request opensavvy/formulaide!163
  • Loading branch information
maximegirardet committed Jun 27, 2023
2 parents 8c05668 + adb02d4 commit 7685a9c
Show file tree
Hide file tree
Showing 38 changed files with 172 additions and 42 deletions.
4 changes: 3 additions & 1 deletion backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ plugins {
}

dependencies {
implementation(projects.core)
implementation(projects.core.coreData)
implementation(projects.core.coreUsers)
implementation(projects.core.coreDomain)
implementation(projects.fake)
implementation(projects.mongo)
implementation(projects.remoteServer)
Expand Down
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ fun calculateVersion(): String {
else
"${details.lastTag}-post.${details.commitDistance}+${details.gitHash}"
}

// Workaround for https://github.com/Kotlin/dokka/issues/2954
tasks.named("dokkaHtmlMultiModule") {
dependsOn(
":core:dokkaHtmlMultiModule",
)
}
3 changes: 3 additions & 0 deletions core/core-data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Module core-data

Data structures and other helpers for the other core modules.
51 changes: 51 additions & 0 deletions core/core-data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import java.net.URL

plugins {
kotlin("multiplatform")
}

kotlin {
jvm {
jvmToolchain(17)
testRuns.named("test") {
executionTask.configure {
useJUnitPlatform()
}
}
}
js(IR) {
browser {
testTask {
useMocha {
timeout = "1 minute"
}
}
}
}

sourceSets {
val commonMain by getting {
dependencies {
// Nothing here
}
}

val commonTest by getting {
dependencies {
implementation(projects.testStructure)
}
}
}
}

tasks.withType<org.jetbrains.dokka.gradle.DokkaTaskPartial>().configureEach {
dokkaSourceSets.configureEach {
includes.from("${project.projectDir}/README.md")

sourceLink {
localDirectory.set(file("src"))
remoteUrl.set(URL("https://gitlab.com/opensavvy/formulaide/-/blob/main/core/core-data/src"))
remoteLineSuffix.set("#L")
}
}
}
3 changes: 3 additions & 0 deletions core/core-data/src/commonMain/kotlin/Marker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package opensavvy.formulaide.core

// This is a marker for the package declaration
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions core/core-data/src/commonTest/kotlin/Marker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package opensavvy.formulaide.core

// This is a marker for the package declaration
22 changes: 2 additions & 20 deletions core/README.md → core/core-domain/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
# Module core
# Module core-domain

Core APIs for the Formulaide project.

Formulaide administrators can create web forms entirely online, and declare how the data submitted by users is shared between departments of the company to ensure each request is checked by the correct people.

## Users and departments

There are two types of [users][opensavvy.formulaide.core.User] of Formulaide: the end users, called [guests][opensavvy.formulaide.core.User.Role.Guest], and [employees][opensavvy.formulaide.core.User.Role.Employee].

Guests can submit data to the available forms. They are always anonymous and unauthenticated, and therefore cannot access any data (even their own).

Employees can also submit data to forms, as well as accessing internal forms.
Employees are part of [departments][opensavvy.formulaide.core.Department], which represent the different sections of the company or association using Formulaide.
End user submissions are protected to only be visible by employees belonging to specific departments.

The [administrator][opensavvy.formulaide.core.User.Role.Administrator] is a specific role given to employees who are allowed to manage Formulaide itself. They can create and edit forms, browse through all user data, and delete data permanently to comply with GDPR requests.
Core functionality of the Formulaide project.

## Form structure

Expand All @@ -41,7 +27,3 @@ The companion service is an interface that describes the contract all Formulaide
Because each object is immutable, the companion reference is used to access their values over time. This avoids data nesting in other data structures, and makes it easier for a client to only request information they do not already possess.

For more information about this design pattern, see the [Pedestal](https://gitlab.com/opensavvy/pedestal) project.

# Package opensavvy.formulaide.core.data

Additional data structures created for convenience and type safety.
57 changes: 57 additions & 0 deletions core/core-domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import java.net.URL

plugins {
kotlin("multiplatform")
}

kotlin {
jvm {
jvmToolchain(17)
testRuns.named("test") {
executionTask.configure {
useJUnitPlatform()
}
}
}
js(IR) {
browser {
testTask {
useMocha {
timeout = "1 minute"
}
}
}
}

sourceSets {
val commonMain by getting {
dependencies {
api("opensavvy.pedestal:backbone:_")
api("opensavvy.pedestal:state-arrow:_")
api(KotlinX.datetime)

api(projects.core.coreData)
api(projects.core.coreUsers)
}
}

val commonTest by getting {
dependencies {
implementation(projects.test)
implementation(projects.fake)
}
}
}
}

tasks.withType<org.jetbrains.dokka.gradle.DokkaTaskPartial>().configureEach {
dokkaSourceSets.configureEach {
includes.from("${project.projectDir}/README.md")

sourceLink {
localDirectory.set(file("src"))
remoteUrl.set(URL("https://gitlab.com/opensavvy/formulaide/-/blob/main/core/core-domain/src"))
remoteLineSuffix.set("#L")
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,39 @@ class InputTest : TestExecutor() {
val files = FakeFiles(clock)
val bool = Input.Toggle

bool.parse("true", files).shouldSucceedAnd {
Input.Toggle.parse("true", files).shouldSucceedAnd {
assertEquals(true, it)
}

bool.parse("false", files).shouldSucceedAnd {
Input.Toggle.parse("false", files).shouldSucceedAnd {
assertEquals(false, it)
}

bool.parse("other", files) shouldFailWithType Input.Failures.Parsing::class
bool.parse("something", files) shouldFailWithType Input.Failures.Parsing::class
Input.Toggle.parse("other", files) shouldFailWithType Input.Failures.Parsing::class
Input.Toggle.parse("something", files) shouldFailWithType Input.Failures.Parsing::class
}

test("Email") {
val files = FakeFiles(clock)
val email = Input.Email

email.parse("[email protected]", files).shouldSucceedAnd {
Input.Email.parse("[email protected]", files).shouldSucceedAnd {
assertEquals(Email("[email protected]"), it)
}

email.parse("something", files) shouldFailWithType Input.Failures.Parsing::class
Input.Email.parse("something", files) shouldFailWithType Input.Failures.Parsing::class
}

test("Parse phone number") {
val files = FakeFiles(clock)
val phone = Input.Phone

phone.parse("+332345678", files).shouldSucceedAnd {
Input.Phone.parse("+332345678", files).shouldSucceedAnd {
assertEquals("+332345678", it)
}

phone.parse("thing", files) shouldFailWithType Input.Failures.Parsing::class
phone.parse("123456789123456789123456789", files) shouldFailWithType Input.Failures.Parsing::class
Input.Phone.parse("thing", files) shouldFailWithType Input.Failures.Parsing::class
Input.Phone.parse("123456789123456789123456789", files) shouldFailWithType Input.Failures.Parsing::class
}

test("Int range constructor") {
Expand Down
13 changes: 13 additions & 0 deletions core/core-users/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Module core-users

Authentication and role management for Formulaide users.

There are two types of [users][opensavvy.formulaide.core.User] of Formulaide: the end users, called [guests][opensavvy.formulaide.core.User.Role.Guest], and [employees][opensavvy.formulaide.core.User.Role.Employee].

Guests can submit data to the available forms. They are always anonymous and unauthenticated, and therefore cannot access any data (even their own).

Employees can also submit data to forms, as well as accessing internal forms.
Employees are part of [departments][opensavvy.formulaide.core.Department], which represent the different sections of the company or association using Formulaide.
End user submissions are protected to only be visible by employees belonging to specific departments.

The [administrator][opensavvy.formulaide.core.User.Role.Administrator] is a specific role given to employees who are allowed to manage Formulaide itself. They can create and edit forms, browse through all user data, and delete data permanently to comply with GDPR requests.
7 changes: 3 additions & 4 deletions core/build.gradle.kts → core/core-users/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("UNUSED_VARIABLE")

import java.net.URL

plugins {
Expand Down Expand Up @@ -30,7 +28,8 @@ kotlin {
dependencies {
api("opensavvy.pedestal:backbone:_")
api("opensavvy.pedestal:state-arrow:_")
api(KotlinX.datetime)

api(projects.core.coreData)
}
}

Expand All @@ -49,7 +48,7 @@ tasks.withType<org.jetbrains.dokka.gradle.DokkaTaskPartial>().configureEach {

sourceLink {
localDirectory.set(file("src"))
remoteUrl.set(URL("https://gitlab.com/opensavvy/formulaide/-/blob/main/core/src"))
remoteUrl.set(URL("https://gitlab.com/opensavvy/formulaide/-/blob/main/core/core-users/src"))
remoteLineSuffix.set("#L")
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion fake/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api(projects.core)
api(projects.core.coreData)
api(projects.core.coreUsers)
api(projects.core.coreDomain)

implementation("opensavvy.pedestal:logger:_")
}
Expand Down
4 changes: 3 additions & 1 deletion mongo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ plugins {
}

dependencies {
api(projects.core)
api(projects.core.coreData)
api(projects.core.coreUsers)
api(projects.core.coreDomain)

api(KotlinX.coroutines.core)
implementation("org.litote.kmongo:kmongo-coroutine-serialization:_")
Expand Down
4 changes: 3 additions & 1 deletion remote-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api(projects.core)
api(projects.core.coreData)
api(projects.core.coreUsers)
api(projects.core.coreDomain)

api("opensavvy.pedestal:spine:_")
api(KotlinX.serialization.core)
Expand Down
1 change: 0 additions & 1 deletion remote-common/src/commonMain/kotlin/dto/FieldDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package opensavvy.formulaide.remote.dto
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import opensavvy.formulaide.core.Field
import opensavvy.formulaide.core.Input
import opensavvy.formulaide.core.Template
import opensavvy.formulaide.remote.api
import opensavvy.formulaide.remote.dto.InputDto.Companion.toCore
Expand Down
5 changes: 4 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include(
"backend",
"core",

"core:core-data",
"core:core-users",
"core:core-domain",

"remote-common",
"remote-client",
Expand Down
4 changes: 3 additions & 1 deletion test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ kotlin {

val commonMain by getting {
dependencies {
api(projects.core)
api(projects.core.coreData)
api(projects.core.coreUsers)
api(projects.core.coreDomain)
api(projects.testStructure)
}
}
Expand Down
4 changes: 2 additions & 2 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

plugin.com.palantir.git-version=2.0.0

plugin.org.jetbrains.dokka=1.8.10
plugin.org.jetbrains.dokka=1.8.20

plugin.org.jetbrains.kotlinx.kover=0.6.1

Expand All @@ -19,7 +19,7 @@ version.ch.qos.logback..logback-classic=1.4.6

version.kotest=5.6.1

version.kotlin=1.8.21
version.kotlin=1.8.22

version.kotlinx.coroutines=1.7.0

Expand Down

0 comments on commit 7685a9c

Please sign in to comment.