Skip to content

Commit

Permalink
Merge pull request #1075 from modelix/MODELIX-900-and-MODELIX-601
Browse files Browse the repository at this point in the history
Mark JS API as stable
  • Loading branch information
odzhychko authored Sep 20, 2024
2 parents 0bd81c5 + fe03026 commit 31d40c2
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 88 deletions.
19 changes: 3 additions & 16 deletions model-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,14 @@ val patchTypesScriptInProductionLibrary = tasks.register("patchTypesScriptInProd
into(preparedProductionLibraryOutputDirectory)
}

// Add correct TypeScript imports and mark exports as experimental.
// Add correct TypeScript imports.
val typescriptDeclaration =
preparedProductionLibraryOutputDirectory.get().file("modelix.core-model-client.d.ts").asFile
val originalTypescriptDeclarationContent = typescriptDeclaration.readLines()
val experimentalDeclaration = """
/**
* @experimental This feature is expected to be finalized with https://issues.modelix.org/issue/MODELIX-500.
*/
""".trimIndent()
val originalTypescriptDeclarationContent = typescriptDeclaration.readText()
typescriptDeclaration.writer().use {
it.appendLine("""import { INodeJS } from "@modelix/ts-model-api";""")
.appendLine()
for (line in originalTypescriptDeclarationContent) {
// Only mark the parts of the client (`org.modelix.model.client2`) experimental.
// Reported declarations from `org.modelix.model.api` should not be annotated as experimental.
if (line.startsWith("export declare namespace org.modelix.model.client2")) {
it.appendLine(experimentalDeclaration)
}
it.appendLine(line)
}
.append(originalTypescriptDeclarationContent)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
@file:OptIn(UnstableModelixFeature::class)

package org.modelix.model.client2

import io.ktor.client.plugins.ClientRequestException
import io.ktor.http.HttpStatusCode
import kotlinx.coroutines.await
import kotlinx.coroutines.test.runTest
import org.modelix.kotlin.utils.UnstableModelixFeature
import kotlin.js.Promise
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
* limitations under the License.
*/

@file:OptIn(UnstableModelixFeature::class)

package org.modelix.model.client2

import INodeJS
import INodeReferenceJS
import org.modelix.kotlin.utils.UnstableModelixFeature
import org.modelix.model.api.IBranch
import org.modelix.model.api.IBranchListener
import org.modelix.model.api.INodeReferenceSerializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@
package org.modelix.model.client2

import INodeJS
import org.modelix.kotlin.utils.UnstableModelixFeature

/**
* Represents a change in branch that can be handled by a [ChangeHandler].
* See [BranchJS.addListener]
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
sealed interface ChangeJS {
/**
Expand All @@ -38,10 +33,6 @@ sealed interface ChangeJS {
/**
* Represents a changed property value.
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
data class PropertyChanged(
override val node: INodeJS,
Expand All @@ -54,10 +45,6 @@ data class PropertyChanged(
/**
* Represents moved, added or removed children.
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
data class ChildrenChanged(
override val node: INodeJS,
Expand All @@ -70,10 +57,6 @@ data class ChildrenChanged(
/**
* Represents a changed reference target.
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
data class ReferenceChanged(
override val node: INodeJS,
Expand All @@ -86,19 +69,11 @@ data class ReferenceChanged(
/**
* Represents the change of the parent of [node] changed.
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
data class ContainmentChanged(override val node: INodeJS) : ChangeJS

/**
* Represents the change of the concept of a [node].
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
data class ConceptChanged(override val node: INodeJS) : ChangeJS
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

@file:OptIn(UnstableModelixFeature::class, DelicateCoroutinesApi::class)
@file:OptIn(DelicateCoroutinesApi::class)

package org.modelix.model.client2

Expand All @@ -24,7 +24,6 @@ import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.await
import kotlinx.coroutines.promise
import org.modelix.kotlin.utils.UnstableModelixFeature
import org.modelix.model.ModelFacade
import org.modelix.model.api.INode
import org.modelix.model.api.JSNodeConverter
Expand All @@ -36,10 +35,6 @@ import kotlin.js.Promise
/**
* Same as [loadModelsFromJsonAsBranch] but directly returns the [BranchJS.rootNode] of the created branch.
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
fun loadModelsFromJson(json: Array<String>): INodeJS {
val branch = loadModelsFromJsonAsBranch(json)
Expand All @@ -51,10 +46,6 @@ fun loadModelsFromJson(json: Array<String>): INodeJS {
*
* Each JSON string will be added as child of the [BranchJS.rootNode] the created [BranchJS].
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
fun loadModelsFromJsonAsBranch(json: Array<String>): BranchJS {
val branch = ModelFacade.toLocalBranch(ModelFacade.newLocalTree())
Expand All @@ -68,10 +59,6 @@ fun loadModelsFromJsonAsBranch(json: Array<String>): BranchJS {
* @param url URL to the V2 endpoint of the model server.
* e.g., http://localhost:28102/v2
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
fun connectClient(url: String, bearerTokenProvider: (() -> Promise<String?>)? = null): Promise<ClientJS> {
return GlobalScope.promise {
Expand All @@ -94,10 +81,6 @@ fun connectClient(url: String, bearerTokenProvider: (() -> Promise<String?>)? =
* The full version data of an [ModelClientV2] is not exposed because most parts model API are not exposed to JS yet.
* See https://issues.modelix.org/issue/MODELIX-962
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
interface ClientJS {

Expand Down Expand Up @@ -203,10 +186,6 @@ typealias ChangeHandler = (ChangeJS) -> Unit
* The full version data of an [ModelClientV2] is not exposed because most parts model API are not exposed to JS yet.
* See https://issues.modelix.org/issue/MODELIX-962
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
interface BranchJS {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@
* limitations under the License.
*/

@file:OptIn(UnstableModelixFeature::class, UnstableModelixFeature::class)

package org.modelix.model.client2

import org.modelix.kotlin.utils.UnstableModelixFeature
import kotlin.js.Promise

/**
* Represents a branch two-way live replicated to the model server.
*/
@UnstableModelixFeature(
reason = "The overarching task https://issues.modelix.org/issue/MODELIX-500 is in development.",
intendedFinalization = "The client is intended to be finalized when the overarching task is finished.",
)
@JsExport
interface ReplicatedModelJS {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
* limitations under the License.
*/

@file:OptIn(UnstableModelixFeature::class, DelicateCoroutinesApi::class)
@file:OptIn(DelicateCoroutinesApi::class)

package org.modelix.model.client2

import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.promise
import kotlinx.datetime.toJSDate
import org.modelix.kotlin.utils.UnstableModelixFeature
import org.modelix.model.withAutoTransactions
import kotlin.js.Promise

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
package org.modelix.model.client2

import GeneratedConcept
import org.modelix.kotlin.utils.UnstableModelixFeature
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull

@OptIn(UnstableModelixFeature::class)
class BranchJSTest {

private val emptyRoot = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
package org.modelix.model.client2

import GeneratedConcept
import org.modelix.kotlin.utils.UnstableModelixFeature
import kotlin.test.Test
import kotlin.test.assertEquals

@OptIn(UnstableModelixFeature::class)
class ClientJSTest {

private val emptyRoot = """
Expand Down
2 changes: 0 additions & 2 deletions vue-model-api/src/useModelClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ type ClientJS = org.modelix.model.client2.ClientJS;
*
* The URL is reactive and if it changes, the client is automatically disposed and a new client for the updated URL is created.
*
* @experimental This feature is expected to be finalized with https://issues.modelix.org/issue/MODELIX-500.
*
* @param url - Reactive reference of an URL to a model server.
* @param getClient - Function how to create a cliente given an URL.
*
Expand Down
2 changes: 0 additions & 2 deletions vue-model-api/src/useModelsFromJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ type ChangeJS = org.modelix.model.client2.ChangeJS;
*
* The returned root node uses Vues reactivity and can be used in Vue like an reactive object.
*
* @experimental This feature is expected to be finalized with https://issues.modelix.org/issue/MODELIX-500.
*
* @param modelDataJsonStrings - Array of string, each representing a root node.
* @returns A new root node the combines all children from the loaded root nodes.
*/
Expand Down
2 changes: 0 additions & 2 deletions vue-model-api/src/useReplicatedModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ type ChangeJS = org.modelix.model.client2.ChangeJS;
*
* Calling the returned dispose function stops syncing the root node to the underlying branch on the server.
*
* @experimental This feature is expected to be finalized with https://issues.modelix.org/issue/MODELIX-500.
*
* @param client - Reactive reference of a client to a model server.
* @param repositoryId - Reactive reference of a repositoryId on the model server.
* @param branchId - Reactive reference of a branchId in the repository of the model server.
Expand Down

0 comments on commit 31d40c2

Please sign in to comment.