A continuation of HomeBox the inventory and organization system built for the Home User
feat: item-attachments CRUD (#22)
Hayden31b34241e02d
diff --git a/.gitignore b/.gitignoreindex 0aeaf716..b81b742e 100644--- a/.gitignore+++ b/.gitignore@@ -1,4 +1,5 @@# Project Specific+backend/homebox-data/*config.ymlhomebox.db.ideadiff --git a/Dockerfile b/Dockerfileindex 6aff8580..8be44f22 100644--- a/Dockerfile+++ b/Dockerfile@@ -29,8 +29,11 @@ RUN CGO_ENABLED=1 GOOS=linux go build \# Production StageFROM alpine:latest+ENV HBOX_MODE=production+ENV HBOX_STORAGE_DATA=/data/+ENV HBOX_STORAGE_SQLITE_URL=/data/homebox.db?_fk=1+RUN apk --no-cache add ca-certificates-COPY ./backend/config.template.yml /data/config.ymlRUN mkdir /appCOPY --from=builder /go/bin/api /appdiff --git a/Taskfile.yml b/Taskfile.ymlindex 903fb2c4..04aa8e14 100644--- a/Taskfile.yml+++ b/Taskfile.yml@@ -2,6 +2,9 @@ version: "3"tasks:generate:+ desc: |+ Generates collateral files from the backend project+ including swagger docs and typescripts type for the frontendcmds:- |cd backend && ent generate ./ent/schema \@@ -11,16 +14,26 @@ tasks:- |npx swagger-typescript-api \--no-client \- --clean-output \--modular \--path ./backend/app/api/docs/swagger.json \--output ./frontend/lib/api/typespython3 ./scripts/process-types.py ./frontend/lib/api/types/data-contracts.ts+ sources:+ - "./backend/app/api/**/*"+ - "./backend/app/internal/types/**/*"+ - "./scripts/process-types.py"+ generates:+ - "./frontend/lib/api/types/data-contracts.ts"+ - "./backend/app/api/docs/swagger.json"+ - "./backend/app/api/docs/swagger.yaml"+api:+ desc: Starts the backend api server (depends on generate task)+ deps:+ - generatecmds:- - task: generate- - cd backend && go run ./app/api/ {{.CLI_ARGS}} ./config.yml+ - cd backend && go run ./app/api/ {{ .CLI_ARGS }}silent: falseapi:build:diff --git a/backend/app/api/app.go b/backend/app/api/app.goindex 71767589..7f6b23f8 100644--- a/backend/app/api/app.go+++ b/backend/app/api/app.go@@ -3,12 +3,12 @@ package mainimport ("time"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/config"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/pkgs/mailer"- "github.com/hay-kot/content/backend/pkgs/server"+ "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/pkgs/mailer"+ "github.com/hay-kot/homebox/backend/pkgs/server")type app struct {diff --git a/backend/app/api/docs/docs.go b/backend/app/api/docs/docs.goindex 90e77cea..17af2624 100644--- a/backend/app/api/docs/docs.go+++ b/backend/app/api/docs/docs.go@@ -224,6 +224,222 @@ const docTemplate = `{}}},+ "/v1/items/{id}/attachments": {+ "post": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "Items"+ ],+ "summary": "imports items into the database",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "file",+ "description": "File attachment",+ "name": "file",+ "in": "formData",+ "required": true+ },+ {+ "type": "string",+ "description": "Type of file",+ "name": "type",+ "in": "formData",+ "required": true+ },+ {+ "type": "string",+ "description": "name of the file including extension",+ "name": "name",+ "in": "formData",+ "required": true+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/types.ItemOut"+ }+ },+ "422": {+ "description": "Unprocessable Entity",+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/definitions/server.ValidationError"+ }+ }+ }+ }+ }+ },+ "/v1/items/{id}/attachments/download": {+ "get": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "produces": [+ "application/octet-stream"+ ],+ "tags": [+ "Items"+ ],+ "summary": "retrieves an attachment for an item",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "string",+ "description": "Attachment token",+ "name": "token",+ "in": "query",+ "required": true+ }+ ],+ "responses": {+ "200": {+ "description": ""+ }+ }+ }+ },+ "/v1/items/{id}/attachments/{attachment_id}": {+ "get": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "produces": [+ "application/octet-stream"+ ],+ "tags": [+ "Items"+ ],+ "summary": "retrieves an attachment for an item",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "string",+ "description": "Attachment ID",+ "name": "attachment_id",+ "in": "path",+ "required": true+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/types.ItemAttachmentToken"+ }+ }+ }+ },+ "put": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "tags": [+ "Items"+ ],+ "summary": "retrieves an attachment for an item",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "string",+ "description": "Attachment ID",+ "name": "attachment_id",+ "in": "path",+ "required": true+ },+ {+ "description": "Attachment Update",+ "name": "payload",+ "in": "body",+ "required": true,+ "schema": {+ "$ref": "#/definitions/types.ItemAttachmentUpdate"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/types.ItemOut"+ }+ }+ }+ },+ "delete": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "tags": [+ "Items"+ ],+ "summary": "retrieves an attachment for an item",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "string",+ "description": "Attachment ID",+ "name": "attachment_id",+ "in": "path",+ "required": true+ }+ ],+ "responses": {+ "204": {+ "description": ""+ }+ }+ }+ },"/v1/labels": {"get": {"security": [@@ -818,6 +1034,17 @@ const docTemplate = `{}}},+ "server.ValidationError": {+ "type": "object",+ "properties": {+ "field": {+ "type": "string"+ },+ "reason": {+ "type": "string"+ }+ }+ },"types.ApiSummary": {"type": "object","properties": {@@ -881,11 +1108,33 @@ const docTemplate = `{"id": {"type": "string"},+ "type": {+ "type": "string"+ },"updatedAt": {"type": "string"}}},+ "types.ItemAttachmentToken": {+ "type": "object",+ "properties": {+ "token": {+ "type": "string"+ }+ }+ },+ "types.ItemAttachmentUpdate": {+ "type": "object",+ "properties": {+ "title": {+ "type": "string"+ },+ "type": {+ "type": "string"+ }+ }+ },"types.ItemCreate": {"type": "object","properties": {@@ -1185,9 +1434,6 @@ const docTemplate = `{"description": {"type": "string"},- "groupId": {- "type": "string"- },"id": {"type": "string"},@@ -1214,9 +1460,6 @@ const docTemplate = `{"description": {"type": "string"},- "groupId": {- "type": "string"- },"id": {"type": "string"},diff --git a/backend/app/api/docs/swagger.json b/backend/app/api/docs/swagger.jsonindex 3d56184c..87ae6363 100644--- a/backend/app/api/docs/swagger.json+++ b/backend/app/api/docs/swagger.json@@ -216,6 +216,222 @@}}},+ "/v1/items/{id}/attachments": {+ "post": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "Items"+ ],+ "summary": "imports items into the database",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "file",+ "description": "File attachment",+ "name": "file",+ "in": "formData",+ "required": true+ },+ {+ "type": "string",+ "description": "Type of file",+ "name": "type",+ "in": "formData",+ "required": true+ },+ {+ "type": "string",+ "description": "name of the file including extension",+ "name": "name",+ "in": "formData",+ "required": true+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/types.ItemOut"+ }+ },+ "422": {+ "description": "Unprocessable Entity",+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/definitions/server.ValidationError"+ }+ }+ }+ }+ }+ },+ "/v1/items/{id}/attachments/download": {+ "get": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "produces": [+ "application/octet-stream"+ ],+ "tags": [+ "Items"+ ],+ "summary": "retrieves an attachment for an item",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "string",+ "description": "Attachment token",+ "name": "token",+ "in": "query",+ "required": true+ }+ ],+ "responses": {+ "200": {+ "description": ""+ }+ }+ }+ },+ "/v1/items/{id}/attachments/{attachment_id}": {+ "get": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "produces": [+ "application/octet-stream"+ ],+ "tags": [+ "Items"+ ],+ "summary": "retrieves an attachment for an item",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "string",+ "description": "Attachment ID",+ "name": "attachment_id",+ "in": "path",+ "required": true+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/types.ItemAttachmentToken"+ }+ }+ }+ },+ "put": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "tags": [+ "Items"+ ],+ "summary": "retrieves an attachment for an item",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "string",+ "description": "Attachment ID",+ "name": "attachment_id",+ "in": "path",+ "required": true+ },+ {+ "description": "Attachment Update",+ "name": "payload",+ "in": "body",+ "required": true,+ "schema": {+ "$ref": "#/definitions/types.ItemAttachmentUpdate"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/types.ItemOut"+ }+ }+ }+ },+ "delete": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "tags": [+ "Items"+ ],+ "summary": "retrieves an attachment for an item",+ "parameters": [+ {+ "type": "string",+ "description": "Item ID",+ "name": "id",+ "in": "path",+ "required": true+ },+ {+ "type": "string",+ "description": "Attachment ID",+ "name": "attachment_id",+ "in": "path",+ "required": true+ }+ ],+ "responses": {+ "204": {+ "description": ""+ }+ }+ }+ },"/v1/labels": {"get": {"security": [@@ -810,6 +1026,17 @@}}},+ "server.ValidationError": {+ "type": "object",+ "properties": {+ "field": {+ "type": "string"+ },+ "reason": {+ "type": "string"+ }+ }+ },"types.ApiSummary": {"type": "object","properties": {@@ -873,11 +1100,33 @@"id": {"type": "string"},+ "type": {+ "type": "string"+ },"updatedAt": {"type": "string"}}},+ "types.ItemAttachmentToken": {+ "type": "object",+ "properties": {+ "token": {+ "type": "string"+ }+ }+ },+ "types.ItemAttachmentUpdate": {+ "type": "object",+ "properties": {+ "title": {+ "type": "string"+ },+ "type": {+ "type": "string"+ }+ }+ },"types.ItemCreate": {"type": "object","properties": {@@ -1177,9 +1426,6 @@"description": {"type": "string"},- "groupId": {- "type": "string"- },"id": {"type": "string"},@@ -1206,9 +1452,6 @@"description": {"type": "string"},- "groupId": {- "type": "string"- },"id": {"type": "string"},diff --git a/backend/app/api/docs/swagger.yaml b/backend/app/api/docs/swagger.yamlindex 10cb3589..17490318 100644--- a/backend/app/api/docs/swagger.yaml+++ b/backend/app/api/docs/swagger.yaml@@ -14,6 +14,13 @@ definitions:items:type: anytype: object+ server.ValidationError:+ properties:+ field:+ type: string+ reason:+ type: string+ type: objecttypes.ApiSummary:properties:build:@@ -55,9 +62,23 @@ definitions:$ref: '#/definitions/types.DocumentOut'id:type: string+ type:+ type: stringupdatedAt:type: stringtype: object+ types.ItemAttachmentToken:+ properties:+ token:+ type: string+ type: object+ types.ItemAttachmentUpdate:+ properties:+ title:+ type: string+ type:+ type: string+ type: objecttypes.ItemCreate:properties:description:@@ -264,8 +285,6 @@ definitions:type: stringdescription:type: string- groupId:- type: stringid:type: stringitems:@@ -283,8 +302,6 @@ definitions:type: stringdescription:type: string- groupId:- type: stringid:type: stringname:@@ -503,6 +520,143 @@ paths:summary: updates a itemtags:- Items+ /v1/items/{id}/attachments:+ post:+ parameters:+ - description: Item ID+ in: path+ name: id+ required: true+ type: string+ - description: File attachment+ in: formData+ name: file+ required: true+ type: file+ - description: Type of file+ in: formData+ name: type+ required: true+ type: string+ - description: name of the file including extension+ in: formData+ name: name+ required: true+ type: string+ produces:+ - application/json+ responses:+ "200":+ description: OK+ schema:+ $ref: '#/definitions/types.ItemOut'+ "422":+ description: Unprocessable Entity+ schema:+ items:+ $ref: '#/definitions/server.ValidationError'+ type: array+ security:+ - Bearer: []+ summary: imports items into the database+ tags:+ - Items+ /v1/items/{id}/attachments/{attachment_id}:+ delete:+ parameters:+ - description: Item ID+ in: path+ name: id+ required: true+ type: string+ - description: Attachment ID+ in: path+ name: attachment_id+ required: true+ type: string+ responses:+ "204":+ description: ""+ security:+ - Bearer: []+ summary: retrieves an attachment for an item+ tags:+ - Items+ get:+ parameters:+ - description: Item ID+ in: path+ name: id+ required: true+ type: string+ - description: Attachment ID+ in: path+ name: attachment_id+ required: true+ type: string+ produces:+ - application/octet-stream+ responses:+ "200":+ description: OK+ schema:+ $ref: '#/definitions/types.ItemAttachmentToken'+ security:+ - Bearer: []+ summary: retrieves an attachment for an item+ tags:+ - Items+ put:+ parameters:+ - description: Item ID+ in: path+ name: id+ required: true+ type: string+ - description: Attachment ID+ in: path+ name: attachment_id+ required: true+ type: string+ - description: Attachment Update+ in: body+ name: payload+ required: true+ schema:+ $ref: '#/definitions/types.ItemAttachmentUpdate'+ responses:+ "200":+ description: OK+ schema:+ $ref: '#/definitions/types.ItemOut'+ security:+ - Bearer: []+ summary: retrieves an attachment for an item+ tags:+ - Items+ /v1/items/{id}/attachments/download:+ get:+ parameters:+ - description: Item ID+ in: path+ name: id+ required: true+ type: string+ - description: Attachment token+ in: query+ name: token+ required: true+ type: string+ produces:+ - application/octet-stream+ responses:+ "200":+ description: ""+ security:+ - Bearer: []+ summary: retrieves an attachment for an item+ tags:+ - Items/v1/items/import:post:parameters:diff --git a/backend/app/api/logger.go b/backend/app/api/logger.goindex f0cfee4b..6756ffc8 100644--- a/backend/app/api/logger.go+++ b/backend/app/api/logger.go@@ -4,7 +4,7 @@ import ("os""strings"- "github.com/hay-kot/content/backend/internal/config"+ "github.com/hay-kot/homebox/backend/internal/config""github.com/rs/zerolog""github.com/rs/zerolog/log")diff --git a/backend/app/api/main.go b/backend/app/api/main.goindex b1b90eb7..5d233e73 100644--- a/backend/app/api/main.go+++ b/backend/app/api/main.go@@ -5,12 +5,12 @@ import ("os""time"- "github.com/hay-kot/content/backend/app/api/docs"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/config"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/pkgs/server"+ "github.com/hay-kot/homebox/backend/app/api/docs"+ "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/pkgs/server"_ "github.com/mattn/go-sqlite3""github.com/rs/zerolog/log")@@ -37,10 +37,6 @@ func main() {path = os.Args[1]}- if path == "" {- log.Warn().Msg("No configuration detected, using defaults")- }-cfg, err := config.NewConfig(path)if err != nil {panic(err)@@ -55,17 +51,22 @@ func main() {func run(cfg *config.Config) error {app := new(cfg)-app.setupLogger()+// =========================================================================// Initialize Database & Repos- c, err := ent.Open(cfg.Database.GetDriver(), cfg.Database.GetUrl())+ err := os.MkdirAll(cfg.Storage.Data, 0755)+ if err != nil {+ log.Fatal().Err(err).Msg("failed to create data directory")+ }++ c, err := ent.Open("sqlite3", cfg.Storage.SqliteUrl)if err != nil {log.Fatal().Err(err).- Str("driver", cfg.Database.GetDriver()).- Str("url", cfg.Database.GetUrl()).+ Str("driver", "sqlite").+ Str("url", cfg.Storage.SqliteUrl).Msg("failed opening connection to sqlite")}defer func(c *ent.Client) {@@ -74,12 +75,14 @@ func run(cfg *config.Config) error {if err := c.Schema.Create(context.Background()); err != nil {log.Fatal().Err(err).+ Str("driver", "sqlite").+ Str("url", cfg.Storage.SqliteUrl).Msg("failed creating schema resources")}app.db = capp.repos = repo.EntAllRepos(c)- app.services = services.NewServices(app.repos)+ app.services = services.NewServices(app.repos, cfg.Storage.Data)// =========================================================================// Start Serverdiff --git a/backend/app/api/middleware.go b/backend/app/api/middleware.goindex aec49176..53f70bb5 100644--- a/backend/app/api/middleware.go+++ b/backend/app/api/middleware.go@@ -8,9 +8,9 @@ import ("github.com/go-chi/chi/v5""github.com/go-chi/chi/v5/middleware"- "github.com/hay-kot/content/backend/internal/config"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/pkgs/server"+ "github.com/hay-kot/homebox/backend/internal/config"+ "github.com/hay-kot/homebox/backend/internal/services"+ "github.com/hay-kot/homebox/backend/pkgs/server""github.com/rs/zerolog/log")diff --git a/backend/app/api/routes.go b/backend/app/api/routes.goindex a82a3835..1ed16684 100644--- a/backend/app/api/routes.go+++ b/backend/app/api/routes.go@@ -11,10 +11,10 @@ import ("path/filepath""github.com/go-chi/chi/v5"- _ "github.com/hay-kot/content/backend/app/api/docs"- v1 "github.com/hay-kot/content/backend/app/api/v1"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/types"+ _ "github.com/hay-kot/homebox/backend/app/api/docs"+ v1 "github.com/hay-kot/homebox/backend/app/api/v1"+ "github.com/hay-kot/homebox/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/rs/zerolog/log"httpSwagger "github.com/swaggo/http-swagger" // http-swagger middleware)@@ -43,7 +43,7 @@ func (a *app) newRouter(repos *repo.AllRepos) *chi.Mux {// API Version 1v1Base := v1.BaseUrlFunc(prefix)- v1Ctrl := v1.NewControllerV1(a.services)+ v1Ctrl := v1.NewControllerV1(a.services, v1.WithMaxUploadSize(a.conf.Web.MaxUploadSize)){r.Get(v1Base("/status"), v1Ctrl.HandleBase(func() bool { return true }, types.Build{Version: Version,@@ -54,6 +54,10 @@ func (a *app) newRouter(repos *repo.AllRepos) *chi.Mux {r.Post(v1Base("/users/register"), v1Ctrl.HandleUserRegistration())r.Post(v1Base("/users/login"), v1Ctrl.HandleAuthLogin())+ // Attachment download URl needs a `token` query param to be passed in the request.+ // and also needs to be outside of the `auth` middleware.+ r.Get(v1Base("/items/{id}/attachments/download"), v1Ctrl.HandleItemAttachmentDownload())+r.Group(func(r chi.Router) {r.Use(a.mwAuthToken)r.Get(v1Base("/users/self"), v1Ctrl.HandleUserSelf())@@ -81,6 +85,11 @@ func (a *app) newRouter(repos *repo.AllRepos) *chi.Mux {r.Get(v1Base("/items/{id}"), v1Ctrl.HandleItemGet())r.Put(v1Base("/items/{id}"), v1Ctrl.HandleItemUpdate())r.Delete(v1Base("/items/{id}"), v1Ctrl.HandleItemDelete())++ r.Post(v1Base("/items/{id}/attachments"), v1Ctrl.HandleItemAttachmentCreate())+ r.Get(v1Base("/items/{id}/attachments/{attachment_id}"), v1Ctrl.HandleItemAttachmentToken())+ r.Put(v1Base("/items/{id}/attachments/{attachment_id}"), v1Ctrl.HandleItemAttachmentUpdate())+ r.Delete(v1Base("/items/{id}/attachments/{attachment_id}"), v1Ctrl.HandleItemAttachmentDelete())})}diff --git a/backend/app/api/v1/controller.go b/backend/app/api/v1/controller.goindex dda2e208..ac135efa 100644--- a/backend/app/api/v1/controller.go+++ b/backend/app/api/v1/controller.go@@ -3,13 +3,20 @@ package v1import ("net/http"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/server"+ "github.com/hay-kot/homebox/backend/internal/services"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/server")+func WithMaxUploadSize(maxUploadSize int64) func(*V1Controller) {+ return func(ctrl *V1Controller) {+ ctrl.maxUploadSize = maxUploadSize+ }+}+type V1Controller struct {- svc *services.AllServices+ svc *services.AllServices+ maxUploadSize int64}func BaseUrlFunc(prefix string) func(s string) string {@@ -21,7 +28,7 @@ func BaseUrlFunc(prefix string) func(s string) string {return prefixFunc}-func NewControllerV1(svc *services.AllServices) *V1Controller {+func NewControllerV1(svc *services.AllServices, options ...func(*V1Controller)) *V1Controller {ctrl := &V1Controller{svc: svc,}diff --git a/backend/app/api/v1/controller_test.go b/backend/app/api/v1/controller_test.goindex de8a73eb..6f555bb4 100644--- a/backend/app/api/v1/controller_test.go+++ b/backend/app/api/v1/controller_test.go@@ -5,7 +5,7 @@ import ("net/http/httptest""testing"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/stretchr/testify/assert")diff --git a/backend/app/api/v1/main_test.go b/backend/app/api/v1/main_test.goindex 408a6418..ee08ccd5 100644--- a/backend/app/api/v1/main_test.go+++ b/backend/app/api/v1/main_test.go@@ -4,10 +4,10 @@ import ("context""testing"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/mocks"- "github.com/hay-kot/content/backend/internal/mocks/factories"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/mocks"+ "github.com/hay-kot/homebox/backend/internal/mocks/factories"+ "github.com/hay-kot/homebox/backend/internal/types")var mockHandler = &V1Controller{}diff --git a/backend/app/api/v1/partials.go b/backend/app/api/v1/partials.goindex 7fe0cbf7..195ce8b8 100644--- a/backend/app/api/v1/partials.go+++ b/backend/app/api/v1/partials.go@@ -5,9 +5,9 @@ import ("github.com/go-chi/chi/v5""github.com/google/uuid"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/server"+ "github.com/hay-kot/homebox/backend/internal/services"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/server""github.com/rs/zerolog/log")diff --git a/backend/app/api/v1/v1_ctrl_auth.go b/backend/app/api/v1/v1_ctrl_auth.goindex 851a6381..2a446645 100644--- a/backend/app/api/v1/v1_ctrl_auth.go+++ b/backend/app/api/v1/v1_ctrl_auth.go@@ -4,9 +4,9 @@ import ("errors""net/http"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/server"+ "github.com/hay-kot/homebox/backend/internal/services"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/server""github.com/rs/zerolog/log")diff --git a/backend/app/api/v1/v1_ctrl_items.go b/backend/app/api/v1/v1_ctrl_items.goindex 23a0d924..7de278ed 100644--- a/backend/app/api/v1/v1_ctrl_items.go+++ b/backend/app/api/v1/v1_ctrl_items.go@@ -4,9 +4,9 @@ import ("encoding/csv""net/http"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/server"+ "github.com/hay-kot/homebox/backend/internal/services"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/server""github.com/rs/zerolog/log")@@ -64,7 +64,7 @@ func (ctrl *V1Controller) HandleItemsCreate() http.HandlerFunc {// @Summary deletes a item// @Tags Items// @Produce json-// @Param id path string true "Item ID"+// @Param id path string true "Item ID"// @Success 204// @Router /v1/items/{id} [DELETE]// @Security Bearer@@ -114,7 +114,7 @@ func (ctrl *V1Controller) HandleItemGet() http.HandlerFunc {// @Summary updates a item// @Tags Items// @Produce json-// @Param id path string true "Item ID"+// @Param id path string true "Item ID"// @Param payload body types.ItemUpdate true "Item Data"// @Success 200 {object} types.ItemOut// @Router /v1/items/{id} [PUT]diff --git a/backend/app/api/v1/v1_ctrl_items_attachments.go b/backend/app/api/v1/v1_ctrl_items_attachments.gonew file mode 100644index 00000000..b373eade--- /dev/null+++ b/backend/app/api/v1/v1_ctrl_items_attachments.go@@ -0,0 +1,237 @@+package v1++import (+ "errors"+ "fmt"+ "net/http"+ "path/filepath"++ "github.com/go-chi/chi/v5"+ "github.com/google/uuid"+ "github.com/hay-kot/homebox/backend/ent/attachment"+ "github.com/hay-kot/homebox/backend/internal/services"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/server"+ "github.com/rs/zerolog/log"+)++// HandleItemsImport godocs+// @Summary imports items into the database+// @Tags Items+// @Produce json+// @Param id path string true "Item ID"+// @Param file formData file true "File attachment"+// @Param type formData string true "Type of file"+// @Param name formData string true "name of the file including extension"+// @Success 200 {object} types.ItemOut+// @Failure 422 {object} []server.ValidationError+// @Router /v1/items/{id}/attachments [POST]+// @Security Bearer+func (ctrl *V1Controller) HandleItemAttachmentCreate() http.HandlerFunc {+ return func(w http.ResponseWriter, r *http.Request) {+ err := r.ParseMultipartForm(ctrl.maxUploadSize << 20)+ if err != nil {+ log.Err(err).Msg("failed to parse multipart form")+ server.RespondError(w, http.StatusBadRequest, errors.New("failed to parse multipart form"))+ return+ }++ errs := make(server.ValidationErrors, 0)++ file, _, err := r.FormFile("file")+ if err != nil {+ switch {+ case errors.Is(err, http.ErrMissingFile):+ log.Debug().Msg("file for attachment is missing")+ errs = errs.Append("file", "file is required")+ default:+ log.Err(err).Msg("failed to get file from form")+ server.RespondServerError(w)+ return+ }+ }++ attachmentName := r.FormValue("name")+ if attachmentName == "" {+ log.Debug().Msg("failed to get name from form")+ errs = errs.Append("name", "name is required")+ }++ if errs.HasErrors() {+ server.Respond(w, http.StatusUnprocessableEntity, errs)+ return+ }++ attachmentType := r.FormValue("type")+ if attachmentType == "" {+ attachmentType = attachment.TypeAttachment.String()+ }++ id, _, err := ctrl.partialParseIdAndUser(w, r)+ if err != nil {+ return+ }++ ctx := services.NewContext(r.Context())++ item, err := ctrl.svc.Items.AttachmentAdd(+ ctx,+ id,+ attachmentName,+ attachment.Type(attachmentType),+ file,+ )++ if err != nil {+ log.Err(err).Msg("failed to add attachment")+ server.RespondServerError(w)+ return+ }++ server.Respond(w, http.StatusCreated, item)+ }+}++// HandleItemAttachmentGet godocs+// @Summary retrieves an attachment for an item+// @Tags Items+// @Produce application/octet-stream+// @Param id path string true "Item ID"+// @Param token query string true "Attachment token"+// @Success 200+// @Router /v1/items/{id}/attachments/download [GET]+// @Security Bearer+func (ctrl *V1Controller) HandleItemAttachmentDownload() http.HandlerFunc {+ return func(w http.ResponseWriter, r *http.Request) {+ token := server.GetParam(r, "token", "")++ path, err := ctrl.svc.Items.AttachmentPath(r.Context(), token)++ if err != nil {+ log.Err(err).Msg("failed to get attachment")+ server.RespondServerError(w)+ return+ }++ w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filepath.Base(path)))+ w.Header().Set("Content-Type", "application/octet-stream")+ http.ServeFile(w, r, path)+ }+}++// HandleItemAttachmentToken godocs+// @Summary retrieves an attachment for an item+// @Tags Items+// @Produce application/octet-stream+// @Param id path string true "Item ID"+// @Param attachment_id path string true "Attachment ID"+// @Success 200 {object} types.ItemAttachmentToken+// @Router /v1/items/{id}/attachments/{attachment_id} [GET]+// @Security Bearer+func (ctrl *V1Controller) HandleItemAttachmentToken() http.HandlerFunc {+ return ctrl.handleItemAttachmentsHandler+}++// HandleItemAttachmentDelete godocs+// @Summary retrieves an attachment for an item+// @Tags Items+// @Param id path string true "Item ID"+// @Param attachment_id path string true "Attachment ID"+// @Success 204+// @Router /v1/items/{id}/attachments/{attachment_id} [DELETE]+// @Security Bearer+func (ctrl *V1Controller) HandleItemAttachmentDelete() http.HandlerFunc {+ return ctrl.handleItemAttachmentsHandler+}++// HandleItemAttachmentUpdate godocs+// @Summary retrieves an attachment for an item+// @Tags Items+// @Param id path string true "Item ID"+// @Param attachment_id path string true "Attachment ID"+// @Param payload body types.ItemAttachmentUpdate true "Attachment Update"+// @Success 200 {object} types.ItemOut+// @Router /v1/items/{id}/attachments/{attachment_id} [PUT]+// @Security Bearer+func (ctrl *V1Controller) HandleItemAttachmentUpdate() http.HandlerFunc {+ return ctrl.handleItemAttachmentsHandler+}++func (ctrl *V1Controller) handleItemAttachmentsHandler(w http.ResponseWriter, r *http.Request) {+ uid, user, err := ctrl.partialParseIdAndUser(w, r)+ if err != nil {+ return+ }++ attachmentId, err := uuid.Parse(chi.URLParam(r, "attachment_id"))+ if err != nil {+ log.Err(err).Msg("failed to parse attachment_id param")+ server.RespondError(w, http.StatusBadRequest, err)+ return+ }++ ctx := services.NewContext(r.Context())++ switch r.Method {++ // Token Handler+ case http.MethodGet:+ token, err := ctrl.svc.Items.AttachmentToken(ctx, uid, attachmentId)+ if err != nil {+ switch err {+ case services.ErrNotFound:+ log.Err(err).+ Str("id", attachmentId.String()).+ Msg("failed to find attachment with id")++ server.RespondError(w, http.StatusNotFound, err)++ case services.ErrFileNotFound:+ log.Err(err).+ Str("id", attachmentId.String()).+ Msg("failed to find file path for attachment with id")+ log.Warn().Msg("attachment with no file path removed from database")++ server.RespondError(w, http.StatusNotFound, err)++ default:+ log.Err(err).Msg("failed to get attachment")+ server.RespondServerError(w)+ return+ }+ }++ server.Respond(w, http.StatusOK, types.ItemAttachmentToken{Token: token})++ // Delete Attachment Handler+ case http.MethodDelete:+ err = ctrl.svc.Items.AttachmentDelete(r.Context(), user.GroupID, uid, attachmentId)+ if err != nil {+ log.Err(err).Msg("failed to delete attachment")+ server.RespondServerError(w)+ return+ }++ server.Respond(w, http.StatusNoContent, nil)++ // Update Attachment Handler+ case http.MethodPut:+ var attachment types.ItemAttachmentUpdate+ err = server.Decode(r, &attachment)+ if err != nil {+ log.Err(err).Msg("failed to decode attachment")+ server.RespondError(w, http.StatusBadRequest, err)+ return+ }++ attachment.ID = attachmentId+ val, err := ctrl.svc.Items.AttachmentUpdate(ctx, uid, &attachment)+ if err != nil {+ log.Err(err).Msg("failed to delete attachment")+ server.RespondServerError(w)+ return+ }++ server.Respond(w, http.StatusOK, val)+ }+}diff --git a/backend/app/api/v1/v1_ctrl_labels.go b/backend/app/api/v1/v1_ctrl_labels.goindex 359d3853..38bd6669 100644--- a/backend/app/api/v1/v1_ctrl_labels.go+++ b/backend/app/api/v1/v1_ctrl_labels.go@@ -3,10 +3,10 @@ package v1import ("net/http"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/server"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/services"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/server""github.com/rs/zerolog/log")diff --git a/backend/app/api/v1/v1_ctrl_locations.go b/backend/app/api/v1/v1_ctrl_locations.goindex 38de8729..6126d3d0 100644--- a/backend/app/api/v1/v1_ctrl_locations.go+++ b/backend/app/api/v1/v1_ctrl_locations.go@@ -3,10 +3,10 @@ package v1import ("net/http"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/server"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/services"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/server""github.com/rs/zerolog/log")diff --git a/backend/app/api/v1/v1_ctrl_user.go b/backend/app/api/v1/v1_ctrl_user.goindex f7c4de66..0a4b7c7f 100644--- a/backend/app/api/v1/v1_ctrl_user.go+++ b/backend/app/api/v1/v1_ctrl_user.go@@ -4,9 +4,9 @@ import ("net/http""github.com/google/uuid"- "github.com/hay-kot/content/backend/internal/services"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/server"+ "github.com/hay-kot/homebox/backend/internal/services"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/server""github.com/rs/zerolog/log")diff --git a/backend/config.template.yml b/backend/config.template.ymldeleted file mode 100644index 7ee50a62..00000000--- a/backend/config.template.yml+++ /dev/null@@ -1,19 +0,0 @@-----mode: development-swagger:- host: localhost:7745- scheme: http-web:- port: 7745- host: ""-database:- driver: sqlite3- sqlite-url: ./homebox.db?_fk=1-logger:- level: debug-mailer:- host: smtp.example.com- port: 465- username:- password:- from: [email protected]diff --git a/backend/ent/attachment.go b/backend/ent/attachment.goindex b22b8db4..8e703417 100644--- a/backend/ent/attachment.go+++ b/backend/ent/attachment.go@@ -9,9 +9,9 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/attachment"+ "github.com/hay-kot/homebox/backend/ent/document"+ "github.com/hay-kot/homebox/backend/ent/item")// Attachment is the model entity for the Attachment schema.diff --git a/backend/ent/attachment/where.go b/backend/ent/attachment/where.goindex c6019492..e898d495 100644--- a/backend/ent/attachment/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/attachment_create.go b/backend/ent/attachment_create.goindex fdce24b6..75d6cecc 100644--- a/backend/ent/attachment_create.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/attachment"+ "github.com/hay-kot/homebox/backend/ent/document"+ "github.com/hay-kot/homebox/backend/ent/item")// AttachmentCreate is the builder for creating a Attachment entity.diff --git a/backend/ent/attachment_delete.go b/backend/ent/attachment_delete.goindex 0b858cc2..a1cda49a 100644--- a/backend/ent/attachment_delete.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/attachment"+ "github.com/hay-kot/homebox/backend/ent/predicate")// AttachmentDelete is the builder for deleting a Attachment entity.diff --git a/backend/ent/attachment_query.go b/backend/ent/attachment_query.goindex f6570575..d088cce8 100644--- a/backend/ent/attachment_query.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// AttachmentQuery is the builder for querying Attachment entities.diff --git a/backend/ent/attachment_update.go b/backend/ent/attachment_update.goindex 53b5feb6..1801c221 100644--- a/backend/ent/attachment_update.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// AttachmentUpdate is the builder for updating Attachment entities.diff --git a/backend/ent/authtokens.go b/backend/ent/authtokens.goindex 94784d8a..24731d52 100644--- a/backend/ent/authtokens.go+++ b/backend/ent/authtokens.go@@ -9,8 +9,8 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/authtokens"+ "github.com/hay-kot/homebox/backend/ent/user")// AuthTokens is the model entity for the AuthTokens schema.diff --git a/backend/ent/authtokens/where.go b/backend/ent/authtokens/where.goindex 015b4af5..edb237bc 100644--- a/backend/ent/authtokens/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/authtokens_create.go b/backend/ent/authtokens_create.goindex 4336c2b4..491711ab 100644--- a/backend/ent/authtokens_create.go+++ b/backend/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/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/authtokens"+ "github.com/hay-kot/homebox/backend/ent/user")// AuthTokensCreate is the builder for creating a AuthTokens entity.diff --git a/backend/ent/authtokens_delete.go b/backend/ent/authtokens_delete.goindex 682f0d53..7b861223 100644--- a/backend/ent/authtokens_delete.go+++ b/backend/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/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/authtokens"+ "github.com/hay-kot/homebox/backend/ent/predicate")// AuthTokensDelete is the builder for deleting a AuthTokens entity.diff --git a/backend/ent/authtokens_query.go b/backend/ent/authtokens_query.goindex 38fa9c57..d1484e63 100644--- a/backend/ent/authtokens_query.go+++ b/backend/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/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/predicate"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/authtokens"+ "github.com/hay-kot/homebox/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/user")// AuthTokensQuery is the builder for querying AuthTokens entities.diff --git a/backend/ent/authtokens_update.go b/backend/ent/authtokens_update.goindex 0c64f162..11e06f25 100644--- a/backend/ent/authtokens_update.go+++ b/backend/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/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/predicate"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/authtokens"+ "github.com/hay-kot/homebox/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/user")// AuthTokensUpdate is the builder for updating AuthTokens entities.diff --git a/backend/ent/client.go b/backend/ent/client.goindex fd397926..63c91ac0 100644--- a/backend/ent/client.go+++ b/backend/ent/client.go@@ -9,18 +9,18 @@ import ("log""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/migrate"-- "github.com/hay-kot/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/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/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""entgo.io/ent/dialect""entgo.io/ent/dialect/sql"diff --git a/backend/ent/document.go b/backend/ent/document.goindex 14a33caa..aef3bc29 100644--- a/backend/ent/document.go+++ b/backend/ent/document.go@@ -9,8 +9,8 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/document"+ "github.com/hay-kot/homebox/backend/ent/group")// Document is the model entity for the Document schema.diff --git a/backend/ent/document/where.go b/backend/ent/document/where.goindex f859293a..c4efce5d 100644--- a/backend/ent/document/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/document_create.go b/backend/ent/document_create.goindex ea98c1e6..4411e16c 100644--- a/backend/ent/document_create.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/group"+ "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")// DocumentCreate is the builder for creating a Document entity.diff --git a/backend/ent/document_delete.go b/backend/ent/document_delete.goindex 2b5f19a6..06ccaf1f 100644--- a/backend/ent/document_delete.go+++ b/backend/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/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/document"+ "github.com/hay-kot/homebox/backend/ent/predicate")// DocumentDelete is the builder for deleting a Document entity.diff --git a/backend/ent/document_query.go b/backend/ent/document_query.goindex 0739e026..1f430790 100644--- a/backend/ent/document_query.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// DocumentQuery is the builder for querying Document entities.diff --git a/backend/ent/document_update.go b/backend/ent/document_update.goindex 6aab168d..fb1b9710 100644--- a/backend/ent/document_update.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// DocumentUpdate is the builder for updating Document entities.diff --git a/backend/ent/documenttoken.go b/backend/ent/documenttoken.goindex c3b0a9e8..c4de9a5b 100644--- a/backend/ent/documenttoken.go+++ b/backend/ent/documenttoken.go@@ -9,8 +9,8 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"+ "github.com/hay-kot/homebox/backend/ent/document"+ "github.com/hay-kot/homebox/backend/ent/documenttoken")// DocumentToken is the model entity for the DocumentToken schema.diff --git a/backend/ent/documenttoken/where.go b/backend/ent/documenttoken/where.goindex 918b975a..9975a336 100644--- a/backend/ent/documenttoken/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/documenttoken_create.go b/backend/ent/documenttoken_create.goindex 65908b60..b4585d58 100644--- a/backend/ent/documenttoken_create.go+++ b/backend/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/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"+ "github.com/hay-kot/homebox/backend/ent/document"+ "github.com/hay-kot/homebox/backend/ent/documenttoken")// DocumentTokenCreate is the builder for creating a DocumentToken entity.diff --git a/backend/ent/documenttoken_delete.go b/backend/ent/documenttoken_delete.goindex bc8f4888..fa9b7a11 100644--- a/backend/ent/documenttoken_delete.go+++ b/backend/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/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/documenttoken"+ "github.com/hay-kot/homebox/backend/ent/predicate")// DocumentTokenDelete is the builder for deleting a DocumentToken entity.diff --git a/backend/ent/documenttoken_query.go b/backend/ent/documenttoken_query.goindex bd48c10e..f0c21989 100644--- a/backend/ent/documenttoken_query.go+++ b/backend/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/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/document"+ "github.com/hay-kot/homebox/backend/ent/documenttoken"+ "github.com/hay-kot/homebox/backend/ent/predicate")// DocumentTokenQuery is the builder for querying DocumentToken entities.diff --git a/backend/ent/documenttoken_update.go b/backend/ent/documenttoken_update.goindex e4586bed..dc77dcc5 100644--- a/backend/ent/documenttoken_update.go+++ b/backend/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/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/document"+ "github.com/hay-kot/homebox/backend/ent/documenttoken"+ "github.com/hay-kot/homebox/backend/ent/predicate")// DocumentTokenUpdate is the builder for updating DocumentToken entities.diff --git a/backend/ent/ent.go b/backend/ent/ent.goindex 997c25ed..03647593 100644--- a/backend/ent/ent.go+++ b/backend/ent/ent.go@@ -10,16 +10,16 @@ import ("entgo.io/ent""entgo.io/ent/dialect/sql""entgo.io/ent/dialect/sql/sqlgraph"- "github.com/hay-kot/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/user"+ "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/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")// ent aliases to avoid import conflicts in user's code.diff --git a/backend/ent/enttest/enttest.go b/backend/ent/enttest/enttest.goindex b14ee608..ee46d3da 100644--- a/backend/ent/enttest/enttest.go+++ b/backend/ent/enttest/enttest.go@@ -5,12 +5,12 @@ package enttestimport ("context"- "github.com/hay-kot/content/backend/ent"+ "github.com/hay-kot/homebox/backend/ent"// required by schema hooks.- _ "github.com/hay-kot/content/backend/ent/runtime"+ _ "github.com/hay-kot/homebox/backend/ent/runtime""entgo.io/ent/dialect/sql/schema"- "github.com/hay-kot/content/backend/ent/migrate"+ "github.com/hay-kot/homebox/backend/ent/migrate")type (diff --git a/backend/ent/group.go b/backend/ent/group.goindex 39f38ca7..65d956a5 100644--- a/backend/ent/group.go+++ b/backend/ent/group.go@@ -9,7 +9,7 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/group")// Group is the model entity for the Group schema.diff --git a/backend/ent/group/where.go b/backend/ent/group/where.goindex f6c759da..04f7ec88 100644--- a/backend/ent/group/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/group_create.go b/backend/ent/group_create.goindex a72eefe9..86080f2c 100644--- a/backend/ent/group_create.go+++ b/backend/ent/group_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/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/document"+ "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/location"+ "github.com/hay-kot/homebox/backend/ent/user")// GroupCreate is the builder for creating a Group entity.diff --git a/backend/ent/group_delete.go b/backend/ent/group_delete.goindex a15128fe..23dfa0c1 100644--- a/backend/ent/group_delete.go+++ b/backend/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/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/predicate")// GroupDelete is the builder for deleting a Group entity.diff --git a/backend/ent/group_query.go b/backend/ent/group_query.goindex cb3a1c62..e82f725b 100644--- a/backend/ent/group_query.go+++ b/backend/ent/group_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/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/predicate"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/document"+ "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/location"+ "github.com/hay-kot/homebox/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/user")// GroupQuery is the builder for querying Group entities.diff --git a/backend/ent/group_update.go b/backend/ent/group_update.goindex 4ebf7093..0c607089 100644--- a/backend/ent/group_update.go+++ b/backend/ent/group_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/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/predicate"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/document"+ "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/location"+ "github.com/hay-kot/homebox/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/user")// GroupUpdate is the builder for updating Group entities.diff --git a/backend/ent/hook/hook.go b/backend/ent/hook/hook.goindex 095e9294..fe2ec6d7 100644--- a/backend/ent/hook/hook.go+++ b/backend/ent/hook/hook.go@@ -6,7 +6,7 @@ import ("context""fmt"- "github.com/hay-kot/content/backend/ent"+ "github.com/hay-kot/homebox/backend/ent")// The AttachmentFunc type is an adapter to allow the use of ordinarydiff --git a/backend/ent/item.go b/backend/ent/item.goindex d2d6a6a0..b58cbd25 100644--- a/backend/ent/item.go+++ b/backend/ent/item.go@@ -9,9 +9,9 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/location"+ "github.com/hay-kot/homebox/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/location")// Item is the model entity for the Item schema.diff --git a/backend/ent/item/where.go b/backend/ent/item/where.goindex 258af9b8..6cec8316 100644--- a/backend/ent/item/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/item_create.go b/backend/ent/item_create.goindex e2290999..1ad1837f 100644--- a/backend/ent/item_create.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"+ "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")// ItemCreate is the builder for creating a Item entity.diff --git a/backend/ent/item_delete.go b/backend/ent/item_delete.goindex 9fea4856..1f8b6f8b 100644--- a/backend/ent/item_delete.go+++ b/backend/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/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ItemDelete is the builder for deleting a Item entity.diff --git a/backend/ent/item_query.go b/backend/ent/item_query.goindex a922b5bd..70ea7d49 100644--- a/backend/ent/item_query.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// ItemQuery is the builder for querying Item entities.diff --git a/backend/ent/item_update.go b/backend/ent/item_update.goindex d2a691d9..ef31b2a6 100644--- a/backend/ent/item_update.go+++ b/backend/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/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// ItemUpdate is the builder for updating Item entities.diff --git a/backend/ent/itemfield.go b/backend/ent/itemfield.goindex 9dfbf651..d252ec98 100644--- a/backend/ent/itemfield.go+++ b/backend/ent/itemfield.go@@ -9,8 +9,8 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"+ "github.com/hay-kot/homebox/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/itemfield")// ItemField is the model entity for the ItemField schema.diff --git a/backend/ent/itemfield/where.go b/backend/ent/itemfield/where.goindex e319aa60..ebe4b61d 100644--- a/backend/ent/itemfield/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/itemfield_create.go b/backend/ent/itemfield_create.goindex 3e01a89b..ad9fd96a 100644--- a/backend/ent/itemfield_create.go+++ b/backend/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/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"+ "github.com/hay-kot/homebox/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/itemfield")// ItemFieldCreate is the builder for creating a ItemField entity.diff --git a/backend/ent/itemfield_delete.go b/backend/ent/itemfield_delete.goindex 2db4de38..e5ba38f1 100644--- a/backend/ent/itemfield_delete.go+++ b/backend/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/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/itemfield"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ItemFieldDelete is the builder for deleting a ItemField entity.diff --git a/backend/ent/itemfield_query.go b/backend/ent/itemfield_query.goindex d26cfcfb..ac1b9e3d 100644--- a/backend/ent/itemfield_query.go+++ b/backend/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/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/itemfield"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ItemFieldQuery is the builder for querying ItemField entities.diff --git a/backend/ent/itemfield_update.go b/backend/ent/itemfield_update.goindex 1ba66dfb..cac8fed5 100644--- a/backend/ent/itemfield_update.go+++ b/backend/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/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/itemfield"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ItemFieldUpdate is the builder for updating ItemField entities.diff --git a/backend/ent/label.go b/backend/ent/label.goindex a010753a..39420f4c 100644--- a/backend/ent/label.go+++ b/backend/ent/label.go@@ -9,8 +9,8 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/label"+ "github.com/hay-kot/homebox/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/label")// Label is the model entity for the Label schema.diff --git a/backend/ent/label/where.go b/backend/ent/label/where.goindex 01d0f2d1..e01eea7a 100644--- a/backend/ent/label/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/label_create.go b/backend/ent/label_create.goindex 65db3c6f..7330747c 100644--- a/backend/ent/label_create.go+++ b/backend/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/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/label"+ "github.com/hay-kot/homebox/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/label")// LabelCreate is the builder for creating a Label entity.diff --git a/backend/ent/label_delete.go b/backend/ent/label_delete.goindex e9eb6bc5..aef8be05 100644--- a/backend/ent/label_delete.go+++ b/backend/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/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/label"+ "github.com/hay-kot/homebox/backend/ent/predicate")// LabelDelete is the builder for deleting a Label entity.diff --git a/backend/ent/label_query.go b/backend/ent/label_query.goindex b54aa583..80b4af51 100644--- a/backend/ent/label_query.go+++ b/backend/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/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// LabelQuery is the builder for querying Label entities.diff --git a/backend/ent/label_update.go b/backend/ent/label_update.goindex 8135a567..ef0af158 100644--- a/backend/ent/label_update.go+++ b/backend/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/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// LabelUpdate is the builder for updating Label entities.diff --git a/backend/ent/location.go b/backend/ent/location.goindex 42221521..e0c95176 100644--- a/backend/ent/location.go+++ b/backend/ent/location.go@@ -9,8 +9,8 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/location"+ "github.com/hay-kot/homebox/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/location")// Location is the model entity for the Location schema.diff --git a/backend/ent/location/where.go b/backend/ent/location/where.goindex 625a0386..f72c16da 100644--- a/backend/ent/location/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/location_create.go b/backend/ent/location_create.goindex a468ce96..df6a88e9 100644--- a/backend/ent/location_create.go+++ b/backend/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/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/location"+ "github.com/hay-kot/homebox/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/item"+ "github.com/hay-kot/homebox/backend/ent/location")// LocationCreate is the builder for creating a Location entity.diff --git a/backend/ent/location_delete.go b/backend/ent/location_delete.goindex 5ec513b3..8bc6db37 100644--- a/backend/ent/location_delete.go+++ b/backend/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/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/location"+ "github.com/hay-kot/homebox/backend/ent/predicate")// LocationDelete is the builder for deleting a Location entity.diff --git a/backend/ent/location_query.go b/backend/ent/location_query.goindex 447ed9f3..5edd2d2b 100644--- a/backend/ent/location_query.go+++ b/backend/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/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// LocationQuery is the builder for querying Location entities.diff --git a/backend/ent/location_update.go b/backend/ent/location_update.goindex 05065584..064634c2 100644--- a/backend/ent/location_update.go+++ b/backend/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/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/predicate"+ "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")// LocationUpdate is the builder for updating Location entities.diff --git a/backend/ent/mutation.go b/backend/ent/mutation.goindex ed69d150..bbd71a59 100644--- a/backend/ent/mutation.go+++ b/backend/ent/mutation.go@@ -10,17 +10,17 @@ import ("time""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/predicate"- "github.com/hay-kot/content/backend/ent/user"+ "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/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""entgo.io/ent")diff --git a/backend/ent/runtime.go b/backend/ent/runtime.goindex a82fb103..6414b695 100644--- a/backend/ent/runtime.go+++ b/backend/ent/runtime.go@@ -6,17 +6,17 @@ import ("time""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/ent/itemfield"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/ent/schema"- "github.com/hay-kot/content/backend/ent/user"+ "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/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")// The init function reads all schema descriptors with runtime codediff --git a/backend/ent/runtime/runtime.go b/backend/ent/runtime/runtime.goindex f07467e3..e0a57180 100644--- a/backend/ent/runtime/runtime.go+++ b/backend/ent/runtime/runtime.go@@ -2,7 +2,7 @@package runtime-// The schema-stitching logic is generated in github.com/hay-kot/content/backend/ent/runtime.go+// The schema-stitching logic is generated in github.com/hay-kot/homebox/backend/ent/runtime.goconst (Version = "v0.11.2" // Version of ent codegen.diff --git a/backend/ent/schema/attachment.go b/backend/ent/schema/attachment.goindex b0adb8c1..4a13ba82 100644--- a/backend/ent/schema/attachment.go+++ b/backend/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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// Attachment holds the schema definition for the Attachment entity.diff --git a/backend/ent/schema/auth_tokens.go b/backend/ent/schema/auth_tokens.goindex 9063581b..41beafa4 100644--- a/backend/ent/schema/auth_tokens.go+++ b/backend/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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// AuthTokens holds the schema definition for the AuthTokens entity.diff --git a/backend/ent/schema/document.go b/backend/ent/schema/document.goindex 9797b0ff..f6b2c575 100644--- a/backend/ent/schema/document.go+++ b/backend/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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// Document holds the schema definition for the Document entity.diff --git a/backend/ent/schema/document_token.go b/backend/ent/schema/document_token.goindex 8a4d10ad..74239960 100644--- a/backend/ent/schema/document_token.go+++ b/backend/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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// DocumentToken holds the schema definition for the DocumentToken entity.diff --git a/backend/ent/schema/group.go b/backend/ent/schema/group.goindex a5c863e9..97237ca3 100644--- a/backend/ent/schema/group.go+++ b/backend/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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// Group holds the schema definition for the Group entity.diff --git a/backend/ent/schema/item.go b/backend/ent/schema/item.goindex 127f8d85..9728fd81 100644--- a/backend/ent/schema/item.go+++ b/backend/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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// Item holds the schema definition for the Item entity.diff --git a/backend/ent/schema/item_field.go b/backend/ent/schema/item_field.goindex e5d157c7..56be98a3 100644--- a/backend/ent/schema/item_field.go+++ b/backend/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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// ItemField holds the schema definition for the ItemField entity.diff --git a/backend/ent/schema/label.go b/backend/ent/schema/label.goindex 7f60552e..7f65d55e 100644--- a/backend/ent/schema/label.go+++ b/backend/ent/schema/label.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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// Label holds the schema definition for the Label entity.diff --git a/backend/ent/schema/location.go b/backend/ent/schema/location.goindex 42069834..74e0abba 100644--- a/backend/ent/schema/location.go+++ b/backend/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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// Location holds the schema definition for the Location entity.diff --git a/backend/ent/schema/user.go b/backend/ent/schema/user.goindex 6fe72b6c..b058b20b 100644--- a/backend/ent/schema/user.go+++ b/backend/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/content/backend/ent/schema/mixins"+ "github.com/hay-kot/homebox/backend/ent/schema/mixins")// User holds the schema definition for the User entity.diff --git a/backend/ent/user.go b/backend/ent/user.goindex b3387f48..ff21fa16 100644--- a/backend/ent/user.go+++ b/backend/ent/user.go@@ -9,8 +9,8 @@ import ("entgo.io/ent/dialect/sql""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/user")// User is the model entity for the User schema.diff --git a/backend/ent/user/where.go b/backend/ent/user/where.goindex b7b468c7..d020d3bd 100644--- a/backend/ent/user/where.go+++ b/backend/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/content/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/predicate")// ID filters vertices based on their ID field.diff --git a/backend/ent/user_create.go b/backend/ent/user_create.goindex c0f4c251..51c81515 100644--- a/backend/ent/user_create.go+++ b/backend/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/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/authtokens"+ "github.com/hay-kot/homebox/backend/ent/group"+ "github.com/hay-kot/homebox/backend/ent/user")// UserCreate is the builder for creating a User entity.diff --git a/backend/ent/user_delete.go b/backend/ent/user_delete.goindex cb23cc32..6d8b9492 100644--- a/backend/ent/user_delete.go+++ b/backend/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/content/backend/ent/predicate"- "github.com/hay-kot/content/backend/ent/user"+ "github.com/hay-kot/homebox/backend/ent/predicate"+ "github.com/hay-kot/homebox/backend/ent/user")// UserDelete is the builder for deleting a User entity.diff --git a/backend/ent/user_query.go b/backend/ent/user_query.goindex 8dc24612..f83e90ff 100644--- a/backend/ent/user_query.go+++ b/backend/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/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/predicate"- "github.com/hay-kot/content/backend/ent/user"+ "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")// UserQuery is the builder for querying User entities.diff --git a/backend/ent/user_update.go b/backend/ent/user_update.goindex 1cccc6f2..7d9bbadc 100644--- a/backend/ent/user_update.go+++ b/backend/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/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/predicate"- "github.com/hay-kot/content/backend/ent/user"+ "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")// UserUpdate is the builder for updating User entities.diff --git a/backend/go.mod b/backend/go.modindex 0d9d4eb6..18f63b6c 100644--- a/backend/go.mod+++ b/backend/go.mod@@ -1,4 +1,4 @@-module github.com/hay-kot/content/backend+module github.com/hay-kot/homebox/backendgo 1.19diff --git a/backend/internal/config/conf.go b/backend/internal/config/conf.goindex d9ffe0c4..7d63ea81 100644--- a/backend/internal/config/conf.go+++ b/backend/internal/config/conf.go@@ -17,12 +17,12 @@ const ()type Config struct {- Mode string `yaml:"mode" conf:"default:development"` // development or production- Web WebConfig `yaml:"web"`- Database Database `yaml:"database"`- Log LoggerConf `yaml:"logger"`- Mailer MailerConf `yaml:"mailer"`- Swagger SwaggerConf `yaml:"swagger"`+ Mode string `yaml:"mode" conf:"default:development"` // development or production+ Web WebConfig `yaml:"web"`+ Storage Storage `yaml:"storage"`+ Log LoggerConf `yaml:"logger"`+ Mailer MailerConf `yaml:"mailer"`+ Swagger SwaggerConf `yaml:"swagger"`}type SwaggerConf struct {@@ -31,8 +31,9 @@ type SwaggerConf struct {}type WebConfig struct {- Port string `yaml:"port" conf:"default:7745"`- Host string `yaml:"host"`+ Port string `yaml:"port" conf:"default:7745"`+ Host string `yaml:"host"`+ MaxUploadSize int64 `yaml:"max_file_upload" conf:"default:10"`}// NewConfig parses the CLI/Config file and returns a Config struct. If the file argument is an empty string, thediff --git a/backend/internal/config/conf_database.go b/backend/internal/config/conf_database.goindex 7b396bdb..047d5d25 100644--- a/backend/internal/config/conf_database.go+++ b/backend/internal/config/conf_database.go@@ -4,20 +4,8 @@ const (DriverSqlite3 = "sqlite3")-type Database struct {- Driver string `yaml:"driver" conf:"default:sqlite3"`- SqliteUrl string `yaml:"sqlite-url" conf:"default:file:ent?mode=memory&cache=shared&_fk=1"`-}--func (d *Database) GetDriver() string {- return d.Driver-}--func (d *Database) GetUrl() string {- switch d.Driver {- case DriverSqlite3:- return d.SqliteUrl- default:- panic("unknown database driver")- }+type Storage struct {+ // Data is the path to the root directory+ Data string `yaml:"data" conf:"default:./homebox-data"`+ SqliteUrl string `yaml:"sqlite-url" conf:"default:./homebox-data/homebox.db?_fk=1"`}diff --git a/backend/internal/config/conf_database_test.go b/backend/internal/config/conf_database_test.godeleted file mode 100644index f11c21cb..00000000--- a/backend/internal/config/conf_database_test.go+++ /dev/null@@ -1,26 +0,0 @@-package config--import (- "testing"-- "github.com/stretchr/testify/assert"-)--func Test_DatabaseConfig_Sqlite(t *testing.T) {- dbConf := &Database{- Driver: DriverSqlite3,- SqliteUrl: "file:ent?mode=memory&cache=shared&_fk=1",- }-- assert.Equal(t, "sqlite3", dbConf.GetDriver())- assert.Equal(t, "file:ent?mode=memory&cache=shared&_fk=1", dbConf.GetUrl())-}--func Test_DatabaseConfig_Unknown(t *testing.T) {- dbConf := &Database{- Driver: "null",- }-- assert.Panics(t, func() { dbConf.GetUrl() })--}diff --git a/backend/internal/mocks/factories/users.go b/backend/internal/mocks/factories/users.goindex 12657687..4f9389d6 100644--- a/backend/internal/mocks/factories/users.go+++ b/backend/internal/mocks/factories/users.go@@ -1,8 +1,8 @@package factoriesimport (- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/faker"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/faker")func UserFactory() types.UserCreate {diff --git a/backend/internal/mocks/mocker_services.go b/backend/internal/mocks/mocker_services.goindex e44b4640..d1e80bdd 100644--- a/backend/internal/mocks/mocker_services.go+++ b/backend/internal/mocks/mocker_services.go@@ -1,10 +1,10 @@package mocksimport (- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/services"+ "github.com/hay-kot/homebox/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/internal/services")func GetMockServices(repos *repo.AllRepos) *services.AllServices {- return services.NewServices(repos)+ return services.NewServices(repos, "/tmp/homebox")}diff --git a/backend/internal/mocks/mocks_ent_repo.go b/backend/internal/mocks/mocks_ent_repo.goindex e0b7e816..4b7abcc6 100644--- a/backend/internal/mocks/mocks_ent_repo.go+++ b/backend/internal/mocks/mocks_ent_repo.go@@ -3,8 +3,8 @@ package mocksimport ("context"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/repo"_ "github.com/mattn/go-sqlite3")diff --git a/backend/internal/repo/main_test.go b/backend/internal/repo/main_test.goindex 5644178a..14bfbd86 100644--- a/backend/internal/repo/main_test.go+++ b/backend/internal/repo/main_test.go@@ -8,8 +8,8 @@ import ("testing""time"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/pkgs/faker"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/pkgs/faker"_ "github.com/mattn/go-sqlite3")diff --git a/backend/internal/repo/repo_documents.go b/backend/internal/repo/repo_documents.goindex 9cb4c0f2..e91b9a62 100644--- a/backend/internal/repo/repo_documents.go+++ b/backend/internal/repo/repo_documents.go@@ -4,10 +4,10 @@ import ("context""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/document"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/internal/types"+ "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/types")// DocumentRepository is a repository for Document entitydiff --git a/backend/internal/repo/repo_documents_test.go b/backend/internal/repo/repo_documents_test.goindex 187ca0f6..df5cd7b7 100644--- a/backend/internal/repo/repo_documents_test.go+++ b/backend/internal/repo/repo_documents_test.go@@ -5,8 +5,8 @@ import ("testing""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/stretchr/testify/assert")diff --git a/backend/internal/repo/repo_documents_tokens.go b/backend/internal/repo/repo_documents_tokens.goindex 7c260c45..1924f1dc 100644--- a/backend/internal/repo/repo_documents_tokens.go+++ b/backend/internal/repo/repo_documents_tokens.go@@ -5,9 +5,9 @@ import ("time""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/ent/documenttoken"+ "github.com/hay-kot/homebox/backend/internal/types")// DocumentTokensRepository is a repository for Document entitydiff --git a/backend/internal/repo/repo_documents_tokens_test.go b/backend/internal/repo/repo_documents_tokens_test.goindex 7106253f..ebd84edb 100644--- a/backend/internal/repo/repo_documents_tokens_test.go+++ b/backend/internal/repo/repo_documents_tokens_test.go@@ -6,9 +6,9 @@ import ("time""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/documenttoken"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/ent/documenttoken"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/stretchr/testify/assert")diff --git a/backend/internal/repo/repo_group.go b/backend/internal/repo/repo_group.goindex c5c173ec..dfc7e070 100644--- a/backend/internal/repo/repo_group.go+++ b/backend/internal/repo/repo_group.go@@ -4,7 +4,7 @@ import ("context""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"+ "github.com/hay-kot/homebox/backend/ent")type GroupRepository struct {diff --git a/backend/internal/repo/repo_item_attachments.go b/backend/internal/repo/repo_item_attachments.goindex f21bb7ef..76b06d67 100644--- a/backend/internal/repo/repo_item_attachments.go+++ b/backend/internal/repo/repo_item_attachments.go@@ -4,8 +4,8 @@ import ("context""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/attachment"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/ent/attachment")// AttachmentRepo is a repository for Attachments table that links Items to Documents@@ -34,9 +34,15 @@ func (r *AttachmentRepo) Get(ctx context.Context, id uuid.UUID) (*ent.Attachment}func (r *AttachmentRepo) Update(ctx context.Context, itemId uuid.UUID, typ attachment.Type) (*ent.Attachment, error) {- return r.db.Attachment.UpdateOneID(itemId).+ itm, err := r.db.Attachment.UpdateOneID(itemId).SetType(typ).Save(ctx)++ if err != nil {+ return nil, err+ }++ return r.Get(ctx, itm.ID)}func (r *AttachmentRepo) Delete(ctx context.Context, id uuid.UUID) error {diff --git a/backend/internal/repo/repo_item_attachments_test.go b/backend/internal/repo/repo_item_attachments_test.goindex 0165b8ec..e8610018 100644--- a/backend/internal/repo/repo_item_attachments_test.go+++ b/backend/internal/repo/repo_item_attachments_test.go@@ -5,8 +5,8 @@ import ("testing""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/attachment"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/ent/attachment""github.com/stretchr/testify/assert")diff --git a/backend/internal/repo/repo_items.go b/backend/internal/repo/repo_items.goindex 8a95a222..ab7cd8e2 100644--- a/backend/internal/repo/repo_items.go+++ b/backend/internal/repo/repo_items.go@@ -4,10 +4,10 @@ import ("context""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/item"- "github.com/hay-kot/content/backend/internal/types"+ "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/internal/types")type ItemsRepository struct {diff --git a/backend/internal/repo/repo_items_test.go b/backend/internal/repo/repo_items_test.goindex 631f7cb9..5917afed 100644--- a/backend/internal/repo/repo_items_test.go+++ b/backend/internal/repo/repo_items_test.go@@ -6,8 +6,8 @@ import ("time""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/stretchr/testify/assert")diff --git a/backend/internal/repo/repo_labels.go b/backend/internal/repo/repo_labels.goindex bbdcfb14..12780680 100644--- a/backend/internal/repo/repo_labels.go+++ b/backend/internal/repo/repo_labels.go@@ -4,10 +4,10 @@ import ("context""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/group"- "github.com/hay-kot/content/backend/ent/label"- "github.com/hay-kot/content/backend/internal/types"+ "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/internal/types")type LabelRepository struct {diff --git a/backend/internal/repo/repo_labels_test.go b/backend/internal/repo/repo_labels_test.goindex 137376af..4c9753aa 100644--- a/backend/internal/repo/repo_labels_test.go+++ b/backend/internal/repo/repo_labels_test.go@@ -4,8 +4,8 @@ import ("context""testing"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/stretchr/testify/assert")diff --git a/backend/internal/repo/repo_locations.go b/backend/internal/repo/repo_locations.goindex a1ce0557..cb224e2c 100644--- a/backend/internal/repo/repo_locations.go+++ b/backend/internal/repo/repo_locations.go@@ -4,9 +4,9 @@ import ("context""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/location"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/ent/location"+ "github.com/hay-kot/homebox/backend/internal/types")type LocationRepository struct {diff --git a/backend/internal/repo/repo_locations_test.go b/backend/internal/repo/repo_locations_test.goindex 9370305a..6c95c5d9 100644--- a/backend/internal/repo/repo_locations_test.go+++ b/backend/internal/repo/repo_locations_test.go@@ -4,7 +4,7 @@ import ("context""testing"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/stretchr/testify/assert")diff --git a/backend/internal/repo/repo_tokens.go b/backend/internal/repo/repo_tokens.goindex 13d5c723..d452b315 100644--- a/backend/internal/repo/repo_tokens.go+++ b/backend/internal/repo/repo_tokens.go@@ -4,9 +4,9 @@ import ("context""time"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/authtokens"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/ent/authtokens"+ "github.com/hay-kot/homebox/backend/internal/types")type TokenRepository struct {diff --git a/backend/internal/repo/repo_tokens_test.go b/backend/internal/repo/repo_tokens_test.goindex 2ab453a1..a0bc6548 100644--- a/backend/internal/repo/repo_tokens_test.go+++ b/backend/internal/repo/repo_tokens_test.go@@ -5,8 +5,8 @@ import ("testing""time"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/hasher"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/hasher""github.com/stretchr/testify/assert")diff --git a/backend/internal/repo/repo_users.go b/backend/internal/repo/repo_users.goindex f4acaf4a..ad6cd1bf 100644--- a/backend/internal/repo/repo_users.go+++ b/backend/internal/repo/repo_users.go@@ -4,9 +4,9 @@ import ("context""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/ent/user"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/ent/user"+ "github.com/hay-kot/homebox/backend/internal/types")type UserRepository struct {diff --git a/backend/internal/repo/repo_users_test.go b/backend/internal/repo/repo_users_test.goindex f08acb4e..27e3ece0 100644--- a/backend/internal/repo/repo_users_test.go+++ b/backend/internal/repo/repo_users_test.go@@ -5,8 +5,8 @@ import ("fmt""testing"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/stretchr/testify/assert")diff --git a/backend/internal/repo/repos_all.go b/backend/internal/repo/repos_all.goindex e89fe331..c47f5a4f 100644--- a/backend/internal/repo/repos_all.go+++ b/backend/internal/repo/repos_all.go@@ -1,6 +1,6 @@package repo-import "github.com/hay-kot/content/backend/ent"+import "github.com/hay-kot/homebox/backend/ent"// AllRepos is a container for all the repository interfacestype AllRepos struct {diff --git a/backend/internal/services/all.go b/backend/internal/services/all.goindex bba6e438..e255e285 100644--- a/backend/internal/services/all.go+++ b/backend/internal/services/all.go@@ -1,6 +1,6 @@package services-import "github.com/hay-kot/content/backend/internal/repo"+import "github.com/hay-kot/homebox/backend/internal/repo"type AllServices struct {User *UserService@@ -10,7 +10,14 @@ type AllServices struct {Items *ItemService}-func NewServices(repos *repo.AllRepos) *AllServices {+func NewServices(repos *repo.AllRepos, root string) *AllServices {+ if repos == nil {+ panic("repos cannot be nil")+ }+ if root == "" {+ panic("root cannot be empty")+ }+return &AllServices{User: &UserService{repos},Admin: &AdminService{repos},@@ -18,7 +25,8 @@ func NewServices(repos *repo.AllRepos) *AllServices {Labels: &LabelService{repos},Items: &ItemService{repo: repos,- filepath: "/tmp/content",+ filepath: root,+ at: attachmentTokens{},},}}diff --git a/backend/internal/services/contexts.go b/backend/internal/services/contexts.goindex bc18fcce..94a2168d 100644--- a/backend/internal/services/contexts.go+++ b/backend/internal/services/contexts.go@@ -3,7 +3,8 @@ package servicesimport ("context"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/google/uuid"+ "github.com/hay-kot/homebox/backend/internal/types")type contextKeys struct {@@ -15,6 +16,31 @@ var (ContextUserToken = &contextKeys{name: "UserToken"})+type Context struct {+ context.Context++ // UID is a unique identifier for the acting user.+ UID uuid.UUID++ // GID is a unique identifier for the acting users group.+ GID uuid.UUID++ // User is the acting user.+ User *types.UserOut+}++// NewContext is a helper function that returns the service context from the context.+// This extracts the users from the context and embeds it into the ServiceContext struct+func NewContext(ctx context.Context) Context {+ user := UseUserCtx(ctx)+ return Context{+ Context: ctx,+ UID: user.ID,+ GID: user.GroupID,+ User: user,+ }+}+// SetUserCtx is a helper function that sets the ContextUser and ContextUserToken// values within the context of a web request (or any context).func SetUserCtx(ctx context.Context, user *types.UserOut, token string) context.Context {diff --git a/backend/internal/services/contexts_test.go b/backend/internal/services/contexts_test.goindex cf5a8625..bcbf2708 100644--- a/backend/internal/services/contexts_test.go+++ b/backend/internal/services/contexts_test.go@@ -5,7 +5,7 @@ import ("testing""github.com/google/uuid"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/stretchr/testify/assert")diff --git a/backend/internal/services/main_test.go b/backend/internal/services/main_test.goindex c5f35753..df0369fa 100644--- a/backend/internal/services/main_test.go+++ b/backend/internal/services/main_test.go@@ -8,16 +8,17 @@ import ("testing""time"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/faker"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/faker"_ "github.com/mattn/go-sqlite3")var (fk = faker.NewFaker()+ tCtx = Context{}tClient *ent.ClienttRepos *repo.AllRepostUser *ent.User@@ -63,10 +64,16 @@ func TestMain(m *testing.M) {tClient = clienttRepos = repo.EntAllRepos(tClient)- tSvc = NewServices(tRepos)+ tSvc = NewServices(tRepos, "/tmp/homebox")defer client.Close()+bootstrap()+ tCtx = Context{+ Context: context.Background(),+ GID: tGroup.ID,+ UID: tUser.ID,+ }os.Exit(m.Run())}diff --git a/backend/internal/services/mappers/items.go b/backend/internal/services/mappers/items.goindex 7698c864..6b9df8d7 100644--- a/backend/internal/services/mappers/items.go+++ b/backend/internal/services/mappers/items.go@@ -1,8 +1,8 @@package mappersimport (- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/types")func ToItemAttachment(attachment *ent.Attachment) *types.ItemAttachment {@@ -10,6 +10,7 @@ func ToItemAttachment(attachment *ent.Attachment) *types.ItemAttachment {ID: attachment.ID,CreatedAt: attachment.CreatedAt,UpdatedAt: attachment.UpdatedAt,+ Type: attachment.Type.String(),Document: types.DocumentOut{ID: attachment.Edges.Document.ID,Title: attachment.Edges.Document.Title,diff --git a/backend/internal/services/mappers/labels.go b/backend/internal/services/mappers/labels.goindex c5b886b7..a593784f 100644--- a/backend/internal/services/mappers/labels.go+++ b/backend/internal/services/mappers/labels.go@@ -1,8 +1,8 @@package mappersimport (- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/types")func ToLabelSummary(label *ent.Label) *types.LabelSummary {diff --git a/backend/internal/services/mappers/locations.go b/backend/internal/services/mappers/locations.goindex 77f0eff8..6b4bc5fe 100644--- a/backend/internal/services/mappers/locations.go+++ b/backend/internal/services/mappers/locations.go@@ -1,9 +1,9 @@package mappersimport (- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/internal/types")func ToLocationCount(location *repo.LocationWithCount) *types.LocationCount {diff --git a/backend/internal/services/mappers/user.go b/backend/internal/services/mappers/user.goindex 37c702ba..f5736fbb 100644--- a/backend/internal/services/mappers/user.go+++ b/backend/internal/services/mappers/user.go@@ -1,8 +1,8 @@package mappersimport (- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/types")func ToOutUser(user *ent.User, err error) (*types.UserOut, error) {diff --git a/backend/internal/services/service_admin.go b/backend/internal/services/service_admin.goindex 8be4f681..dfc643a0 100644--- a/backend/internal/services/service_admin.go+++ b/backend/internal/services/service_admin.go@@ -4,9 +4,9 @@ import ("context""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/ent"+ "github.com/hay-kot/homebox/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/internal/types")type AdminService struct {diff --git a/backend/internal/services/service_items.go b/backend/internal/services/service_items.goindex 147cb5f9..fc768385 100644--- a/backend/internal/services/service_items.go+++ b/backend/internal/services/service_items.go@@ -2,24 +2,28 @@ package servicesimport ("context"+ "errors""fmt"- "io"- "os"- "path/filepath""github.com/google/uuid"- "github.com/hay-kot/content/backend/ent/attachment"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/services/mappers"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/internal/services/mappers"+ "github.com/hay-kot/homebox/backend/internal/types""github.com/rs/zerolog/log")+var (+ ErrNotFound = errors.New("not found")+ ErrFileNotFound = errors.New("file not found")+)+type ItemService struct {repo *repo.AllRepos- // filepath is the root of the storage location that will be used to store all files from.filepath string+ // at is a map of tokens to attachment IDs. This is used to store the attachment ID+ // for issued URLs+ at attachmentTokens}func (svc *ItemService) GetOne(ctx context.Context, gid uuid.UUID, id uuid.UUID) (*types.ItemOut, error) {@@ -94,59 +98,6 @@ func (svc *ItemService) Update(ctx context.Context, gid uuid.UUID, data types.Itreturn mappers.ToItemOut(item), nil}-func (svc *ItemService) attachmentPath(gid, itemId uuid.UUID, filename string) string {- return filepath.Join(svc.filepath, gid.String(), itemId.String(), filename)-}--// AddAttachment adds an attachment to an item by creating an entry in the Documents table and linking it to the Attachment-// Table and Items table. The file provided via the reader is stored on the file system based on the provided-// relative path during construction of the service.-func (svc *ItemService) AddAttachment(ctx context.Context, gid, itemId uuid.UUID, filename string, file io.Reader) (*types.ItemOut, error) {- // Get the Item- item, err := svc.repo.Items.GetOne(ctx, itemId)- if err != nil {- return nil, err- }-- if item.Edges.Group.ID != gid {- return nil, ErrNotOwner- }-- // Create the document- doc, err := svc.repo.Docs.Create(ctx, gid, types.DocumentCreate{- Title: filename,- Path: svc.attachmentPath(gid, itemId, filename),- })- if err != nil {- return nil, err- }-- // Create the attachment- _, err = svc.repo.Attachments.Create(ctx, itemId, doc.ID, attachment.TypeAttachment)- if err != nil {- return nil, err- }-- // Read the contents and write them to a file on the file system- err = os.MkdirAll(filepath.Dir(doc.Path), os.ModePerm)- if err != nil {- return nil, err- }-- f, err := os.Create(doc.Path)- if err != nil {- log.Err(err).Msg("failed to create file")- return nil, err- }-- _, err = io.Copy(f, file)- if err != nil {- return nil, err- }-- return svc.GetOne(ctx, gid, itemId)-}-func (svc *ItemService) CsvImport(ctx context.Context, gid uuid.UUID, data [][]string) error {loaded := []csvRow{}diff --git a/backend/internal/services/service_items_attachments.go b/backend/internal/services/service_items_attachments.gonew file mode 100644index 00000000..9969ee94--- /dev/null+++ b/backend/internal/services/service_items_attachments.go@@ -0,0 +1,199 @@+package services++import (+ "context"+ "io"+ "os"+ "path/filepath"+ "time"++ "github.com/google/uuid"+ "github.com/hay-kot/homebox/backend/ent/attachment"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/hasher"+ "github.com/hay-kot/homebox/backend/pkgs/pathlib"+ "github.com/rs/zerolog/log"+)++// TODO: this isn't a scalable solution, tokens should be stored in the database+type attachmentTokens map[string]uuid.UUID++func (at attachmentTokens) Add(token string, id uuid.UUID) {+ at[token] = id++ log.Debug().Str("token", token).Str("uuid", id.String()).Msg("added token")++ go func() {+ ch := time.After(1 * time.Minute)+ <-ch+ at.Delete(token)+ log.Debug().Str("token", token).Msg("deleted token")+ }()+}++func (at attachmentTokens) Get(token string) (uuid.UUID, bool) {+ id, ok := at[token]+ return id, ok+}++func (at attachmentTokens) Delete(token string) {+ delete(at, token)+}++func (svc *ItemService) AttachmentToken(ctx Context, itemId, attachmentId uuid.UUID) (string, error) {+ item, err := svc.repo.Items.GetOne(ctx, itemId)+ if err != nil {+ return "", err+ }+ if item.Edges.Group.ID != ctx.GID {+ return "", ErrNotOwner+ }++ token := hasher.GenerateToken()++ // Ensure that the file exists+ attachment, err := svc.repo.Attachments.Get(ctx, attachmentId)+ if err != nil {+ return "", err+ }++ if _, err := os.Stat(attachment.Edges.Document.Path); os.IsNotExist(err) {+ _ = svc.AttachmentDelete(ctx, ctx.GID, itemId, attachmentId)+ return "", ErrNotFound+ }++ svc.at.Add(token.Raw, attachmentId)++ return token.Raw, nil+}++func (svc *ItemService) attachmentPath(gid, itemId uuid.UUID, filename string) string {+ path := filepath.Join(svc.filepath, gid.String(), itemId.String(), filename)+ path = pathlib.Safe(path)+ log.Debug().Str("path", path).Msg("attachment path")+ return path+}++func (svc *ItemService) AttachmentPath(ctx context.Context, token string) (string, error) {+ attachmentId, ok := svc.at.Get(token)+ if !ok {+ return "", ErrNotFound+ }++ attachment, err := svc.repo.Attachments.Get(ctx, attachmentId)+ if err != nil {+ return "", err+ }++ return attachment.Edges.Document.Path, nil+}++func (svc *ItemService) AttachmentUpdate(ctx Context, itemId uuid.UUID, data *types.ItemAttachmentUpdate) (*types.ItemOut, error) {+ // Update Properties+ attachment, err := svc.repo.Attachments.Update(ctx, data.ID, attachment.Type(data.Type))+ if err != nil {+ return nil, err+ }++ attDoc := attachment.Edges.Document++ if data.Title != attachment.Edges.Document.Title {+ newPath := pathlib.Safe(svc.attachmentPath(ctx.GID, itemId, data.Title))++ // Move File+ err = os.Rename(attachment.Edges.Document.Path, newPath)+ if err != nil {+ return nil, err+ }++ _, err = svc.repo.Docs.Update(ctx, attDoc.ID, types.DocumentUpdate{+ Title: data.Title,+ Path: newPath,+ })+ if err != nil {+ return nil, err+ }+ }++ return svc.GetOne(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+// Table and Items table. The file provided via the reader is stored on the file system based on the provided+// relative path during construction of the service.+func (svc *ItemService) AttachmentAdd(ctx Context, itemId uuid.UUID, filename string, attachmentType attachment.Type, file io.Reader) (*types.ItemOut, error) {+ // Get the Item+ item, err := svc.repo.Items.GetOne(ctx, itemId)+ if err != nil {+ return nil, err+ }++ if item.Edges.Group.ID != ctx.GID {+ return nil, ErrNotOwner+ }++ fp := svc.attachmentPath(ctx.GID, itemId, filename)+ filename = filepath.Base(fp)++ // Create the document+ doc, err := svc.repo.Docs.Create(ctx, ctx.GID, types.DocumentCreate{+ Title: filename,+ Path: fp,+ })+ if err != nil {+ return nil, err+ }++ // Create the attachment+ _, err = svc.repo.Attachments.Create(ctx, itemId, doc.ID, attachmentType)+ if err != nil {+ return nil, err+ }++ // Read the contents and write them to a file on the file system+ err = os.MkdirAll(filepath.Dir(doc.Path), os.ModePerm)+ if err != nil {+ return nil, err+ }++ f, err := os.Create(doc.Path)+ if err != nil {+ log.Err(err).Msg("failed to create file")+ return nil, err+ }++ _, err = io.Copy(f, file)+ if err != nil {+ return nil, err+ }++ return svc.GetOne(ctx, ctx.GID, itemId)+}++func (svc *ItemService) AttachmentDelete(ctx context.Context, gid, itemId, attachmentId uuid.UUID) error {+ // Get the Item+ item, err := svc.repo.Items.GetOne(ctx, itemId)+ if err != nil {+ return err+ }++ if item.Edges.Group.ID != gid {+ return ErrNotOwner+ }++ attachment, err := svc.repo.Attachments.Get(ctx, attachmentId)+ if err != nil {+ return err+ }++ // Delete the attachment+ err = svc.repo.Attachments.Delete(ctx, attachmentId)+ if err != nil {+ return err+ }++ // Remove File+ err = os.Remove(attachment.Edges.Document.Path)++ return err+}diff --git a/backend/internal/services/service_items_attachments_test.go b/backend/internal/services/service_items_attachments_test.gonew file mode 100644index 00000000..71f9b603--- /dev/null+++ b/backend/internal/services/service_items_attachments_test.go@@ -0,0 +1,62 @@+package services++import (+ "context"+ "os"+ "path"+ "strings"+ "testing"++ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/stretchr/testify/assert"+)++func TestItemService_AddAttachment(t *testing.T) {+ temp := os.TempDir()++ svc := &ItemService{+ repo: tRepos,+ filepath: temp,+ }++ loc, err := tSvc.Location.Create(context.Background(), tGroup.ID, types.LocationCreate{+ Description: "test",+ Name: "test",+ })+ assert.NoError(t, err)+ assert.NotNil(t, loc)++ itmC := types.ItemCreate{+ Name: fk.Str(10),+ Description: fk.Str(10),+ LocationID: loc.ID,+ }++ itm, err := svc.Create(context.Background(), tGroup.ID, itmC)+ assert.NoError(t, err)+ assert.NotNil(t, itm)+ t.Cleanup(func() {+ err := svc.repo.Items.Delete(context.Background(), itm.ID)+ assert.NoError(t, err)+ })++ contents := fk.Str(1000)+ reader := strings.NewReader(contents)++ // Setup+ afterAttachment, err := svc.AttachmentAdd(tCtx, itm.ID, "testfile.txt", "attachment", reader)+ assert.NoError(t, err)+ assert.NotNil(t, afterAttachment)++ // Check that the file exists+ storedPath := afterAttachment.Attachments[0].Document.Path++ // {root}/{group}/{item}/{attachment}+ assert.Equal(t, path.Join(temp, tGroup.ID.String(), itm.ID.String(), "testfile.txt"), storedPath)++ // Check that the file contents are correct+ bts, err := os.ReadFile(storedPath)+ assert.NoError(t, err)+ assert.Equal(t, contents, string(bts))++}diff --git a/backend/internal/services/service_items_csv.go b/backend/internal/services/service_items_csv.goindex ed8e5a46..e1d1a960 100644--- a/backend/internal/services/service_items_csv.go+++ b/backend/internal/services/service_items_csv.go@@ -6,7 +6,7 @@ import ("strings""time"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/internal/types")var ErrInvalidCsv = errors.New("invalid csv")diff --git a/backend/internal/services/service_items_test.go b/backend/internal/services/service_items_test.goindex b71a74ed..5a215089 100644--- a/backend/internal/services/service_items_test.go+++ b/backend/internal/services/service_items_test.go@@ -2,13 +2,9 @@ package servicesimport ("context"- "os"- "path"- "strings""testing""github.com/google/uuid"- "github.com/hay-kot/content/backend/internal/types""github.com/stretchr/testify/assert")@@ -92,53 +88,3 @@ func TestItemService_CsvImport(t *testing.T) {}}}--func TestItemService_AddAttachment(t *testing.T) {- temp := os.TempDir()-- svc := &ItemService{- repo: tRepos,- filepath: temp,- }-- loc, err := tSvc.Location.Create(context.Background(), tGroup.ID, types.LocationCreate{- Description: "test",- Name: "test",- })- assert.NoError(t, err)- assert.NotNil(t, loc)-- itmC := types.ItemCreate{- Name: fk.Str(10),- Description: fk.Str(10),- LocationID: loc.ID,- }-- itm, err := svc.Create(context.Background(), tGroup.ID, itmC)- assert.NoError(t, err)- assert.NotNil(t, itm)- t.Cleanup(func() {- err := svc.repo.Items.Delete(context.Background(), itm.ID)- assert.NoError(t, err)- })-- contents := fk.Str(1000)- reader := strings.NewReader(contents)-- // Setup- afterAttachment, err := svc.AddAttachment(context.Background(), tGroup.ID, itm.ID, "testfile.txt", reader)- assert.NoError(t, err)- assert.NotNil(t, afterAttachment)-- // Check that the file exists- storedPath := afterAttachment.Attachments[0].Document.Path-- // {root}/{group}/{item}/{attachment}- assert.Equal(t, path.Join(temp, tGroup.ID.String(), itm.ID.String(), "testfile.txt"), storedPath)-- // Check that the file contents are correct- bts, err := os.ReadFile(storedPath)- assert.NoError(t, err)- assert.Equal(t, contents, string(bts))--}diff --git a/backend/internal/services/service_labels.go b/backend/internal/services/service_labels.goindex 70bfa30f..5a284e7a 100644--- a/backend/internal/services/service_labels.go+++ b/backend/internal/services/service_labels.go@@ -4,9 +4,9 @@ import ("context""github.com/google/uuid"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/services/mappers"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/internal/services/mappers"+ "github.com/hay-kot/homebox/backend/internal/types")type LabelService struct {diff --git a/backend/internal/services/service_locations.go b/backend/internal/services/service_locations.goindex 30db743c..2349f6b6 100644--- a/backend/internal/services/service_locations.go+++ b/backend/internal/services/service_locations.go@@ -5,9 +5,9 @@ import ("errors""github.com/google/uuid"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/services/mappers"- "github.com/hay-kot/content/backend/internal/types"+ "github.com/hay-kot/homebox/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/internal/services/mappers"+ "github.com/hay-kot/homebox/backend/internal/types")var (diff --git a/backend/internal/services/service_user.go b/backend/internal/services/service_user.goindex b5ced214..8d1abcf2 100644--- a/backend/internal/services/service_user.go+++ b/backend/internal/services/service_user.go@@ -6,10 +6,10 @@ import ("time""github.com/google/uuid"- "github.com/hay-kot/content/backend/internal/repo"- "github.com/hay-kot/content/backend/internal/services/mappers"- "github.com/hay-kot/content/backend/internal/types"- "github.com/hay-kot/content/backend/pkgs/hasher"+ "github.com/hay-kot/homebox/backend/internal/repo"+ "github.com/hay-kot/homebox/backend/internal/services/mappers"+ "github.com/hay-kot/homebox/backend/internal/types"+ "github.com/hay-kot/homebox/backend/pkgs/hasher")var (diff --git a/backend/internal/services/service_user_defaults.go b/backend/internal/services/service_user_defaults.goindex 185c7823..2b5cbbe9 100644--- a/backend/internal/services/service_user_defaults.go+++ b/backend/internal/services/service_user_defaults.go@@ -1,6 +1,6 @@package services-import "github.com/hay-kot/content/backend/internal/types"+import "github.com/hay-kot/homebox/backend/internal/types"func defaultLocations() []types.LocationCreate {return []types.LocationCreate{diff --git a/backend/internal/types/item_types.go b/backend/internal/types/item_types.goindex ae682aef..d86696fa 100644--- a/backend/internal/types/item_types.go+++ b/backend/internal/types/item_types.go@@ -103,5 +103,16 @@ type ItemAttachment struct {ID uuid.UUID `json:"id"`CreatedAt time.Time `json:"createdAt"`UpdatedAt time.Time `json:"updatedAt"`+ Type string `json:"type"`Document DocumentOut `json:"document"`}++type ItemAttachmentToken struct {+ Token string `json:"token"`+}++type ItemAttachmentUpdate struct {+ ID uuid.UUID `json:"-"`+ Type string `json:"type"`+ Title string `json:"title"`+}diff --git a/backend/internal/types/label_types.go b/backend/internal/types/label_types.goindex 301a3fdb..725361c5 100644--- a/backend/internal/types/label_types.go+++ b/backend/internal/types/label_types.go@@ -21,7 +21,6 @@ type LabelUpdate struct {type LabelSummary struct {ID uuid.UUID `json:"id"`- GroupID uuid.UUID `json:"groupId"`Name string `json:"name"`Description string `json:"description"`CreatedAt time.Time `json:"createdAt"`diff --git a/backend/pkgs/pathlib/pathlib.go b/backend/pkgs/pathlib/pathlib.gonew file mode 100644index 00000000..24420aaa--- /dev/null+++ b/backend/pkgs/pathlib/pathlib.go@@ -0,0 +1,64 @@+package pathlib++import (+ "fmt"+ "os"+ "path/filepath"+ "strings"+)++type dirReaderFunc func(name string) []string++var dirReader dirReaderFunc = func(directory string) []string {+ f, err := os.Open(directory)+ if err != nil {+ return nil+ }+ defer f.Close()++ names, err := f.Readdirnames(-1)+ if err != nil {+ return nil+ }+ return names+}++func hasConflict(path string, neighbors []string) bool {+ filename := strings.ToLower(filepath.Base(path))++ for _, n := range neighbors {+ if strings.ToLower(n) == filename {+ return true+ }+ }+ return false+}++// Safe will take a destination path and return a validated path that is safe to use.+// without overwriting any existing files. If a conflict exists, it will append a number+// to the end of the file name. If the parent directory does not exist this function will+// return the original path.+func Safe(path string) string {+ parent := filepath.Dir(path)++ neighbors := dirReader(parent)+ if neighbors == nil {+ return path+ }++ if hasConflict(path, neighbors) {+ ext := filepath.Ext(path)++ name := strings.TrimSuffix(filepath.Base(path), ext)++ for i := 1; i < 1000; i++ {+ newName := fmt.Sprintf("%s (%d)%s", name, i, ext)+ newPath := filepath.Join(parent, newName)+ if !hasConflict(newPath, neighbors) {+ return newPath+ }+ }+ }++ return path+}diff --git a/backend/pkgs/pathlib/pathlib_test.go b/backend/pkgs/pathlib/pathlib_test.gonew file mode 100644index 00000000..193c4ab6--- /dev/null+++ b/backend/pkgs/pathlib/pathlib_test.go@@ -0,0 +1,94 @@+package pathlib++import (+ "testing"+)++func Test_hasConflict(t *testing.T) {+ type args struct {+ path string+ neighbors []string+ }+ tests := []struct {+ name string+ args args+ want bool+ }{+ {+ name: "no conflict",+ args: args{+ path: "foo",+ neighbors: []string{"bar", "baz"},+ },+ want: false,+ },+ {+ name: "conflict",+ args: args{+ path: "foo",+ neighbors: []string{"bar", "foo"},+ },+ want: true,+ },+ {+ name: "conflict with different case",+ args: args{+ path: "foo",+ neighbors: []string{"bar", "Foo"},+ },+ want: true,+ },+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ if got := hasConflict(tt.args.path, tt.args.neighbors); got != tt.want {+ t.Errorf("hasConflict() = %v, want %v", got, tt.want)+ }+ })+ }+}++func TestSafePath(t *testing.T) {+ // override dirReader+ dirReader = func(name string) []string {+ return []string{"bar.pdf", "bar (1).pdf", "bar (2).pdf"}+ }++ type args struct {+ path string+ }+ tests := []struct {+ name string+ args args+ want string+ }{+ {+ name: "no conflict",+ args: args{+ path: "/foo/foo.pdf",+ },+ want: "/foo/foo.pdf",+ },+ {+ name: "conflict",+ args: args{+ path: "/foo/bar.pdf",+ },+ want: "/foo/bar (3).pdf",+ },+ {+ name: "conflict with different case",+ args: args{+ path: "/foo/BAR.pdf",+ },+ want: "/foo/BAR (3).pdf",+ },+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ if got := Safe(tt.args.path); got != tt.want {+ t.Errorf("SafePath() = %v, want %v", got, tt.want)+ }+ })+ }+}diff --git a/backend/pkgs/server/response_error_builder.go b/backend/pkgs/server/response_error_builder.goindex ac8d34d8..4c6d80f6 100644--- a/backend/pkgs/server/response_error_builder.go+++ b/backend/pkgs/server/response_error_builder.go@@ -4,22 +4,47 @@ import ("net/http")+type ValidationError struct {+ Field string `json:"field"`+ Reason string `json:"reason"`+}++type ValidationErrors []ValidationError++func (ve *ValidationErrors) HasErrors() bool {+ if (ve == nil) || (len(*ve) == 0) {+ return false+ }++ for _, err := range *ve {+ if err.Field != "" {+ return true+ }+ }+ return false+}++func (ve ValidationErrors) Append(field, reasons string) ValidationErrors {+ return append(ve, ValidationError{+ Field: field,+ Reason: reasons,+ })+}+// ErrorBuilder is a helper type to build a response that contains an array of errors.// Typical use cases are for returning an array of validation errors back to the user.//// Example://-//-// {-// "errors": [-// "invalid id",-// "invalid name",-// "invalid description"-// ],-// "message": "Unprocessable Entity",-// "status": 422-// }-//+// {+// "errors": [+// "invalid id",+// "invalid name",+// "invalid description"+// ],+// "message": "Unprocessable Entity",+// "status": 422+// }type ErrorBuilder struct {errs []string}diff --git a/backend/pkgs/server/response_error_builder_test.go b/backend/pkgs/server/response_error_builder_test.goindex 40de1411..689faaa1 100644--- a/backend/pkgs/server/response_error_builder_test.go+++ b/backend/pkgs/server/response_error_builder_test.go@@ -7,7 +7,7 @@ import ("net/http/httptest""testing"- "github.com/hay-kot/content/backend/pkgs/faker"+ "github.com/hay-kot/homebox/backend/pkgs/faker""github.com/stretchr/testify/assert")diff --git a/docs/docs/quick-start.md b/docs/docs/quick-start.mdindex fce544d5..4a488df9 100644--- a/docs/docs/quick-start.md+++ b/docs/docs/quick-start.md@@ -23,6 +23,7 @@ version: "3.4"environment:- HBOX_LOG_LEVEL=info- HBOX_LOG_FORMAT=text+ - HBOX_WEB_MAX_UPLOAD_SIZE=10volumes:- homebox-data:/data/ports:@@ -35,22 +36,23 @@ volumes:## Env Variables & Configuration-| Variable | Default | Description |-| ------------------------ | ---------------- | ---------------------------------------------------------------------------------- |-| HBOX_MODE | production | application mode used for runtime behavior can be one of: development, production |-| HBOX_WEB_PORT | 7745 | port to run the web server on, in you're using docker do not change this |-| HBOX_WEB_HOST | | host to run the web server on, in you're using docker do not change this |-| HBOX_DATABASE_DRIVER | sqlite | database driver to use, currently only sqlite is supported |-| HBOX_DATABASE_SQLITE_URL | /data/homebox.db | sqlite database url, in you're using docker do not change this |-| HBOX_LOG_LEVEL | info | log level to use, can be one of: trace, debug, info, warn, error, critical |-| HBOX_LOG_FORMAT | text | log format to use, can be one of: text, json |-| HBOX_MAILER_HOST | | email host to use, if not set no email provider will be used |-| HBOX_MAILER_PORT | 587 | email port to use |-| HBOX_MAILER_USERNAME | | email user to use |-| HBOX_MAILER_PASSWORD | | email password to use |-| HBOX_MAILER_FROM | | email from address to use |-| HBOX_SWAGGER_HOST | 7745 | swagger host to use, if not set swagger will be disabled |-| HBOX_SWAGGER_SCHEMA | http | swagger schema to use, can be one of: http, https |+| Variable | Default | Description |+| ------------------------ | ---------------------- | ---------------------------------------------------------------------------------- |+| HBOX_MODE | production | application mode used for runtime behavior can be one of: development, production |+| HBOX_WEB_PORT | 7745 | port to run the web server on, in you're using docker do not change this |+| HBOX_WEB_HOST | | host to run the web server on, in you're using docker do not change this |+| HBOX_STORAGE_DATA | /data/ | path to the data directory, do not change this if you're using docker |+| HBOX_STORAGE_SQLITE_URL | /data/homebox.db?_fk=1 | sqlite database url, in you're using docker do not change this |+| HBOX_WEB_MAX_UPLOAD_SIZE | 10 | maximum file upload size supported in MB |+| HBOX_LOG_LEVEL | info | log level to use, can be one of: trace, debug, info, warn, error, critical |+| HBOX_LOG_FORMAT | text | log format to use, can be one of: text, json |+| HBOX_MAILER_HOST | | email host to use, if not set no email provider will be used |+| HBOX_MAILER_PORT | 587 | email port to use |+| HBOX_MAILER_USERNAME | | email user to use |+| HBOX_MAILER_PASSWORD | | email password to use |+| HBOX_MAILER_FROM | | email from address to use |+| HBOX_SWAGGER_HOST | 7745 | swagger host to use, if not set swagger will be disabled |+| HBOX_SWAGGER_SCHEMA | http | swagger schema to use, can be one of: http, https |!!! tip "CLI Arguments"If you're deploying without docker you can use command line arguments to configure the application. Run `homebox --help` for more information.@@ -62,10 +64,11 @@ volumes:--mode/$HBOX_MODE <string> (default: development)--web-port/$HBOX_WEB_PORT <string> (default: 7745)--web-host/$HBOX_WEB_HOST <string>- --database-driver/$HBOX_DATABASE_DRIVER <string> (default: sqlite3)- --database-sqlite-url/$HBOX_DATABASE_SQLITE_URL <string> (default: file:ent?mode=memory&cache=shared&_fk=1)- --log-level/$HBOX_LOG_LEVEL <string> (default: debug)- --log-file/$HBOX_LOG_FILE <string>+ --web-max-upload-size/$HBOX_WEB_MAX_UPLOAD_SIZE <int> (default: 10)+ --storage-data/$HBOX_STORAGE_DATA <string> (default: ./homebox-data)+ --storage-sqlite-url/$HBOX_STORAGE_SQLITE_URL <string> (default: ./homebox-data/homebox.db?_fk=1)+ --log-level/$HBOX_LOG_LEVEL <string> (default: info)+ --log-format/$HBOX_LOG_FORMAT <string> (default: text)--mailer-host/$HBOX_MAILER_HOST <string>--mailer-port/$HBOX_MAILER_PORT <int>--mailer-username/$HBOX_MAILER_USERNAME <string>diff --git a/frontend/components/Form/Select.vue b/frontend/components/Form/Select.vueindex bfdc9ff1..27e36839 100644--- a/frontend/components/Form/Select.vue+++ b/frontend/components/Form/Select.vue@@ -25,7 +25,7 @@},modelValue: {// eslint-disable-next-line @typescript-eslint/no-explicit-any- type: Object as any,+ type: [Object, String, Boolean] as any,default: null,},items: {@@ -37,18 +37,47 @@type: String,default: "name",},+ value: {+ type: String,+ default: null,+ required: false,+ },selectFirst: {type: Boolean,default: false,},});- watchOnce(- () => props.items,- () => {- if (props.selectFirst && props.items.length > 0) {+ function syncSelect() {+ if (!props.modelValue) {+ if (props.selectFirst) {selectedIdx.value = 0;}+ return;+ }+ // Check if we're already synced+ if (props.value) {+ if (props.modelValue[props.value] === props.items[selectedIdx.value][props.value]) {+ return;+ }+ } else if (props.modelValue === props.items[selectedIdx.value]) {+ return;+ }++ const idx = props.items.findIndex(item => {+ if (props.value) {+ return item[props.value] === props.modelValue;+ }+ return item === props.modelValue;+ });++ selectedIdx.value = idx;+ }++ watch(+ () => props.modelValue,+ () => {+ syncSelect();});@@ -56,6 +85,10 @@watch(() => selectedIdx.value,() => {+ if (props.value) {+ emit("update:modelValue", props.items[selectedIdx.value][props.value]);+ return;+ }emit("update:modelValue", props.items[selectedIdx.value]);});diff --git a/frontend/components/Item/AttachmentsList.vue b/frontend/components/Item/AttachmentsList.vuenew file mode 100644index 00000000..f2152568--- /dev/null+++ b/frontend/components/Item/AttachmentsList.vue@@ -0,0 +1,56 @@+<template>+ <ul role="list" class="divide-y divide-gray-400 rounded-md border border-gray-400">+ <li+ v-for="attachment in attachments"+ :key="attachment.id"+ class="flex items-center justify-between py-3 pl-3 pr-4 text-sm"+ >+ <div class="flex w-0 flex-1 items-center">+ <Icon name="mdi-paperclip" class="h-5 w-5 flex-shrink-0 text-gray-400" aria-hidden="true" />+ <span class="ml-2 w-0 flex-1 truncate"> {{ attachment.document.title }}</span>+ </div>+ <div class="ml-4 flex-shrink-0">+ <button class="font-medium" @click="getAttachmentUrl(attachment)">Download</button>+ </div>+ </li>+ </ul>+</template>++<script setup lang="ts">+ import { ItemAttachment } from "~~/lib/api/types/data-contracts";++ const props = defineProps({+ attachments: {+ type: Object as () => ItemAttachment[],+ required: true,+ },+ itemId: {+ type: String,+ required: true,+ },+ });++ const api = useUserApi();+ const toast = useNotifier();+ async function getAttachmentUrl(attachment: ItemAttachment) {+ const url = await api.items.getAttachmentUrl(props.itemId, attachment.id);++ if (!url) {+ toast.error("Failed to get attachment url");+ return;+ }++ if (!document) {+ window.open(url, "_blank");+ return;+ }++ const link = document.createElement("a");+ link.href = url;+ link.target = "_blank";+ link.setAttribute("download", attachment.document.title);+ link.click();+ }+</script>++<style scoped></style>diff --git a/frontend/components/Item/Card.vue b/frontend/components/Item/Card.vueindex d5a8fed9..6be75a9f 100644--- a/frontend/components/Item/Card.vue+++ b/frontend/components/Item/Card.vue@@ -23,6 +23,7 @@<script setup lang="ts">import { ItemOut, ItemSummary } from "~~/lib/api/types/data-contracts";+ import { truncate } from "~~/lib/strings";const props = defineProps({item: {diff --git a/frontend/components/global/DropZone.vue b/frontend/components/global/DropZone.vuenew file mode 100644index 00000000..786a0776--- /dev/null+++ b/frontend/components/global/DropZone.vue@@ -0,0 +1,31 @@+<template>+ <div+ ref="el"+ class="h-24 w-full border-2 border-primary border-dashed grid place-content-center"+ :class="isOverDropZone ? 'bg-primary bg-opacity-10' : ''"+ >+ <slot />+ </div>+</template>++<script setup lang="ts">+ defineProps({+ modelValue: {+ type: Boolean,+ required: false,+ },+ });++ const emit = defineEmits(["update:modelValue", "drop"]);++ const el = ref<HTMLDivElement>(null);+ const { isOverDropZone } = useDropZone(el, files => {+ emit("drop", files);+ });++ watch(isOverDropZone, () => {+ emit("update:modelValue", isOverDropZone.value);+ });+</script>++<style scoped></style>diff --git a/frontend/composables/use-strings.ts b/frontend/composables/use-strings.tsdeleted file mode 100644index e0658d31..00000000--- a/frontend/composables/use-strings.ts+++ /dev/null@@ -1,7 +0,0 @@-export function truncate(str: string, length: number) {- return str.length > length ? str.substring(0, length) + "..." : str;-}--export function capitalize(str: string) {- return str.charAt(0).toUpperCase() + str.slice(1);-}diff --git a/frontend/lib/api/__test__/user/items.test.ts b/frontend/lib/api/__test__/user/items.test.tsnew file mode 100644index 00000000..75ca5cf3--- /dev/null+++ b/frontend/lib/api/__test__/user/items.test.ts@@ -0,0 +1,61 @@+import { describe, test, expect } from "vitest";+import { LocationOut } from "../../types/data-contracts";+import { AttachmentTypes } from "../../types/non-generated";+import { UserApi } from "../../user";+import { sharedUserClient } from "../test-utils";++describe("user should be able to create an item and add an attachment", () => {+ let increment = 0;+ /**+ * useLocatio sets up a location resource for testing, and returns a function+ * that can be used to delete the location from the backend server.+ */+ async function useLocation(api: UserApi): Promise<[LocationOut, () => Promise<void>]> {+ const { response, data } = await api.locations.create({+ name: `__test__.location.name_${increment}`,+ description: `__test__.location.description_${increment}`,+ });+ expect(response.status).toBe(201);+ increment++;++ const cleanup = async () => {+ const { response } = await api.locations.delete(data.id);+ expect(response.status).toBe(204);+ };++ return [data, cleanup];+ }++ test("user should be able to create an item and add an attachment", async () => {+ const api = await sharedUserClient();+ const [location, cleanup] = await useLocation(api);++ const { response, data: item } = await api.items.create({+ name: "test-item",+ labelIds: [],+ description: "test-description",+ locationId: location.id,+ });+ expect(response.status).toBe(201);++ // Add attachment+ {+ const testFile = new Blob(["test"], { type: "text/plain" });+ const { response } = await api.items.addAttachment(item.id, testFile, "test.txt", AttachmentTypes.Attachment);+ expect(response.status).toBe(201);+ }++ // Get Attachment+ const { response: itmResp, data } = await api.items.get(item.id);+ expect(itmResp.status).toBe(200);++ expect(data.attachments).toHaveLength(1);+ expect(data.attachments[0].document.title).toBe("test.txt");++ const resp = await api.items.deleteAttachment(data.id, data.attachments[0].id);+ expect(resp.response.status).toBe(204);++ api.items.delete(item.id);+ await cleanup();+ });+});diff --git a/frontend/lib/api/classes/items.ts b/frontend/lib/api/classes/items.tsindex bfcfde36..e98c785f 100644--- a/frontend/lib/api/classes/items.ts+++ b/frontend/lib/api/classes/items.ts@@ -1,15 +1,23 @@import { BaseAPI, route } from "../base";import { parseDate } from "../base/base-api";-import { ItemCreate, ItemOut, ItemSummary, ItemUpdate } from "../types/data-contracts";+import {+ ItemAttachmentToken,+ ItemAttachmentUpdate,+ ItemCreate,+ ItemOut,+ ItemSummary,+ ItemUpdate,+} from "../types/data-contracts";+import { AttachmentTypes } from "../types/non-generated";import { Results } from "./types";export class ItemsApi extends BaseAPI {getAll() {- return this.http.get<Results<ItemOut>>({ url: route("/items") });+ return this.http.get<Results<ItemSummary>>({ url: route("/items") });}create(item: ItemCreate) {- return this.http.post<ItemCreate, ItemSummary>({ url: route("/items"), body: item });+ return this.http.post<ItemCreate, ItemOut>({ url: route("/items"), body: item });}async get(id: string) {@@ -45,6 +53,44 @@ export class ItemsApi extends BaseAPI {const formData = new FormData();formData.append("csv", file);- return this.http.post<FormData, void>({ url: route("/items/import"), data: formData });+ return this.http.post<FormData, void>({+ url: route("/items/import"),+ data: formData,+ });+ }++ addAttachment(id: string, file: File | Blob, filename: string, type: AttachmentTypes) {+ const formData = new FormData();+ formData.append("file", file);+ formData.append("type", type);+ formData.append("name", filename);++ return this.http.post<FormData, ItemOut>({+ url: route(`/items/${id}/attachments`),+ data: formData,+ });+ }++ async getAttachmentUrl(id: string, attachmentId: string): Promise<string> {+ const payload = await this.http.get<ItemAttachmentToken>({+ url: route(`/items/${id}/attachments/${attachmentId}`),+ });++ if (!payload.data) {+ return "";+ }++ return route(`/items/${id}/attachments/download`, { token: payload.data.token });+ }++ async deleteAttachment(id: string, attachmentId: string) {+ return await this.http.delete<void>({ url: route(`/items/${id}/attachments/${attachmentId}`) });+ }++ async updateAttachment(id: string, attachmentId: string, data: ItemAttachmentUpdate) {+ return await this.http.put<ItemAttachmentUpdate, ItemOut>({+ url: route(`/items/${id}/attachments/${attachmentId}`),+ body: data,+ });}}diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.tsindex 4d0d9aa1..80a6367b 100644--- a/frontend/lib/api/types/data-contracts.ts+++ b/frontend/lib/api/types/data-contracts.ts@@ -21,6 +21,11 @@ export interface ServerResults {items: any;}+export interface ServerValidationError {+ field: string;+ reason: string;+}+export interface ApiSummary {build: Build;health: boolean;@@ -45,9 +50,19 @@ export interface ItemAttachment {createdAt: Date;document: DocumentOut;id: string;+ type: string;updatedAt: Date;}+export interface ItemAttachmentToken {+ token: string;+}++export interface ItemAttachmentUpdate {+ title: string;+ type: string;+}+export interface ItemCreate {description: string;labelIds: string[];@@ -191,7 +206,6 @@ export interface LabelCreate {export interface LabelOut {createdAt: Date;description: string;- groupId: string;id: string;items: ItemSummary[];name: string;@@ -201,7 +215,6 @@ export interface LabelOut {export interface LabelSummary {createdAt: Date;description: string;- groupId: string;id: string;name: string;updatedAt: Date;diff --git a/frontend/lib/api/types/non-generated.ts b/frontend/lib/api/types/non-generated.tsnew file mode 100644index 00000000..69287843--- /dev/null+++ b/frontend/lib/api/types/non-generated.ts@@ -0,0 +1,6 @@+export enum AttachmentTypes {+ Photo = "photo",+ Manual = "manual",+ Warranty = "warranty",+ Attachment = "attachment",+}diff --git a/frontend/lib/requests/requests.ts b/frontend/lib/requests/requests.tsindex 55e89a7f..9d62c365 100644--- a/frontend/lib/requests/requests.ts+++ b/frontend/lib/requests/requests.ts@@ -97,11 +97,15 @@ export class Requests {return {} as T;}- try {- return await response.json();- } catch (e) {- return {} as T;+ if (response.headers.get("Content-Type")?.startsWith("application/json")) {+ try {+ return await response.json();+ } catch (e) {+ return {} as T;+ }}++ return response.body as unknown as T;})();return {diff --git a/frontend/lib/strings/index.test.ts b/frontend/lib/strings/index.test.tsnew file mode 100644index 00000000..1f266ea0--- /dev/null+++ b/frontend/lib/strings/index.test.ts@@ -0,0 +1,56 @@+import { describe, it, expect } from "vitest";+import { titlecase, capitalize, truncate } from ".";++describe("title case tests", () => {+ it("should return the same string if it's already title case", () => {+ expect(titlecase("Hello World")).toBe("Hello World");+ });++ it("should title case a lower case word", () => {+ expect(titlecase("hello")).toBe("Hello");+ });++ it("should title case a sentence", () => {+ expect(titlecase("hello world")).toBe("Hello World");+ });++ it("should title case a sentence with multiple words", () => {+ expect(titlecase("hello world this is a test")).toBe("Hello World This Is A Test");+ });+});++describe("capitilize tests", () => {+ it("should return the same string if it's already capitalized", () => {+ expect(capitalize("Hello")).toBe("Hello");+ });++ it("should capitalize a lower case word", () => {+ expect(capitalize("hello")).toBe("Hello");+ });++ it("should capitalize a sentence", () => {+ expect(capitalize("hello world")).toBe("Hello world");+ });++ it("should capitalize a sentence with multiple words", () => {+ expect(capitalize("hello world this is a test")).toBe("Hello world this is a test");+ });+});++describe("truncase tests", () => {+ it("should return the same string if it's already truncated", () => {+ expect(truncate("Hello", 5)).toBe("Hello");+ });++ it("should truncate a lower case word", () => {+ expect(truncate("hello", 3)).toBe("hel...");+ });++ it("should truncate a sentence", () => {+ expect(truncate("hello world", 5)).toBe("hello...");+ });++ it("should truncate a sentence with multiple words", () => {+ expect(truncate("hello world this is a test", 10)).toBe("hello worl...");+ });+});diff --git a/frontend/lib/strings/index.ts b/frontend/lib/strings/index.tsnew file mode 100644index 00000000..9f23e90c--- /dev/null+++ b/frontend/lib/strings/index.ts@@ -0,0 +1,14 @@+export function titlecase(str: string) {+ return str+ .split(" ")+ .map(word => word[0].toUpperCase() + word.slice(1))+ .join(" ");+}++export function capitalize(str: string) {+ return str[0].toUpperCase() + str.slice(1);+}++export function truncate(str: string, length: number) {+ return str.length > length ? str.substring(0, length) + "..." : str;+}diff --git a/frontend/pages/home.vue b/frontend/pages/home.vueindex ae6d8c1f..f39eb6bc 100644--- a/frontend/pages/home.vue+++ b/frontend/pages/home.vue@@ -121,7 +121,7 @@<div class="sm:flex sm:space-x-5"><div class="mt-4 text-center sm:mt-0 sm:pt-1 sm:text-left"><p class="text-sm font-medium text-gray-600">Welcome back,</p>- <p class="text-xl font-bold text-gray-900 sm:text-2xl">Hayden Kotelman</p>+ <p class="text-xl font-bold text-gray-900 sm:text-2xl">Username</p><p class="text-sm font-medium text-gray-600">User</p></div></div>diff --git a/frontend/pages/item/[id]/edit.vue b/frontend/pages/item/[id]/edit.vueindex afc5d88a..59ab0a40 100644--- a/frontend/pages/item/[id]/edit.vue+++ b/frontend/pages/item/[id]/edit.vue@@ -1,7 +1,9 @@<script setup lang="ts">- import { ItemUpdate } from "~~/lib/api/types/data-contracts";+ import { ItemAttachment, ItemUpdate } from "~~/lib/api/types/data-contracts";+ import { AttachmentTypes } from "~~/lib/api/types/non-generated";import { useLabelStore } from "~~/stores/labels";import { useLocationStore } from "~~/stores/locations";+ import { capitalize } from "~~/lib/strings";definePageMeta({layout: "home",@@ -154,10 +156,131 @@ref: "soldTime",},];++ // - Attachments+ const attDropZone = ref<HTMLDivElement>();+ const { isOverDropZone: attDropZoneActive } = useDropZone(attDropZone);++ const refAttachmentInput = ref<HTMLInputElement>();++ function clickUpload() {+ if (!refAttachmentInput.value) {+ return;+ }+ refAttachmentInput.value.click();+ }++ function uploadImage(e: InputEvent) {+ const files = (e.target as HTMLInputElement).files;+ if (!files) {+ return;+ }++ uploadAttachment([files.item(0)], AttachmentTypes.Attachment);+ }++ const dropPhoto = (files: File[] | null) => uploadAttachment(files, AttachmentTypes.Photo);+ const dropAttachment = (files: File[] | null) => uploadAttachment(files, AttachmentTypes.Attachment);+ const dropWarranty = (files: File[] | null) => uploadAttachment(files, AttachmentTypes.Warranty);+ const dropManual = (files: File[] | null) => uploadAttachment(files, AttachmentTypes.Manual);++ async function uploadAttachment(files: File[] | null, type: AttachmentTypes) {+ if (!files && files.length === 0) {+ return;+ }++ const { data, error } = await api.items.addAttachment(itemId.value, files[0], files[0].name, type);++ if (error) {+ toast.error("Failed to upload attachment");+ return;+ }++ toast.success("Attachment uploaded");++ item.value.attachments = data.attachments;+ }++ const confirm = useConfirm();++ async function deleteAttachment(attachmentId: string) {+ const confirmed = await confirm.reveal("Are you sure you want to delete this attachment?");++ if (confirmed.isCanceled) {+ return;+ }++ const { error } = await api.items.deleteAttachment(itemId.value, attachmentId);++ if (error) {+ toast.error("Failed to delete attachment");+ return;+ }++ toast.success("Attachment deleted");+ item.value.attachments = item.value.attachments.filter(a => a.id !== attachmentId);+ }++ const editState = reactive({+ modal: false,+ loading: false,++ // Values+ id: "",+ title: "",+ type: "",+ });++ const attachmentOpts = Object.entries(AttachmentTypes).map(([key, value]) => ({+ text: capitalize(key),+ value,+ }));++ function openAttachmentEditDialog(attachment: ItemAttachment) {+ editState.id = attachment.id;+ editState.title = attachment.document.title;+ editState.type = attachment.type;+ editState.modal = true;+ }++ async function updateAttachment() {+ editState.loading = true;++ const { error, data } = await api.items.updateAttachment(itemId.value, editState.id, {+ title: editState.title,+ type: editState.type,+ });++ if (error) {+ toast.error("Failed to update attachment");+ return;+ }++ item.value.attachments = data.attachments;++ editState.loading = false;+ editState.modal = false;++ editState.id = "";+ editState.title = "";+ editState.type = "";++ toast.success("Attachment updated");+ }</script><template><BaseContainer v-if="item" class="pb-8">+ <BaseModal v-model="editState.modal">+ <template #title> Attachment Edit </template>++ <FormTextField v-model="editState.title" label="Attachment Title" />+ <FormSelect v-model="editState.type" label="Attachment Type" value="value" name="text" :items="attachmentOpts" />+ <div class="modal-action">+ <BaseButton :loading="editState.loading" @click="updateAttachment"> Update </BaseButton>+ </div>+ </BaseModal>+<section class="px-3"><div class="space-y-4"><div class="overflow-hidden card bg-base-100 shadow-xl sm:rounded-lg">@@ -223,6 +346,62 @@</div></div>+ <div+ v-if="!preferences.editorSimpleView"+ ref="attDropZone"+ class="overflow-visible card bg-base-100 shadow-xl sm:rounded-lg"+ >+ <div class="px-4 py-5 sm:px-6">+ <h3 class="text-lg font-medium leading-6">Attachments</h3>+ <p class="text-xs">Changes to attachments will be saved immediately</p>+ </div>+ <div class="border-t border-gray-300 p-4">+ <div v-if="attDropZoneActive" class="grid grid-cols-4 gap-4">+ <DropZone @drop="dropPhoto"> Photo </DropZone>+ <DropZone @drop="dropWarranty"> Warranty </DropZone>+ <DropZone @drop="dropManual"> Manual </DropZone>+ <DropZone @drop="dropAttachment"> Attachment </DropZone>+ </div>+ <button+ v-else+ class="h-24 w-full border-2 border-primary border-dashed grid place-content-center"+ @click="clickUpload"+ >+ <input ref="refAttachmentInput" hidden type="file" @change="uploadImage" />+ <p>Drag and drop files here or click to select files</p>+ </button>+ </div>++ <div class="border-t border-gray-300 p-4">+ <ul role="list" class="divide-y divide-gray-400 rounded-md border border-gray-400">+ <li+ v-for="attachment in item.attachments"+ :key="attachment.id"+ class="grid grid-cols-6 justify-between py-3 pl-3 pr-4 text-sm"+ >+ <p class="my-auto col-span-4">+ {{ attachment.document.title }}+ </p>+ <p class="my-auto">+ {{ capitalize(attachment.type) }}+ </p>+ <div class="flex gap-2 justify-end">+ <div class="tooltip" data-tip="Delete">+ <button class="btn btn-sm btn-square" @click="deleteAttachment(attachment.id)">+ <Icon name="mdi-delete" />+ </button>+ </div>+ <div class="tooltip" data-tip="Edit">+ <button class="btn btn-sm btn-square" @click="openAttachmentEditDialog(attachment)">+ <Icon name="mdi-pencil" />+ </button>+ </div>+ </div>+ </li>+ </ul>+ </div>+ </div>+<div v-if="!preferences.editorSimpleView" class="overflow-visible card bg-base-100 shadow-xl sm:rounded-lg"><div class="px-4 py-5 sm:px-6"><h3 class="text-lg font-medium leading-6">Purchase Details</h3>diff --git a/frontend/pages/item/[id]/index.vue b/frontend/pages/item/[id]/index.vueindex a6196070..762ff514 100644--- a/frontend/pages/item/[id]/index.vue+++ b/frontend/pages/item/[id]/index.vue@@ -1,4 +1,6 @@<script setup lang="ts">+ import { ItemAttachment } from "~~/lib/api/types/data-contracts";+definePageMeta({layout: "home",});@@ -23,6 +25,45 @@refresh();});+ type FilteredAttachments = {+ photos: ItemAttachment[];+ attachments: ItemAttachment[];+ warranty: ItemAttachment[];+ manuals: ItemAttachment[];+ };++ const attachments = computed<FilteredAttachments>(() => {+ if (!item.value) {+ return {+ photos: [],+ attachments: [],+ manuals: [],+ warranty: [],+ };+ }++ return item.value.attachments.reduce(+ (acc, attachment) => {+ if (attachment.type === "photo") {+ acc.photos.push(attachment);+ } else if (attachment.type === "warranty") {+ acc.warranty.push(attachment);+ } else if (attachment.type === "manual") {+ acc.manuals.push(attachment);+ } else {+ acc.attachments.push(attachment);+ }+ return acc;+ },+ {+ photos: [] as ItemAttachment[],+ attachments: [] as ItemAttachment[],+ warranty: [] as ItemAttachment[],+ manuals: [] as ItemAttachment[],+ }+ );+ });+const itemSummary = computed(() => {return {Description: item.value?.description || "",@@ -31,10 +72,53 @@Manufacturer: item.value?.manufacturer || "",Notes: item.value?.notes || "",Insured: item.value?.insured ? "Yes" : "No",- Attachments: "", // TODO: Attachments};});+ const showAttachments = computed(() => {+ if (preferences.value?.showEmpty) {+ return true;+ }++ return (+ attachments.value.photos.length > 0 ||+ attachments.value.attachments.length > 0 ||+ attachments.value.warranty.length > 0 ||+ attachments.value.manuals.length > 0+ );+ });++ const itemAttachments = computed(() => {+ const val: Record<string, string> = {};++ if (preferences.value.showEmpty) {+ return {+ Photos: "",+ Manuals: "",+ Warranty: "",+ Attachments: "",+ };+ }++ if (attachments.value.photos.length > 0) {+ val.Photos = "";+ }++ if (attachments.value.manuals.length > 0) {+ val.Manuals = "";+ }++ if (attachments.value.warranty.length > 0) {+ val.Warranty = "";+ }++ if (attachments.value.attachments.length > 0) {+ val.Attachments = "";+ }++ return val;+ });+const showWarranty = computed(() => {if (preferences.value.showEmpty) {return true;@@ -148,27 +232,36 @@</template></BaseSectionHeader></template>+ </BaseDetails>+ <BaseDetails v-if="showAttachments" :details="itemAttachments">+ <template #title> Attachments </template>+ <template #Manuals>+ <ItemAttachmentsList+ v-if="attachments.manuals.length > 0"+ :attachments="attachments.manuals"+ :item-id="item.id"+ />+ </template><template #Attachments>- <ul role="list" class="divide-y divide-gray-400 rounded-md border border-gray-400">- <li class="flex items-center justify-between py-3 pl-3 pr-4 text-sm">- <div class="flex w-0 flex-1 items-center">- <Icon name="mdi-paperclip" class="h-5 w-5 flex-shrink-0 text-gray-400" aria-hidden="true" />- <span class="ml-2 w-0 flex-1 truncate">User Guide.pdf</span>- </div>- <div class="ml-4 flex-shrink-0">- <a href="#" class="font-medium">Download</a>- </div>- </li>- <li class="flex items-center justify-between py-3 pl-3 pr-4 text-sm">- <div class="flex w-0 flex-1 items-center">- <Icon name="mdi-paperclip" class="h-5 w-5 flex-shrink-0 text-gray-400" aria-hidden="true" />- <span class="ml-2 w-0 flex-1 truncate">Purchase Receipts.pdf</span>- </div>- <div class="ml-4 flex-shrink-0">- <a href="#" class="font-medium">Download</a>- </div>- </li>- </ul>+ <ItemAttachmentsList+ v-if="attachments.attachments.length > 0"+ :attachments="attachments.attachments"+ :item-id="item.id"+ />+ </template>+ <template #Warranty>+ <ItemAttachmentsList+ v-if="attachments.warranty.length > 0"+ :attachments="attachments.warranty"+ :item-id="item.id"+ />+ </template>+ <template #Photos>+ <ItemAttachmentsList+ v-if="attachments.photos.length > 0"+ :attachments="attachments.photos"+ :item-id="item.id"+ /></template></BaseDetails><BaseDetails v-if="showPurchase" :details="purchaseDetails">