@@ -8,18 +8,23 @@ import kotlinx.coroutines.DelicateCoroutinesApi
8
8
import kotlinx.coroutines.GlobalScope
9
9
import kotlinx.coroutines.await
10
10
import kotlinx.coroutines.promise
11
+ import kotlinx.datetime.toJSDate
11
12
import org.modelix.datastructures.model.IGenericModelTree
13
+ import org.modelix.datastructures.objects.ObjectHash
12
14
import org.modelix.model.TreeId
13
15
import org.modelix.model.api.INode
14
16
import org.modelix.model.api.INodeReference
15
17
import org.modelix.model.api.JSNodeConverter
16
18
import org.modelix.model.client.IdGenerator
17
19
import org.modelix.model.data.ModelData
20
+ import org.modelix.model.lazy.CLVersion
18
21
import org.modelix.model.lazy.RepositoryId
19
22
import org.modelix.model.lazy.createObjectStoreCache
20
23
import org.modelix.model.mutable.DummyIdGenerator
21
24
import org.modelix.model.mutable.INodeIdGenerator
22
25
import org.modelix.model.mutable.ModelixIdGenerator
26
+ import org.modelix.model.mutable.VersionedModelTree
27
+ import org.modelix.model.mutable.asMutableSingleThreaded
23
28
import org.modelix.model.mutable.asMutableThreadSafe
24
29
import org.modelix.model.mutable.load
25
30
import org.modelix.model.mutable.withAutoTransactions
@@ -111,6 +116,8 @@ interface ClientJS {
111
116
*/
112
117
fun initRepository (repositoryId : String , useRoleIds : Boolean = true): Promise <Unit >
113
118
119
+ fun getHistoryRangeForBranch (repositoryId : String , branchId : String , skip : Int , limit : Int ): Promise <Array <VersionInformationJS >>
120
+ fun getHistoryRange (repositoryId : String , headVersion : String , skip : Int , limit : Int ): Promise <Array <VersionInformationJS >>
114
121
/* *
115
122
* Fetch existing branches for a given repository from the model server.
116
123
*
@@ -192,6 +199,28 @@ internal class ClientJSImpl(private val modelClient: ModelClientV2) : ClientJS {
192
199
}
193
200
}
194
201
202
+ override fun getHistoryRangeForBranch (repositoryId : String , branchId : String , skip : Int , limit : Int ) =
203
+ GlobalScope .promise{ modelClient.pullHash(RepositoryId (repositoryId).getBranchReference(branchId)) }
204
+ .then { getHistoryRange(repositoryId, it, skip, limit) }
205
+ .then { it }
206
+
207
+ override fun getHistoryRange (repositoryId : String , headVersion : String , skip : Int , limit : Int ) =
208
+ GlobalScope .promise {
209
+ modelClient.getHistoryRange(
210
+ RepositoryId (repositoryId),
211
+ ObjectHash (headVersion),
212
+ skip.toLong(),
213
+ limit.toLong()
214
+ )
215
+ .filterIsInstance<CLVersion >()
216
+ .map { VersionInformationJS (
217
+ it.author,
218
+ it.getTimestamp()?.toJSDate(),
219
+ it.getObjectHash().toString()
220
+ ) }
221
+ .toTypedArray()
222
+ }
223
+
195
224
override fun dispose () {
196
225
modelClient.close()
197
226
}
0 commit comments