A continuation of HomeBox the inventory and organization system built for the Home User
Comprehensive backend cleanup with github.com/samber/lo helpers (#1301)
Copilot574cb79127b9
diff --git a/.scaffold/go.sum b/.scaffold/go.sumindex 36f3018c..16f190a2 100644--- a/.scaffold/go.sum+++ b/.scaffold/go.sum@@ -8,7 +8,7 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIgithub.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=-github.com/sysadminsmedia/homebox/backend v0.0.0-20251228172914-2a6773d1d610 h1:kNLtnxaPaOryBUZ7RgUHPQVWxIExXYR/q9pYCbum5Vk=-github.com/sysadminsmedia/homebox/backend v0.0.0-20251228172914-2a6773d1d610/go.mod h1:9zHHw5TNttw5Kn4Wks+SxwXmJPz6PgGNbnB4BtF1Z4c=+github.com/sysadminsmedia/homebox/backend v0.0.0-20260205022116-745fac6438b1 h1:A7TT5wp8hfU/2k/n/toPky4H3dv3Jhza0x3nriiK10E=+github.com/sysadminsmedia/homebox/backend v0.0.0-20260205022116-745fac6438b1/go.mod h1:70G3l97IfOTqHgM4G2fCTsR/kY087J6k/d1iS3D3D3g=gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=diff --git a/backend/app/api/handlers/v1/query_params.go b/backend/app/api/handlers/v1/query_params.goindex 0ac84d8e..7b53223d 100644--- a/backend/app/api/handlers/v1/query_params.go+++ b/backend/app/api/handlers/v1/query_params.go@@ -5,18 +5,14 @@ import ("strconv""github.com/google/uuid"+ "github.com/samber/lo")func queryUUIDList(params url.Values, key string) []uuid.UUID {- var ids []uuid.UUID- for _, id := range params[key] {+ return lo.FilterMap(params[key], func(id string, _ int) (uuid.UUID, bool) {uid, err := uuid.Parse(id)- if err != nil {- continue- }- ids = append(ids, uid)- }- return ids+ return uid, err == nil+ })}func queryIntOrNegativeOne(s string) int {diff --git a/backend/app/api/handlers/v1/v1_ctrl_actions.go b/backend/app/api/handlers/v1/v1_ctrl_actions.goindex 9098637c..e58f1479 100644--- a/backend/app/api/handlers/v1/v1_ctrl_actions.go+++ b/backend/app/api/handlers/v1/v1_ctrl_actions.go@@ -99,7 +99,7 @@ func (ctrl *V1Controller) HandleCreateMissingThumbnails() errchain.HandlerFunc {// WipeInventoryOptions represents the options for wiping inventorytype WipeInventoryOptions struct {- WipeTags bool `json:"wipeTags"`+ WipeTags bool `json:"wipeTags"`WipeLocations bool `json:"wipeLocations"`WipeMaintenance bool `json:"wipeMaintenance"`}@@ -132,7 +132,7 @@ func (ctrl *V1Controller) HandleWipeInventory() errchain.HandlerFunc {if err := server.Decode(r, &options); err != nil {// If no body provided, use default (false for all)options = WipeInventoryOptions{- WipeTags: false,+ WipeTags: false,WipeLocations: false,WipeMaintenance: false,}diff --git a/backend/app/api/handlers/v1/v1_ctrl_auth.go b/backend/app/api/handlers/v1/v1_ctrl_auth.goindex 88b04238..cc9078ea 100644--- a/backend/app/api/handlers/v1/v1_ctrl_auth.go+++ b/backend/app/api/handlers/v1/v1_ctrl_auth.go@@ -11,6 +11,7 @@ import ("github.com/hay-kot/httpkit/errchain""github.com/hay-kot/httpkit/server""github.com/rs/zerolog/log"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/core/services""github.com/sysadminsmedia/homebox/backend/internal/sys/validate")@@ -94,11 +95,10 @@ func (ctrl *V1Controller) HandleAuthLogin(ps ...AuthProvider) errchain.HandlerFupanic("no auth providers provided")}- providers := make(map[string]AuthProvider)- for _, p := range ps {+ providers := lo.SliceToMap(ps, func(p AuthProvider) (string, AuthProvider) {log.Info().Str("name", p.Name()).Msg("registering auth provider")- providers[p.Name()] = p- }+ return p.Name(), p+ })return func(w http.ResponseWriter, r *http.Request) error {// Extract provider querydiff --git a/backend/app/api/handlers/v1/v1_ctrl_group.go b/backend/app/api/handlers/v1/v1_ctrl_group.goindex c64d2f46..d00d76f4 100644--- a/backend/app/api/handlers/v1/v1_ctrl_group.go+++ b/backend/app/api/handlers/v1/v1_ctrl_group.go@@ -8,6 +8,7 @@ import ("github.com/go-chi/chi/v5""github.com/google/uuid""github.com/hay-kot/httpkit/errchain"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/core/services""github.com/sysadminsmedia/homebox/backend/internal/data/repo""github.com/sysadminsmedia/homebox/backend/internal/sys/validate"@@ -178,13 +179,9 @@ func (ctrl *V1Controller) HandleGroupDelete() errchain.HandlerFunc {// If the group being deleted is the user's default group, reassign to another groupif currentUser.DefaultGroupID == auth.GID {// Find another group the user is a member of- var newDefaultGroupID uuid.UUID- for _, gid := range currentUser.GroupIDs {- if gid != auth.GID {- newDefaultGroupID = gid- break- }- }+ newDefaultGroupID, _ := lo.Find(currentUser.GroupIDs, func(gid uuid.UUID) bool {+ return gid != auth.GID+ })// Update the user's default groupif err := ctrl.repo.Users.UpdateDefaultGroup(auth, auth.UID, newDefaultGroupID); err != nil {diff --git a/backend/app/api/handlers/v1/v1_ctrl_item_templates.go b/backend/app/api/handlers/v1/v1_ctrl_item_templates.goindex 562063e3..0dc92452 100644--- a/backend/app/api/handlers/v1/v1_ctrl_item_templates.go+++ b/backend/app/api/handlers/v1/v1_ctrl_item_templates.go@@ -5,6 +5,7 @@ import ("github.com/google/uuid""github.com/hay-kot/httpkit/errchain"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/core/services""github.com/sysadminsmedia/homebox/backend/internal/data/repo""github.com/sysadminsmedia/homebox/backend/internal/web/adapters"@@ -135,14 +136,13 @@ func (ctrl *V1Controller) HandleItemTemplatesCreateItem() errchain.HandlerFunc {}// Build custom fields from template- fields := make([]repo.ItemField, len(template.Fields))- for i, f := range template.Fields {- fields[i] = repo.ItemField{+ fields := lo.Map(template.Fields, func(f repo.TemplateField, _ int) repo.ItemField {+ return repo.ItemField{Type: f.Type,Name: f.Name,TextValue: f.TextValue,}- }+ })// Create item with all template data in a single transactionreturn ctrl.repo.Items.CreateFromTemplate(r.Context(), auth.GID, repo.ItemCreateFromTemplate{diff --git a/backend/app/api/handlers/v1/v1_ctrl_items.go b/backend/app/api/handlers/v1/v1_ctrl_items.goindex 7de13820..4bdeb943 100644--- a/backend/app/api/handlers/v1/v1_ctrl_items.go+++ b/backend/app/api/handlers/v1/v1_ctrl_items.go@@ -14,6 +14,7 @@ import ("github.com/hay-kot/httpkit/errchain""github.com/hay-kot/httpkit/server""github.com/rs/zerolog/log"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/core/services""github.com/sysadminsmedia/homebox/backend/internal/data/repo""github.com/sysadminsmedia/homebox/backend/internal/sys/validate"@@ -39,19 +40,16 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc {params := r.URL.Query()filterFieldItems := func(raw []string) []repo.FieldQuery {- var items []repo.FieldQuery-- for _, v := range raw {+ return lo.FilterMap(raw, func(v string, _ int) (repo.FieldQuery, bool) {parts := strings.SplitN(v, "=", 2)- if len(parts) == 2 {- items = append(items, repo.FieldQuery{- Name: parts[0],- Value: parts[1],- })+ if len(parts) != 2 {+ return repo.FieldQuery{}, false}- }-- return items+ return repo.FieldQuery{+ Name: parts[0],+ Value: parts[1],+ }, true+ })}v := repo.ItemQuery{diff --git a/backend/app/api/providers/oidc.go b/backend/app/api/providers/oidc.goindex 7120baea..f2e399e8 100644--- a/backend/app/api/providers/oidc.go+++ b/backend/app/api/providers/oidc.go@@ -14,6 +14,7 @@ import ("github.com/coreos/go-oidc/v3/oidc""github.com/rs/zerolog/log"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/core/services""github.com/sysadminsmedia/homebox/backend/internal/sys/config""golang.org/x/oauth2"@@ -280,11 +281,10 @@ func (p *OIDCProvider) parseOIDCClaims(rawClaims map[string]interface{}) (OIDCClif groupsValue, exists := rawClaims[key]; exists {switch groups := groupsValue.(type) {case []interface{}:- for _, group := range groups {- if groupStr, ok := group.(string); ok {- claims.Groups = append(claims.Groups, groupStr)- }- }+ claims.Groups = lo.FilterMap(groups, func(group interface{}, _ int) (string, bool) {+ groupStr, ok := group.(string)+ return groupStr, ok+ })case []string:claims.Groups = groupscase string:@@ -314,18 +314,13 @@ func (p *OIDCProvider) hasAllowedGroup(userGroups, allowedGroups []string) boolreturn true}- allowedGroupsMap := make(map[string]bool)- for _, group := range allowedGroups {- allowedGroupsMap[strings.TrimSpace(group)] = true- }-- for _, userGroup := range userGroups {- if allowedGroupsMap[userGroup] {- return true- }- }+ allowedSet := lo.SliceToMap(allowedGroups, func(group string) (string, bool) {+ return strings.TrimSpace(group), true+ })- return false+ return lo.SomeBy(userGroups, func(userGroup string) bool {+ return allowedSet[userGroup]+ })}func (p *OIDCProvider) GetAuthURL(baseURL, state, nonce, pkceVerifier string) string {diff --git a/backend/go.mod b/backend/go.modindex d8105c12..5dd791aa 100644--- a/backend/go.mod+++ b/backend/go.mod@@ -25,6 +25,7 @@ require (github.com/pkg/errors v0.9.1github.com/pressly/goose/v3 v3.26.0github.com/rs/zerolog v1.34.0+ github.com/samber/lo v1.52.0github.com/shirou/gopsutil/v4 v4.25.12github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686egithub.com/stretchr/testify v1.11.1diff --git a/backend/go.sum b/backend/go.sumindex 159beac4..694e780a 100644--- a/backend/go.sum+++ b/backend/go.sum@@ -4,10 +4,6 @@ cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=cloud.google.com/go v0.121.6 h1:waZiuajrI28iAf40cWgycWNgaXPO06dupuS+sgibK6c=cloud.google.com/go v0.121.6/go.mod h1:coChdst4Ea5vUpiALcYKXEpR1S9ZgXbhEzzMcMR66vI=-cloud.google.com/go/auth v0.17.0 h1:74yCm7hCj2rUyyAocqnFzsAYXgJhrG26XCFimrc/Kz4=-cloud.google.com/go/auth v0.17.0/go.mod h1:6wv/t5/6rOPAX4fJiRjKkJCvswLwdet7G8+UGXt7nCQ=-cloud.google.com/go/auth v0.18.0 h1:wnqy5hrv7p3k7cShwAU/Br3nzod7fxoqG+k0VZ+/Pk0=-cloud.google.com/go/auth v0.18.0/go.mod h1:wwkPM1AgE1f2u6dG443MiWoD8C3BtOywNsUMcUTVDRo=cloud.google.com/go/auth v0.18.1 h1:IwTEx92GFUo2pJ6Qea0EU3zYvKnTAeRCODxfA/G5UWs=cloud.google.com/go/auth v0.18.1/go.mod h1:GfTYoS9G3CWpRA3Va9doKN9mjPGRS+v41jmZAhBzbrA=cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc=@@ -180,16 +176,12 @@ github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKgithub.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=github.com/gen2brain/avif v0.4.4 h1:Ga/ss7qcWWQm2bxFpnjYjhJsNfZrWs5RsyklgFjKRSE=github.com/gen2brain/avif v0.4.4/go.mod h1:/XCaJcjZraQwKVhpu9aEd9aLOssYOawLvhMBtmHVGqk=-github.com/gen2brain/heic v0.4.7 h1:xw/e9R3HdIvb+uEhRDMRJdviYnB3ODe/VwL8SYLaMGc=-github.com/gen2brain/heic v0.4.7/go.mod h1:ECnpqbqLu0qSje4KSNWUUDK47UPXPzl80T27GWGEL5I=github.com/gen2brain/heic v0.4.9 h1:sHM7kjMV2+AlrSfYNsJiD0NrqAJqIMWAOqMSZ0HXrU8=github.com/gen2brain/heic v0.4.9/go.mod h1:0/0SrVQnUhOA3ekFY5/lApZYniF/DsgS3g9COWe83dM=github.com/gen2brain/jpegxl v0.4.5 h1:TWpVEn5xkIfsswzkjHBArd0Cc9AE0tbjBSoa0jDsrbo=github.com/gen2brain/jpegxl v0.4.5/go.mod h1:4kWYJ18xCEuO2vzocYdGpeqNJ990/Gjy3uLMg5TBN6I=github.com/gen2brain/webp v0.5.5 h1:MvQR75yIPU/9nSqYT5h13k4URaJK3gf9tgz/ksRbyEg=github.com/gen2brain/webp v0.5.5/go.mod h1:xOSMzp4aROt2KFW++9qcK/RBTOVC2S9tJG66ip/9Oc0=-github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE=-github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=github.com/go-chi/chi/v5 v5.2.4 h1:WtFKPHwlywe8Srng8j2BhOD9312j9cGUxG1SP4V2cR4=github.com/go-chi/chi/v5 v5.2.4/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0=github.com/go-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs=@@ -273,10 +265,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4=github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18=-github.com/googleapis/enterprise-certificate-proxy v0.3.7 h1:zrn2Ee/nWmHulBx5sAVrGgAa0f2/R35S4DJwfFaUPFQ=-github.com/googleapis/enterprise-certificate-proxy v0.3.7/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA=-github.com/googleapis/enterprise-certificate-proxy v0.3.9 h1:TOpi/QG8iDcZlkQlGlFUti/ZtyLkliXvHDcyUIMuFrU=-github.com/googleapis/enterprise-certificate-proxy v0.3.9/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA=github.com/googleapis/enterprise-certificate-proxy v0.3.11 h1:vAe81Msw+8tKUxi2Dqh/NZMz7475yUvmRIkXr4oN2ao=github.com/googleapis/enterprise-certificate-proxy v0.3.11/go.mod h1:RFV7MUdlb7AgEq2v7FmMCfeSMCllAzWxFgRdusoGks8=github.com/googleapis/gax-go/v2 v2.16.0 h1:iHbQmKLLZrexmb0OSsNGTeSTS0HO4YvFOG8g5E4Zd0Y=@@ -314,8 +302,6 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU=github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXwkPPMeUgOK1k=-github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=-github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=github.com/klauspost/compress v1.18.3 h1:9PJRvfbmTabkOX8moIpXPbMMbYN60bWImDDU7L+/6zw=github.com/klauspost/compress v1.18.3/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=@@ -328,8 +314,6 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=-github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=-github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=github.com/lib/pq v1.11.1 h1:wuChtj2hfsGmmx3nf1m7xC2XpK6OtelS2shMY+bGMtI=github.com/lib/pq v1.11.1/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=@@ -341,10 +325,6 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=-github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=-github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=-github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=-github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=github.com/mattn/go-sqlite3 v1.14.33 h1:A5blZ5ulQo2AtayQ9/limgHEkFreKj1Dv226a1K73s0=github.com/mattn/go-sqlite3 v1.14.33/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=@@ -359,8 +339,6 @@ github.com/nats-io/nats-server/v2 v2.9.23 h1:6Wj6H6QpP9FMlpCyWUaNu2yeZ/qGj+mdRkZgithub.com/nats-io/nats-server/v2 v2.9.23/go.mod h1:wEjrEy9vnqIGE4Pqz4/c75v9Pmaq7My2IgFmnykc4C0=github.com/nats-io/nats.go v1.48.0 h1:pSFyXApG+yWU/TgbKCjmm5K4wrHu86231/w84qRVR+U=github.com/nats-io/nats.go v1.48.0/go.mod h1:iRWIPokVIFbVijxuMQq4y9ttaBTMe0SFdlZfMDd+33g=-github.com/nats-io/nkeys v0.4.12 h1:nssm7JKOG9/x4J8II47VWCL1Ds29avyiQDRn0ckMvDc=-github.com/nats-io/nkeys v0.4.12/go.mod h1:MT59A1HYcjIcyQDJStTfaOY6vhy9XTUjOFo+SVsvpBg=github.com/nats-io/nkeys v0.4.15 h1:JACV5jRVO9V856KOapQ7x+EY8Jo3qw1vJt/9Jpwzkk4=github.com/nats-io/nkeys v0.4.15/go.mod h1:CpMchTXC9fxA5zrMo4KpySxNjiDVvr8ANOSZdiNfUrs=github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=@@ -369,16 +347,12 @@ github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFgithub.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=github.com/olahol/melody v1.4.0 h1:Pa5SdeZL/zXPi1tJuMAPDbl4n3gQOThSL6G1p4qZ4SI=github.com/olahol/melody v1.4.0/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4=-github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=-github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU=github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=-github.com/pierrec/lz4/v4 v4.1.23 h1:oJE7T90aYBGtFNrI8+KbETnPymobAhzRrR8Mu8n1yfU=-github.com/pierrec/lz4/v4 v4.1.23/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4=github.com/pierrec/lz4/v4 v4.1.25 h1:kocOqRffaIbU5djlIBr7Wh+cx82C0vtFb0fOurZHqD0=github.com/pierrec/lz4/v4 v4.1.25/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4=github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=@@ -407,20 +381,16 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=+github.com/samber/lo v1.52.0 h1:Rvi+3BFHES3A8meP33VPAxiBZX/Aws5RxrschYGjomw=+github.com/samber/lo v1.52.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=-github.com/shirou/gopsutil/v4 v4.25.11 h1:X53gB7muL9Gnwwo2evPSE+SfOrltMoR6V3xJAXZILTY=-github.com/shirou/gopsutil/v4 v4.25.11/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU=github.com/shirou/gopsutil/v4 v4.25.12 h1:e7PvW/0RmJ8p8vPGJH4jvNkOyLmbkXgXW4m6ZPic6CY=github.com/shirou/gopsutil/v4 v4.25.12/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU=github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=-github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=-github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=-github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=-github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=github.com/spiffe/go-spiffe/v2 v2.6.0 h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo=github.com/spiffe/go-spiffe/v2 v2.6.0/go.mod h1:gm2SeUoMZEtpnzPNs2Csc0D/gX33k1xIx7lEzqblHEs=github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=@@ -442,8 +412,6 @@ github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=-github.com/tinylib/msgp v1.6.1 h1:ESRv8eL3u+DNHUoSAAQRE50Hm162zqAnBoGv9PzScPY=-github.com/tinylib/msgp v1.6.1/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=github.com/tinylib/msgp v1.6.3 h1:bCSxiTz386UTgyT1i0MSCvdbWjVW+8sG3PjkGsZQt4s=github.com/tinylib/msgp v1.6.3/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=@@ -509,21 +477,13 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkgolang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=-golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=-golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=-golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0=-golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU=golang.org/x/exp v0.0.0-20260112195511-716be5621a96 h1:Z/6YuSHTLOHfNFdb8zVZomZr7cqNgTJvA8+Qz75D8gU=golang.org/x/exp v0.0.0-20260112195511-716be5621a96/go.mod h1:nzimsREAkjBCIEFtHiYkrJyT+2uy9YZJB7H1k68CXZU=-golang.org/x/image v0.34.0 h1:33gCkyw9hmwbZJeZkct8XyR11yH889EQt/QH4VmXMn8=-golang.org/x/image v0.34.0/go.mod h1:2RNFBZRB+vnwwFil8GkMdRvrJOFd1AzdZI6vOY+eJVU=golang.org/x/image v0.35.0 h1:LKjiHdgMtO8z7Fh18nGY6KDcoEtVfsgLDPeLyguqb7I=golang.org/x/image v0.35.0/go.mod h1:MwPLTVgvxSASsxdLzKrl8BRFuyqMyGhLwmC+TO1Sybk=golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=-golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=-golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=@@ -533,8 +493,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9vgolang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=-golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=-golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=@@ -556,8 +514,6 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=-golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=-golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=@@ -567,8 +523,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=-golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=-golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=@@ -576,8 +530,6 @@ golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=-golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=-golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=@@ -586,20 +538,12 @@ golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSgolang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=-google.golang.org/api v0.258.0 h1:IKo1j5FBlN74fe5isA2PVozN3Y5pwNKriEgAXPOkDAc=-google.golang.org/api v0.258.0/go.mod h1:qhOMTQEZ6lUps63ZNq9jhODswwjkjYYguA7fA3TBFww=-google.golang.org/api v0.260.0 h1:XbNi5E6bOVEj/uLXQRlt6TKuEzMD7zvW/6tNwltE4P4=-google.golang.org/api v0.260.0/go.mod h1:Shj1j0Phr/9sloYrKomICzdYgsSDImpTxME8rGLaZ/o=google.golang.org/api v0.264.0 h1:+Fo3DQXBK8gLdf8rFZ3uLu39JpOnhvzJrLMQSoSYZJM=google.golang.org/api v0.264.0/go.mod h1:fAU1xtNNisHgOF5JooAs8rRaTkl2rT3uaoNGo9NS3R8=google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217 h1:GvESR9BIyHUahIb0NcTum6itIWtdoglGX+rnGxm2934=google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:yJ2HH4EHEDTd3JiLmhds6NkJ17ITVYOdV3m3VKOnws0=google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls=google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto=-google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b h1:Mv8VFug0MP9e5vUxfBcE3vUkV6CImK3cMNMIDFjmzxU=-google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=-google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3 h1:C4WAdL+FbjnGlpp2S+HMVhBeCq2Lcib4xZqfPNF6OoQ=-google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 h1:H86B94AW+VfJWDqFeEbBPhEtHzJwJfTbgE2lZa54ZAQ=google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc=@@ -625,10 +569,6 @@ modernc.org/gc/v3 v3.1.1 h1:k8T3gkXWY9sEiytKhcgyiZ2L0DTyCQ/nvX+LoCljoRE=modernc.org/gc/v3 v3.1.1/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=-modernc.org/libc v1.67.2 h1:ZbNmly1rcbjhot5jlOZG0q4p5VwFfjwWqZ5rY2xxOXo=-modernc.org/libc v1.67.2/go.mod h1:QvvnnJ5P7aitu0ReNpVIEyesuhmDLQ8kaEoyMjIFZJA=-modernc.org/libc v1.67.6 h1:eVOQvpModVLKOdT+LvBPjdQqfrZq+pC39BygcT+E7OI=-modernc.org/libc v1.67.6/go.mod h1:JAhxUVlolfYDErnwiqaLvUqc8nfb2r6S6slAgZOnaiE=modernc.org/libc v1.67.7 h1:H+gYQw2PyidyxwxQsGTwQw6+6H+xUk+plvOKW7+d3TI=modernc.org/libc v1.67.7/go.mod h1:UjCSJFl2sYbJbReVQeVpq/MgzlbmDM4cRHIYFelnaDk=modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=@@ -639,10 +579,6 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=-modernc.org/sqlite v1.41.0 h1:bJXddp4ZpsqMsNN1vS0jWo4IJTZzb8nWpcgvyCFG9Ck=-modernc.org/sqlite v1.41.0/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE=-modernc.org/sqlite v1.44.2 h1:EdYqXeBpKFJjg8QYnw6E71MpANkoxyuYi+g68ugOL8g=-modernc.org/sqlite v1.44.2/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=modernc.org/sqlite v1.44.3 h1:+39JvV/HWMcYslAwRxHb8067w+2zowvFOUrOWIy9PjY=modernc.org/sqlite v1.44.3/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=diff --git a/backend/internal/core/currencies/currencies.go b/backend/internal/core/currencies/currencies.goindex becd6812..57f1e65c 100644--- a/backend/internal/core/currencies/currencies.go+++ b/backend/internal/core/currencies/currencies.go@@ -11,6 +11,8 @@ import ("slices""strings""sync"++ "github.com/samber/lo")//go:embed currencies.json@@ -85,13 +87,10 @@ type CurrencyRegistry struct {}func NewCurrencyService(currencies []Currency) *CurrencyRegistry {- registry := make(map[string]Currency, len(currencies))- for i := range currencies {- // Clamp decimals to safe range before adding to registry- currency := currencies[i]- currency.Decimals = clampDecimals(currency.Decimals, currency.Code)- registry[currency.Code] = currency- }+ registry := lo.SliceToMap(currencies, func(c Currency) (string, Currency) {+ c.Decimals = clampDecimals(c.Decimals, c.Code)+ return c.Code, c+ })return &CurrencyRegistry{registry: registry,@@ -102,10 +101,7 @@ func (cs *CurrencyRegistry) Slice() []Currency {cs.mu.RLock()defer cs.mu.RUnlock()- out := make([]Currency, 0, len(cs.registry))- for key := range cs.registry {- out = append(out, cs.registry[key])- }+ out := lo.Values(cs.registry)slices.SortFunc(out, func(a, b Currency) int {if a.Name < b.Name {@@ -127,6 +123,5 @@ func (cs *CurrencyRegistry) IsSupported(code string) bool {cs.mu.RLock()defer cs.mu.RUnlock()- _, ok := cs.registry[upper]- return ok+ return lo.HasKey(cs.registry, upper)}diff --git a/backend/internal/core/services/reporting/bill_of_materials.go b/backend/internal/core/services/reporting/bill_of_materials.goindex e6873d70..8f1b6c67 100644--- a/backend/internal/core/services/reporting/bill_of_materials.go+++ b/backend/internal/core/services/reporting/bill_of_materials.go@@ -2,6 +2,7 @@ package reportingimport ("github.com/gocarina/gocsv"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/data/repo""github.com/sysadminsmedia/homebox/backend/internal/data/types")@@ -23,9 +24,8 @@ type BillOfMaterialsEntry struct {// BillOfMaterialsCSV returns a byte slice of the Bill of Materials for a given GID in CSV format// See BillOfMaterialsEntry for the format of the outputfunc BillOfMaterialsCSV(entities []repo.ItemOut) ([]byte, error) {- bomEntries := make([]BillOfMaterialsEntry, len(entities))- for i, entity := range entities {- bomEntries[i] = BillOfMaterialsEntry{+ bomEntries := lo.Map(entities, func(entity repo.ItemOut, _ int) BillOfMaterialsEntry {+ return BillOfMaterialsEntry{PurchaseDate: entity.PurchaseTime,Name: entity.Name,Description: entity.Description,@@ -36,7 +36,7 @@ func BillOfMaterialsCSV(entities []repo.ItemOut) ([]byte, error) {Price: entity.PurchasePrice,TotalPrice: entity.PurchasePrice * float64(entity.Quantity),}- }+ })return gocsv.MarshalBytes(&bomEntries)}diff --git a/backend/internal/core/services/reporting/import.go b/backend/internal/core/services/reporting/import.goindex 9e5ca6e2..d1a41f9b 100644--- a/backend/internal/core/services/reporting/import.go+++ b/backend/internal/core/services/reporting/import.go@@ -1,4 +1,3 @@-// Package reporting provides a way to import CSV files into the database.package reportingimport (@@ -7,6 +6,8 @@ import ("errors""io""strings"++ "github.com/samber/lo")var (@@ -51,7 +52,7 @@ func readRawCsv(r io.Reader) ([][]string, error) {// We read up to 4KB which should be more than enough for any header rowfirstLineBuffer := make([]byte, separatorDetectionBufferSize)n, err := io.ReadFull(r, firstLineBuffer)- if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {+ if err != nil && !errors.Is(err, io.ErrUnexpectedEOF) && !errors.Is(err, io.EOF) {return nil, err}firstLineBuffer = firstLineBuffer[:n]@@ -89,10 +90,10 @@ func parseHeaders(headers []string) (hbHeaders map[string]int, fieldHeaders []st}required := []string{"HB.location", "HB.name"}- for _, h := range required {- if _, ok := hbHeaders[h]; !ok {- return nil, nil, ErrMissingRequiredHeaders- }+ if !lo.EveryBy(required, func(h string) bool {+ return lo.HasKey(hbHeaders, h)+ }) {+ return nil, nil, ErrMissingRequiredHeaders}if len(hbHeaders) == 0 {diff --git a/backend/internal/core/services/reporting/io_row.go b/backend/internal/core/services/reporting/io_row.goindex 51897a04..d141aac2 100644--- a/backend/internal/core/services/reporting/io_row.go+++ b/backend/internal/core/services/reporting/io_row.go@@ -3,6 +3,7 @@ package reportingimport ("strings"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/data/repo""github.com/sysadminsmedia/homebox/backend/internal/data/types")@@ -86,11 +87,7 @@ func (csf LocationString) String() string {}func fromPathSlice(s []repo.ItemPath) LocationString {- v := make(LocationString, len(s))-- for i := range s {- v[i] = s[i].Name- }-- return v+ return lo.Map(s, func(p repo.ItemPath, _ int) string {+ return p.Name+ })}diff --git a/backend/internal/core/services/reporting/io_sheet.go b/backend/internal/core/services/reporting/io_sheet.goindex 0f364278..2125acc0 100644--- a/backend/internal/core/services/reporting/io_sheet.go+++ b/backend/internal/core/services/reporting/io_sheet.go@@ -11,6 +11,7 @@ import ("github.com/google/uuid""github.com/rs/zerolog/log"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/data/repo""github.com/sysadminsmedia/homebox/backend/internal/data/types")@@ -60,10 +61,9 @@ func csvTagAlternatives(tag string) []string {return nil}parts := strings.Split(tag, "|")- for i := range parts {- parts[i] = strings.TrimSpace(parts[i])- }- return parts+ return lo.Map(parts, func(s string, _ int) string {+ return strings.TrimSpace(s)+ })}// findColumnForTag tries to find a column index for a csv tag. The tag may@@ -220,24 +220,19 @@ func (s *IOSheet) ReadItems(ctx context.Context, items []repo.ItemOut, gid uuid.locString := fromPathSlice(locPaths)- tagString := make([]string, len(item.Tags))-- for i, l := range item.Tags {- tagString[i] = l.Name- }+ tagString := lo.Map(item.Tags, func(l repo.TagSummary, _ int) string {+ return l.Name+ })url := generateItemURL(item, hbURL)- customFields := make([]ExportItemFields, len(item.Fields))-- for i, f := range item.Fields {+ customFields := lo.Map(item.Fields, func(f repo.ItemField, _ int) ExportItemFields {extraHeaders[f.Name] = struct{}{}-- customFields[i] = ExportItemFields{+ return ExportItemFields{Name: f.Name,Value: f.TextValue,}- }+ })s.Rows[i] = ExportCSVRow{// fill struct@@ -276,11 +271,7 @@ func (s *IOSheet) ReadItems(ctx context.Context, items []repo.ItemOut, gid uuid.}// Extract and sort additional headers for deterministic output- customHeaders := make([]string, 0, len(extraHeaders))-- for k := range extraHeaders {- customHeaders = append(customHeaders, k)- }+ customHeaders := lo.Keys(extraHeaders)sort.Strings(customHeaders)diff --git a/backend/internal/core/services/reporting/value_parsers.go b/backend/internal/core/services/reporting/value_parsers.goindex 7410396e..6bb8a13c 100644--- a/backend/internal/core/services/reporting/value_parsers.go+++ b/backend/internal/core/services/reporting/value_parsers.go@@ -3,20 +3,20 @@ package reportingimport ("strconv""strings"++ "github.com/samber/lo")func parseSeparatedString(s string, sep string) ([]string, error) {list := strings.Split(s, sep)- csf := make([]string, 0, len(list))- for _, s := range list {- trimmed := strings.TrimSpace(s)- if trimmed != "" {- csf = append(csf, trimmed)- }- }+ trimmed := lo.Map(list, func(s string, _ int) string {+ return strings.TrimSpace(s)+ })- return csf, nil+ return lo.Filter(trimmed, func(s string, _ int) bool {+ return s != ""+ }), nil}func parseFloat(s string) float64 {diff --git a/backend/internal/core/services/service_background.go b/backend/internal/core/services/service_background.goindex b3c65154..aa31a085 100644--- a/backend/internal/core/services/service_background.go+++ b/backend/internal/core/services/service_background.go@@ -11,6 +11,7 @@ import ("github.com/containrrr/shoutrrr""github.com/google/uuid""github.com/rs/zerolog/log"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/data/repo""github.com/sysadminsmedia/homebox/backend/internal/data/types")@@ -54,10 +55,9 @@ func (svc *BackgroundService) SendNotifiersToday(ctx context.Context) error {return err}- urls := make([]string, len(notifiers))- for i := range notifiers {- urls[i] = notifiers[i].URL- }+ urls := lo.Map(notifiers, func(n repo.NotifierOut, _ int) string {+ return n.URL+ })bldr := strings.Builder{}diff --git a/backend/internal/core/services/service_items.go b/backend/internal/core/services/service_items.goindex 251a0e59..bad49264 100644--- a/backend/internal/core/services/service_items.go+++ b/backend/internal/core/services/service_items.go@@ -8,6 +8,7 @@ import ("strings""github.com/google/uuid"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting""github.com/sysadminsmedia/homebox/backend/internal/data/repo")@@ -111,16 +112,16 @@ func (svc *ItemService) CsvImport(ctx context.Context, gid uuid.UUID, data io.Re// ========================================// Tags- tagMap := make(map[string]uuid.UUID)+ var tagMap map[string]uuid.UUID{tags, err := svc.repo.Tags.GetAll(ctx, gid)if err != nil {return 0, err}- for _, tag := range tags {- tagMap[tag.Name] = tag.ID- }+ tagMap = lo.SliceToMap(tags, func(tag repo.TagSummary) (string, uuid.UUID) {+ return tag.Name, tag.ID+ })}// ========================================@@ -280,14 +281,13 @@ func (svc *ItemService) CsvImport(ctx context.Context, gid uuid.UUID, data io.Repanic("item ID is nil on import - this should never happen")}- fields := make([]repo.ItemField, len(row.Fields))- for i := range row.Fields {- fields[i] = repo.ItemField{- Name: row.Fields[i].Name,+ fields := lo.Map(row.Fields, func(f reporting.ExportItemFields, _ int) repo.ItemField {+ return repo.ItemField{+ Name: f.Name,Type: "text",- TextValue: row.Fields[i].Value,+ TextValue: f.Value,}- }+ })updateItem := repo.ItemUpdate{ID: item.ID,diff --git a/backend/internal/data/repo/automappers.go b/backend/internal/data/repo/automappers.goindex 279164bd..e31ed4c7 100644--- a/backend/internal/data/repo/automappers.go+++ b/backend/internal/data/repo/automappers.go@@ -1,5 +1,7 @@package repo+import "github.com/samber/lo"+type MapFunc[T any, U any] func(T) Ufunc (a MapFunc[T, U]) Map(v T) U {@@ -7,11 +9,9 @@ func (a MapFunc[T, U]) Map(v T) U {}func (a MapFunc[T, U]) MapEach(v []T) []U {- result := make([]U, len(v))- for i, item := range v {- result[i] = a(item)- }- return result+ return lo.Map(v, func(item T, _ int) U {+ return a(item)+ })}func (a MapFunc[T, U]) MapErr(v T, err error) (U, error) {diff --git a/backend/internal/data/repo/id_set.go b/backend/internal/data/repo/id_set.goindex 233bd15d..de02a767 100644--- a/backend/internal/data/repo/id_set.go+++ b/backend/internal/data/repo/id_set.go@@ -2,6 +2,7 @@ package repoimport ("github.com/google/uuid"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/pkgs/set")@@ -12,10 +13,9 @@ type HasID interface {}func newIDSet[T HasID](entities []T) set.Set[uuid.UUID] {- uuids := make([]uuid.UUID, 0, len(entities))- for _, e := range entities {- uuids = append(uuids, e.GetID())- }+ uuids := lo.Map(entities, func(e T, _ int) uuid.UUID {+ return e.GetID()+ })return set.New(uuids...)}diff --git a/backend/internal/data/repo/map_helpers.go b/backend/internal/data/repo/map_helpers.goindex 9404cb0d..da568dd0 100644--- a/backend/internal/data/repo/map_helpers.go+++ b/backend/internal/data/repo/map_helpers.go@@ -1,5 +1,7 @@package repo+import "github.com/samber/lo"+// mapTErrFunc is a factory function that returns a mapper function that// wraps the given mapper function but first will check for an error and// return the error if present.@@ -18,12 +20,9 @@ func mapTErrFunc[T any, Y any](fn func(T) Y) func(T, error) (Y, error) {func mapTEachFunc[T any, Y any](fn func(T) Y) func([]T) []Y {return func(items []T) []Y {- result := make([]Y, len(items))- for i, item := range items {- result[i] = fn(item)- }-- return result+ return lo.Map(items, func(item T, _ int) Y {+ return fn(item)+ })}}@@ -33,19 +32,14 @@ func mapTEachErrFunc[T any, Y any](fn func(T) Y) func([]T, error) ([]Y, error) {return nil, err}- result := make([]Y, len(items))- for i, item := range items {- result[i] = fn(item)- }-- return result, nil+ return lo.Map(items, func(item T, _ int) Y {+ return fn(item)+ }), nil}}func mapEach[T any, U any](items []T, fn func(T) U) []U {- result := make([]U, len(items))- for i, item := range items {- result[i] = fn(item)- }- return result+ return lo.Map(items, func(item T, _ int) U {+ return fn(item)+ })}diff --git a/backend/internal/data/repo/pagination.go b/backend/internal/data/repo/pagination.goindex 2a357331..0ed9784e 100644--- a/backend/internal/data/repo/pagination.go+++ b/backend/internal/data/repo/pagination.go@@ -1,5 +1,7 @@package repo+import "github.com/samber/lo"+type PaginationResult[T any] struct {Page int `json:"page"`PageSize int `json:"pageSize"`@@ -9,9 +11,5 @@ type PaginationResult[T any] struct {func calculateOffset(page, pageSize int) int {offset := (page - 1) * pageSize- if offset < 0 {- return 0- } else {- return offset- }+ return lo.Ternary(offset < 0, 0, offset)}diff --git a/backend/internal/data/repo/query_helpers.go b/backend/internal/data/repo/query_helpers.goindex 2205d81f..e7430aa6 100644--- a/backend/internal/data/repo/query_helpers.go+++ b/backend/internal/data/repo/query_helpers.go@@ -1,6 +1,10 @@package repo-import "time"+import (+ "time"++ "github.com/samber/lo"+)func sqliteDateFormat(t time.Time) string {return t.Format("2006-01-02 15:04:05")@@ -11,8 +15,5 @@ func sqliteDateFormat(t time.Time) string {// This is used for nullable or potentially nullable fields (or aggregates) in the database when running// queries. If the field is null, the pointer will be nil, so we return the default value instead.func orDefault[T any](v *T, def T) T {- if v == nil {- return def- }- return *v+ return lo.FromPtrOr(v, def)}diff --git a/backend/internal/data/repo/repo_group.go b/backend/internal/data/repo/repo_group.goindex 4a1ff642..6b533af6 100644--- a/backend/internal/data/repo/repo_group.go+++ b/backend/internal/data/repo/repo_group.go@@ -9,13 +9,14 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid""github.com/rs/zerolog/log"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/data/ent""github.com/sysadminsmedia/homebox/backend/internal/data/ent/group""github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken""github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag""github.com/sysadminsmedia/homebox/backend/internal/data/ent/location""github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag""github.com/sysadminsmedia/homebox/backend/internal/data/ent/user")@@ -84,7 +85,7 @@ type (TotalUsers int `json:"totalUsers"`TotalItems int `json:"totalItems"`TotalLocations int `json:"totalLocations"`- TotalTags int `json:"totalTags"`+ TotalTags int `json:"totalTags"`TotalItemPrice float64 `json:"totalItemPrice"`TotalWithWarranty int `json:"totalWithWarranty"`}@@ -192,12 +193,14 @@ func (r *GroupRepository) StatsPurchasePrice(ctx context.Context, gid uuid.UUID,stats.PriceAtStart = orDefault(maybeStart, 0)stats.PriceAtEnd = orDefault(maybeEnd, 0)- var v []struct {+ type itemPriceEntry struct {Name string `json:"name"`CreatedAt time.Time `json:"created_at"`PurchasePrice float64 `json:"purchase_price"`}+ var v []itemPriceEntry+// Get Created Date and Price of all items between start and enderr = r.db.Item.Query().Where(@@ -217,14 +220,12 @@ func (r *GroupRepository) StatsPurchasePrice(ctx context.Context, gid uuid.UUID,return nil, err}- stats.Entries = make([]ValueOverTimeEntry, len(v))-- for i, vv := range v {- stats.Entries[i] = ValueOverTimeEntry{+ stats.Entries = lo.Map(v, func(vv itemPriceEntry, _ int) ValueOverTimeEntry {+ return ValueOverTimeEntry{Date: vv.CreatedAt,Value: vv.PurchasePrice,}- }+ })return &stats, nil}diff --git a/backend/internal/data/repo/repo_item_attachments.go b/backend/internal/data/repo/repo_item_attachments.goindex 3ca5f72b..b8dd6466 100644--- a/backend/internal/data/repo/repo_item_attachments.go+++ b/backend/internal/data/repo/repo_item_attachments.go@@ -757,20 +757,20 @@ func (r *AttachmentRepo) UploadFile(ctx context.Context, itemGroup *ent.Group, d// Use a buffer to store content for blake3 key derivation and storage// While buffering, we compute MD5 and blake3 hashes in parallel for efficiencybuf := new(bytes.Buffer)-+// Create hash writersblake3Hasher := blake3.New()md5Hasher := md5.New()-+// Use MultiWriter to write to buffer and both hashers simultaneouslymultiWriter := io.MultiWriter(buf, blake3Hasher, md5Hasher)-+_, err := io.Copy(multiWriter, doc.Content)if err != nil {log.Err(err).Msg("failed to read file content")return UploadResult{}, err}-+// Now the buffer contains all the data, and streaming hashes are computedcontentBytes := buf.Bytes()@@ -790,7 +790,7 @@ func (r *AttachmentRepo) UploadFile(ctx context.Context, itemGroup *ent.Group, dlog.Err(err).Msg("failed to close bucket")}}(bucket)-+contentType := http.DetectContentType(contentBytes[:min(512, len(contentBytes))])options := &blob.WriterOptions{ContentType: contentType,diff --git a/backend/internal/data/repo/repo_item_templates.go b/backend/internal/data/repo/repo_item_templates.goindex 6eae7ca8..8fe4cbaa 100644--- a/backend/internal/data/repo/repo_item_templates.go+++ b/backend/internal/data/repo/repo_item_templates.go@@ -6,6 +6,7 @@ import ("github.com/google/uuid""github.com/rs/zerolog/log"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus""github.com/sysadminsmedia/homebox/backend/internal/data/ent""github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"@@ -54,7 +55,7 @@ type (// Default location and tagsDefaultLocationID uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"`- DefaultTagIDs *[]uuid.UUID `json:"defaultTagIds,omitempty" extensions:"x-nullable"`+ DefaultTagIDs *[]uuid.UUID `json:"defaultTagIds,omitempty" extensions:"x-nullable"`// Metadata flagsIncludeWarrantyFields bool `json:"includeWarrantyFields"`@@ -83,7 +84,7 @@ type (// Default location and tagsDefaultLocationID uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"`- DefaultTagIDs *[]uuid.UUID `json:"defaultTagIds,omitempty" extensions:"x-nullable"`+ DefaultTagIDs *[]uuid.UUID `json:"defaultTagIds,omitempty" extensions:"x-nullable"`// Metadata flagsIncludeWarrantyFields bool `json:"includeWarrantyFields"`@@ -122,7 +123,7 @@ type (// Default location and tagsDefaultLocation *TemplateLocationSummary `json:"defaultLocation"`- DefaultTags []TemplateTagSummary `json:"defaultTags"`+ DefaultTags []TemplateTagSummary `json:"defaultTags"`// Metadata flagsIncludeWarrantyFields bool `json:"includeWarrantyFields"`@@ -145,11 +146,9 @@ func mapTemplateField(field *ent.TemplateField) TemplateField {}func mapTemplateFieldSlice(fields []*ent.TemplateField) []TemplateField {- result := make([]TemplateField, len(fields))- for i, field := range fields {- result[i] = mapTemplateField(field)- }- return result+ return lo.Map(fields, func(field *ent.TemplateField, _ int) TemplateField {+ return mapTemplateField(field)+ })}func mapTemplateSummary(template *ent.ItemTemplate) ItemTemplateSummary {@@ -184,12 +183,12 @@ func (r *ItemTemplatesRepository) mapTemplateOut(ctx context.Context, template *Where(tag.IDIn(template.DefaultTagIds...)).All(ctx)if err == nil {- for _, l := range tagEntities {- tags = append(tags, TemplateTagSummary{+ tags = lo.Map(tagEntities, func(l *ent.Tag, _ int) TemplateTagSummary {+ return TemplateTagSummary{ID: l.ID,Name: l.Name,- })- }+ }+ })}}@@ -234,10 +233,9 @@ func (r *ItemTemplatesRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]return nil, err}- result := make([]ItemTemplateSummary, len(templates))- for i, template := range templates {- result[i] = mapTemplateSummary(template)- }+ result := lo.Map(templates, func(template *ent.ItemTemplate, _ int) ItemTemplateSummary {+ return mapTemplateSummary(template)+ })return result, nil}@@ -372,12 +370,6 @@ func (r *ItemTemplatesRepository) Update(ctx context.Context, gid uuid.UUID, datreturn ItemTemplateOut{}, err}- // Create a map of existing field IDs for quick lookup- existingFieldMap := make(map[uuid.UUID]bool)- for _, field := range existingFields {- existingFieldMap[field.ID] = true- }-// Track which fields are being updatedupdatedFieldIDs := make(map[uuid.UUID]bool)diff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.goindex dc529ffd..178e481d 100644--- a/backend/internal/data/repo/repo_items.go+++ b/backend/internal/data/repo/repo_items.go@@ -7,16 +7,17 @@ import ("github.com/google/uuid""github.com/rs/zerolog/log"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus""github.com/sysadminsmedia/homebox/backend/internal/data/ent""github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment""github.com/sysadminsmedia/homebox/backend/internal/data/ent/group""github.com/sysadminsmedia/homebox/backend/internal/data/ent/item""github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag""github.com/sysadminsmedia/homebox/backend/internal/data/ent/location""github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry""github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag""github.com/sysadminsmedia/homebox/backend/internal/data/types")@@ -125,7 +126,7 @@ type (Quantity *int `json:"quantity,omitempty" extensions:"x-nullable,x-omitempty"`ImportRef *string `json:"-,omitempty" extensions:"x-nullable,x-omitempty"`LocationID uuid.UUID `json:"locationId" extensions:"x-nullable,x-omitempty"`- TagIDs []uuid.UUID `json:"tagIds" extensions:"x-nullable,x-omitempty"`+ TagIDs []uuid.UUID `json:"tagIds" extensions:"x-nullable,x-omitempty"`}ItemSummary struct {@@ -196,27 +197,17 @@ func mapItemSummary(item *ent.Item) ItemSummary {location = &loc}- tags := make([]TagSummary, len(item.Edges.Tag))- if item.Edges.Tag != nil {- tags = mapEach(item.Edges.Tag, mapTagSummary)- }+ tags := lo.Ternary(item.Edges.Tag != nil, mapEach(item.Edges.Tag, mapTagSummary), []TagSummary{})var imageID *uuid.UUIDvar thumbnailID *uuid.UUIDif item.Edges.Attachments != nil {- for _, a := range item.Edges.Attachments {- if a.Primary && a.Type == attachment.TypePhoto {- imageID = &a.ID- if a.Edges.Thumbnail != nil {- if a.Edges.Thumbnail.ID != uuid.Nil {- thumbnailID = &a.Edges.Thumbnail.ID- } else {- thumbnailID = nil- }- } else {- thumbnailID = nil- }- break+ if a, ok := lo.Find(item.Edges.Attachments, func(a *ent.Attachment) bool {+ return a.Primary && a.Type == attachment.TypePhoto+ }); ok {+ imageID = &a.ID+ if a.Edges.Thumbnail != nil && a.Edges.Thumbnail.ID != uuid.Nil {+ thumbnailID = &a.Edges.Thumbnail.ID}}}@@ -250,9 +241,8 @@ var ()func mapFields(fields []*ent.ItemField) []ItemField {- result := make([]ItemField, len(fields))- for i, f := range fields {- result[i] = ItemField{+ return lo.Map(fields, func(f *ent.ItemField, _ int) ItemField {+ return ItemField{ID: f.ID,Type: f.Type.String(),Name: f.Name,@@ -261,8 +251,7 @@ func mapFields(fields []*ent.ItemField) []ItemField {BooleanValue: f.BooleanValue,// TimeValue: f.TimeValue,}- }- return result+ })}func mapItemOut(item *ent.Item) ItemOut {@@ -418,17 +407,16 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Itevar andPredicates []predicate.Item{if len(q.TagIDs) > 0 {- tagPredicates := make([]predicate.Item, 0, len(q.TagIDs))- for _, l := range q.TagIDs {- if !q.NegateTags {- tagPredicates = append(tagPredicates, item.HasTagWith(tag.ID(l)))- } else {- tagPredicates = append(tagPredicates, item.Not(item.HasTagWith(tag.ID(l))))- }- }+ var tagPredicates []predicate.Itemif !q.NegateTags {+ tagPredicates = lo.Map(q.TagIDs, func(l uuid.UUID, _ int) predicate.Item {+ return item.HasTagWith(tag.ID(l))+ })andPredicates = append(andPredicates, item.Or(tagPredicates...))} else {+ tagPredicates = lo.Map(q.TagIDs, func(l uuid.UUID, _ int) predicate.Item {+ return item.Not(item.HasTagWith(tag.ID(l)))+ })andPredicates = append(andPredicates, item.And(tagPredicates...))}}@@ -455,24 +443,22 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite}if len(q.LocationIDs) > 0 {- locationPredicates := make([]predicate.Item, 0, len(q.LocationIDs))- for _, l := range q.LocationIDs {- locationPredicates = append(locationPredicates, item.HasLocationWith(location.ID(l)))- }+ locationPredicates := lo.Map(q.LocationIDs, func(l uuid.UUID, _ int) predicate.Item {+ return item.HasLocationWith(location.ID(l))+ })andPredicates = append(andPredicates, item.Or(locationPredicates...))}if len(q.Fields) > 0 {- fieldPredicates := make([]predicate.Item, 0, len(q.Fields))- for _, f := range q.Fields {- fieldPredicates = append(fieldPredicates, item.HasFieldsWith(+ fieldPredicates := lo.Map(q.Fields, func(f FieldQuery, _ int) predicate.Item {+ return item.HasFieldsWith(itemfield.And(itemfield.Name(f.Name),itemfield.TextValue(f.Value),),- ))- }+ )+ })andPredicates = append(andPredicates, item.Or(fieldPredicates...))}@@ -1177,10 +1163,9 @@ func (e *ItemsRepository) GetAllCustomFieldValues(ctx context.Context, gid uuid.return nil, fmt.Errorf("failed to get field values: %w", err)}- valueStrings := make([]string, len(values))- for i, f := range values {- valueStrings[i] = f.Value- }+ valueStrings := lo.Map(values, func(f st, _ int) string {+ return f.Value+ })return valueStrings, nil}@@ -1204,10 +1189,9 @@ func (e *ItemsRepository) GetAllCustomFieldNames(ctx context.Context, gid uuid.Ureturn nil, fmt.Errorf("failed to get custom fields: %w", err)}- fieldNames := make([]string, len(fields))- for i, f := range fields {- fieldNames[i] = f.Name- }+ fieldNames := lo.Map(fields, func(f st, _ int) string {+ return f.Name+ })return fieldNames, nil}@@ -1404,10 +1388,9 @@ func (e *ItemsRepository) Duplicate(ctx context.Context, gid, id uuid.UUID, opti// Add tagsif len(originalItem.Tags) > 0 {- tagIDs := make([]uuid.UUID, len(originalItem.Tags))- for i, tag := range originalItem.Tags {- tagIDs[i] = tag.ID- }+ tagIDs := lo.Map(originalItem.Tags, func(tag TagSummary, _ int) uuid.UUID {+ return tag.ID+ })itemBuilder.AddTagIDs(tagIDs...)}diff --git a/backend/internal/data/repo/repo_items_test.go b/backend/internal/data/repo/repo_items_test.goindex a371938d..3c12c67a 100644--- a/backend/internal/data/repo/repo_items_test.go+++ b/backend/internal/data/repo/repo_items_test.go@@ -550,4 +550,3 @@ func TestItemsRepository_WipeInventory_OnlyItems(t *testing.T) {_ = tRepos.Tags.DeleteByGroup(context.Background(), tGroup.ID, tag.ID)_ = tRepos.Locations.delete(context.Background(), loc.ID)}-diff --git a/backend/internal/data/repo/repo_labels.go b/backend/internal/data/repo/repo_labels.goindex 43d19a30..450110cc 100644--- a/backend/internal/data/repo/repo_labels.go+++ b/backend/internal/data/repo/repo_labels.go@@ -8,8 +8,8 @@ import ("github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus""github.com/sysadminsmedia/homebox/backend/internal/data/ent""github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag""github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag")type TagRepository struct {diff --git a/backend/internal/data/repo/repo_locations.go b/backend/internal/data/repo/repo_locations.goindex 62c2bca6..a50ee651 100644--- a/backend/internal/data/repo/repo_locations.go+++ b/backend/internal/data/repo/repo_locations.go@@ -6,6 +6,8 @@ import ("time""github.com/google/uuid"+ "github.com/samber/lo"+ "github.com/samber/lo/mutable""github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus""github.com/sysadminsmedia/homebox/backend/internal/data/ent""github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"@@ -72,10 +74,9 @@ func mapLocationOut(location *ent.Location) LocationOut {parent = &p}- children := make([]LocationSummary, 0, len(location.Edges.Children))- for _, c := range location.Edges.Children {- children = append(children, mapLocationSummary(c))- }+ children := lo.Map(location.Edges.Children, func(c *ent.Location, _ int) LocationSummary {+ return mapLocationSummary(c)+ })return LocationOut{Parent: parent,@@ -315,10 +316,7 @@ func (r *LocationRepository) PathForLoc(ctx context.Context, gid, locID uuid.UUI}// Reverse the order of the locations so that the root is last- for i := len(locations)/2 - 1; i >= 0; i-- {- opp := len(locations) - 1 - i- locations[i], locations[opp] = locations[opp], locations[i]- }+ mutable.Reverse(locations)return locations, nil}@@ -449,10 +447,7 @@ func ConvertLocationsToTree(locations []FlatTreeItem) []TreeItem {}}- roots := make([]TreeItem, 0, len(rootIds))- for _, id := range rootIds {- roots = append(roots, *locationMap[id])- }-- return roots+ return lo.Map(rootIds, func(id uuid.UUID, _ int) TreeItem {+ return *locationMap[id]+ })}diff --git a/backend/internal/data/repo/repo_tokens.go b/backend/internal/data/repo/repo_tokens.goindex 355a9df1..9b4c2466 100644--- a/backend/internal/data/repo/repo_tokens.go+++ b/backend/internal/data/repo/repo_tokens.go@@ -5,6 +5,7 @@ import ("time""github.com/google/uuid"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/data/ent""github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles""github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens"@@ -62,12 +63,11 @@ func (r *TokenRepository) GetRoles(ctx context.Context, token string) (*set.Set[return nil, err}- roleSet := set.Make[string](len(roles))-- for _, role := range roles {- roleSet.Insert(role.Role.String())- }+ roleStrings := lo.Map(roles, func(role *ent.AuthRoles, _ int) string {+ return role.Role.String()+ })+ roleSet := set.New(roleStrings...)return &roleSet, nil}diff --git a/backend/internal/data/repo/repo_users.go b/backend/internal/data/repo/repo_users.goindex 814edeb8..b53b60e6 100644--- a/backend/internal/data/repo/repo_users.go+++ b/backend/internal/data/repo/repo_users.go@@ -4,6 +4,7 @@ import ("context""github.com/google/uuid"+ "github.com/samber/lo""github.com/sysadminsmedia/homebox/backend/internal/data/ent""github.com/sysadminsmedia/homebox/backend/internal/data/ent/group""github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"@@ -59,33 +60,19 @@ var ()func mapUserOut(user *ent.User) UserOut {- var passwordHash string- if user.Password != nil {- passwordHash = *user.Password- }-- groupIDs := make([]uuid.UUID, len(user.Edges.Groups))- for i, g := range user.Edges.Groups {- groupIDs[i] = g.ID- }-- // Get the default group ID, handling the optional pointer- defaultGroupID := uuid.Nil- if user.DefaultGroupID != nil {- defaultGroupID = *user.DefaultGroupID- }-return UserOut{ID: user.ID,Name: user.Name,Email: user.Email,IsSuperuser: user.IsSuperuser,- DefaultGroupID: defaultGroupID,- GroupIDs: groupIDs,- PasswordHash: passwordHash,- IsOwner: user.Role == "owner",- OidcIssuer: user.OidcIssuer,- OidcSubject: user.OidcSubject,+ DefaultGroupID: lo.FromPtrOr(user.DefaultGroupID, uuid.Nil),+ GroupIDs: lo.Map(user.Edges.Groups, func(g *ent.Group, _ int) uuid.UUID {+ return g.ID+ }),+ PasswordHash: lo.FromPtrOr(user.Password, ""),+ IsOwner: user.Role == "owner",+ OidcIssuer: user.OidcIssuer,+ OidcSubject: user.OidcSubject,}}diff --git a/backend/internal/data/repo/repo_wipe_integration_test.go b/backend/internal/data/repo/repo_wipe_integration_test.goindex 3db4e42f..8498d9a5 100644--- a/backend/internal/data/repo/repo_wipe_integration_test.go+++ b/backend/internal/data/repo/repo_wipe_integration_test.go@@ -46,7 +46,7 @@ func TestWipeInventory_Integration(t *testing.T) {Name: "Test Laptop",Description: "Work laptop",LocationID: loc1.ID,- TagIDs: []uuid.UUID{tag1.ID},+ TagIDs: []uuid.UUID{tag1.ID},})require.NoError(t, err)@@ -54,7 +54,7 @@ func TestWipeInventory_Integration(t *testing.T) {Name: "Test Drill",Description: "Power drill",LocationID: loc2.ID,- TagIDs: []uuid.UUID{tag2.ID},+ TagIDs: []uuid.UUID{tag2.ID},})require.NoError(t, err)@@ -62,7 +62,7 @@ func TestWipeInventory_Integration(t *testing.T) {Name: "Test Monitor",Description: "Computer monitor",LocationID: loc1.ID,- TagIDs: []uuid.UUID{tag1.ID},+ TagIDs: []uuid.UUID{tag1.ID},})require.NoError(t, err)@@ -153,7 +153,7 @@ func TestWipeInventory_SelectiveWipe(t *testing.T) {Name: "Test Computer",Description: "Desktop computer",LocationID: loc.ID,- TagIDs: []uuid.UUID{tag.ID},+ TagIDs: []uuid.UUID{tag.ID},})require.NoError(t, err)diff --git a/backend/internal/sys/config/conf.go b/backend/internal/sys/config/conf.goindex 0b34fdcf..09534159 100644--- a/backend/internal/sys/config/conf.go+++ b/backend/internal/sys/config/conf.go@@ -107,11 +107,11 @@ type AuthConfig struct {}type AuthRateLimit struct {- Enabled bool `yaml:"enabled" conf:"default:true"`- Window time.Duration `yaml:"window" conf:"default:1m"`- MaxAttempts int `yaml:"max_attempts" conf:"default:5"`- BaseBackoff time.Duration `yaml:"base_backoff" conf:"default:10s"`- MaxBackoff time.Duration `yaml:"max_backoff" conf:"default:5m"`+ Enabled bool `yaml:"enabled" conf:"default:true"`+ Window time.Duration `yaml:"window" conf:"default:1m"`+ MaxAttempts int `yaml:"max_attempts" conf:"default:5"`+ BaseBackoff time.Duration `yaml:"base_backoff" conf:"default:10s"`+ MaxBackoff time.Duration `yaml:"max_backoff" conf:"default:5m"`}// New parses the CLI/Config file and returns a Config struct. If the file argument is an empty string, the