feat(enrichment): apply semantic markup
This commit is contained in:
@@ -11,7 +11,7 @@ import retrofit2.http.*
|
||||
|
||||
// [ENTITY: Interface('HomeboxApiService')]
|
||||
/**
|
||||
* @summary Определяет эндпоинты для взаимодействия с Homebox API, используя DTO.
|
||||
* @summary Defines the endpoints for interacting with the Homebox API using DTOs.
|
||||
*/
|
||||
interface HomeboxApiService {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] CustomFieldDto.kt
|
||||
// [SEMANTICS] data_transfer_object, custom_field
|
||||
// [SEMANTICS] data, dto, custom_field
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.homebox.lens.domain.model.CustomField
|
||||
|
||||
// [ENTITY: DataClass('CustomFieldDto')]
|
||||
/**
|
||||
* @summary DTO для кастомного поля.
|
||||
* @summary DTO for a custom field.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class CustomFieldDto(
|
||||
@@ -25,7 +25,7 @@ data class CustomFieldDto(
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('CustomField')]
|
||||
/**
|
||||
* @summary Маппер из CustomFieldDto в доменную модель CustomField.
|
||||
* @summary Mapper from CustomFieldDto to the CustomField domain model.
|
||||
*/
|
||||
fun CustomFieldDto.toDomain(): CustomField {
|
||||
return CustomField(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] GroupStatisticsDto.kt
|
||||
// [SEMANTICS] data_transfer_object, statistics
|
||||
// [SEMANTICS] data, dto, statistics
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.homebox.lens.domain.model.GroupStatistics
|
||||
|
||||
// [ENTITY: DataClass('GroupStatisticsDto')]
|
||||
/**
|
||||
* @summary DTO для статистики.
|
||||
* @summary DTO for statistics.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class GroupStatisticsDto(
|
||||
@@ -28,7 +28,7 @@ data class GroupStatisticsDto(
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('GroupStatistics')]
|
||||
/**
|
||||
* @summary Маппер из GroupStatisticsDto в доменную модель GroupStatistics.
|
||||
* @summary Mapper from GroupStatisticsDto to the GroupStatistics domain model.
|
||||
*/
|
||||
fun GroupStatisticsDto.toDomain(): GroupStatistics {
|
||||
return GroupStatistics(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] ImageDto.kt
|
||||
// [SEMANTICS] data_transfer_object, image
|
||||
// [SEMANTICS] data, dto, image
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -12,10 +12,10 @@ import com.homebox.lens.domain.model.Image
|
||||
|
||||
// [ENTITY: DataClass('ImageDto')]
|
||||
/**
|
||||
* @summary DTO для изображения.
|
||||
* @param id Уникальный идентификатор.
|
||||
* @param path Путь к файлу.
|
||||
* @param isPrimary Является ли основным.
|
||||
* @summary DTO for an image.
|
||||
* @param id The unique identifier.
|
||||
* @param path The path to the file.
|
||||
* @param isPrimary Whether it is the primary image.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ImageDto(
|
||||
@@ -28,7 +28,7 @@ data class ImageDto(
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('Image')]
|
||||
/**
|
||||
* @summary Маппер из ImageDto в доменную модель Image.
|
||||
* @summary Mapper from ImageDto to the Image domain model.
|
||||
*/
|
||||
fun ImageDto.toDomain(): Image {
|
||||
return Image(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] ItemAttachmentDto.kt
|
||||
// [SEMANTICS] data_transfer_object, attachment
|
||||
// [SEMANTICS] data, dto, attachment
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.homebox.lens.domain.model.ItemAttachment
|
||||
|
||||
// [ENTITY: DataClass('ItemAttachmentDto')]
|
||||
/**
|
||||
* @summary DTO для вложения.
|
||||
* @summary DTO for an attachment.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ItemAttachmentDto(
|
||||
@@ -28,7 +28,7 @@ data class ItemAttachmentDto(
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('ItemAttachment')]
|
||||
/**
|
||||
* @summary Маппер из ItemAttachmentDto в доменную модель ItemAttachment.
|
||||
* @summary Mapper from ItemAttachmentDto to the ItemAttachment domain model.
|
||||
*/
|
||||
fun ItemAttachmentDto.toDomain(): ItemAttachment {
|
||||
return ItemAttachment(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] ItemCreateDto.kt
|
||||
// [SEMANTICS] data_transfer_object, item_creation
|
||||
// [SEMANTICS] data, dto, item_creation
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.homebox.lens.domain.model.ItemCreate
|
||||
|
||||
// [ENTITY: DataClass('ItemCreateDto')]
|
||||
/**
|
||||
* @summary DTO для создания вещи.
|
||||
* @summary DTO for creating an item.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ItemCreateDto(
|
||||
@@ -46,7 +46,7 @@ data class ItemCreateDto(
|
||||
// [ENTITY: Function('toDto')]
|
||||
// [RELATION: Function('toDto')] -> [RETURNS] -> [DataClass('ItemCreateDto')]
|
||||
/**
|
||||
* @summary Маппер из доменной модели ItemCreate в ItemCreateDto.
|
||||
* @summary Mapper from the ItemCreate domain model to ItemCreateDto.
|
||||
*/
|
||||
fun ItemCreate.toItemCreateDto(): ItemCreateDto {
|
||||
return ItemCreateDto(
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] ItemDto.kt
|
||||
// [SEMANTICS] data, dto, api
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import java.math.BigDecimal
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('ItemOut')]
|
||||
// [RELATION: DataClass('ItemOut')] -> [DEPENDS_ON] -> [DataClass('LocationOut')]
|
||||
// [RELATION: DataClass('ItemOut')] -> [DEPENDS_ON] -> [DataClass('LabelOutDto')]
|
||||
/**
|
||||
* @summary DTO для полной информации о вещи (GET /v1/items/{id}).
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ItemOut(
|
||||
@Json(name = "id") val id: String,
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "description") val description: String?,
|
||||
@Json(name = "image") val image: String?,
|
||||
@Json(name = "location") val location: LocationOut?,
|
||||
@Json(name = "labels") val labels: List<LabelOutDto>,
|
||||
@Json(name = "value") val value: BigDecimal?,
|
||||
@Json(name = "createdAt") val createdAt: String?
|
||||
)
|
||||
// [END_ENTITY: DataClass('ItemOut')]
|
||||
|
||||
// [ENTITY: DataClass('ItemSummary')]
|
||||
// [RELATION: DataClass('ItemSummary')] -> [DEPENDS_ON] -> [DataClass('LocationOut')]
|
||||
/**
|
||||
* @summary DTO для краткой информации о вещи в списках (GET /v1/items).
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ItemSummary(
|
||||
@Json(name = "id") val id: String,
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "image") val image: String?,
|
||||
@Json(name = "location") val location: LocationOut?,
|
||||
@Json(name = "createdAt") val createdAt: String?
|
||||
)
|
||||
// [END_ENTITY: DataClass('ItemSummary')]
|
||||
|
||||
// [ENTITY: DataClass('ItemCreate')]
|
||||
/**
|
||||
* @summary DTO для создания новой вещи (POST /v1/items).
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ItemCreate(
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "description") val description: String?,
|
||||
@Json(name = "locationId") val locationId: String?,
|
||||
@Json(name = "labelIds") val labelIds: List<String>?,
|
||||
@Json(name = "value") val value: BigDecimal?
|
||||
)
|
||||
// [END_ENTITY: DataClass('ItemCreate')]
|
||||
|
||||
// [ENTITY: DataClass('ItemUpdate')]
|
||||
/**
|
||||
* @summary DTO для обновления вещи (PUT /v1/items/{id}).
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ItemUpdate(
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "description") val description: String?,
|
||||
@Json(name = "locationId") val locationId: String?,
|
||||
@Json(name = "labelIds") val labelIds: List<String>?,
|
||||
@Json(name = "value") val value: BigDecimal?
|
||||
)
|
||||
// [END_ENTITY: DataClass('ItemUpdate')]
|
||||
|
||||
// [END_FILE_ItemDto.kt]
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] ItemOutDto.kt
|
||||
// [SEMANTICS] data_transfer_object, item_detailed
|
||||
// [SEMANTICS] data, dto, item_detailed
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -50,3 +50,46 @@ data class ItemOutDto(
|
||||
@Json(name = "updatedAt") val updatedAt: String
|
||||
)
|
||||
// [END_ENTITY: DataClass('ItemOutDto')]
|
||||
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('ItemOut')]
|
||||
/**
|
||||
* @summary Mapper from ItemOutDto to the ItemOut domain model.
|
||||
*/
|
||||
fun ItemOutDto.toDomain(): ItemOut {
|
||||
return ItemOut(
|
||||
id = this.id,
|
||||
name = this.name,
|
||||
assetId = this.assetId,
|
||||
description = this.description,
|
||||
notes = this.notes,
|
||||
serialNumber = this.serialNumber,
|
||||
quantity = this.quantity,
|
||||
isArchived = this.isArchived,
|
||||
purchasePrice = this.purchasePrice,
|
||||
purchaseTime = this.purchaseTime,
|
||||
purchaseFrom = this.purchaseFrom,
|
||||
warrantyExpires = this.warrantyExpires,
|
||||
warrantyDetails = this.warrantyDetails,
|
||||
lifetimeWarranty = this.lifetimeWarranty,
|
||||
insured = this.insured,
|
||||
manufacturer = this.manufacturer,
|
||||
modelNumber = this.modelNumber,
|
||||
soldPrice = this.soldPrice,
|
||||
soldTime = this.soldTime,
|
||||
soldTo = this.soldTo,
|
||||
soldNotes = this.soldNotes,
|
||||
syncChildItemsLocations = this.syncChildItemsLocations,
|
||||
location = this.location?.toDomain(),
|
||||
parent = this.parent?.toDomain(),
|
||||
children = this.children.map { it.toDomain() },
|
||||
labels = this.labels.map { it.toDomain() },
|
||||
attachments = this.attachments.map { it.toDomain() },
|
||||
images = this.images.map { it.toDomain() },
|
||||
fields = this.fields.map { it.toDomain() },
|
||||
maintenance = this.maintenance.map { it.toDomain() },
|
||||
createdAt = this.createdAt,
|
||||
updatedAt = this.updatedAt
|
||||
)
|
||||
}
|
||||
// [END_ENTITY: Function('toDomain')]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] ItemSummaryDto.kt
|
||||
// [SEMANTICS] data_transfer_object, item_summary
|
||||
// [SEMANTICS] data, dto, item_summary
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -28,3 +28,24 @@ data class ItemSummaryDto(
|
||||
@Json(name = "updatedAt") val updatedAt: String
|
||||
)
|
||||
// [END_ENTITY: DataClass('ItemSummaryDto')]
|
||||
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('ItemSummary')]
|
||||
/**
|
||||
* @summary Mapper from ItemSummaryDto to the ItemSummary domain model.
|
||||
*/
|
||||
fun ItemSummaryDto.toDomain(): ItemSummary {
|
||||
return ItemSummary(
|
||||
id = this.id,
|
||||
name = this.name,
|
||||
assetId = this.assetId,
|
||||
image = this.image?.toDomain(),
|
||||
isArchived = this.isArchived,
|
||||
labels = this.labels.map { it.toDomain() },
|
||||
location = this.location?.toDomain(),
|
||||
value = this.value,
|
||||
createdAt = this.createdAt,
|
||||
updatedAt = this.updatedAt
|
||||
)
|
||||
}
|
||||
// [END_ENTITY: Function('toDomain')]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] ItemUpdateDto.kt
|
||||
// [SEMANTICS] data_transfer_object, item_update
|
||||
// [SEMANTICS] data, dto, item_update
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LabelCreateDto.kt
|
||||
// [SEMANTICS] data_transfer_object, label, create, api
|
||||
// [SEMANTICS] data, dto, label, create
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LabelOutDto.kt
|
||||
// [SEMANTICS] data_transfer_object, label
|
||||
// [SEMANTICS] data, dto, label
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -26,4 +26,21 @@ data class LabelOutDto(
|
||||
)
|
||||
// [END_ENTITY: DataClass('LabelOutDto')]
|
||||
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('LabelOut')]
|
||||
/**
|
||||
* @summary Mapper from LabelOutDto to the LabelOut domain model.
|
||||
*/
|
||||
fun LabelOutDto.toDomain(): LabelOut {
|
||||
return LabelOut(
|
||||
id = this.id,
|
||||
name = this.name,
|
||||
description = this.description,
|
||||
color = this.color ?: "#000000",
|
||||
isArchived = this.isArchived ?: false,
|
||||
createdAt = this.createdAt,
|
||||
updatedAt = this.updatedAt
|
||||
)
|
||||
}
|
||||
// [END_ENTITY: Function('toDomain')]
|
||||
// [END_FILE_LabelOutDto.kt]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LabelSummaryDto.kt
|
||||
// [SEMANTICS] data_transfer_object, label, summary, api, mapper
|
||||
// [SEMANTICS] data, dto, label, summary
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LabelUpdateDto.kt
|
||||
// [SEMANTICS] data_transfer_object, label, update
|
||||
// [SEMANTICS] data, dto, label, update
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import com.homebox.lens.domain.model.LabelUpdate
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('LabelUpdateDto')]
|
||||
/**
|
||||
* @summary DTO for updating a label.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class LabelUpdateDto(
|
||||
@Json(name = "name")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LocationCreateDto.kt
|
||||
// [SEMANTICS] data_transfer_object, location, create
|
||||
// [SEMANTICS] data, dto, location, create
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
@@ -9,6 +9,9 @@ import com.squareup.moshi.JsonClass
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('LocationCreateDto')]
|
||||
/**
|
||||
* @summary DTO for creating a location.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class LocationCreateDto(
|
||||
@Json(name = "name")
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LocationDto.kt
|
||||
// [SEMANTICS] data, dto, api, location
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('LocationOut')]
|
||||
/**
|
||||
* @summary DTO для информации о местоположении.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class LocationOut(
|
||||
@Json(name = "id") val id: String,
|
||||
@Json(name = "name") val name: String
|
||||
)
|
||||
// [END_ENTITY: DataClass('LocationOut')]
|
||||
|
||||
// [ENTITY: DataClass('LocationOutCount')]
|
||||
/**
|
||||
* @summary DTO для информации о местоположении со счетчиком вещей.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class LocationOutCount(
|
||||
@Json(name = "id") val id: String,
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "itemCount") val itemCount: Int
|
||||
)
|
||||
// [END_ENTITY: DataClass('LocationOutCount')]
|
||||
|
||||
// [END_FILE_LocationDto.kt]
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LocationOutCountDto.kt
|
||||
// [SEMANTICS] data_transfer_object, location, count
|
||||
// [SEMANTICS] data, dto, location, count
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.homebox.lens.domain.model.LocationOutCount
|
||||
|
||||
// [ENTITY: DataClass('LocationOutCountDto')]
|
||||
/**
|
||||
* @summary DTO для местоположения со счетчиком.
|
||||
* @summary DTO for a location with an item count.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class LocationOutCountDto(
|
||||
@@ -27,4 +27,21 @@ data class LocationOutCountDto(
|
||||
)
|
||||
// [END_ENTITY: DataClass('LocationOutCountDto')]
|
||||
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('LocationOutCount')]
|
||||
/**
|
||||
* @summary Mapper from LocationOutCountDto to the LocationOutCount domain model.
|
||||
*/
|
||||
fun LocationOutCountDto.toDomain(): LocationOutCount {
|
||||
return LocationOutCount(
|
||||
id = this.id,
|
||||
name = this.name,
|
||||
color = this.color ?: "#000000",
|
||||
isArchived = this.isArchived ?: false,
|
||||
itemCount = this.itemCount,
|
||||
createdAt = this.createdAt,
|
||||
updatedAt = this.updatedAt
|
||||
)
|
||||
}
|
||||
// [END_ENTITY: Function('toDomain')]
|
||||
// [END_FILE_LocationOutCountDto.kt]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LocationOutDto.kt
|
||||
// [SEMANTICS] data_transfer_object, location, output
|
||||
// [SEMANTICS] data, dto, location
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
@@ -27,4 +27,20 @@ data class LocationOutDto(
|
||||
)
|
||||
// [END_ENTITY: DataClass('LocationOutDto')]
|
||||
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('LocationOut')]
|
||||
/**
|
||||
* @summary Mapper from LocationOutDto to the LocationOut domain model.
|
||||
*/
|
||||
fun LocationOutDto.toDomain(): LocationOut {
|
||||
return LocationOut(
|
||||
id = this.id,
|
||||
name = this.name,
|
||||
color = this.color,
|
||||
isArchived = this.isArchived,
|
||||
createdAt = this.createdAt,
|
||||
updatedAt = this.updatedAt
|
||||
)
|
||||
}
|
||||
// [END_ENTITY: Function('toDomain')]
|
||||
// [END_FILE_LocationOutDto.kt]
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LocationUpdateDto.kt
|
||||
// [SEMANTICS] data_transfer_object, location, update
|
||||
// [SEMANTICS] data, dto, location, update
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import com.homebox.lens.domain.model.LocationUpdate
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('LocationUpdateDto')]
|
||||
/**
|
||||
* @summary DTO for updating a location.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class LocationUpdateDto(
|
||||
@Json(name = "name")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] LoginFormDto.kt
|
||||
// [SEMANTICS] data, dto, api, login
|
||||
// [SEMANTICS] data, dto, login
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
@@ -9,6 +9,9 @@ import com.squareup.moshi.JsonClass
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('LoginFormDto')]
|
||||
/**
|
||||
* @summary DTO for the login form.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class LoginFormDto(
|
||||
@Json(name = "username") val username: String,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] MaintenanceEntryDto.kt
|
||||
// [SEMANTICS] data_transfer_object, maintenance
|
||||
// [SEMANTICS] data, dto, maintenance
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.homebox.lens.domain.model.MaintenanceEntry
|
||||
|
||||
// [ENTITY: DataClass('MaintenanceEntryDto')]
|
||||
/**
|
||||
* @summary DTO для записи об обслуживании.
|
||||
* @summary DTO for a maintenance entry.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class MaintenanceEntryDto(
|
||||
@@ -30,7 +30,7 @@ data class MaintenanceEntryDto(
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('MaintenanceEntry')]
|
||||
/**
|
||||
* @summary Маппер из MaintenanceEntryDto в доменную модель MaintenanceEntry.
|
||||
* @summary Mapper from MaintenanceEntryDto to the MaintenanceEntry domain model.
|
||||
*/
|
||||
fun MaintenanceEntryDto.toDomain(): MaintenanceEntry {
|
||||
return MaintenanceEntry(
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] PaginationDto.kt
|
||||
// [SEMANTICS] data, dto, api, pagination
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('PaginationResult')]
|
||||
/**
|
||||
* @summary DTO для пагинированных результатов от API.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class PaginationResult<T>(
|
||||
@Json(name = "items") val items: List<T>,
|
||||
@Json(name = "page") val page: Int,
|
||||
@Json(name = "pages") val pages: Int,
|
||||
@Json(name = "total") val total: Int,
|
||||
@Json(name = "pageSize") val pageSize: Int
|
||||
)
|
||||
// [END_ENTITY: DataClass('PaginationResult')]
|
||||
|
||||
// [END_FILE_PaginationDto.kt]
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] PaginationResultDto.kt
|
||||
// [SEMANTICS] data_transfer_object, pagination
|
||||
// [SEMANTICS] data, dto, pagination
|
||||
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
@@ -22,3 +22,18 @@ data class PaginationResultDto<T>(
|
||||
@Json(name = "total") val total: Int
|
||||
)
|
||||
// [END_ENTITY: DataClass('PaginationResultDto')]
|
||||
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('PaginationResult')]
|
||||
/**
|
||||
* @summary Mapper from PaginationResultDto to the PaginationResult domain model.
|
||||
*/
|
||||
fun <T, R> PaginationResultDto<T>.toDomain(mapper: (T) -> R): PaginationResult<R> {
|
||||
return PaginationResult(
|
||||
items = this.items.map(mapper),
|
||||
page = this.page,
|
||||
pageSize = this.pageSize,
|
||||
total = this.total
|
||||
)
|
||||
}
|
||||
// [END_ENTITY: Function('toDomain')]
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] StatisticsDto.kt
|
||||
// [SEMANTICS] data, dto, api, statistics
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import java.math.BigDecimal
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('GroupStatistics')]
|
||||
/**
|
||||
* @summary DTO для статистической информации.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class GroupStatistics(
|
||||
@Json(name = "totalValue") val totalValue: BigDecimal,
|
||||
@Json(name = "totalItems") val totalItems: Int,
|
||||
@Json(name = "locations") val locations: Int,
|
||||
@Json(name = "labels") val labels: Int
|
||||
)
|
||||
// [END_ENTITY: DataClass('GroupStatistics')]
|
||||
|
||||
// [END_FILE_StatisticsDto.kt]
|
||||
@@ -1,14 +1,18 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.dto
|
||||
// [FILE] TokenResponseDto.kt
|
||||
// [SEMANTICS] data, dto, api, token
|
||||
// [SEMANTICS] data, dto, token
|
||||
package com.homebox.lens.data.api.dto
|
||||
|
||||
// [IMPORTS]
|
||||
import com.homebox.lens.domain.model.TokenResponse
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('TokenResponseDto')]
|
||||
/**
|
||||
* @summary DTO for the token response.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class TokenResponseDto(
|
||||
@Json(name = "token") val token: String,
|
||||
@@ -16,4 +20,16 @@ data class TokenResponseDto(
|
||||
@Json(name = "expiresAt") val expiresAt: String
|
||||
)
|
||||
// [END_ENTITY: DataClass('TokenResponseDto')]
|
||||
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('TokenResponse')]
|
||||
/**
|
||||
* @summary Mapper from TokenResponseDto to the TokenResponse domain model.
|
||||
*/
|
||||
fun TokenResponseDto.toDomain(): TokenResponse {
|
||||
return TokenResponse(
|
||||
token = this.token
|
||||
)
|
||||
}
|
||||
// [END_ENTITY: Function('toDomain')]
|
||||
// [END_FILE_TokenResponseDto.kt]
|
||||
@@ -1,30 +0,0 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.mapper
|
||||
// [FILE] TokenMapper.kt
|
||||
// [SEMANTICS] mapper, data_conversion, clean_architecture
|
||||
|
||||
package com.homebox.lens.data.api.mapper
|
||||
|
||||
// [IMPORTS]
|
||||
import com.homebox.lens.data.api.dto.TokenResponseDto
|
||||
import com.homebox.lens.domain.model.TokenResponse
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: Function('toDomain')]
|
||||
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('TokenResponse')]
|
||||
/**
|
||||
* @summary Преобразует DTO-объект токена в доменную модель.
|
||||
* @receiver [TokenResponseDto] объект из слоя данных.
|
||||
* @return [TokenResponse] объект для доменного слоя.
|
||||
* @throws IllegalArgumentException если токен в DTO пустой.
|
||||
*/
|
||||
fun TokenResponseDto.toDomain(): TokenResponse {
|
||||
require(this.token.isNotBlank()) { "DTO token is blank, cannot map to domain model." }
|
||||
|
||||
val domainModel = TokenResponse(token = this.token)
|
||||
|
||||
check(domainModel.token.isNotBlank()) { "Domain model token is blank after mapping." }
|
||||
|
||||
return domainModel
|
||||
}
|
||||
// [END_ENTITY: Function('toDomain')]
|
||||
// [END_FILE_TokenMapper.kt]
|
||||
@@ -1,19 +1,23 @@
|
||||
// [PACKAGE] com.homebox.lens.data.api.model
|
||||
// [FILE] LoginRequest.kt
|
||||
// [SEMANTICS] dto, network, serialization, authentication
|
||||
// [SEMANTICS] data, dto, login
|
||||
|
||||
package com.homebox.lens.data.api.model
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
// [IMPORTS]
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
// [END_IMPORTS]
|
||||
|
||||
// [ENTITY: DataClass('LoginRequest')]
|
||||
/**
|
||||
* [ENTITY: DataClass('LoginRequest')]
|
||||
* [CONTRACT]
|
||||
* DTO (Data Transfer Object) для запроса на аутентификацию.
|
||||
* @property username Имя пользователя.
|
||||
* @property password Пароль пользователя.
|
||||
* @invariant Свойства не должны быть пустыми.
|
||||
* @summary DTO for the authentication request.
|
||||
* @property username The user's name.
|
||||
* @property password The user's password.
|
||||
* @invariant The properties must not be blank.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class LoginRequest(
|
||||
@@ -21,9 +25,9 @@ data class LoginRequest(
|
||||
@Json(name = "password") val password: String
|
||||
) {
|
||||
init {
|
||||
// [INVARIANT_CHECK]
|
||||
require(username.isNotBlank()) { "[INVARIANT_FAILED] Username cannot be blank." }
|
||||
require(password.isNotBlank()) { "[INVARIANT_FAILED] Password cannot be blank." }
|
||||
require(username.isNotBlank()) { "Username cannot be blank." }
|
||||
require(password.isNotBlank()) { "Password cannot be blank." }
|
||||
}
|
||||
}
|
||||
// [END_ENTITY: DataClass('LoginRequest')]
|
||||
// [END_FILE_LoginRequest.kt]
|
||||
@@ -10,7 +10,7 @@ import java.math.BigDecimal
|
||||
|
||||
// [ENTITY: Class('Converters')]
|
||||
/**
|
||||
* @summary Предоставляет TypeConverters для Room для типов, не поддерживаемых по умолчанию.
|
||||
* @summary Provides TypeConverters for Room for types not supported by default.
|
||||
*/
|
||||
class Converters {
|
||||
// [ENTITY: Function('fromString')]
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.homebox.lens.data.db.entity.*
|
||||
|
||||
// [ENTITY: Database('HomeboxDatabase')]
|
||||
/**
|
||||
* @summary Основной класс для работы с локальной базой данных Room.
|
||||
* @summary The main class for working with the local Room database.
|
||||
*/
|
||||
@Database(
|
||||
entities = [
|
||||
|
||||
@@ -13,7 +13,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
|
||||
// [ENTITY: Interface('ItemDao')]
|
||||
/**
|
||||
* @summary Предоставляет методы для работы с 'items' в локальной БД.
|
||||
* @summary Provides methods for working with 'items' in the local DB.
|
||||
*/
|
||||
@Dao
|
||||
interface ItemDao {
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.homebox.lens.data.db.entity.LabelEntity
|
||||
|
||||
// [ENTITY: Interface('LabelDao')]
|
||||
/**
|
||||
* @summary Предоставляет методы для работы с 'labels' в локальной БД.
|
||||
* @summary Provides methods for working with 'labels' in the local DB.
|
||||
*/
|
||||
@Dao
|
||||
interface LabelDao {
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.homebox.lens.data.db.entity.LocationEntity
|
||||
|
||||
// [ENTITY: Interface('LocationDao')]
|
||||
/**
|
||||
* @summary Предоставляет методы для работы с 'locations' в локальной БД.
|
||||
* @summary Provides methods for working with 'locations' in the local DB.
|
||||
*/
|
||||
@Dao
|
||||
interface LocationDao {
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.room.PrimaryKey
|
||||
|
||||
// [ENTITY: DatabaseTable('ItemEntity')]
|
||||
/**
|
||||
* @summary Представляет собой строку в таблице 'items' в локальной БД.
|
||||
* @summary Represents a row in the 'items' table in the local DB.
|
||||
*/
|
||||
@Entity(tableName = "items")
|
||||
data class ItemEntity(
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.room.Index
|
||||
|
||||
// [ENTITY: DatabaseTable('ItemLabelCrossRef')]
|
||||
/**
|
||||
* @summary Таблица для связи "многие-ко-многим" между ItemEntity и LabelEntity.
|
||||
* @summary Table for the many-to-many relationship between ItemEntity and LabelEntity.
|
||||
*/
|
||||
@Entity(
|
||||
primaryKeys = ["itemId", "labelId"],
|
||||
|
||||
@@ -13,7 +13,7 @@ import androidx.room.Relation
|
||||
// [RELATION: DataClass('ItemWithLabels')] -> [DEPENDS_ON] -> [DatabaseTable('ItemEntity')]
|
||||
// [RELATION: DataClass('ItemWithLabels')] -> [DEPENDS_ON] -> [DatabaseTable('LabelEntity')]
|
||||
/**
|
||||
* @summary POJO для получения ItemEntity вместе со связанными LabelEntity.
|
||||
* @summary POJO for retrieving an ItemEntity with its associated LabelEntity objects.
|
||||
*/
|
||||
data class ItemWithLabels(
|
||||
@Embedded val item: ItemEntity,
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.room.PrimaryKey
|
||||
|
||||
// [ENTITY: DatabaseTable('LabelEntity')]
|
||||
/**
|
||||
* @summary Представляет собой строку в таблице 'labels' в локальной БД.
|
||||
* @summary Represents a row in the 'labels' table in the local DB.
|
||||
*/
|
||||
@Entity(tableName = "labels")
|
||||
data class LabelEntity(
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.room.PrimaryKey
|
||||
|
||||
// [ENTITY: DatabaseTable('LocationEntity')]
|
||||
/**
|
||||
* @summary Представляет собой строку в таблице 'locations' в локальной БД.
|
||||
* @summary Represents a row in the 'locations' table in the local DB.
|
||||
*/
|
||||
@Entity(tableName = "locations")
|
||||
data class LocationEntity(
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.homebox.lens.domain.model.*
|
||||
// [ENTITY: Function('ItemWithLabels.toDomainItemSummary')]
|
||||
// [RELATION: Function('ItemWithLabels.toDomainItemSummary')] -> [RETURNS] -> [DataClass('ItemSummary')]
|
||||
/**
|
||||
* @summary Преобразует [ItemWithLabels] (сущность БД) в [ItemSummary] (доменную модель).
|
||||
* @summary Converts [ItemWithLabels] (DB entity) to [ItemSummary] (domain model).
|
||||
*/
|
||||
fun ItemWithLabels.toDomainItemSummary(): ItemSummary {
|
||||
return ItemSummary(
|
||||
@@ -32,7 +32,7 @@ fun ItemWithLabels.toDomainItemSummary(): ItemSummary {
|
||||
// [ENTITY: Function('ItemEntity.toDomainItem')]
|
||||
// [RELATION: Function('ItemEntity.toDomainItem')] -> [RETURNS] -> [DataClass('Item')]
|
||||
/**
|
||||
* @summary Преобразует [ItemEntity] (сущность БД) в [Item] (доменную модель).
|
||||
* @summary Converts [ItemEntity] (DB entity) to [Item] (domain model).
|
||||
*/
|
||||
fun ItemEntity.toDomainItem(): Item {
|
||||
return Item(
|
||||
@@ -71,7 +71,7 @@ fun ItemEntity.toDomainItem(): Item {
|
||||
// [ENTITY: Function('Item.toItemEntity')]
|
||||
// [RELATION: Function('Item.toItemEntity')] -> [RETURNS] -> [DataClass('ItemEntity')]
|
||||
/**
|
||||
* @summary Преобразует [Item] (доменную модель) в [ItemEntity] (сущность БД).
|
||||
* @summary Converts [Item] (domain model) to [ItemEntity] (DB entity).
|
||||
*/
|
||||
fun Item.toItemEntity(): ItemEntity {
|
||||
return ItemEntity(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.di
|
||||
// [FILE] ApiModule.kt
|
||||
// [SEMANTICS] di, networking
|
||||
// [SEMANTICS] data, di, networking
|
||||
package com.homebox.lens.data.di
|
||||
|
||||
// [IMPORTS]
|
||||
@@ -25,8 +25,8 @@ import javax.inject.Singleton
|
||||
|
||||
// [ENTITY: Module('ApiModule')]
|
||||
/**
|
||||
* @summary Hilt-модуль, отвечающий за создание и предоставление всех зависимостей,
|
||||
* необходимых для сетевого взаимодействия.
|
||||
* @summary Hilt module responsible for creating and providing all dependencies
|
||||
* necessary for network interaction.
|
||||
*/
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.di
|
||||
// [FILE] DatabaseModule.kt
|
||||
// [SEMANTICS] di, hilt, database
|
||||
// [SEMANTICS] data, di, database
|
||||
package com.homebox.lens.data.di
|
||||
|
||||
// [IMPORTS]
|
||||
@@ -18,7 +18,7 @@ import javax.inject.Singleton
|
||||
|
||||
// [ENTITY: Module('DatabaseModule')]
|
||||
/**
|
||||
* @summary Предоставляет зависимости для работы с базой данных Room.
|
||||
* @summary Provides dependencies for working with the Room database.
|
||||
*/
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.di
|
||||
// [FILE] RepositoryModule.kt
|
||||
// [SEMANTICS] dependency_injection, hilt, module, binding
|
||||
// [SEMANTICS] data, di, repository
|
||||
|
||||
package com.homebox.lens.data.di
|
||||
|
||||
@@ -20,8 +20,8 @@ import javax.inject.Singleton
|
||||
|
||||
// [ENTITY: Module('RepositoryModule')]
|
||||
/**
|
||||
* @summary Hilt-модуль для предоставления реализаций репозиториев.
|
||||
* @description Использует `@Binds` для эффективного связывания интерфейсов с их реализациями.
|
||||
* @summary Hilt module for providing repository implementations.
|
||||
* @description Uses `@Binds` for efficient binding of interfaces to their implementations.
|
||||
*/
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@@ -30,7 +30,7 @@ abstract class RepositoryModule {
|
||||
// [ENTITY: Function('bindItemRepository')]
|
||||
// [RELATION: Function('bindItemRepository')] -> [PROVIDES] -> [Interface('ItemRepository')]
|
||||
/**
|
||||
* @summary Связывает интерфейс ItemRepository с его реализацией.
|
||||
* @summary Binds the ItemRepository interface to its implementation.
|
||||
*/
|
||||
@Binds
|
||||
@Singleton
|
||||
@@ -42,7 +42,7 @@ abstract class RepositoryModule {
|
||||
// [ENTITY: Function('bindCredentialsRepository')]
|
||||
// [RELATION: Function('bindCredentialsRepository')] -> [PROVIDES] -> [Interface('CredentialsRepository')]
|
||||
/**
|
||||
* @summary Связывает интерфейс CredentialsRepository с его реализацией.
|
||||
* @summary Binds the CredentialsRepository interface to its implementation.
|
||||
*/
|
||||
@Binds
|
||||
@Singleton
|
||||
@@ -54,7 +54,7 @@ abstract class RepositoryModule {
|
||||
// [ENTITY: Function('bindAuthRepository')]
|
||||
// [RELATION: Function('bindAuthRepository')] -> [PROVIDES] -> [Interface('AuthRepository')]
|
||||
/**
|
||||
* @summary Связывает интерфейс AuthRepository с его реализацией.
|
||||
* @summary Binds the AuthRepository interface to its implementation.
|
||||
*/
|
||||
@Binds
|
||||
@Singleton
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.di
|
||||
// [FILE] StorageModule.kt
|
||||
// [SEMANTICS] di, hilt, storage
|
||||
// [SEMANTICS] data, di, storage
|
||||
package com.homebox.lens.data.di
|
||||
|
||||
// [IMPORTS]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.mapper
|
||||
// [FILE] DomainToDto.kt
|
||||
// [SEMANTICS] data, mapper, domain, dto
|
||||
// [SEMANTICS] data, mapper
|
||||
package com.homebox.lens.data.mapper
|
||||
|
||||
// [IMPORTS]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.mapper
|
||||
// [FILE] DtoToDomain.kt
|
||||
// [SEMANTICS] data, mapper, dto, domain
|
||||
// [SEMANTICS] data, mapper
|
||||
package com.homebox.lens.data.mapper
|
||||
|
||||
// [IMPORTS]
|
||||
@@ -133,6 +133,13 @@ fun LabelOutDto.toDomainLabel(): DomainLabel {
|
||||
name = this.name
|
||||
)
|
||||
}
|
||||
|
||||
fun com.homebox.lens.domain.model.LabelOut.toDomain(): DomainLabel {
|
||||
return DomainLabel(
|
||||
id = this.id,
|
||||
name = this.name
|
||||
)
|
||||
}
|
||||
// [END_ENTITY: Function('LabelOutDto.toDomain')]
|
||||
|
||||
// [ENTITY: Function('LocationOutDto.toDomain')]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.repository
|
||||
// [FILE] AuthRepositoryImpl.kt
|
||||
// [SEMANTICS] data_implementation, authentication, repository
|
||||
// [SEMANTICS] data, repository, authentication
|
||||
|
||||
package com.homebox.lens.data.repository
|
||||
|
||||
@@ -30,10 +30,10 @@ import javax.inject.Inject
|
||||
// [RELATION: Class('AuthRepositoryImpl')] -> [DEPENDS_ON] -> [Framework('OkHttpClient')]
|
||||
// [RELATION: Class('AuthRepositoryImpl')] -> [DEPENDS_ON] -> [Framework('MoshiConverterFactory')]
|
||||
/**
|
||||
* @summary Реализация репозитория для управления аутентификацией.
|
||||
* @param encryptedPrefs Защищенное хранилище для токена.
|
||||
* @param okHttpClient Общий OkHttp клиент для переиспользования.
|
||||
* @param moshiConverterFactory Общий конвертер Moshi для переиспользования.
|
||||
* @summary Implementation of the repository for managing authentication.
|
||||
* @param encryptedPrefs The secure storage for the token.
|
||||
* @param okHttpClient The shared OkHttp client for reuse.
|
||||
* @param moshiConverterFactory The shared Moshi converter for reuse.
|
||||
*/
|
||||
class AuthRepositoryImpl @Inject constructor(
|
||||
private val encryptedPrefs: SharedPreferences,
|
||||
@@ -47,10 +47,10 @@ class AuthRepositoryImpl @Inject constructor(
|
||||
|
||||
// [ENTITY: Function('login')]
|
||||
/**
|
||||
* @summary Реализует вход пользователя. Создает временный API сервис для выполнения запроса
|
||||
* на указанный пользователем URL сервера.
|
||||
* @param credentials Учетные данные пользователя, включая URL сервера.
|
||||
* @return [Result] с доменной моделью [TokenResponse] при успехе или [Exception] при ошибке.
|
||||
* @summary Implements user login. Creates a temporary API service to execute a request
|
||||
* to the server URL specified by the user.
|
||||
* @param credentials The user's credentials, including the server URL.
|
||||
* @return A [Result] with a [TokenResponse] domain model on success or an [Exception] on failure.
|
||||
*/
|
||||
override suspend fun login(credentials: Credentials): Result<TokenResponse> {
|
||||
require(credentials.serverUrl.isNotBlank()) { "Server URL cannot be blank." }
|
||||
|
||||
@@ -20,10 +20,10 @@ import javax.inject.Inject
|
||||
// [RELATION: Class('CredentialsRepositoryImpl')] -> [IMPLEMENTS] -> [Interface('CredentialsRepository')]
|
||||
// [RELATION: Class('CredentialsRepositoryImpl')] -> [DEPENDS_ON] -> [Framework('SharedPreferences')]
|
||||
/**
|
||||
* @summary Реализует репозиторий для управления учетными данными пользователя.
|
||||
* @description Взаимодействует с зашифрованными SharedPreferences для сохранения и извлечения данных.
|
||||
* @param encryptedPrefs Зашифрованное хранилище ключ-значение, предоставляемое Hilt.
|
||||
* @invariant Состояние этого репозитория полностью зависит от содержимого `encryptedPrefs`.
|
||||
* @summary Implements the repository for managing user credentials.
|
||||
* @description Interacts with encrypted SharedPreferences to save and retrieve data.
|
||||
* @param encryptedPrefs The encrypted key-value store provided by Hilt.
|
||||
* @invariant The state of this repository is entirely dependent on the contents of `encryptedPrefs`.
|
||||
*/
|
||||
class CredentialsRepositoryImpl @Inject constructor(
|
||||
private val encryptedPrefs: SharedPreferences
|
||||
@@ -38,9 +38,9 @@ class CredentialsRepositoryImpl @Inject constructor(
|
||||
|
||||
// [ENTITY: Function('saveCredentials')]
|
||||
/**
|
||||
* @summary Сохраняет основные учетные данные пользователя.
|
||||
* @param credentials Объект с учетными данными для сохранения.
|
||||
* @sideeffect Перезаписывает существующие учетные данные в SharedPreferences.
|
||||
* @summary Saves the user's primary credentials.
|
||||
* @param credentials The credentials object to save.
|
||||
* @sideeffect Overwrites existing credentials in SharedPreferences.
|
||||
*/
|
||||
override suspend fun saveCredentials(credentials: Credentials) {
|
||||
withContext(Dispatchers.IO) {
|
||||
@@ -56,8 +56,8 @@ class CredentialsRepositoryImpl @Inject constructor(
|
||||
|
||||
// [ENTITY: Function('getCredentials')]
|
||||
/**
|
||||
* @summary Извлекает сохраненные учетные данные пользователя в виде потока.
|
||||
* @return Flow, который эммитит объект [Credentials] или null, если данные отсутствуют.
|
||||
* @summary Retrieves the saved user credentials as a Flow.
|
||||
* @return A Flow that emits a [Credentials] object or null if no data is present.
|
||||
*/
|
||||
override fun getCredentials(): Flow<Credentials?> = flow {
|
||||
Timber.d("[DEBUG][ACTION][getting_credentials] Getting user credentials.")
|
||||
@@ -77,9 +77,9 @@ class CredentialsRepositoryImpl @Inject constructor(
|
||||
|
||||
// [ENTITY: Function('saveToken')]
|
||||
/**
|
||||
* @summary Сохраняет токен авторизации.
|
||||
* @param token Токен для сохранения.
|
||||
* @sideeffect Перезаписывает существующий токен в SharedPreferences.
|
||||
* @summary Saves the authorization token.
|
||||
* @param token The token to save.
|
||||
* @sideeffect Overwrites the existing token in SharedPreferences.
|
||||
*/
|
||||
override suspend fun saveToken(token: String) {
|
||||
withContext(Dispatchers.IO) {
|
||||
@@ -93,8 +93,8 @@ class CredentialsRepositoryImpl @Inject constructor(
|
||||
|
||||
// [ENTITY: Function('getToken')]
|
||||
/**
|
||||
* @summary Извлекает сохраненный токен авторизации.
|
||||
* @return Строка с токеном или null, если он не найден.
|
||||
* @summary Retrieves the saved authorization token.
|
||||
* @return A string with the token or null if it is not found.
|
||||
*/
|
||||
override suspend fun getToken(): String? {
|
||||
return withContext(Dispatchers.IO) {
|
||||
@@ -111,8 +111,8 @@ class CredentialsRepositoryImpl @Inject constructor(
|
||||
|
||||
// [ENTITY: Function('clearAllCredentials')]
|
||||
/**
|
||||
* @summary Очищает все сохраненные учетные данные и токены.
|
||||
* @sideeffect Удаляет все записи, связанные с учетными данными, из SharedPreferences.
|
||||
* @summary Clears all saved credentials and tokens.
|
||||
* @sideeffect Removes all records related to credentials from SharedPreferences.
|
||||
*/
|
||||
override suspend fun clearAllCredentials() {
|
||||
withContext(Dispatchers.IO) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.repository
|
||||
// [FILE] ItemRepositoryImpl.kt
|
||||
// [SEMANTICS] data_repository, implementation, items, labels
|
||||
// [SEMANTICS] data, repository, item
|
||||
package com.homebox.lens.data.repository
|
||||
|
||||
// [IMPORTS]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// [PACKAGE] com.homebox.lens.data.security
|
||||
// [FILE] CryptoManager.kt
|
||||
// [SEMANTICS] data, security, cryptography
|
||||
// [SEMANTICS] data, security, crypto
|
||||
package com.homebox.lens.data.security
|
||||
|
||||
// [IMPORTS]
|
||||
|
||||
Reference in New Issue
Block a user