@@ -8,13 +8,16 @@ 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
@@ -111,6 +114,9 @@ interface ClientJS {
111
114
*/
112
115
fun initRepository (repositoryId : String , useRoleIds : Boolean = true): Promise <Unit >
113
116
117
+ fun getHistoryRangeForBranch (repositoryId : String , branchId : String , skip : Int , limit : Int ): Promise <Array <VersionInformationJS >>
118
+ fun getHistoryRange (repositoryId : String , headVersion : String , skip : Int , limit : Int ): Promise <Array <VersionInformationJS >>
119
+
114
120
/* *
115
121
* Fetch existing branches for a given repository from the model server.
116
122
*
@@ -192,6 +198,30 @@ internal class ClientJSImpl(private val modelClient: ModelClientV2) : ClientJS {
192
198
}
193
199
}
194
200
201
+ override fun getHistoryRangeForBranch (repositoryId : String , branchId : String , skip : Int , limit : Int ) =
202
+ GlobalScope .promise { modelClient.pullHash(RepositoryId (repositoryId).getBranchReference(branchId)) }
203
+ .then { getHistoryRange(repositoryId, it, skip, limit) }
204
+ .then { it }
205
+
206
+ override fun getHistoryRange (repositoryId : String , headVersion : String , skip : Int , limit : Int ) =
207
+ GlobalScope .promise {
208
+ modelClient.getHistoryRange(
209
+ RepositoryId (repositoryId),
210
+ ObjectHash (headVersion),
211
+ skip.toLong(),
212
+ limit.toLong(),
213
+ )
214
+ .filterIsInstance<CLVersion >()
215
+ .map {
216
+ VersionInformationJS (
217
+ it.author,
218
+ it.getTimestamp()?.toJSDate(),
219
+ it.getObjectHash().toString(),
220
+ )
221
+ }
222
+ .toTypedArray()
223
+ }
224
+
195
225
override fun dispose () {
196
226
modelClient.close()
197
227
}
0 commit comments