diff --git a/Taskfile.yml b/Taskfile.yml index 48044ee..51a756b 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -29,12 +29,12 @@ tasks: - python3 ./scripts/process-types.py ./frontend/lib/api/types/data-contracts.ts sources: - "./backend/app/api/**/*" - - "./backend/internal/repo/**/*" + - "./backend/internal/data/**" - "./backend/internal/services/**/*" - "./scripts/process-types.py" generates: - "./frontend/lib/api/types/data-contracts.ts" - - "./backend/ent/schema" + - "./backend/internal/data/ent/schema" - "./backend/app/api/static/docs/swagger.json" - "./backend/app/api/static/docs/swagger.yaml" @@ -83,19 +83,19 @@ tasks: desc: Run Entgo.io Code Generation cmds: - | - cd backend && go generate ./... \ - --template=ent/schema/templates/has_id.tmpl + cd backend/internal/ && go generate ./... \ + --template=./data/ent/schema/templates/has_id.tmpl sources: - - "./backend/ent/schema/**/*" + - "./backend/internal/data/ent/schema/**/*" generates: - - "./backend/ent/" + - "./backend/internal/ent/" db:migration: desc: Runs the database diff engine to generate a SQL migration files deps: - db:generate cmds: - - cd backend && go run app/migrations/main.go {{ .CLI_ARGS }} + - cd backend && go run app/tools/migrations/main.go {{ .CLI_ARGS }} ui:watch: desc: Starts the vitest test runner in watch mode diff --git a/backend/app/api/app.go b/backend/app/api/app.go index 7f6b23f..854c4e5 100644 --- a/backend/app/api/app.go +++ b/backend/app/api/app.go @@ -3,10 +3,10 @@ package main import ( "time" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/internal/config" - "github.com/hay-kot/homebox/backend/internal/repo" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/repo" + "github.com/hay-kot/homebox/backend/internal/sys/config" "github.com/hay-kot/homebox/backend/pkgs/mailer" "github.com/hay-kot/homebox/backend/pkgs/server" ) diff --git a/backend/app/api/demo.go b/backend/app/api/demo.go index a98f03d..538655d 100644 --- a/backend/app/api/demo.go +++ b/backend/app/api/demo.go @@ -5,7 +5,7 @@ import ( "encoding/csv" "strings" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" "github.com/rs/zerolog/log" ) diff --git a/backend/app/api/handlers/v1/controller.go b/backend/app/api/handlers/v1/controller.go index 2c41bc1..4f7a73e 100644 --- a/backend/app/api/handlers/v1/controller.go +++ b/backend/app/api/handlers/v1/controller.go @@ -3,7 +3,8 @@ package v1 import ( "net/http" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/pkgs/server" ) @@ -26,6 +27,7 @@ func WithRegistration(allowRegistration bool) func(*V1Controller) { } type V1Controller struct { + repo *repo.AllRepos svc *services.AllServices maxUploadSize int64 isDemo bool @@ -57,8 +59,9 @@ func BaseUrlFunc(prefix string) func(s string) string { } } -func NewControllerV1(svc *services.AllServices, options ...func(*V1Controller)) *V1Controller { +func NewControllerV1(svc *services.AllServices, repos *repo.AllRepos, options ...func(*V1Controller)) *V1Controller { ctrl := &V1Controller{ + repo: repos, svc: svc, allowRegistration: true, } diff --git a/backend/app/api/handlers/v1/v1_ctrl_auth.go b/backend/app/api/handlers/v1/v1_ctrl_auth.go index 28ee0dc..b005a9d 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_auth.go +++ b/backend/app/api/handlers/v1/v1_ctrl_auth.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" "github.com/hay-kot/homebox/backend/internal/sys/validate" "github.com/hay-kot/homebox/backend/pkgs/server" "github.com/rs/zerolog/log" diff --git a/backend/app/api/handlers/v1/v1_ctrl_group.go b/backend/app/api/handlers/v1/v1_ctrl_group.go index a403877..a3e8992 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_group.go +++ b/backend/app/api/handlers/v1/v1_ctrl_group.go @@ -2,11 +2,10 @@ package v1 import ( "net/http" - "strings" "time" - "github.com/hay-kot/homebox/backend/internal/repo" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/internal/sys/validate" "github.com/hay-kot/homebox/backend/pkgs/server" "github.com/rs/zerolog/log" @@ -54,13 +53,12 @@ func (ctrl *V1Controller) handleGroupGeneral() server.HandlerFunc { switch r.Method { case http.MethodGet: - group, err := ctrl.svc.Group.Get(ctx) + group, err := ctrl.repo.Groups.GroupByID(ctx, ctx.GID) if err != nil { log.Err(err).Msg("failed to get group") return validate.NewRequestError(err, http.StatusInternalServerError) } - group.Currency = strings.ToUpper(group.Currency) // TODO: Hack to fix the currency enums being lower caseƍ return server.Respond(w, http.StatusOK, group) case http.MethodPut: @@ -74,7 +72,7 @@ func (ctrl *V1Controller) handleGroupGeneral() server.HandlerFunc { log.Err(err).Msg("failed to update group") return validate.NewRequestError(err, http.StatusInternalServerError) } - group.Currency = strings.ToUpper(group.Currency) // TODO: Hack to fix the currency enums being lower case + return server.Respond(w, http.StatusOK, group) } diff --git a/backend/app/api/handlers/v1/v1_ctrl_items.go b/backend/app/api/handlers/v1/v1_ctrl_items.go index 84591ca..b43333a 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_items.go +++ b/backend/app/api/handlers/v1/v1_ctrl_items.go @@ -7,8 +7,8 @@ import ( "strconv" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/internal/repo" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/internal/sys/validate" "github.com/hay-kot/homebox/backend/pkgs/server" "github.com/rs/zerolog/log" @@ -61,7 +61,7 @@ func (ctrl *V1Controller) HandleItemsGetAll() server.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) error { ctx := services.NewContext(r.Context()) - items, err := ctrl.svc.Items.Query(ctx, extractQuery(r)) + items, err := ctrl.repo.Items.QueryByGroup(ctx, ctx.GID, extractQuery(r)) if err != nil { log.Err(err).Msg("failed to get items") return validate.NewRequestError(err, http.StatusInternalServerError) @@ -87,7 +87,7 @@ func (ctrl *V1Controller) HandleItemsCreate() server.HandlerFunc { } user := services.UseUserCtx(r.Context()) - item, err := ctrl.svc.Items.Create(r.Context(), user.GroupID, createData) + item, err := ctrl.repo.Items.Create(r.Context(), user.GroupID, createData) if err != nil { log.Err(err).Msg("failed to create item") return validate.NewRequestError(err, http.StatusInternalServerError) @@ -144,14 +144,14 @@ func (ctrl *V1Controller) handleItemsGeneral() server.HandlerFunc { switch r.Method { case http.MethodGet: - items, err := ctrl.svc.Items.GetOne(r.Context(), ctx.GID, ID) + items, err := ctrl.repo.Items.GetOneByGroup(r.Context(), ctx.GID, ID) if err != nil { log.Err(err).Msg("failed to get item") return validate.NewRequestError(err, http.StatusInternalServerError) } return server.Respond(w, http.StatusOK, items) case http.MethodDelete: - err = ctrl.svc.Items.Delete(r.Context(), ctx.GID, ID) + err = ctrl.repo.Items.DeleteByGroup(r.Context(), ctx.GID, ID) if err != nil { log.Err(err).Msg("failed to delete item") return validate.NewRequestError(err, http.StatusInternalServerError) @@ -164,7 +164,7 @@ func (ctrl *V1Controller) handleItemsGeneral() server.HandlerFunc { return validate.NewRequestError(err, http.StatusInternalServerError) } body.ID = ID - result, err := ctrl.svc.Items.Update(r.Context(), ctx.GID, body) + result, err := ctrl.repo.Items.UpdateByGroup(r.Context(), ctx.GID, body) if err != nil { log.Err(err).Msg("failed to update item") return validate.NewRequestError(err, http.StatusInternalServerError) diff --git a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go index 5d90157..e776e9a 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go +++ b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go @@ -5,9 +5,9 @@ import ( "fmt" "net/http" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/internal/repo" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/internal/sys/validate" "github.com/hay-kot/homebox/backend/pkgs/server" "github.com/rs/zerolog/log" diff --git a/backend/app/api/handlers/v1/v1_ctrl_labels.go b/backend/app/api/handlers/v1/v1_ctrl_labels.go index f02a929..2551b46 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_labels.go +++ b/backend/app/api/handlers/v1/v1_ctrl_labels.go @@ -3,9 +3,9 @@ package v1 import ( "net/http" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/internal/repo" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/internal/sys/validate" "github.com/hay-kot/homebox/backend/pkgs/server" "github.com/rs/zerolog/log" @@ -21,7 +21,7 @@ import ( func (ctrl *V1Controller) HandleLabelsGetAll() server.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) error { user := services.UseUserCtx(r.Context()) - labels, err := ctrl.svc.Labels.GetAll(r.Context(), user.GroupID) + labels, err := ctrl.repo.Labels.GetAll(r.Context(), user.GroupID) if err != nil { log.Err(err).Msg("error getting labels") return validate.NewRequestError(err, http.StatusInternalServerError) @@ -47,7 +47,7 @@ func (ctrl *V1Controller) HandleLabelsCreate() server.HandlerFunc { } user := services.UseUserCtx(r.Context()) - label, err := ctrl.svc.Labels.Create(r.Context(), user.GroupID, createData) + label, err := ctrl.repo.Labels.Create(r.Context(), user.GroupID, createData) if err != nil { log.Err(err).Msg("error creating label") return validate.NewRequestError(err, http.StatusInternalServerError) @@ -103,7 +103,7 @@ func (ctrl *V1Controller) handleLabelsGeneral() server.HandlerFunc { switch r.Method { case http.MethodGet: - labels, err := ctrl.svc.Labels.Get(r.Context(), ctx.GID, ID) + labels, err := ctrl.repo.Labels.GetOneByGroup(r.Context(), ctx.GID, ID) if err != nil { if ent.IsNotFound(err) { log.Err(err). @@ -117,7 +117,7 @@ func (ctrl *V1Controller) handleLabelsGeneral() server.HandlerFunc { return server.Respond(w, http.StatusOK, labels) case http.MethodDelete: - err = ctrl.svc.Labels.Delete(r.Context(), ctx.GID, ID) + err = ctrl.repo.Labels.DeleteByGroup(ctx, ctx.GID, ID) if err != nil { log.Err(err).Msg("error deleting label") return validate.NewRequestError(err, http.StatusInternalServerError) @@ -127,14 +127,12 @@ func (ctrl *V1Controller) handleLabelsGeneral() server.HandlerFunc { case http.MethodPut: body := repo.LabelUpdate{} if err := server.Decode(r, &body); err != nil { - log.Err(err).Msg("error decoding label update data") return validate.NewRequestError(err, http.StatusInternalServerError) } body.ID = ID - result, err := ctrl.svc.Labels.Update(r.Context(), ctx.GID, body) + result, err := ctrl.repo.Labels.UpdateByGroup(ctx, ctx.GID, body) if err != nil { - log.Err(err).Msg("error updating label") return validate.NewRequestError(err, http.StatusInternalServerError) } return server.Respond(w, http.StatusOK, result) diff --git a/backend/app/api/handlers/v1/v1_ctrl_locations.go b/backend/app/api/handlers/v1/v1_ctrl_locations.go index 775cf76..5e85766 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_locations.go +++ b/backend/app/api/handlers/v1/v1_ctrl_locations.go @@ -3,9 +3,9 @@ package v1 import ( "net/http" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/internal/repo" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/internal/sys/validate" "github.com/hay-kot/homebox/backend/pkgs/server" "github.com/rs/zerolog/log" @@ -21,7 +21,7 @@ import ( func (ctrl *V1Controller) HandleLocationGetAll() server.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) error { user := services.UseUserCtx(r.Context()) - locations, err := ctrl.svc.Location.GetAll(r.Context(), user.GroupID) + locations, err := ctrl.repo.Locations.GetAll(r.Context(), user.GroupID) if err != nil { log.Err(err).Msg("failed to get locations") return validate.NewRequestError(err, http.StatusInternalServerError) @@ -48,7 +48,7 @@ func (ctrl *V1Controller) HandleLocationCreate() server.HandlerFunc { } user := services.UseUserCtx(r.Context()) - location, err := ctrl.svc.Location.Create(r.Context(), user.GroupID, createData) + location, err := ctrl.repo.Locations.Create(r.Context(), user.GroupID, createData) if err != nil { log.Err(err).Msg("failed to create location") return validate.NewRequestError(err, http.StatusInternalServerError) @@ -105,7 +105,7 @@ func (ctrl *V1Controller) handleLocationGeneral() server.HandlerFunc { switch r.Method { case http.MethodGet: - location, err := ctrl.svc.Location.GetOne(r.Context(), ctx.GID, ID) + location, err := ctrl.repo.Locations.GetOneByGroup(r.Context(), ctx.GID, ID) if err != nil { l := log.Err(err). Str("ID", ID.String()). @@ -129,14 +129,14 @@ func (ctrl *V1Controller) handleLocationGeneral() server.HandlerFunc { body.ID = ID - result, err := ctrl.svc.Location.Update(r.Context(), ctx.GID, body) + result, err := ctrl.repo.Locations.UpdateOneByGroup(r.Context(), ctx.GID, ID, body) if err != nil { log.Err(err).Msg("failed to update location") return validate.NewRequestError(err, http.StatusInternalServerError) } return server.Respond(w, http.StatusOK, result) case http.MethodDelete: - err = ctrl.svc.Location.Delete(r.Context(), ctx.GID, ID) + err = ctrl.repo.Locations.DeleteByGroup(r.Context(), ctx.GID, ID) if err != nil { log.Err(err).Msg("failed to delete location") return validate.NewRequestError(err, http.StatusInternalServerError) diff --git a/backend/app/api/handlers/v1/v1_ctrl_user.go b/backend/app/api/handlers/v1/v1_ctrl_user.go index b7bf5ee..565a723 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_user.go +++ b/backend/app/api/handlers/v1/v1_ctrl_user.go @@ -4,8 +4,8 @@ import ( "net/http" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/internal/repo" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/internal/sys/validate" "github.com/hay-kot/homebox/backend/pkgs/server" "github.com/rs/zerolog/log" diff --git a/backend/app/api/logger.go b/backend/app/api/logger.go index 86085a5..ddc574f 100644 --- a/backend/app/api/logger.go +++ b/backend/app/api/logger.go @@ -4,7 +4,7 @@ import ( "os" "strings" - "github.com/hay-kot/homebox/backend/internal/config" + "github.com/hay-kot/homebox/backend/internal/sys/config" "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) diff --git a/backend/app/api/main.go b/backend/app/api/main.go index e48ae04..c62d5df 100644 --- a/backend/app/api/main.go +++ b/backend/app/api/main.go @@ -10,11 +10,11 @@ import ( atlas "ariga.io/atlas/sql/migrate" "entgo.io/ent/dialect/sql/schema" "github.com/hay-kot/homebox/backend/app/api/static/docs" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/internal/config" - "github.com/hay-kot/homebox/backend/internal/migrations" - "github.com/hay-kot/homebox/backend/internal/repo" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/migrations" + "github.com/hay-kot/homebox/backend/internal/data/repo" + "github.com/hay-kot/homebox/backend/internal/sys/config" "github.com/hay-kot/homebox/backend/internal/web/mid" "github.com/hay-kot/homebox/backend/pkgs/server" _ "github.com/mattn/go-sqlite3" diff --git a/backend/app/api/middleware.go b/backend/app/api/middleware.go index 68bfde1..505ba40 100644 --- a/backend/app/api/middleware.go +++ b/backend/app/api/middleware.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "github.com/hay-kot/homebox/backend/internal/services" + "github.com/hay-kot/homebox/backend/internal/core/services" "github.com/hay-kot/homebox/backend/internal/sys/validate" "github.com/hay-kot/homebox/backend/pkgs/server" ) diff --git a/backend/app/api/routes.go b/backend/app/api/routes.go index 02a7f74..9074838 100644 --- a/backend/app/api/routes.go +++ b/backend/app/api/routes.go @@ -13,7 +13,7 @@ import ( "github.com/hay-kot/homebox/backend/app/api/handlers/debughandlers" v1 "github.com/hay-kot/homebox/backend/app/api/handlers/v1" _ "github.com/hay-kot/homebox/backend/app/api/static/docs" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/pkgs/server" httpSwagger "github.com/swaggo/http-swagger" // http-swagger middleware ) @@ -49,6 +49,7 @@ func (a *app) mountRoutes(repos *repo.AllRepos) { v1Ctrl := v1.NewControllerV1( a.services, + a.repos, v1.WithMaxUploadSize(a.conf.Web.MaxUploadSize), v1.WithRegistration(a.conf.AllowRegistration), v1.WithDemoStatus(a.conf.Demo), // Disable Password Change in Demo Mode diff --git a/backend/app/migrations/main.go b/backend/app/tools/migrations/main.go similarity index 90% rename from backend/app/migrations/main.go rename to backend/app/tools/migrations/main.go index bcbb0dd..a2f6624 100644 --- a/backend/app/migrations/main.go +++ b/backend/app/tools/migrations/main.go @@ -5,7 +5,7 @@ import ( "log" "os" - "github.com/hay-kot/homebox/backend/ent/migrate" + "github.com/hay-kot/homebox/backend/internal/data/ent/migrate" atlas "ariga.io/atlas/sql/migrate" _ "ariga.io/atlas/sql/sqlite" @@ -17,7 +17,7 @@ import ( func main() { ctx := context.Background() // Create a local migration directory able to understand Atlas migration file format for replay. - dir, err := atlas.NewLocalDir("internal/migrations/migrations") + dir, err := atlas.NewLocalDir("internal/data/migrations/migrations") if err != nil { log.Fatalf("failed creating atlas migration directory: %v", err) } diff --git a/backend/go.mod b/backend/go.mod index d9d7116..3127969 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -7,6 +7,7 @@ require ( entgo.io/ent v0.11.3 github.com/ardanlabs/conf/v2 v2.2.0 github.com/go-chi/chi/v5 v5.0.7 + github.com/go-playground/validator/v10 v10.11.1 github.com/google/uuid v1.3.0 github.com/mattn/go-sqlite3 v1.14.16 github.com/rs/zerolog v1.28.0 @@ -26,10 +27,12 @@ require ( github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/spec v0.20.7 // indirect github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-playground/locales v0.14.0 // indirect + github.com/go-playground/universal-translator v0.18.0 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/hashicorp/hcl/v2 v2.14.1 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/kr/pretty v0.3.0 // indirect + github.com/leodido/go-urn v1.2.1 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.16 // indirect diff --git a/backend/go.sum b/backend/go.sum index 3510f5d..a16fd64 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -31,6 +31,14 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -43,6 +51,7 @@ github.com/hashicorp/hcl/v2 v2.14.1/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0z github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -50,6 +59,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= @@ -61,25 +72,32 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= @@ -92,16 +110,20 @@ github.com/swaggo/swag v1.8.7 h1:2K9ivTD3teEO+2fXV6zrZKDqk5IuU2aJtBDo8U7omWU= github.com/swaggo/swag v1.8.7/go.mod h1:ezQVUUhly8dludpVk+/PuwJWvLLanB13ygV5Pr9enSk= github.com/zclconf/go-cty v1.11.0 h1:726SxLdi2SDnjY+BStqB9J1hNp4+2WlzyXLuimibIe0= github.com/zclconf/go-cty v1.11.0/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220923203811-8be639271d50 h1:vKyz8L3zkd+xrMeIaBsQ/MNVPVFSffdaU3ZyYlBGFnI= golang.org/x/net v0.0.0-20220923203811-8be639271d50/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 h1:h+EGohizhe9XlX18rfpa8k8RAc5XyaeamM+0VHRd4lc= @@ -117,11 +139,13 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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/internal/core/services/all.go b/backend/internal/core/services/all.go new file mode 100644 index 0000000..5147b8a --- /dev/null +++ b/backend/internal/core/services/all.go @@ -0,0 +1,24 @@ +package services + +import "github.com/hay-kot/homebox/backend/internal/data/repo" + +type AllServices struct { + User *UserService + Group *GroupService + Items *ItemService +} + +func New(repos *repo.AllRepos) *AllServices { + if repos == nil { + panic("repos cannot be nil") + } + + return &AllServices{ + User: &UserService{repos}, + Group: &GroupService{repos}, + Items: &ItemService{ + repo: repos, + at: attachmentTokens{}, + }, + } +} diff --git a/backend/internal/services/contexts.go b/backend/internal/core/services/contexts.go similarity index 96% rename from backend/internal/services/contexts.go rename to backend/internal/core/services/contexts.go index 72ef84f..d82dcfa 100644 --- a/backend/internal/services/contexts.go +++ b/backend/internal/core/services/contexts.go @@ -4,7 +4,7 @@ import ( "context" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/repo" ) type contextKeys struct { diff --git a/backend/internal/services/contexts_test.go b/backend/internal/core/services/contexts_test.go similarity index 92% rename from backend/internal/services/contexts_test.go rename to backend/internal/core/services/contexts_test.go index 2462258..8b7dfa4 100644 --- a/backend/internal/services/contexts_test.go +++ b/backend/internal/core/services/contexts_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/stretchr/testify/assert" ) diff --git a/backend/internal/services/main_test.go b/backend/internal/core/services/main_test.go similarity index 92% rename from backend/internal/services/main_test.go rename to backend/internal/core/services/main_test.go index 37cb556..e1f7282 100644 --- a/backend/internal/services/main_test.go +++ b/backend/internal/core/services/main_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/pkgs/faker" _ "github.com/mattn/go-sqlite3" ) diff --git a/backend/internal/services/service_group.go b/backend/internal/core/services/service_group.go similarity index 77% rename from backend/internal/services/service_group.go rename to backend/internal/core/services/service_group.go index 4859f85..2ca3f86 100644 --- a/backend/internal/services/service_group.go +++ b/backend/internal/core/services/service_group.go @@ -2,10 +2,9 @@ package services import ( "errors" - "strings" "time" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/pkgs/hasher" ) @@ -13,10 +12,6 @@ type GroupService struct { repos *repo.AllRepos } -func (svc *GroupService) Get(ctx Context) (repo.Group, error) { - return svc.repos.Groups.GroupByID(ctx.Context, ctx.GID) -} - func (svc *GroupService) UpdateGroup(ctx Context, data repo.GroupUpdate) (repo.Group, error) { if data.Name == "" { data.Name = ctx.User.GroupName @@ -26,8 +21,6 @@ func (svc *GroupService) UpdateGroup(ctx Context, data repo.GroupUpdate) (repo.G return repo.Group{}, errors.New("currency cannot be empty") } - data.Currency = strings.ToLower(data.Currency) - return svc.repos.Groups.GroupUpdate(ctx.Context, ctx.GID, data) } diff --git a/backend/internal/services/service_items.go b/backend/internal/core/services/service_items.go similarity index 80% rename from backend/internal/services/service_items.go rename to backend/internal/core/services/service_items.go index 7650a97..5c02724 100644 --- a/backend/internal/services/service_items.go +++ b/backend/internal/core/services/service_items.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/rs/zerolog/log" ) @@ -23,30 +23,6 @@ type ItemService struct { at attachmentTokens } -func (svc *ItemService) GetOne(ctx context.Context, gid uuid.UUID, id uuid.UUID) (repo.ItemOut, error) { - return svc.repo.Items.GetOneByGroup(ctx, gid, id) -} - -func (svc *ItemService) Query(ctx Context, q repo.ItemQuery) (repo.PaginationResult[repo.ItemSummary], error) { - return svc.repo.Items.QueryByGroup(ctx, ctx.GID, q) -} - -func (svc *ItemService) GetAll(ctx context.Context, gid uuid.UUID) ([]repo.ItemSummary, error) { - return svc.repo.Items.GetAll(ctx, gid) -} - -func (svc *ItemService) Create(ctx context.Context, gid uuid.UUID, data repo.ItemCreate) (repo.ItemOut, error) { - return svc.repo.Items.Create(ctx, gid, data) -} - -func (svc *ItemService) Delete(ctx context.Context, gid uuid.UUID, id uuid.UUID) error { - return svc.repo.Items.DeleteByGroup(ctx, gid, id) -} - -func (svc *ItemService) Update(ctx context.Context, gid uuid.UUID, data repo.ItemUpdate) (repo.ItemOut, error) { - return svc.repo.Items.UpdateByGroup(ctx, gid, data) -} - func (svc *ItemService) CsvImport(ctx context.Context, gid uuid.UUID, data [][]string) (int, error) { loaded := []csvRow{} diff --git a/backend/internal/services/service_items_attachments.go b/backend/internal/core/services/service_items_attachments.go similarity index 92% rename from backend/internal/services/service_items_attachments.go rename to backend/internal/core/services/service_items_attachments.go index 0f2afde..b5df5f8 100644 --- a/backend/internal/services/service_items_attachments.go +++ b/backend/internal/core/services/service_items_attachments.go @@ -7,9 +7,9 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/pkgs/hasher" "github.com/rs/zerolog/log" ) @@ -91,7 +91,7 @@ func (svc *ItemService) AttachmentUpdate(ctx Context, itemId uuid.UUID, data *re return repo.ItemOut{}, err } - return svc.GetOne(ctx, ctx.GID, itemId) + return svc.repo.Items.GetOneByGroup(ctx, ctx.GID, itemId) } // AttachmentAdd adds an attachment to an item by creating an entry in the Documents table and linking it to the Attachment @@ -118,7 +118,7 @@ func (svc *ItemService) AttachmentAdd(ctx Context, itemId uuid.UUID, filename st return repo.ItemOut{}, err } - return svc.GetOne(ctx, ctx.GID, itemId) + return svc.repo.Items.GetOneByGroup(ctx, ctx.GID, itemId) } func (svc *ItemService) AttachmentDelete(ctx context.Context, gid, itemId, attachmentId uuid.UUID) error { diff --git a/backend/internal/services/service_items_attachments_test.go b/backend/internal/core/services/service_items_attachments_test.go similarity index 84% rename from backend/internal/services/service_items_attachments_test.go rename to backend/internal/core/services/service_items_attachments_test.go index c3ab032..14e822e 100644 --- a/backend/internal/services/service_items_attachments_test.go +++ b/backend/internal/core/services/service_items_attachments_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/stretchr/testify/assert" ) @@ -19,7 +19,7 @@ func TestItemService_AddAttachment(t *testing.T) { filepath: temp, } - loc, err := tSvc.Location.Create(context.Background(), tGroup.ID, repo.LocationCreate{ + loc, err := tRepos.Locations.Create(context.Background(), tGroup.ID, repo.LocationCreate{ Description: "test", Name: "test", }) @@ -32,7 +32,7 @@ func TestItemService_AddAttachment(t *testing.T) { LocationID: loc.ID, } - itm, err := svc.Create(context.Background(), tGroup.ID, itmC) + itm, err := svc.repo.Items.Create(context.Background(), tGroup.ID, itmC) assert.NoError(t, err) assert.NotNil(t, itm) t.Cleanup(func() { diff --git a/backend/internal/services/service_items_csv.go b/backend/internal/core/services/service_items_csv.go similarity index 97% rename from backend/internal/services/service_items_csv.go rename to backend/internal/core/services/service_items_csv.go index c559386..c9748f7 100644 --- a/backend/internal/services/service_items_csv.go +++ b/backend/internal/core/services/service_items_csv.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/repo" ) var ErrInvalidCsv = errors.New("invalid csv") diff --git a/backend/internal/services/service_items_csv_test.go b/backend/internal/core/services/service_items_csv_test.go similarity index 100% rename from backend/internal/services/service_items_csv_test.go rename to backend/internal/core/services/service_items_csv_test.go diff --git a/backend/internal/services/service_items_test.go b/backend/internal/core/services/service_items_test.go similarity index 83% rename from backend/internal/services/service_items_test.go rename to backend/internal/core/services/service_items_test.go index 018dbc1..1daa0b7 100644 --- a/backend/internal/services/service_items_test.go +++ b/backend/internal/core/services/service_items_test.go @@ -22,7 +22,7 @@ func TestItemService_CsvImport(t *testing.T) { assert.Equal(t, 0, count) assert.NoError(t, err) - items, err := svc.GetAll(context.Background(), tGroup.ID) + items, err := svc.repo.Items.GetAll(context.Background(), tGroup.ID) assert.NoError(t, err) t.Cleanup(func() { for _, item := range items { @@ -38,22 +38,14 @@ func TestItemService_CsvImport(t *testing.T) { dataCsv = append(dataCsv, newCsvRow(item)) } - locationService := &LocationService{ - repos: tRepos, - } - - LabelService := &LabelService{ - repos: tRepos, - } - - allLocation, err := locationService.GetAll(context.Background(), tGroup.ID) + allLocation, err := tRepos.Locations.GetAll(context.Background(), tGroup.ID) assert.NoError(t, err) locNames := []string{} for _, loc := range allLocation { locNames = append(locNames, loc.Name) } - allLabels, err := LabelService.GetAll(context.Background(), tGroup.ID) + allLabels, err := tRepos.Labels.GetAll(context.Background(), tGroup.ID) assert.NoError(t, err) labelNames := []string{} for _, label := range allLabels { diff --git a/backend/internal/services/service_user.go b/backend/internal/core/services/service_user.go similarity index 99% rename from backend/internal/services/service_user.go rename to backend/internal/core/services/service_user.go index 3060ee7..e3d8f8a 100644 --- a/backend/internal/services/service_user.go +++ b/backend/internal/core/services/service_user.go @@ -6,7 +6,7 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/repo" "github.com/hay-kot/homebox/backend/pkgs/hasher" "github.com/rs/zerolog/log" ) diff --git a/backend/internal/services/service_user_defaults.go b/backend/internal/core/services/service_user_defaults.go similarity index 91% rename from backend/internal/services/service_user_defaults.go rename to backend/internal/core/services/service_user_defaults.go index 9882d5e..34344d1 100644 --- a/backend/internal/services/service_user_defaults.go +++ b/backend/internal/core/services/service_user_defaults.go @@ -1,7 +1,7 @@ package services import ( - "github.com/hay-kot/homebox/backend/internal/repo" + "github.com/hay-kot/homebox/backend/internal/data/repo" ) func defaultLocations() []repo.LocationCreate { diff --git a/backend/ent/attachment.go b/backend/internal/data/ent/attachment.go similarity index 97% rename from backend/ent/attachment.go rename to backend/internal/data/ent/attachment.go index e65f1e2..e5f738a 100644 --- a/backend/ent/attachment.go +++ b/backend/internal/data/ent/attachment.go @@ -9,9 +9,9 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" ) // Attachment is the model entity for the Attachment schema. diff --git a/backend/ent/attachment/attachment.go b/backend/internal/data/ent/attachment/attachment.go similarity index 100% rename from backend/ent/attachment/attachment.go rename to backend/internal/data/ent/attachment/attachment.go diff --git a/backend/ent/attachment/where.go b/backend/internal/data/ent/attachment/where.go similarity index 99% rename from backend/ent/attachment/where.go rename to backend/internal/data/ent/attachment/where.go index 28b806e..e2adb4f 100644 --- a/backend/ent/attachment/where.go +++ b/backend/internal/data/ent/attachment/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/attachment_create.go b/backend/internal/data/ent/attachment_create.go similarity index 98% rename from backend/ent/attachment_create.go rename to backend/internal/data/ent/attachment_create.go index 75d6cec..8725984 100644 --- a/backend/ent/attachment_create.go +++ b/backend/internal/data/ent/attachment_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" ) // AttachmentCreate is the builder for creating a Attachment entity. diff --git a/backend/ent/attachment_delete.go b/backend/internal/data/ent/attachment_delete.go similarity index 95% rename from backend/ent/attachment_delete.go rename to backend/internal/data/ent/attachment_delete.go index a1cda49..eeeca20 100644 --- a/backend/ent/attachment_delete.go +++ b/backend/internal/data/ent/attachment_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // AttachmentDelete is the builder for deleting a Attachment entity. diff --git a/backend/ent/attachment_query.go b/backend/internal/data/ent/attachment_query.go similarity index 98% rename from backend/ent/attachment_query.go rename to backend/internal/data/ent/attachment_query.go index 5554bfb..2262c0b 100644 --- a/backend/ent/attachment_query.go +++ b/backend/internal/data/ent/attachment_query.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // AttachmentQuery is the builder for querying Attachment entities. diff --git a/backend/ent/attachment_update.go b/backend/internal/data/ent/attachment_update.go similarity index 98% rename from backend/ent/attachment_update.go rename to backend/internal/data/ent/attachment_update.go index 1801c22..fbaf485 100644 --- a/backend/ent/attachment_update.go +++ b/backend/internal/data/ent/attachment_update.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // AttachmentUpdate is the builder for updating Attachment entities. diff --git a/backend/ent/authtokens.go b/backend/internal/data/ent/authtokens.go similarity index 97% rename from backend/ent/authtokens.go rename to backend/internal/data/ent/authtokens.go index 285412f..6e8e53d 100644 --- a/backend/ent/authtokens.go +++ b/backend/internal/data/ent/authtokens.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // AuthTokens is the model entity for the AuthTokens schema. diff --git a/backend/ent/authtokens/authtokens.go b/backend/internal/data/ent/authtokens/authtokens.go similarity index 100% rename from backend/ent/authtokens/authtokens.go rename to backend/internal/data/ent/authtokens/authtokens.go diff --git a/backend/ent/authtokens/where.go b/backend/internal/data/ent/authtokens/where.go similarity index 99% rename from backend/ent/authtokens/where.go rename to backend/internal/data/ent/authtokens/where.go index d54ebdd..5ef7df9 100644 --- a/backend/ent/authtokens/where.go +++ b/backend/internal/data/ent/authtokens/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/authtokens_create.go b/backend/internal/data/ent/authtokens_create.go similarity index 98% rename from backend/ent/authtokens_create.go rename to backend/internal/data/ent/authtokens_create.go index 491711a..e05e849 100644 --- a/backend/ent/authtokens_create.go +++ b/backend/internal/data/ent/authtokens_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // AuthTokensCreate is the builder for creating a AuthTokens entity. diff --git a/backend/ent/authtokens_delete.go b/backend/internal/data/ent/authtokens_delete.go similarity index 95% rename from backend/ent/authtokens_delete.go rename to backend/internal/data/ent/authtokens_delete.go index 7b86122..5041362 100644 --- a/backend/ent/authtokens_delete.go +++ b/backend/internal/data/ent/authtokens_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // AuthTokensDelete is the builder for deleting a AuthTokens entity. diff --git a/backend/ent/authtokens_query.go b/backend/internal/data/ent/authtokens_query.go similarity index 98% rename from backend/ent/authtokens_query.go rename to backend/internal/data/ent/authtokens_query.go index 672a368..77c13e2 100644 --- a/backend/ent/authtokens_query.go +++ b/backend/internal/data/ent/authtokens_query.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/predicate" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // AuthTokensQuery is the builder for querying AuthTokens entities. diff --git a/backend/ent/authtokens_update.go b/backend/internal/data/ent/authtokens_update.go similarity index 98% rename from backend/ent/authtokens_update.go rename to backend/internal/data/ent/authtokens_update.go index 11e06f2..7d7c541 100644 --- a/backend/ent/authtokens_update.go +++ b/backend/internal/data/ent/authtokens_update.go @@ -12,9 +12,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/predicate" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // AuthTokensUpdate is the builder for updating AuthTokens entities. diff --git a/backend/ent/client.go b/backend/internal/data/ent/client.go similarity index 98% rename from backend/ent/client.go rename to backend/internal/data/ent/client.go index a9a8168..8273e32 100644 --- a/backend/ent/client.go +++ b/backend/internal/data/ent/client.go @@ -9,19 +9,19 @@ import ( "log" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/migrate" + "github.com/hay-kot/homebox/backend/internal/data/ent/migrate" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" diff --git a/backend/ent/config.go b/backend/internal/data/ent/config.go similarity index 100% rename from backend/ent/config.go rename to backend/internal/data/ent/config.go diff --git a/backend/ent/context.go b/backend/internal/data/ent/context.go similarity index 100% rename from backend/ent/context.go rename to backend/internal/data/ent/context.go diff --git a/backend/ent/document.go b/backend/internal/data/ent/document.go similarity index 98% rename from backend/ent/document.go rename to backend/internal/data/ent/document.go index bfc552e..0c84d7d 100644 --- a/backend/ent/document.go +++ b/backend/internal/data/ent/document.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" ) // Document is the model entity for the Document schema. diff --git a/backend/ent/document/document.go b/backend/internal/data/ent/document/document.go similarity index 100% rename from backend/ent/document/document.go rename to backend/internal/data/ent/document/document.go diff --git a/backend/ent/document/where.go b/backend/internal/data/ent/document/where.go similarity index 99% rename from backend/ent/document/where.go rename to backend/internal/data/ent/document/where.go index 0cb7139..dc02fa4 100644 --- a/backend/ent/document/where.go +++ b/backend/internal/data/ent/document/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/document_create.go b/backend/internal/data/ent/document_create.go similarity index 97% rename from backend/ent/document_create.go rename to backend/internal/data/ent/document_create.go index 4411e16..b6577df 100644 --- a/backend/ent/document_create.go +++ b/backend/internal/data/ent/document_create.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" ) // DocumentCreate is the builder for creating a Document entity. diff --git a/backend/ent/document_delete.go b/backend/internal/data/ent/document_delete.go similarity index 95% rename from backend/ent/document_delete.go rename to backend/internal/data/ent/document_delete.go index 06ccaf1..6e21bef 100644 --- a/backend/ent/document_delete.go +++ b/backend/internal/data/ent/document_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // DocumentDelete is the builder for deleting a Document entity. diff --git a/backend/ent/document_query.go b/backend/internal/data/ent/document_query.go similarity index 98% rename from backend/ent/document_query.go rename to backend/internal/data/ent/document_query.go index fe439af..7505152 100644 --- a/backend/ent/document_query.go +++ b/backend/internal/data/ent/document_query.go @@ -12,11 +12,11 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // DocumentQuery is the builder for querying Document entities. diff --git a/backend/ent/document_update.go b/backend/internal/data/ent/document_update.go similarity index 98% rename from backend/ent/document_update.go rename to backend/internal/data/ent/document_update.go index fb1b971..c6dd9fe 100644 --- a/backend/ent/document_update.go +++ b/backend/internal/data/ent/document_update.go @@ -12,11 +12,11 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // DocumentUpdate is the builder for updating Document entities. diff --git a/backend/ent/documenttoken.go b/backend/internal/data/ent/documenttoken.go similarity index 97% rename from backend/ent/documenttoken.go rename to backend/internal/data/ent/documenttoken.go index f42a40f..c484a9e 100644 --- a/backend/ent/documenttoken.go +++ b/backend/internal/data/ent/documenttoken.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" ) // DocumentToken is the model entity for the DocumentToken schema. diff --git a/backend/ent/documenttoken/documenttoken.go b/backend/internal/data/ent/documenttoken/documenttoken.go similarity index 100% rename from backend/ent/documenttoken/documenttoken.go rename to backend/internal/data/ent/documenttoken/documenttoken.go diff --git a/backend/ent/documenttoken/where.go b/backend/internal/data/ent/documenttoken/where.go similarity index 99% rename from backend/ent/documenttoken/where.go rename to backend/internal/data/ent/documenttoken/where.go index 1d0949a..32dbb39 100644 --- a/backend/ent/documenttoken/where.go +++ b/backend/internal/data/ent/documenttoken/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/documenttoken_create.go b/backend/internal/data/ent/documenttoken_create.go similarity index 98% rename from backend/ent/documenttoken_create.go rename to backend/internal/data/ent/documenttoken_create.go index b4585d5..2b29079 100644 --- a/backend/ent/documenttoken_create.go +++ b/backend/internal/data/ent/documenttoken_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" ) // DocumentTokenCreate is the builder for creating a DocumentToken entity. diff --git a/backend/ent/documenttoken_delete.go b/backend/internal/data/ent/documenttoken_delete.go similarity index 95% rename from backend/ent/documenttoken_delete.go rename to backend/internal/data/ent/documenttoken_delete.go index fa9b7a1..722ec1b 100644 --- a/backend/ent/documenttoken_delete.go +++ b/backend/internal/data/ent/documenttoken_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // DocumentTokenDelete is the builder for deleting a DocumentToken entity. diff --git a/backend/ent/documenttoken_query.go b/backend/internal/data/ent/documenttoken_query.go similarity index 98% rename from backend/ent/documenttoken_query.go rename to backend/internal/data/ent/documenttoken_query.go index a8f264e..6c5386c 100644 --- a/backend/ent/documenttoken_query.go +++ b/backend/internal/data/ent/documenttoken_query.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // DocumentTokenQuery is the builder for querying DocumentToken entities. diff --git a/backend/ent/documenttoken_update.go b/backend/internal/data/ent/documenttoken_update.go similarity index 98% rename from backend/ent/documenttoken_update.go rename to backend/internal/data/ent/documenttoken_update.go index dc77dcc..c6b5e77 100644 --- a/backend/ent/documenttoken_update.go +++ b/backend/internal/data/ent/documenttoken_update.go @@ -12,9 +12,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // DocumentTokenUpdate is the builder for updating DocumentToken entities. diff --git a/backend/ent/ent.go b/backend/internal/data/ent/ent.go similarity index 94% rename from backend/ent/ent.go rename to backend/internal/data/ent/ent.go index 66676f3..e2552db 100644 --- a/backend/ent/ent.go +++ b/backend/internal/data/ent/ent.go @@ -10,17 +10,17 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // ent aliases to avoid import conflicts in user's code. diff --git a/backend/ent/enttest/enttest.go b/backend/internal/data/ent/enttest/enttest.go similarity index 90% rename from backend/ent/enttest/enttest.go rename to backend/internal/data/ent/enttest/enttest.go index f39fc09..495bddb 100644 --- a/backend/ent/enttest/enttest.go +++ b/backend/internal/data/ent/enttest/enttest.go @@ -5,12 +5,12 @@ package enttest import ( "context" - "github.com/hay-kot/homebox/backend/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent" // required by schema hooks. - _ "github.com/hay-kot/homebox/backend/ent/runtime" + _ "github.com/hay-kot/homebox/backend/internal/data/ent/runtime" "entgo.io/ent/dialect/sql/schema" - "github.com/hay-kot/homebox/backend/ent/migrate" + "github.com/hay-kot/homebox/backend/internal/data/ent/migrate" ) type ( diff --git a/backend/ent/external.go b/backend/internal/data/ent/external.go similarity index 100% rename from backend/ent/external.go rename to backend/internal/data/ent/external.go diff --git a/backend/ent/generate.go b/backend/internal/data/ent/generate.go similarity index 100% rename from backend/ent/generate.go rename to backend/internal/data/ent/generate.go diff --git a/backend/ent/group.go b/backend/internal/data/ent/group.go similarity index 99% rename from backend/ent/group.go rename to backend/internal/data/ent/group.go index 814560c..8140104 100644 --- a/backend/ent/group.go +++ b/backend/internal/data/ent/group.go @@ -9,7 +9,7 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" ) // Group is the model entity for the Group schema. diff --git a/backend/ent/group/group.go b/backend/internal/data/ent/group/group.go similarity index 100% rename from backend/ent/group/group.go rename to backend/internal/data/ent/group/group.go diff --git a/backend/ent/group/where.go b/backend/internal/data/ent/group/where.go similarity index 99% rename from backend/ent/group/where.go rename to backend/internal/data/ent/group/where.go index b95fef7..62106cc 100644 --- a/backend/ent/group/where.go +++ b/backend/internal/data/ent/group/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/group_create.go b/backend/internal/data/ent/group_create.go similarity index 97% rename from backend/ent/group_create.go rename to backend/internal/data/ent/group_create.go index cdb4619..37ca739 100644 --- a/backend/ent/group_create.go +++ b/backend/internal/data/ent/group_create.go @@ -11,13 +11,13 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // GroupCreate is the builder for creating a Group entity. diff --git a/backend/ent/group_delete.go b/backend/internal/data/ent/group_delete.go similarity index 95% rename from backend/ent/group_delete.go rename to backend/internal/data/ent/group_delete.go index 23dfa0c..4bcefc8 100644 --- a/backend/ent/group_delete.go +++ b/backend/internal/data/ent/group_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // GroupDelete is the builder for deleting a Group entity. diff --git a/backend/ent/group_query.go b/backend/internal/data/ent/group_query.go similarity index 98% rename from backend/ent/group_query.go rename to backend/internal/data/ent/group_query.go index 13bfd9b..796f81d 100644 --- a/backend/ent/group_query.go +++ b/backend/internal/data/ent/group_query.go @@ -12,14 +12,14 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // GroupQuery is the builder for querying Group entities. diff --git a/backend/ent/group_update.go b/backend/internal/data/ent/group_update.go similarity index 98% rename from backend/ent/group_update.go rename to backend/internal/data/ent/group_update.go index 6400c1b..bc4dbf9 100644 --- a/backend/ent/group_update.go +++ b/backend/internal/data/ent/group_update.go @@ -12,14 +12,14 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // GroupUpdate is the builder for updating Group entities. diff --git a/backend/ent/groupinvitationtoken.go b/backend/internal/data/ent/groupinvitationtoken.go similarity index 98% rename from backend/ent/groupinvitationtoken.go rename to backend/internal/data/ent/groupinvitationtoken.go index 50346d8..248e40f 100644 --- a/backend/ent/groupinvitationtoken.go +++ b/backend/internal/data/ent/groupinvitationtoken.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" ) // GroupInvitationToken is the model entity for the GroupInvitationToken schema. diff --git a/backend/ent/groupinvitationtoken/groupinvitationtoken.go b/backend/internal/data/ent/groupinvitationtoken/groupinvitationtoken.go similarity index 100% rename from backend/ent/groupinvitationtoken/groupinvitationtoken.go rename to backend/internal/data/ent/groupinvitationtoken/groupinvitationtoken.go diff --git a/backend/ent/groupinvitationtoken/where.go b/backend/internal/data/ent/groupinvitationtoken/where.go similarity index 99% rename from backend/ent/groupinvitationtoken/where.go rename to backend/internal/data/ent/groupinvitationtoken/where.go index a613e6a..bf4ccaa 100644 --- a/backend/ent/groupinvitationtoken/where.go +++ b/backend/internal/data/ent/groupinvitationtoken/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/groupinvitationtoken_create.go b/backend/internal/data/ent/groupinvitationtoken_create.go similarity index 98% rename from backend/ent/groupinvitationtoken_create.go rename to backend/internal/data/ent/groupinvitationtoken_create.go index b36d623..34a3f48 100644 --- a/backend/ent/groupinvitationtoken_create.go +++ b/backend/internal/data/ent/groupinvitationtoken_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" ) // GroupInvitationTokenCreate is the builder for creating a GroupInvitationToken entity. diff --git a/backend/ent/groupinvitationtoken_delete.go b/backend/internal/data/ent/groupinvitationtoken_delete.go similarity index 95% rename from backend/ent/groupinvitationtoken_delete.go rename to backend/internal/data/ent/groupinvitationtoken_delete.go index 42fad8b..4fa2ceb 100644 --- a/backend/ent/groupinvitationtoken_delete.go +++ b/backend/internal/data/ent/groupinvitationtoken_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // GroupInvitationTokenDelete is the builder for deleting a GroupInvitationToken entity. diff --git a/backend/ent/groupinvitationtoken_query.go b/backend/internal/data/ent/groupinvitationtoken_query.go similarity index 98% rename from backend/ent/groupinvitationtoken_query.go rename to backend/internal/data/ent/groupinvitationtoken_query.go index ea380b0..4e8536b 100644 --- a/backend/ent/groupinvitationtoken_query.go +++ b/backend/internal/data/ent/groupinvitationtoken_query.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // GroupInvitationTokenQuery is the builder for querying GroupInvitationToken entities. diff --git a/backend/ent/groupinvitationtoken_update.go b/backend/internal/data/ent/groupinvitationtoken_update.go similarity index 98% rename from backend/ent/groupinvitationtoken_update.go rename to backend/internal/data/ent/groupinvitationtoken_update.go index 3459c4e..33cbef2 100644 --- a/backend/ent/groupinvitationtoken_update.go +++ b/backend/internal/data/ent/groupinvitationtoken_update.go @@ -12,9 +12,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // GroupInvitationTokenUpdate is the builder for updating GroupInvitationToken entities. diff --git a/backend/ent/has_id.go b/backend/internal/data/ent/has_id.go similarity index 100% rename from backend/ent/has_id.go rename to backend/internal/data/ent/has_id.go diff --git a/backend/ent/hook/hook.go b/backend/internal/data/ent/hook/hook.go similarity index 99% rename from backend/ent/hook/hook.go rename to backend/internal/data/ent/hook/hook.go index 0fbd6d1..c0a7378 100644 --- a/backend/ent/hook/hook.go +++ b/backend/internal/data/ent/hook/hook.go @@ -6,7 +6,7 @@ import ( "context" "fmt" - "github.com/hay-kot/homebox/backend/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent" ) // The AttachmentFunc type is an adapter to allow the use of ordinary diff --git a/backend/ent/item.go b/backend/internal/data/ent/item.go similarity index 98% rename from backend/ent/item.go rename to backend/internal/data/ent/item.go index c1b1eff..d9d66b4 100644 --- a/backend/ent/item.go +++ b/backend/internal/data/ent/item.go @@ -9,9 +9,9 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" ) // Item is the model entity for the Item schema. diff --git a/backend/ent/item/item.go b/backend/internal/data/ent/item/item.go similarity index 100% rename from backend/ent/item/item.go rename to backend/internal/data/ent/item/item.go diff --git a/backend/ent/item/where.go b/backend/internal/data/ent/item/where.go similarity index 99% rename from backend/ent/item/where.go rename to backend/internal/data/ent/item/where.go index ec74275..cb4b0d9 100644 --- a/backend/ent/item/where.go +++ b/backend/internal/data/ent/item/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/item_create.go b/backend/internal/data/ent/item_create.go similarity index 98% rename from backend/ent/item_create.go rename to backend/internal/data/ent/item_create.go index 6134705..5b0842d 100644 --- a/backend/ent/item_create.go +++ b/backend/internal/data/ent/item_create.go @@ -11,12 +11,12 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" ) // ItemCreate is the builder for creating a Item entity. diff --git a/backend/ent/item_delete.go b/backend/internal/data/ent/item_delete.go similarity index 95% rename from backend/ent/item_delete.go rename to backend/internal/data/ent/item_delete.go index 1f8b6f8..56b7e03 100644 --- a/backend/ent/item_delete.go +++ b/backend/internal/data/ent/item_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ItemDelete is the builder for deleting a Item entity. diff --git a/backend/ent/item_query.go b/backend/internal/data/ent/item_query.go similarity index 98% rename from backend/ent/item_query.go rename to backend/internal/data/ent/item_query.go index e6d1173..fba0917 100644 --- a/backend/ent/item_query.go +++ b/backend/internal/data/ent/item_query.go @@ -12,13 +12,13 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ItemQuery is the builder for querying Item entities. diff --git a/backend/ent/item_update.go b/backend/internal/data/ent/item_update.go similarity index 99% rename from backend/ent/item_update.go rename to backend/internal/data/ent/item_update.go index 5b08da7..86dd6dd 100644 --- a/backend/ent/item_update.go +++ b/backend/internal/data/ent/item_update.go @@ -12,13 +12,13 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ItemUpdate is the builder for updating Item entities. diff --git a/backend/ent/itemfield.go b/backend/internal/data/ent/itemfield.go similarity index 98% rename from backend/ent/itemfield.go rename to backend/internal/data/ent/itemfield.go index 84db86d..be68023 100644 --- a/backend/ent/itemfield.go +++ b/backend/internal/data/ent/itemfield.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" ) // ItemField is the model entity for the ItemField schema. diff --git a/backend/ent/itemfield/itemfield.go b/backend/internal/data/ent/itemfield/itemfield.go similarity index 100% rename from backend/ent/itemfield/itemfield.go rename to backend/internal/data/ent/itemfield/itemfield.go diff --git a/backend/ent/itemfield/where.go b/backend/internal/data/ent/itemfield/where.go similarity index 99% rename from backend/ent/itemfield/where.go rename to backend/internal/data/ent/itemfield/where.go index 39c2734..2af2d7a 100644 --- a/backend/ent/itemfield/where.go +++ b/backend/internal/data/ent/itemfield/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/itemfield_create.go b/backend/internal/data/ent/itemfield_create.go similarity index 99% rename from backend/ent/itemfield_create.go rename to backend/internal/data/ent/itemfield_create.go index ad9fd96..2a00749 100644 --- a/backend/ent/itemfield_create.go +++ b/backend/internal/data/ent/itemfield_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" ) // ItemFieldCreate is the builder for creating a ItemField entity. diff --git a/backend/ent/itemfield_delete.go b/backend/internal/data/ent/itemfield_delete.go similarity index 95% rename from backend/ent/itemfield_delete.go rename to backend/internal/data/ent/itemfield_delete.go index e5ba38f..e1933d6 100644 --- a/backend/ent/itemfield_delete.go +++ b/backend/internal/data/ent/itemfield_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ItemFieldDelete is the builder for deleting a ItemField entity. diff --git a/backend/ent/itemfield_query.go b/backend/internal/data/ent/itemfield_query.go similarity index 98% rename from backend/ent/itemfield_query.go rename to backend/internal/data/ent/itemfield_query.go index c72441e..fb9a5ea 100644 --- a/backend/ent/itemfield_query.go +++ b/backend/internal/data/ent/itemfield_query.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ItemFieldQuery is the builder for querying ItemField entities. diff --git a/backend/ent/itemfield_update.go b/backend/internal/data/ent/itemfield_update.go similarity index 99% rename from backend/ent/itemfield_update.go rename to backend/internal/data/ent/itemfield_update.go index cac8fed..6b89324 100644 --- a/backend/ent/itemfield_update.go +++ b/backend/internal/data/ent/itemfield_update.go @@ -12,9 +12,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ItemFieldUpdate is the builder for updating ItemField entities. diff --git a/backend/ent/label.go b/backend/internal/data/ent/label.go similarity index 98% rename from backend/ent/label.go rename to backend/internal/data/ent/label.go index 73e0714..9e65bfe 100644 --- a/backend/ent/label.go +++ b/backend/internal/data/ent/label.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" ) // Label is the model entity for the Label schema. diff --git a/backend/ent/label/label.go b/backend/internal/data/ent/label/label.go similarity index 100% rename from backend/ent/label/label.go rename to backend/internal/data/ent/label/label.go diff --git a/backend/ent/label/where.go b/backend/internal/data/ent/label/where.go similarity index 99% rename from backend/ent/label/where.go rename to backend/internal/data/ent/label/where.go index 05d24db..9279ee7 100644 --- a/backend/ent/label/where.go +++ b/backend/internal/data/ent/label/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/label_create.go b/backend/internal/data/ent/label_create.go similarity index 98% rename from backend/ent/label_create.go rename to backend/internal/data/ent/label_create.go index 7330747..a000e35 100644 --- a/backend/ent/label_create.go +++ b/backend/internal/data/ent/label_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" ) // LabelCreate is the builder for creating a Label entity. diff --git a/backend/ent/label_delete.go b/backend/internal/data/ent/label_delete.go similarity index 95% rename from backend/ent/label_delete.go rename to backend/internal/data/ent/label_delete.go index aef8be0..28e103c 100644 --- a/backend/ent/label_delete.go +++ b/backend/internal/data/ent/label_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // LabelDelete is the builder for deleting a Label entity. diff --git a/backend/ent/label_query.go b/backend/internal/data/ent/label_query.go similarity index 98% rename from backend/ent/label_query.go rename to backend/internal/data/ent/label_query.go index 58fa534..fc53ec4 100644 --- a/backend/ent/label_query.go +++ b/backend/internal/data/ent/label_query.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // LabelQuery is the builder for querying Label entities. diff --git a/backend/ent/label_update.go b/backend/internal/data/ent/label_update.go similarity index 98% rename from backend/ent/label_update.go rename to backend/internal/data/ent/label_update.go index ef0af15..16f4a0c 100644 --- a/backend/ent/label_update.go +++ b/backend/internal/data/ent/label_update.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // LabelUpdate is the builder for updating Label entities. diff --git a/backend/ent/location.go b/backend/internal/data/ent/location.go similarity index 98% rename from backend/ent/location.go rename to backend/internal/data/ent/location.go index 337126b..67abd30 100644 --- a/backend/ent/location.go +++ b/backend/internal/data/ent/location.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" ) // Location is the model entity for the Location schema. diff --git a/backend/ent/location/location.go b/backend/internal/data/ent/location/location.go similarity index 100% rename from backend/ent/location/location.go rename to backend/internal/data/ent/location/location.go diff --git a/backend/ent/location/where.go b/backend/internal/data/ent/location/where.go similarity index 99% rename from backend/ent/location/where.go rename to backend/internal/data/ent/location/where.go index 20738b7..73f28bd 100644 --- a/backend/ent/location/where.go +++ b/backend/internal/data/ent/location/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/location_create.go b/backend/internal/data/ent/location_create.go similarity index 98% rename from backend/ent/location_create.go rename to backend/internal/data/ent/location_create.go index ceff804..35081c2 100644 --- a/backend/ent/location_create.go +++ b/backend/internal/data/ent/location_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" ) // LocationCreate is the builder for creating a Location entity. diff --git a/backend/ent/location_delete.go b/backend/internal/data/ent/location_delete.go similarity index 95% rename from backend/ent/location_delete.go rename to backend/internal/data/ent/location_delete.go index 8bc6db3..7fd8e84 100644 --- a/backend/ent/location_delete.go +++ b/backend/internal/data/ent/location_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // LocationDelete is the builder for deleting a Location entity. diff --git a/backend/ent/location_query.go b/backend/internal/data/ent/location_query.go similarity index 98% rename from backend/ent/location_query.go rename to backend/internal/data/ent/location_query.go index 9cf0b55..ff3014b 100644 --- a/backend/ent/location_query.go +++ b/backend/internal/data/ent/location_query.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // LocationQuery is the builder for querying Location entities. diff --git a/backend/ent/location_update.go b/backend/internal/data/ent/location_update.go similarity index 99% rename from backend/ent/location_update.go rename to backend/internal/data/ent/location_update.go index 785036a..eaeb530 100644 --- a/backend/ent/location_update.go +++ b/backend/internal/data/ent/location_update.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // LocationUpdate is the builder for updating Location entities. diff --git a/backend/ent/migrate/migrate.go b/backend/internal/data/ent/migrate/migrate.go similarity index 100% rename from backend/ent/migrate/migrate.go rename to backend/internal/data/ent/migrate/migrate.go diff --git a/backend/ent/migrate/schema.go b/backend/internal/data/ent/migrate/schema.go similarity index 100% rename from backend/ent/migrate/schema.go rename to backend/internal/data/ent/migrate/schema.go diff --git a/backend/ent/mutation.go b/backend/internal/data/ent/mutation.go similarity index 99% rename from backend/ent/mutation.go rename to backend/internal/data/ent/mutation.go index eb2e853..c245719 100644 --- a/backend/ent/mutation.go +++ b/backend/internal/data/ent/mutation.go @@ -10,18 +10,18 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" "entgo.io/ent" ) diff --git a/backend/ent/predicate/predicate.go b/backend/internal/data/ent/predicate/predicate.go similarity index 100% rename from backend/ent/predicate/predicate.go rename to backend/internal/data/ent/predicate/predicate.go diff --git a/backend/ent/runtime.go b/backend/internal/data/ent/runtime.go similarity index 97% rename from backend/ent/runtime.go rename to backend/internal/data/ent/runtime.go index bfa73d1..3929dab 100644 --- a/backend/ent/runtime.go +++ b/backend/internal/data/ent/runtime.go @@ -6,18 +6,18 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/attachment" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/documenttoken" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/schema" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // The init function reads all schema descriptors with runtime code diff --git a/backend/ent/runtime/runtime.go b/backend/internal/data/ent/runtime/runtime.go similarity index 86% rename from backend/ent/runtime/runtime.go rename to backend/internal/data/ent/runtime/runtime.go index 8dd480b..9be6acb 100644 --- a/backend/ent/runtime/runtime.go +++ b/backend/internal/data/ent/runtime/runtime.go @@ -2,7 +2,7 @@ package runtime -// The schema-stitching logic is generated in github.com/hay-kot/homebox/backend/ent/runtime.go +// The schema-stitching logic is generated in github.com/hay-kot/homebox/backend/internal/data/ent/runtime.go const ( Version = "v0.11.3" // Version of ent codegen. diff --git a/backend/ent/schema/attachment.go b/backend/internal/data/ent/schema/attachment.go similarity index 91% rename from backend/ent/schema/attachment.go rename to backend/internal/data/ent/schema/attachment.go index 7dc27d3..7f4673a 100644 --- a/backend/ent/schema/attachment.go +++ b/backend/internal/data/ent/schema/attachment.go @@ -4,7 +4,7 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // Attachment holds the schema definition for the Attachment entity. diff --git a/backend/ent/schema/auth_tokens.go b/backend/internal/data/ent/schema/auth_tokens.go similarity index 92% rename from backend/ent/schema/auth_tokens.go rename to backend/internal/data/ent/schema/auth_tokens.go index 41beafa..0cfd4d1 100644 --- a/backend/ent/schema/auth_tokens.go +++ b/backend/internal/data/ent/schema/auth_tokens.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // AuthTokens holds the schema definition for the AuthTokens entity. diff --git a/backend/ent/schema/document.go b/backend/internal/data/ent/schema/document.go similarity index 93% rename from backend/ent/schema/document.go rename to backend/internal/data/ent/schema/document.go index f6b2c57..2293c39 100644 --- a/backend/ent/schema/document.go +++ b/backend/internal/data/ent/schema/document.go @@ -5,7 +5,7 @@ import ( "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // Document holds the schema definition for the Document entity. diff --git a/backend/ent/schema/document_token.go b/backend/internal/data/ent/schema/document_token.go similarity index 92% rename from backend/ent/schema/document_token.go rename to backend/internal/data/ent/schema/document_token.go index 7423996..c5ec72f 100644 --- a/backend/ent/schema/document_token.go +++ b/backend/internal/data/ent/schema/document_token.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // DocumentToken holds the schema definition for the DocumentToken entity. diff --git a/backend/ent/schema/group.go b/backend/internal/data/ent/schema/group.go similarity index 94% rename from backend/ent/schema/group.go rename to backend/internal/data/ent/schema/group.go index a9d51ed..efd706c 100644 --- a/backend/ent/schema/group.go +++ b/backend/internal/data/ent/schema/group.go @@ -5,7 +5,7 @@ import ( "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // Group holds the schema definition for the Group entity. diff --git a/backend/ent/schema/group_invitation_token.go b/backend/internal/data/ent/schema/group_invitation_token.go similarity index 92% rename from backend/ent/schema/group_invitation_token.go rename to backend/internal/data/ent/schema/group_invitation_token.go index 6ba41cd..1150db8 100644 --- a/backend/ent/schema/group_invitation_token.go +++ b/backend/internal/data/ent/schema/group_invitation_token.go @@ -6,7 +6,7 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // GroupInvitationToken holds the schema definition for the GroupInvitationToken entity. diff --git a/backend/ent/schema/item.go b/backend/internal/data/ent/schema/item.go similarity index 97% rename from backend/ent/schema/item.go rename to backend/internal/data/ent/schema/item.go index 25531d0..17021a5 100644 --- a/backend/ent/schema/item.go +++ b/backend/internal/data/ent/schema/item.go @@ -6,7 +6,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // Item holds the schema definition for the Item entity. diff --git a/backend/ent/schema/item_field.go b/backend/internal/data/ent/schema/item_field.go similarity index 92% rename from backend/ent/schema/item_field.go rename to backend/internal/data/ent/schema/item_field.go index 56be98a..405b99c 100644 --- a/backend/ent/schema/item_field.go +++ b/backend/internal/data/ent/schema/item_field.go @@ -6,7 +6,7 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // ItemField holds the schema definition for the ItemField entity. diff --git a/backend/ent/schema/label.go b/backend/internal/data/ent/schema/label.go similarity index 90% rename from backend/ent/schema/label.go rename to backend/internal/data/ent/schema/label.go index a8eb8d2..72d6078 100644 --- a/backend/ent/schema/label.go +++ b/backend/internal/data/ent/schema/label.go @@ -4,7 +4,7 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // Label holds the schema definition for the Label entity. diff --git a/backend/ent/schema/location.go b/backend/internal/data/ent/schema/location.go similarity index 91% rename from backend/ent/schema/location.go rename to backend/internal/data/ent/schema/location.go index e8f2237..b3142b4 100644 --- a/backend/ent/schema/location.go +++ b/backend/internal/data/ent/schema/location.go @@ -4,7 +4,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema/edge" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // Location holds the schema definition for the Location entity. diff --git a/backend/ent/schema/mixins/base.go b/backend/internal/data/ent/schema/mixins/base.go similarity index 100% rename from backend/ent/schema/mixins/base.go rename to backend/internal/data/ent/schema/mixins/base.go diff --git a/backend/ent/schema/templates/has_id.tmpl b/backend/internal/data/ent/schema/templates/has_id.tmpl similarity index 100% rename from backend/ent/schema/templates/has_id.tmpl rename to backend/internal/data/ent/schema/templates/has_id.tmpl diff --git a/backend/ent/schema/user.go b/backend/internal/data/ent/schema/user.go similarity index 93% rename from backend/ent/schema/user.go rename to backend/internal/data/ent/schema/user.go index d522ddb..b3342a8 100644 --- a/backend/ent/schema/user.go +++ b/backend/internal/data/ent/schema/user.go @@ -5,7 +5,7 @@ import ( "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/schema/mixins" + "github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins" ) // User holds the schema definition for the User entity. diff --git a/backend/ent/tx.go b/backend/internal/data/ent/tx.go similarity index 100% rename from backend/ent/tx.go rename to backend/internal/data/ent/tx.go diff --git a/backend/ent/user.go b/backend/internal/data/ent/user.go similarity index 98% rename from backend/ent/user.go rename to backend/internal/data/ent/user.go index 547e21f..48dbdcb 100644 --- a/backend/ent/user.go +++ b/backend/internal/data/ent/user.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // User is the model entity for the User schema. diff --git a/backend/ent/user/user.go b/backend/internal/data/ent/user/user.go similarity index 100% rename from backend/ent/user/user.go rename to backend/internal/data/ent/user/user.go diff --git a/backend/ent/user/where.go b/backend/internal/data/ent/user/where.go similarity index 99% rename from backend/ent/user/where.go rename to backend/internal/data/ent/user/where.go index df4adbb..567187e 100644 --- a/backend/ent/user/where.go +++ b/backend/internal/data/ent/user/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) // ID filters vertices based on their ID field. diff --git a/backend/ent/user_create.go b/backend/internal/data/ent/user_create.go similarity index 98% rename from backend/ent/user_create.go rename to backend/internal/data/ent/user_create.go index 5835244..317b43a 100644 --- a/backend/ent/user_create.go +++ b/backend/internal/data/ent/user_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // UserCreate is the builder for creating a User entity. diff --git a/backend/ent/user_delete.go b/backend/internal/data/ent/user_delete.go similarity index 95% rename from backend/ent/user_delete.go rename to backend/internal/data/ent/user_delete.go index 6d8b949..9013f6f 100644 --- a/backend/ent/user_delete.go +++ b/backend/internal/data/ent/user_delete.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/hay-kot/homebox/backend/ent/predicate" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // UserDelete is the builder for deleting a User entity. diff --git a/backend/ent/user_query.go b/backend/internal/data/ent/user_query.go similarity index 98% rename from backend/ent/user_query.go rename to backend/internal/data/ent/user_query.go index 09d951d..2178bd3 100644 --- a/backend/ent/user_query.go +++ b/backend/internal/data/ent/user_query.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/predicate" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // UserQuery is the builder for querying User entities. diff --git a/backend/ent/user_update.go b/backend/internal/data/ent/user_update.go similarity index 98% rename from backend/ent/user_update.go rename to backend/internal/data/ent/user_update.go index 9316360..bfe8d3b 100644 --- a/backend/ent/user_update.go +++ b/backend/internal/data/ent/user_update.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent/authtokens" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/predicate" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) // UserUpdate is the builder for updating User entities. diff --git a/backend/internal/migrations/migrations.go b/backend/internal/data/migrations/migrations.go similarity index 100% rename from backend/internal/migrations/migrations.go rename to backend/internal/data/migrations/migrations.go diff --git a/backend/internal/migrations/migrations/20220929052825_init.sql b/backend/internal/data/migrations/migrations/20220929052825_init.sql similarity index 100% rename from backend/internal/migrations/migrations/20220929052825_init.sql rename to backend/internal/data/migrations/migrations/20220929052825_init.sql diff --git a/backend/internal/migrations/migrations/20221001210956_group_invitations.sql b/backend/internal/data/migrations/migrations/20221001210956_group_invitations.sql similarity index 100% rename from backend/internal/migrations/migrations/20221001210956_group_invitations.sql rename to backend/internal/data/migrations/migrations/20221001210956_group_invitations.sql diff --git a/backend/internal/migrations/migrations/20221009173029_add_user_roles.sql b/backend/internal/data/migrations/migrations/20221009173029_add_user_roles.sql similarity index 100% rename from backend/internal/migrations/migrations/20221009173029_add_user_roles.sql rename to backend/internal/data/migrations/migrations/20221009173029_add_user_roles.sql diff --git a/backend/internal/migrations/migrations/20221020043305_allow_nesting_types.sql b/backend/internal/data/migrations/migrations/20221020043305_allow_nesting_types.sql similarity index 100% rename from backend/internal/migrations/migrations/20221020043305_allow_nesting_types.sql rename to backend/internal/data/migrations/migrations/20221020043305_allow_nesting_types.sql diff --git a/backend/internal/migrations/migrations/atlas.sum b/backend/internal/data/migrations/migrations/atlas.sum similarity index 100% rename from backend/internal/migrations/migrations/atlas.sum rename to backend/internal/data/migrations/migrations/atlas.sum diff --git a/backend/internal/repo/id_set.go b/backend/internal/data/repo/id_set.go similarity index 100% rename from backend/internal/repo/id_set.go rename to backend/internal/data/repo/id_set.go diff --git a/backend/internal/repo/main_test.go b/backend/internal/data/repo/main_test.go similarity index 94% rename from backend/internal/repo/main_test.go rename to backend/internal/data/repo/main_test.go index 92fe4be..221fbd5 100644 --- a/backend/internal/repo/main_test.go +++ b/backend/internal/data/repo/main_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/hay-kot/homebox/backend/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent" "github.com/hay-kot/homebox/backend/pkgs/faker" _ "github.com/mattn/go-sqlite3" ) diff --git a/backend/internal/repo/map_helpers.go b/backend/internal/data/repo/map_helpers.go similarity index 100% rename from backend/internal/repo/map_helpers.go rename to backend/internal/data/repo/map_helpers.go diff --git a/backend/internal/repo/pagination.go b/backend/internal/data/repo/pagination.go similarity index 100% rename from backend/internal/repo/pagination.go rename to backend/internal/data/repo/pagination.go diff --git a/backend/internal/repo/repo_document_tokens.go b/backend/internal/data/repo/repo_document_tokens.go similarity index 92% rename from backend/internal/repo/repo_document_tokens.go rename to backend/internal/data/repo/repo_document_tokens.go index 903240c..018ea61 100644 --- a/backend/internal/repo/repo_document_tokens.go +++ b/backend/internal/data/repo/repo_document_tokens.go @@ -5,8 +5,8 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" ) // DocumentTokensRepository is a repository for Document entity diff --git a/backend/internal/repo/repo_document_tokens_test.go b/backend/internal/data/repo/repo_document_tokens_test.go similarity index 96% rename from backend/internal/repo/repo_document_tokens_test.go rename to backend/internal/data/repo/repo_document_tokens_test.go index 34f0a17..6646eca 100644 --- a/backend/internal/repo/repo_document_tokens_test.go +++ b/backend/internal/data/repo/repo_document_tokens_test.go @@ -6,8 +6,8 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/documenttoken" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken" "github.com/stretchr/testify/assert" ) diff --git a/backend/internal/repo/repo_documents.go b/backend/internal/data/repo/repo_documents.go similarity index 92% rename from backend/internal/repo/repo_documents.go rename to backend/internal/data/repo/repo_documents.go index a9a5666..abe340d 100644 --- a/backend/internal/repo/repo_documents.go +++ b/backend/internal/data/repo/repo_documents.go @@ -8,9 +8,9 @@ import ( "path/filepath" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/document" - "github.com/hay-kot/homebox/backend/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/document" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" "github.com/hay-kot/homebox/backend/pkgs/pathlib" ) diff --git a/backend/internal/repo/repo_documents_test.go b/backend/internal/data/repo/repo_documents_test.go similarity index 97% rename from backend/internal/repo/repo_documents_test.go rename to backend/internal/data/repo/repo_documents_test.go index 06e631c..b58b3bb 100644 --- a/backend/internal/repo/repo_documents_test.go +++ b/backend/internal/data/repo/repo_documents_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent" "github.com/stretchr/testify/assert" ) diff --git a/backend/internal/repo/repo_group.go b/backend/internal/data/repo/repo_group.go similarity index 90% rename from backend/internal/repo/repo_group.go rename to backend/internal/data/repo/repo_group.go index ac0e071..fa5b6b8 100644 --- a/backend/internal/repo/repo_group.go +++ b/backend/internal/data/repo/repo_group.go @@ -2,12 +2,13 @@ package repo import ( "context" + "strings" "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/groupinvitationtoken" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" ) type GroupRepository struct { @@ -52,7 +53,7 @@ func mapToGroup(g *ent.Group) Group { Name: g.Name, CreatedAt: g.CreatedAt, UpdatedAt: g.UpdatedAt, - Currency: g.Currency.String(), + Currency: strings.ToUpper(g.Currency.String()), } } @@ -76,7 +77,7 @@ func (r *GroupRepository) GroupCreate(ctx context.Context, name string) (Group, } func (r *GroupRepository) GroupUpdate(ctx context.Context, ID uuid.UUID, data GroupUpdate) (Group, error) { - currency := group.Currency(data.Currency) + currency := group.Currency(strings.ToLower(data.Currency)) entity, err := r.db.Group.UpdateOneID(ID). SetName(data.Name). diff --git a/backend/internal/repo/repo_group_test.go b/backend/internal/data/repo/repo_group_test.go similarity index 95% rename from backend/internal/repo/repo_group_test.go rename to backend/internal/data/repo/repo_group_test.go index 5f3faaf..941e06c 100644 --- a/backend/internal/repo/repo_group_test.go +++ b/backend/internal/data/repo/repo_group_test.go @@ -29,5 +29,5 @@ func Test_Group_Update(t *testing.T) { }) assert.NoError(t, err) assert.Equal(t, "test2", g.Name) - assert.Equal(t, "eur", g.Currency) + assert.Equal(t, "EUR", g.Currency) } diff --git a/backend/internal/repo/repo_item_attachments.go b/backend/internal/data/repo/repo_item_attachments.go similarity index 94% rename from backend/internal/repo/repo_item_attachments.go rename to backend/internal/data/repo/repo_item_attachments.go index 9b0f810..1e2ef7b 100644 --- a/backend/internal/repo/repo_item_attachments.go +++ b/backend/internal/data/repo/repo_item_attachments.go @@ -5,8 +5,8 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" ) // AttachmentRepo is a repository for Attachments table that links Items to Documents diff --git a/backend/internal/repo/repo_item_attachments_test.go b/backend/internal/data/repo/repo_item_attachments_test.go similarity index 95% rename from backend/internal/repo/repo_item_attachments_test.go rename to backend/internal/data/repo/repo_item_attachments_test.go index e861001..15f70c8 100644 --- a/backend/internal/repo/repo_item_attachments_test.go +++ b/backend/internal/data/repo/repo_item_attachments_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/attachment" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" "github.com/stretchr/testify/assert" ) diff --git a/backend/internal/repo/repo_items.go b/backend/internal/data/repo/repo_items.go similarity index 96% rename from backend/internal/repo/repo_items.go rename to backend/internal/data/repo/repo_items.go index 27ddc4c..8eefb5f 100644 --- a/backend/internal/repo/repo_items.go +++ b/backend/internal/data/repo/repo_items.go @@ -5,13 +5,13 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/item" - "github.com/hay-kot/homebox/backend/ent/itemfield" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/item" + "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) type ItemsRepository struct { diff --git a/backend/internal/repo/repo_items_test.go b/backend/internal/data/repo/repo_items_test.go similarity index 100% rename from backend/internal/repo/repo_items_test.go rename to backend/internal/data/repo/repo_items_test.go diff --git a/backend/internal/repo/repo_labels.go b/backend/internal/data/repo/repo_labels.go similarity index 73% rename from backend/internal/repo/repo_labels.go rename to backend/internal/data/repo/repo_labels.go index b899d68..353df17 100644 --- a/backend/internal/repo/repo_labels.go +++ b/backend/internal/data/repo/repo_labels.go @@ -5,10 +5,10 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/label" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/label" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) type LabelRepository struct { @@ -106,13 +106,30 @@ func (r *LabelRepository) Create(ctx context.Context, groupdId uuid.UUID, data L return mapLabelOut(label), err } -func (r *LabelRepository) Update(ctx context.Context, data LabelUpdate) (LabelOut, error) { - _, err := r.db.Label.UpdateOneID(data.ID). +func (r *LabelRepository) update(ctx context.Context, data LabelUpdate, where ...predicate.Label) (int, error) { + if len(where) == 0 { + panic("empty where not supported empty") + } + + return r.db.Label.Update(). + Where(where...). SetName(data.Name). SetDescription(data.Description). SetColor(data.Color). Save(ctx) +} +func (r *LabelRepository) Update(ctx context.Context, data LabelUpdate) (LabelOut, error) { + _, err := r.update(ctx, data, label.ID(data.ID)) + if err != nil { + return LabelOut{}, err + } + + return r.GetOne(ctx, data.ID) +} + +func (r *LabelRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data LabelUpdate) (LabelOut, error) { + _, err := r.update(ctx, data, label.ID(data.ID), label.HasGroupWith(group.ID(GID))) if err != nil { return LabelOut{}, err } @@ -123,3 +140,13 @@ func (r *LabelRepository) Update(ctx context.Context, data LabelUpdate) (LabelOu func (r *LabelRepository) Delete(ctx context.Context, id uuid.UUID) error { return r.db.Label.DeleteOneID(id).Exec(ctx) } + +func (r *LabelRepository) DeleteByGroup(ctx context.Context, gid, id uuid.UUID) error { + _, err := r.db.Label.Delete(). + Where( + label.ID(id), + label.HasGroupWith(group.ID(gid)), + ).Exec(ctx) + + return err +} diff --git a/backend/internal/repo/repo_labels_test.go b/backend/internal/data/repo/repo_labels_test.go similarity index 100% rename from backend/internal/repo/repo_labels_test.go rename to backend/internal/data/repo/repo_labels_test.go diff --git a/backend/internal/repo/repo_locations.go b/backend/internal/data/repo/repo_locations.go similarity index 77% rename from backend/internal/repo/repo_locations.go rename to backend/internal/data/repo/repo_locations.go index f927431..9e5f36d 100644 --- a/backend/internal/repo/repo_locations.go +++ b/backend/internal/data/repo/repo_locations.go @@ -5,10 +5,10 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/group" - "github.com/hay-kot/homebox/backend/ent/location" - "github.com/hay-kot/homebox/backend/ent/predicate" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/group" + "github.com/hay-kot/homebox/backend/internal/data/ent/location" + "github.com/hay-kot/homebox/backend/internal/data/ent/predicate" ) type LocationRepository struct { @@ -154,23 +154,24 @@ func (r *LocationRepository) GetOneByGroup(ctx context.Context, GID, ID uuid.UUI return r.getOne(ctx, location.ID(ID), location.HasGroupWith(group.ID(GID))) } -func (r *LocationRepository) Create(ctx context.Context, gid uuid.UUID, data LocationCreate) (LocationOut, error) { +func (r *LocationRepository) Create(ctx context.Context, GID uuid.UUID, data LocationCreate) (LocationOut, error) { location, err := r.db.Location.Create(). SetName(data.Name). SetDescription(data.Description). - SetGroupID(gid). + SetGroupID(GID). Save(ctx) if err != nil { return LocationOut{}, err } - location.Edges.Group = &ent.Group{ID: gid} // bootstrap group ID + location.Edges.Group = &ent.Group{ID: GID} // bootstrap group ID return mapLocationOut(location), nil } -func (r *LocationRepository) Update(ctx context.Context, data LocationUpdate) (LocationOut, error) { - q := r.db.Location.UpdateOneID(data.ID). +func (r *LocationRepository) update(ctx context.Context, data LocationUpdate, where ...predicate.Location) (LocationOut, error) { + q := r.db.Location.Update(). + Where(where...). SetName(data.Name). SetDescription(data.Description) @@ -181,7 +182,6 @@ func (r *LocationRepository) Update(ctx context.Context, data LocationUpdate) (L } _, err := q.Save(ctx) - if err != nil { return LocationOut{}, err } @@ -189,6 +189,19 @@ func (r *LocationRepository) Update(ctx context.Context, data LocationUpdate) (L return r.Get(ctx, data.ID) } -func (r *LocationRepository) Delete(ctx context.Context, id uuid.UUID) error { - return r.db.Location.DeleteOneID(id).Exec(ctx) +func (r *LocationRepository) Update(ctx context.Context, data LocationUpdate) (LocationOut, error) { + return r.update(ctx, data, location.ID(data.ID)) +} + +func (r *LocationRepository) UpdateOneByGroup(ctx context.Context, GID, ID uuid.UUID, data LocationUpdate) (LocationOut, error) { + return r.update(ctx, data, location.ID(ID), location.HasGroupWith(group.ID(GID))) +} + +func (r *LocationRepository) Delete(ctx context.Context, ID uuid.UUID) error { + return r.db.Location.DeleteOneID(ID).Exec(ctx) +} + +func (r *LocationRepository) DeleteByGroup(ctx context.Context, GID, ID uuid.UUID) error { + _, err := r.db.Location.Delete().Where(location.ID(ID), location.HasGroupWith(group.ID(GID))).Exec(ctx) + return err } diff --git a/backend/internal/repo/repo_locations_test.go b/backend/internal/data/repo/repo_locations_test.go similarity index 100% rename from backend/internal/repo/repo_locations_test.go rename to backend/internal/data/repo/repo_locations_test.go diff --git a/backend/internal/repo/repo_tokens.go b/backend/internal/data/repo/repo_tokens.go similarity index 94% rename from backend/internal/repo/repo_tokens.go rename to backend/internal/data/repo/repo_tokens.go index 38c7443..7d9115b 100644 --- a/backend/internal/repo/repo_tokens.go +++ b/backend/internal/data/repo/repo_tokens.go @@ -5,8 +5,8 @@ import ( "time" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/authtokens" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" ) type TokenRepository struct { diff --git a/backend/internal/repo/repo_tokens_test.go b/backend/internal/data/repo/repo_tokens_test.go similarity index 100% rename from backend/internal/repo/repo_tokens_test.go rename to backend/internal/data/repo/repo_tokens_test.go diff --git a/backend/internal/repo/repo_users.go b/backend/internal/data/repo/repo_users.go similarity index 96% rename from backend/internal/repo/repo_users.go rename to backend/internal/data/repo/repo_users.go index 828c4c2..0eaa127 100644 --- a/backend/internal/repo/repo_users.go +++ b/backend/internal/data/repo/repo_users.go @@ -4,8 +4,8 @@ import ( "context" "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/ent" - "github.com/hay-kot/homebox/backend/ent/user" + "github.com/hay-kot/homebox/backend/internal/data/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent/user" ) type UserRepository struct { diff --git a/backend/internal/repo/repo_users_test.go b/backend/internal/data/repo/repo_users_test.go similarity index 100% rename from backend/internal/repo/repo_users_test.go rename to backend/internal/data/repo/repo_users_test.go diff --git a/backend/internal/repo/repos_all.go b/backend/internal/data/repo/repos_all.go similarity index 92% rename from backend/internal/repo/repos_all.go rename to backend/internal/data/repo/repos_all.go index d01b402..e726e88 100644 --- a/backend/internal/repo/repos_all.go +++ b/backend/internal/data/repo/repos_all.go @@ -1,6 +1,6 @@ package repo -import "github.com/hay-kot/homebox/backend/ent" +import "github.com/hay-kot/homebox/backend/internal/data/ent" // AllRepos is a container for all the repository interfaces type AllRepos struct { diff --git a/backend/internal/mocks/chimocker/chimocker.go b/backend/internal/mocks/chimocker/chimocker.go deleted file mode 100644 index b918403..0000000 --- a/backend/internal/mocks/chimocker/chimocker.go +++ /dev/null @@ -1,30 +0,0 @@ -package chimocker - -import ( - "context" - "net/http" - - "github.com/go-chi/chi/v5" -) - -type Params map[string]string - -// WithUrlParam returns a pointer to a request object with the given URL params -// added to a new chi.Context object. -func WithUrlParam(r *http.Request, key, value string) *http.Request { - chiCtx := chi.NewRouteContext() - req := r.WithContext(context.WithValue(r.Context(), chi.RouteCtxKey, chiCtx)) - chiCtx.URLParams.Add(key, value) - return req -} - -// WithUrlParams returns a pointer to a request object with the given URL params -// added to a new chi.Context object. for single param assignment see WithUrlParam -func WithUrlParams(r *http.Request, params Params) *http.Request { - chiCtx := chi.NewRouteContext() - req := r.WithContext(context.WithValue(r.Context(), chi.RouteCtxKey, chiCtx)) - for key, value := range params { - chiCtx.URLParams.Add(key, value) - } - return req -} diff --git a/backend/internal/mocks/factories/users.go b/backend/internal/mocks/factories/users.go deleted file mode 100644 index 6f618fb..0000000 --- a/backend/internal/mocks/factories/users.go +++ /dev/null @@ -1,16 +0,0 @@ -package factories - -import ( - "github.com/hay-kot/homebox/backend/internal/repo" - "github.com/hay-kot/homebox/backend/pkgs/faker" -) - -func UserFactory() repo.UserCreate { - f := faker.NewFaker() - return repo.UserCreate{ - Name: f.Str(10), - Email: f.Email(), - Password: f.Str(10), - IsSuperuser: f.Bool(), - } -} diff --git a/backend/internal/services/all.go b/backend/internal/services/all.go deleted file mode 100644 index 20e377f..0000000 --- a/backend/internal/services/all.go +++ /dev/null @@ -1,28 +0,0 @@ -package services - -import "github.com/hay-kot/homebox/backend/internal/repo" - -type AllServices struct { - User *UserService - Group *GroupService - Location *LocationService - Labels *LabelService - Items *ItemService -} - -func New(repos *repo.AllRepos) *AllServices { - if repos == nil { - panic("repos cannot be nil") - } - - return &AllServices{ - User: &UserService{repos}, - Group: &GroupService{repos}, - Location: &LocationService{repos}, - Labels: &LabelService{repos}, - Items: &ItemService{ - repo: repos, - at: attachmentTokens{}, - }, - } -} diff --git a/backend/internal/services/service_labels.go b/backend/internal/services/service_labels.go deleted file mode 100644 index 34d67df..0000000 --- a/backend/internal/services/service_labels.go +++ /dev/null @@ -1,37 +0,0 @@ -package services - -import ( - "context" - - "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/internal/repo" -) - -type LabelService struct { - repos *repo.AllRepos -} - -func (svc *LabelService) Create(ctx context.Context, groupId uuid.UUID, data repo.LabelCreate) (repo.LabelOut, error) { - return svc.repos.Labels.Create(ctx, groupId, data) -} - -func (svc *LabelService) Update(ctx context.Context, groupId uuid.UUID, data repo.LabelUpdate) (repo.LabelOut, error) { - return svc.repos.Labels.Update(ctx, data) -} - -func (svc *LabelService) Delete(ctx context.Context, gid uuid.UUID, id uuid.UUID) error { - _, err := svc.repos.Labels.GetOneByGroup(ctx, gid, id) - if err != nil { - return err - } - return svc.repos.Labels.Delete(ctx, id) -} - -func (svc *LabelService) Get(ctx context.Context, gid uuid.UUID, id uuid.UUID) (repo.LabelOut, error) { - return svc.repos.Labels.GetOneByGroup(ctx, gid, id) - -} - -func (svc *LabelService) GetAll(ctx context.Context, groupId uuid.UUID) ([]repo.LabelSummary, error) { - return svc.repos.Labels.GetAll(ctx, groupId) -} diff --git a/backend/internal/services/service_locations.go b/backend/internal/services/service_locations.go deleted file mode 100644 index 7152337..0000000 --- a/backend/internal/services/service_locations.go +++ /dev/null @@ -1,47 +0,0 @@ -package services - -import ( - "context" - "errors" - - "github.com/google/uuid" - "github.com/hay-kot/homebox/backend/internal/repo" -) - -var ( - ErrNotOwner = errors.New("not owner") -) - -type LocationService struct { - repos *repo.AllRepos -} - -func (svc *LocationService) GetOne(ctx context.Context, groupId uuid.UUID, id uuid.UUID) (repo.LocationOut, error) { - return svc.repos.Locations.GetOneByGroup(ctx, groupId, id) -} - -func (svc *LocationService) GetAll(ctx context.Context, groupId uuid.UUID) ([]repo.LocationOutCount, error) { - return svc.repos.Locations.GetAll(ctx, groupId) -} - -func (svc *LocationService) Create(ctx context.Context, groupId uuid.UUID, data repo.LocationCreate) (repo.LocationOut, error) { - return svc.repos.Locations.Create(ctx, groupId, data) -} - -func (svc *LocationService) Delete(ctx context.Context, groupId uuid.UUID, id uuid.UUID) error { - _, err := svc.repos.Locations.GetOneByGroup(ctx, groupId, id) - if err != nil { - return err - } - return svc.repos.Locations.Delete(ctx, id) -} - -func (svc *LocationService) Update(ctx context.Context, groupId uuid.UUID, data repo.LocationUpdate) (repo.LocationOut, error) { - location, err := svc.repos.Locations.GetOneByGroup(ctx, groupId, data.ID) - if err != nil { - return repo.LocationOut{}, err - } - - data.ID = location.ID - return svc.repos.Locations.Update(ctx, data) -} diff --git a/backend/internal/config/conf.go b/backend/internal/sys/config/conf.go similarity index 100% rename from backend/internal/config/conf.go rename to backend/internal/sys/config/conf.go diff --git a/backend/internal/config/conf_database.go b/backend/internal/sys/config/conf_database.go similarity index 100% rename from backend/internal/config/conf_database.go rename to backend/internal/sys/config/conf_database.go diff --git a/backend/internal/config/conf_logger.go b/backend/internal/sys/config/conf_logger.go similarity index 100% rename from backend/internal/config/conf_logger.go rename to backend/internal/sys/config/conf_logger.go diff --git a/backend/internal/config/conf_mailer.go b/backend/internal/sys/config/conf_mailer.go similarity index 100% rename from backend/internal/config/conf_mailer.go rename to backend/internal/sys/config/conf_mailer.go diff --git a/backend/internal/config/conf_mailer_test.go b/backend/internal/sys/config/conf_mailer_test.go similarity index 100% rename from backend/internal/config/conf_mailer_test.go rename to backend/internal/sys/config/conf_mailer_test.go diff --git a/backend/internal/sys/validate/validate.go b/backend/internal/sys/validate/validate.go new file mode 100644 index 0000000..ed22c0f --- /dev/null +++ b/backend/internal/sys/validate/validate.go @@ -0,0 +1,37 @@ +package validate + +import "github.com/go-playground/validator/v10" + +var validate *validator.Validate + +func init() { + validate = validator.New() +} + +// Checks a struct for validation errors and returns any errors the occur. This +// wraps the validate.Struct() function and provides some error wrapping. When +// a validator.ValidationErrors is returned, it is wrapped transformed into a +// FieldErrors array and returned. +func Check(val any) error { + err := validate.Struct(val) + + if err != nil { + verrors, ok := err.(validator.ValidationErrors) + if !ok { + return err + } + + fields := make(FieldErrors, 0, len(verrors)) + for _, verr := range verrors { + field := FieldError{ + Field: verr.Field(), + Error: verr.Error(), + } + + fields = append(fields, field) + } + return fields + } + + return nil +} diff --git a/backend/internal/web/mid/errors.go b/backend/internal/web/mid/errors.go index 0802a11..7aa659c 100644 --- a/backend/internal/web/mid/errors.go +++ b/backend/internal/web/mid/errors.go @@ -3,7 +3,7 @@ package mid import ( "net/http" - "github.com/hay-kot/homebox/backend/ent" + "github.com/hay-kot/homebox/backend/internal/data/ent" "github.com/hay-kot/homebox/backend/internal/sys/validate" "github.com/hay-kot/homebox/backend/pkgs/server" "github.com/rs/zerolog" diff --git a/backend/static/favicon.ico b/backend/static/favicon.ico deleted file mode 100644 index c6f7f74..0000000 Binary files a/backend/static/favicon.ico and /dev/null differ