diff --git a/build.gradle.kts b/build.gradle.kts index b4d7fdd..7c16879 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,26 +1,10 @@ -import java.util.Properties - plugins { - alias(libs.plugins.dokka) - alias(libs.plugins.kotlin.jvm) alias(libs.plugins.maven.publish) } group = "ai.neuon.roadplus.utility" -version = "1.0.0" +version = "1.0.2" repositories { mavenCentral() -} - -dependencies { - implementation(libs.kotlinx.serialization.json) - testImplementation(kotlin("test")) -} - -tasks.test { - useJUnitPlatform() -} -kotlin { - jvmToolchain(11) } \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 0ef71b7..769dca2 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -4,7 +4,8 @@ import java.util.Properties plugins { alias(libs.plugins.dokka) alias(libs.plugins.kotlin.jvm) - alias(libs.plugins.maven.publish)} + alias(libs.plugins.maven.publish) +} repositories { mavenCentral() diff --git a/core/src/main/kotlin/ai/neuon/utility/paging/PagingConfig.kt b/core/src/main/kotlin/ai/neuon/utility/paging/PagingConfig.kt index 5c30225..2a9a14b 100644 --- a/core/src/main/kotlin/ai/neuon/utility/paging/PagingConfig.kt +++ b/core/src/main/kotlin/ai/neuon/utility/paging/PagingConfig.kt @@ -1,5 +1,18 @@ package ai.neuon.utility.paging +/** + * Defines how results should be paginated when fetching data. + * + * @property index Zero-based page index, indicating which page of results to load. + * @property size Number of items to include in a single page. + * + * Validation rules: + * - index must be >= 0 + * - size must be > 0 + * + * Used by repository or service methods to control + * data retrieval and limit result sizes for performance. + */ data class PagingConfig( val index: Int, val size: Int, diff --git a/core/src/main/kotlin/ai/neuon/utility/paging/PagingData.kt b/core/src/main/kotlin/ai/neuon/utility/paging/PagingData.kt index 09e8d2b..5e445a7 100644 --- a/core/src/main/kotlin/ai/neuon/utility/paging/PagingData.kt +++ b/core/src/main/kotlin/ai/neuon/utility/paging/PagingData.kt @@ -7,6 +7,27 @@ import kotlin.math.ceil import kotlin.math.max import kotlin.math.roundToLong +/** + * Represents a single page of results in a paginated query. + * + * @param i The zero-based index of the current page. + * @param pageSize Number of items in each page. + * @param totalItemsCount Optional total number of items available across all pages. + * @param list The list of items in the current page. + * + * ## Purpose + * - Used as the return type for paginated queries (e.g., getPermissions). + * - Couples the actual result list with pagination metadata. + * + * ## Companion object helpers + * - [empty]: Creates an empty page with the given index and size. + * - [empty(config)]: Creates an empty page using a [PagingConfig]. + * + * ## buildPagingJsonObject + * - Serializes the pagination metadata into JSON format: + * - "config" → Contains the current page index and page size. + * - "page" → Can include the total number of pages if totalItemsCount is set. + */ data class PagingData( val i: Int, val pageSize: Int, val totalItemsCount: Long? = null, val list: List,