Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

feat: Add item templates feature (#435) (#1099)

Logan Millercc66330a74e5
diff --git a/backend/app/api/handlers/v1/v1_ctrl_item_templates.go b/backend/app/api/handlers/v1/v1_ctrl_item_templates.go
new file mode 100644
index 00000000..deb4c261
--- /dev/null
+++ b/backend/app/api/handlers/v1/v1_ctrl_item_templates.go
@@ -0,0 +1,164 @@
+package v1
+
+import (
+ "net/http"
+
+ "github.com/google/uuid"
+ "github.com/hay-kot/httpkit/errchain"
+ "github.com/sysadminsmedia/homebox/backend/internal/core/services"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/repo"
+ "github.com/sysadminsmedia/homebox/backend/internal/web/adapters"
+)
+
+// HandleItemTemplatesGetAll godoc
+//
+// @Summary Get All Item Templates
+// @Tags Item Templates
+// @Produce json
+// @Success 200 {object} []repo.ItemTemplateSummary
+// @Router /v1/templates [GET]
+// @Security Bearer
+func (ctrl *V1Controller) HandleItemTemplatesGetAll() errchain.HandlerFunc {
+ fn := func(r *http.Request) ([]repo.ItemTemplateSummary, error) {
+ auth := services.NewContext(r.Context())
+ return ctrl.repo.ItemTemplates.GetAll(r.Context(), auth.GID)
+ }
+
+ return adapters.Command(fn, http.StatusOK)
+}
+
+// HandleItemTemplatesGet godoc
+//
+// @Summary Get Item Template
+// @Tags Item Templates
+// @Produce json
+// @Param id path string true "Template ID"
+// @Success 200 {object} repo.ItemTemplateOut
+// @Router /v1/templates/{id} [GET]
+// @Security Bearer
+func (ctrl *V1Controller) HandleItemTemplatesGet() errchain.HandlerFunc {
+ fn := func(r *http.Request, ID uuid.UUID) (repo.ItemTemplateOut, error) {
+ auth := services.NewContext(r.Context())
+ return ctrl.repo.ItemTemplates.GetOne(r.Context(), auth.GID, ID)
+ }
+
+ return adapters.CommandID("id", fn, http.StatusOK)
+}
+
+// HandleItemTemplatesCreate godoc
+//
+// @Summary Create Item Template
+// @Tags Item Templates
+// @Produce json
+// @Param payload body repo.ItemTemplateCreate true "Template Data"
+// @Success 201 {object} repo.ItemTemplateOut
+// @Router /v1/templates [POST]
+// @Security Bearer
+func (ctrl *V1Controller) HandleItemTemplatesCreate() errchain.HandlerFunc {
+ fn := func(r *http.Request, body repo.ItemTemplateCreate) (repo.ItemTemplateOut, error) {
+ auth := services.NewContext(r.Context())
+ return ctrl.repo.ItemTemplates.Create(r.Context(), auth.GID, body)
+ }
+
+ return adapters.Action(fn, http.StatusCreated)
+}
+
+// HandleItemTemplatesUpdate godoc
+//
+// @Summary Update Item Template
+// @Tags Item Templates
+// @Produce json
+// @Param id path string true "Template ID"
+// @Param payload body repo.ItemTemplateUpdate true "Template Data"
+// @Success 200 {object} repo.ItemTemplateOut
+// @Router /v1/templates/{id} [PUT]
+// @Security Bearer
+func (ctrl *V1Controller) HandleItemTemplatesUpdate() errchain.HandlerFunc {
+ fn := func(r *http.Request, ID uuid.UUID, body repo.ItemTemplateUpdate) (repo.ItemTemplateOut, error) {
+ auth := services.NewContext(r.Context())
+ body.ID = ID
+ return ctrl.repo.ItemTemplates.Update(r.Context(), auth.GID, body)
+ }
+
+ return adapters.ActionID("id", fn, http.StatusOK)
+}
+
+// HandleItemTemplatesDelete godoc
+//
+// @Summary Delete Item Template
+// @Tags Item Templates
+// @Produce json
+// @Param id path string true "Template ID"
+// @Success 204
+// @Router /v1/templates/{id} [DELETE]
+// @Security Bearer
+func (ctrl *V1Controller) HandleItemTemplatesDelete() errchain.HandlerFunc {
+ fn := func(r *http.Request, ID uuid.UUID) (any, error) {
+ auth := services.NewContext(r.Context())
+ err := ctrl.repo.ItemTemplates.Delete(r.Context(), auth.GID, ID)
+ return nil, err
+ }
+
+ return adapters.CommandID("id", fn, http.StatusNoContent)
+}
+
+type ItemTemplateCreateItemRequest struct {
+ Name string `json:"name" validate:"required,min=1,max=255"`
+ Description string `json:"description" validate:"max=1000"`
+ LocationID uuid.UUID `json:"locationId" validate:"required"`
+ LabelIDs []uuid.UUID `json:"labelIds"`
+ Quantity *int `json:"quantity"`
+}
+
+// HandleItemTemplatesCreateItem godoc
+//
+// @Summary Create Item from Template
+// @Tags Item Templates
+// @Produce json
+// @Param id path string true "Template ID"
+// @Param payload body ItemTemplateCreateItemRequest true "Item Data"
+// @Success 201 {object} repo.ItemOut
+// @Router /v1/templates/{id}/create-item [POST]
+// @Security Bearer
+func (ctrl *V1Controller) HandleItemTemplatesCreateItem() errchain.HandlerFunc {
+ fn := func(r *http.Request, templateID uuid.UUID, body ItemTemplateCreateItemRequest) (repo.ItemOut, error) {
+ auth := services.NewContext(r.Context())
+
+ template, err := ctrl.repo.ItemTemplates.GetOne(r.Context(), auth.GID, templateID)
+ if err != nil {
+ return repo.ItemOut{}, err
+ }
+
+ quantity := template.DefaultQuantity
+ if body.Quantity != nil {
+ quantity = *body.Quantity
+ }
+
+ // Build custom fields from template
+ fields := make([]repo.ItemField, len(template.Fields))
+ for i, f := range template.Fields {
+ fields[i] = repo.ItemField{
+ Type: f.Type,
+ Name: f.Name,
+ TextValue: f.TextValue,
+ }
+ }
+
+ // Create item with all template data in a single transaction
+ return ctrl.repo.Items.CreateFromTemplate(r.Context(), auth.GID, repo.ItemCreateFromTemplate{
+ Name: body.Name,
+ Description: body.Description,
+ Quantity: quantity,
+ LocationID: body.LocationID,
+ LabelIDs: body.LabelIDs,
+ Insured: template.DefaultInsured,
+ Manufacturer: template.DefaultManufacturer,
+ ModelNumber: template.DefaultModelNumber,
+ LifetimeWarranty: template.DefaultLifetimeWarranty,
+ WarrantyDetails: template.DefaultWarrantyDetails,
+ Fields: fields,
+ })
+ }
+
+ return adapters.ActionID("id", fn, http.StatusCreated)
+}
diff --git a/backend/app/api/routes.go b/backend/app/api/routes.go
index f3a796f6..30bdeecf 100644
--- a/backend/app/api/routes.go
+++ b/backend/app/api/routes.go
@@ -145,6 +145,14 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
r.Get("/assets/{id}", chain.ToHandlerFunc(v1Ctrl.HandleAssetGet(), userMW...))
+ // Item Templates
+ r.Get("/templates", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesGetAll(), userMW...))
+ r.Post("/templates", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesCreate(), userMW...))
+ r.Get("/templates/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesGet(), userMW...))
+ r.Put("/templates/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesUpdate(), userMW...))
+ r.Delete("/templates/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesDelete(), userMW...))
+ r.Post("/templates/{id}/create-item", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesCreateItem(), userMW...))
+
// Maintenance
r.Get("/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceGetAll(), userMW...))
r.Put("/maintenance/{id}", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceEntryUpdate(), userMW...))
diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go
index 1cbb82bf..1af68fee 100644
--- a/backend/app/api/static/docs/docs.go
+++ b/backend/app/api/static/docs/docs.go
@@ -1963,6 +1963,209 @@ const docTemplate = `{
}
}
},
+ "/v1/templates": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get All Item Templates",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ItemTemplateSummary"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item Template",
+ "parameters": [
+ {
+ "description": "Template Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateCreate"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Update Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Template Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Delete Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}/create-item": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item from Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Item Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v1.ItemTemplateCreateItemRequest"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ }
+ }
+ }
+ },
"/v1/users/change-password": {
"put": {
"security": [
@@ -2032,6 +2235,51 @@ const docTemplate = `{
}
}
},
+ "/v1/users/login/oidc": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Login Initiation",
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
+ "/v1/users/login/oidc/callback": {
+ "get": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Callback Handler",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Authorization code",
+ "name": "code",
+ "in": "query",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "State parameter",
+ "name": "state",
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
"/v1/users/logout": {
"post": {
"security": [
@@ -2092,6 +2340,12 @@ const docTemplate = `{
"responses": {
"204": {
"description": "No Content"
+ },
+ "403": {
+ "description": "Local login is not enabled",
+ "schema": {
+ "type": "string"
+ }
}
}
}
@@ -2462,6 +2716,13 @@ const docTemplate = `{
"$ref": "#/definitions/ent.GroupInvitationToken"
}
},
+ "item_templates": {
+ "description": "ItemTemplates holds the value of the item_templates edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.ItemTemplate"
+ }
+ },
"items": {
"description": "Items holds the value of the items edge.",
"type": "array",
@@ -2799,26 +3060,61 @@ const docTemplate = `{
}
}
},
- "ent.Label": {
+ "ent.ItemTemplate": {
"type": "object",
"properties": {
- "color": {
- "description": "Color holds the value of the \"color\" field.",
- "type": "string"
- },
"created_at": {
"description": "CreatedAt holds the value of the \"created_at\" field.",
"type": "string"
},
+ "default_description": {
+ "description": "Default description for items created from this template",
+ "type": "string"
+ },
+ "default_insured": {
+ "description": "DefaultInsured holds the value of the \"default_insured\" field.",
+ "type": "boolean"
+ },
+ "default_label_ids": {
+ "description": "Default label IDs for items created from this template",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "default_lifetime_warranty": {
+ "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.",
+ "type": "boolean"
+ },
+ "default_manufacturer": {
+ "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.",
+ "type": "string"
+ },
+ "default_model_number": {
+ "description": "Default model number for items created from this template",
+ "type": "string"
+ },
+ "default_name": {
+ "description": "Default name template for items (can use placeholders)",
+ "type": "string"
+ },
+ "default_quantity": {
+ "description": "DefaultQuantity holds the value of the \"default_quantity\" field.",
+ "type": "integer"
+ },
+ "default_warranty_details": {
+ "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.",
+ "type": "string"
+ },
"description": {
"description": "Description holds the value of the \"description\" field.",
"type": "string"
},
"edges": {
- "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.",
"allOf": [
{
- "$ref": "#/definitions/ent.LabelEdges"
+ "$ref": "#/definitions/ent.ItemTemplateEdges"
}
]
},
@@ -2826,20 +3122,101 @@ const docTemplate = `{
"description": "ID of the ent.",
"type": "string"
},
+ "include_purchase_fields": {
+ "description": "Whether to include purchase fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_sold_fields": {
+ "description": "Whether to include sold fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_warranty_fields": {
+ "description": "Whether to include warranty fields in items created from this template",
+ "type": "boolean"
+ },
"name": {
"description": "Name holds the value of the \"name\" field.",
"type": "string"
},
+ "notes": {
+ "description": "Notes holds the value of the \"notes\" field.",
+ "type": "string"
+ },
"updated_at": {
"description": "UpdatedAt holds the value of the \"updated_at\" field.",
"type": "string"
}
}
},
- "ent.LabelEdges": {
+ "ent.ItemTemplateEdges": {
"type": "object",
"properties": {
- "group": {
+ "fields": {
+ "description": "Fields holds the value of the fields edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.TemplateField"
+ }
+ },
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ },
+ "location": {
+ "description": "Location holds the value of the location edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Location"
+ }
+ ]
+ }
+ }
+ },
+ "ent.Label": {
+ "type": "object",
+ "properties": {
+ "color": {
+ "description": "Color holds the value of the \"color\" field.",
+ "type": "string"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.LabelEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.LabelEdges": {
+ "type": "object",
+ "properties": {
+ "group": {
"description": "Group holds the value of the group edge.",
"allOf": [
{
@@ -3048,6 +3425,64 @@ const docTemplate = `{
}
}
},
+ "ent.TemplateField": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.TemplateFieldEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "text_value": {
+ "description": "TextValue holds the value of the \"text_value\" field.",
+ "type": "string"
+ },
+ "type": {
+ "description": "Type holds the value of the \"type\" field.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/templatefield.Type"
+ }
+ ]
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.TemplateFieldEdges": {
+ "type": "object",
+ "properties": {
+ "item_template": {
+ "description": "ItemTemplate holds the value of the item_template edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.ItemTemplate"
+ }
+ ]
+ }
+ }
+ },
"ent.User": {
"type": "object",
"properties": {
@@ -3083,6 +3518,14 @@ const docTemplate = `{
"description": "Name holds the value of the \"name\" field.",
"type": "string"
},
+ "oidc_issuer": {
+ "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.",
+ "type": "string"
+ },
+ "oidc_subject": {
+ "description": "OidcSubject holds the value of the \"oidc_subject\" field.",
+ "type": "string"
+ },
"role": {
"description": "Role holds the value of the \"role\" field.",
"allOf": [
@@ -3583,6 +4026,280 @@ const docTemplate = `{
}
}
},
+ "repo.ItemTemplateCreate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "x-nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "x-nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
+ "repo.ItemTemplateOut": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "defaultDescription": {
+ "type": "string"
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabels": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateLabelSummary"
+ }
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocation": {
+ "description": "Default location and labels",
+ "allOf": [
+ {
+ "$ref": "#/definitions/repo.TemplateLocationSummary"
+ }
+ ]
+ },
+ "defaultManufacturer": {
+ "type": "string"
+ },
+ "defaultModelNumber": {
+ "type": "string"
+ },
+ "defaultName": {
+ "type": "string"
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer"
+ },
+ "defaultWarrantyDetails": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "notes": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateSummary": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateUpdate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "x-nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "x-nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
"repo.ItemType": {
"type": "string",
"enum": [
@@ -4078,6 +4795,45 @@ const docTemplate = `{
}
}
},
+ "repo.TemplateField": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "textValue": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLabelSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLocationSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
"repo.TotalsByOrganizer": {
"type": "object",
"properties": {
@@ -4135,6 +4891,12 @@ const docTemplate = `{
},
"name": {
"type": "string"
+ },
+ "oidcIssuer": {
+ "type": "string"
+ },
+ "oidcSubject": {
+ "type": "string"
}
}
},
@@ -4214,6 +4976,15 @@ const docTemplate = `{
}
}
},
+ "templatefield.Type": {
+ "type": "string",
+ "enum": [
+ "text"
+ ],
+ "x-enum-varnames": [
+ "TypeText"
+ ]
+ },
"user.Role": {
"type": "string",
"enum": [
@@ -4251,6 +5022,9 @@ const docTemplate = `{
"message": {
"type": "string"
},
+ "oidc": {
+ "$ref": "#/definitions/v1.OIDCStatus"
+ },
"title": {
"type": "string"
},
@@ -4333,6 +5107,36 @@ const docTemplate = `{
}
}
},
+ "v1.ItemTemplateCreateItemRequest": {
+ "type": "object",
+ "required": [
+ "locationId",
+ "name"
+ ],
+ "properties": {
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "labelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "locationId": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "quantity": {
+ "type": "integer"
+ }
+ }
+ },
"v1.LoginForm": {
"type": "object",
"properties": {
@@ -4349,6 +5153,23 @@ const docTemplate = `{
}
}
},
+ "v1.OIDCStatus": {
+ "type": "object",
+ "properties": {
+ "allowLocal": {
+ "type": "boolean"
+ },
+ "autoRedirect": {
+ "type": "boolean"
+ },
+ "buttonText": {
+ "type": "string"
+ },
+ "enabled": {
+ "type": "boolean"
+ }
+ }
+ },
"v1.TokenResponse": {
"type": "object",
"properties": {
diff --git a/backend/app/api/static/docs/openapi-3.json b/backend/app/api/static/docs/openapi-3.json
index 2ae3681d..a80a6124 100644
--- a/backend/app/api/static/docs/openapi-3.json
+++ b/backend/app/api/static/docs/openapi-3.json
@@ -2122,6 +2122,223 @@
}
}
},
+ "/v1/templates": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get All Item Templates",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.ItemTemplateSummary"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item Template",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateCreate"
+ }
+ }
+ },
+ "description": "Template Data",
+ "required": true
+ },
+ "responses": {
+ "201": {
+ "description": "Created",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get Item Template",
+ "parameters": [
+ {
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Update Item Template",
+ "parameters": [
+ {
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateUpdate"
+ }
+ }
+ },
+ "description": "Template Data",
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Delete Item Template",
+ "parameters": [
+ {
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}/create-item": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item from Template",
+ "parameters": [
+ {
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/v1.ItemTemplateCreateItemRequest"
+ }
+ }
+ },
+ "description": "Item Data",
+ "required": true
+ },
+ "responses": {
+ "201": {
+ "description": "Created",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemOut"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"/v1/users/change-password": {
"put": {
"security": [
@@ -2197,6 +2414,52 @@
}
}
},
+ "/v1/users/login/oidc": {
+ "get": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Login Initiation",
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
+ "/v1/users/login/oidc/callback": {
+ "get": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Callback Handler",
+ "parameters": [
+ {
+ "description": "Authorization code",
+ "name": "code",
+ "in": "query",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "description": "State parameter",
+ "name": "state",
+ "in": "query",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
"/v1/users/logout": {
"post": {
"security": [
@@ -2254,6 +2517,16 @@
"responses": {
"204": {
"description": "No Content"
+ },
+ "403": {
+ "description": "Local login is not enabled",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
}
}
}
@@ -2640,6 +2913,13 @@
"$ref": "#/components/schemas/ent.GroupInvitationToken"
}
},
+ "item_templates": {
+ "description": "ItemTemplates holds the value of the item_templates edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ent.ItemTemplate"
+ }
+ },
"items": {
"description": "Items holds the value of the items edge.",
"type": "array",
@@ -2977,35 +3257,151 @@
}
}
},
- "ent.Label": {
+ "ent.ItemTemplate": {
"type": "object",
"properties": {
- "color": {
- "description": "Color holds the value of the \"color\" field.",
- "type": "string"
- },
"created_at": {
"description": "CreatedAt holds the value of the \"created_at\" field.",
"type": "string"
},
- "description": {
- "description": "Description holds the value of the \"description\" field.",
+ "default_description": {
+ "description": "Default description for items created from this template",
"type": "string"
},
- "edges": {
- "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
- "allOf": [
- {
- "$ref": "#/components/schemas/ent.LabelEdges"
- }
- ]
- },
- "id": {
- "description": "ID of the ent.",
- "type": "string"
+ "default_insured": {
+ "description": "DefaultInsured holds the value of the \"default_insured\" field.",
+ "type": "boolean"
},
- "name": {
- "description": "Name holds the value of the \"name\" field.",
+ "default_label_ids": {
+ "description": "Default label IDs for items created from this template",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "default_lifetime_warranty": {
+ "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.",
+ "type": "boolean"
+ },
+ "default_manufacturer": {
+ "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.",
+ "type": "string"
+ },
+ "default_model_number": {
+ "description": "Default model number for items created from this template",
+ "type": "string"
+ },
+ "default_name": {
+ "description": "Default name template for items (can use placeholders)",
+ "type": "string"
+ },
+ "default_quantity": {
+ "description": "DefaultQuantity holds the value of the \"default_quantity\" field.",
+ "type": "integer"
+ },
+ "default_warranty_details": {
+ "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.ItemTemplateEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "include_purchase_fields": {
+ "description": "Whether to include purchase fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_sold_fields": {
+ "description": "Whether to include sold fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_warranty_fields": {
+ "description": "Whether to include warranty fields in items created from this template",
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "notes": {
+ "description": "Notes holds the value of the \"notes\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.ItemTemplateEdges": {
+ "type": "object",
+ "properties": {
+ "fields": {
+ "description": "Fields holds the value of the fields edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ent.TemplateField"
+ }
+ },
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.Group"
+ }
+ ]
+ },
+ "location": {
+ "description": "Location holds the value of the location edge.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.Location"
+ }
+ ]
+ }
+ }
+ },
+ "ent.Label": {
+ "type": "object",
+ "properties": {
+ "color": {
+ "description": "Color holds the value of the \"color\" field.",
+ "type": "string"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.LabelEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
"type": "string"
},
"updated_at": {
@@ -3226,6 +3622,64 @@
}
}
},
+ "ent.TemplateField": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.TemplateFieldEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "text_value": {
+ "description": "TextValue holds the value of the \"text_value\" field.",
+ "type": "string"
+ },
+ "type": {
+ "description": "Type holds the value of the \"type\" field.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/templatefield.Type"
+ }
+ ]
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.TemplateFieldEdges": {
+ "type": "object",
+ "properties": {
+ "item_template": {
+ "description": "ItemTemplate holds the value of the item_template edge.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.ItemTemplate"
+ }
+ ]
+ }
+ }
+ },
"ent.User": {
"type": "object",
"properties": {
@@ -3261,6 +3715,14 @@
"description": "Name holds the value of the \"name\" field.",
"type": "string"
},
+ "oidc_issuer": {
+ "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.",
+ "type": "string"
+ },
+ "oidc_subject": {
+ "description": "OidcSubject holds the value of the \"oidc_subject\" field.",
+ "type": "string"
+ },
"role": {
"description": "Role holds the value of the \"role\" field.",
"allOf": [
@@ -3761,6 +4223,280 @@
}
}
},
+ "repo.ItemTemplateCreate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.TemplateField"
+ }
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
+ "repo.ItemTemplateOut": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "defaultDescription": {
+ "type": "string"
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabels": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.TemplateLabelSummary"
+ }
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocation": {
+ "description": "Default location and labels",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/repo.TemplateLocationSummary"
+ }
+ ]
+ },
+ "defaultManufacturer": {
+ "type": "string"
+ },
+ "defaultModelNumber": {
+ "type": "string"
+ },
+ "defaultName": {
+ "type": "string"
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer"
+ },
+ "defaultWarrantyDetails": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "notes": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateSummary": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateUpdate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
"repo.ItemType": {
"type": "string",
"enum": [
@@ -4256,6 +4992,45 @@
}
}
},
+ "repo.TemplateField": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "textValue": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLabelSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLocationSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
"repo.TotalsByOrganizer": {
"type": "object",
"properties": {
@@ -4313,6 +5088,12 @@
},
"name": {
"type": "string"
+ },
+ "oidcIssuer": {
+ "type": "string"
+ },
+ "oidcSubject": {
+ "type": "string"
}
}
},
@@ -4392,6 +5173,15 @@
}
}
},
+ "templatefield.Type": {
+ "type": "string",
+ "enum": [
+ "text"
+ ],
+ "x-enum-varnames": [
+ "TypeText"
+ ]
+ },
"user.Role": {
"type": "string",
"enum": [
@@ -4429,6 +5219,9 @@
"message": {
"type": "string"
},
+ "oidc": {
+ "$ref": "#/components/schemas/v1.OIDCStatus"
+ },
"title": {
"type": "string"
},
@@ -4511,6 +5304,36 @@
}
}
},
+ "v1.ItemTemplateCreateItemRequest": {
+ "type": "object",
+ "required": [
+ "locationId",
+ "name"
+ ],
+ "properties": {
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "labelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "locationId": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "quantity": {
+ "type": "integer"
+ }
+ }
+ },
"v1.LoginForm": {
"type": "object",
"properties": {
@@ -4527,6 +5350,23 @@
}
}
},
+ "v1.OIDCStatus": {
+ "type": "object",
+ "properties": {
+ "allowLocal": {
+ "type": "boolean"
+ },
+ "autoRedirect": {
+ "type": "boolean"
+ },
+ "buttonText": {
+ "type": "string"
+ },
+ "enabled": {
+ "type": "boolean"
+ }
+ }
+ },
"v1.TokenResponse": {
"type": "object",
"properties": {
diff --git a/backend/app/api/static/docs/openapi-3.yaml b/backend/app/api/static/docs/openapi-3.yaml
index bc56d4a2..0a6d2042 100644
--- a/backend/app/api/static/docs/openapi-3.yaml
+++ b/backend/app/api/static/docs/openapi-3.yaml
@@ -1257,6 +1257,134 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/v1.APISummary"
+ /v1/templates:
+ get:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Get All Item Templates
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.ItemTemplateSummary"
+ post:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Create Item Template
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateCreate"
+ description: Template Data
+ required: true
+ responses:
+ "201":
+ description: Created
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateOut"
+ "/v1/templates/{id}":
+ get:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Get Item Template
+ parameters:
+ - description: Template ID
+ name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateOut"
+ put:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Update Item Template
+ parameters:
+ - description: Template ID
+ name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateUpdate"
+ description: Template Data
+ required: true
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateOut"
+ delete:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Delete Item Template
+ parameters:
+ - description: Template ID
+ name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "204":
+ description: No Content
+ "/v1/templates/{id}/create-item":
+ post:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Create Item from Template
+ parameters:
+ - description: Template ID
+ name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/v1.ItemTemplateCreateItemRequest"
+ description: Item Data
+ required: true
+ responses:
+ "201":
+ description: Created
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemOut"
/v1/users/change-password:
put:
security:
@@ -1302,6 +1430,35 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/v1.TokenResponse"
+ /v1/users/login/oidc:
+ get:
+ tags:
+ - Authentication
+ summary: OIDC Login Initiation
+ responses:
+ "302":
+ description: Found
+ /v1/users/login/oidc/callback:
+ get:
+ tags:
+ - Authentication
+ summary: OIDC Callback Handler
+ parameters:
+ - description: Authorization code
+ name: code
+ in: query
+ required: true
+ schema:
+ type: string
+ - description: State parameter
+ name: state
+ in: query
+ required: true
+ schema:
+ type: string
+ responses:
+ "302":
+ description: Found
/v1/users/logout:
post:
security:
@@ -1342,6 +1499,12 @@ paths:
responses:
"204":
description: No Content
+ "403":
+ description: Local login is not enabled
+ content:
+ application/json:
+ schema:
+ type: string
/v1/users/self:
get:
security:
@@ -1590,6 +1753,11 @@ components:
type: array
items:
$ref: "#/components/schemas/ent.GroupInvitationToken"
+ item_templates:
+ description: ItemTemplates holds the value of the item_templates edge.
+ type: array
+ items:
+ $ref: "#/components/schemas/ent.ItemTemplate"
items:
description: Items holds the value of the items edge.
type: array
@@ -1826,6 +1994,93 @@ components:
description: Item holds the value of the item edge.
allOf:
- $ref: "#/components/schemas/ent.Item"
+ ent.ItemTemplate:
+ type: object
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ default_description:
+ description: Default description for items created from this template
+ type: string
+ default_insured:
+ description: DefaultInsured holds the value of the "default_insured" field.
+ type: boolean
+ default_label_ids:
+ description: Default label IDs for items created from this template
+ type: array
+ items:
+ type: string
+ default_lifetime_warranty:
+ description: DefaultLifetimeWarranty holds the value of the
+ "default_lifetime_warranty" field.
+ type: boolean
+ default_manufacturer:
+ description: DefaultManufacturer holds the value of the "default_manufacturer"
+ field.
+ type: string
+ default_model_number:
+ description: Default model number for items created from this template
+ type: string
+ default_name:
+ description: Default name template for items (can use placeholders)
+ type: string
+ default_quantity:
+ description: DefaultQuantity holds the value of the "default_quantity" field.
+ type: integer
+ default_warranty_details:
+ description: DefaultWarrantyDetails holds the value of the
+ "default_warranty_details" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ description: >-
+ Edges holds the relations/edges for other nodes in the graph.
+
+ The values are being populated by the ItemTemplateQuery when eager-loading is set.
+ allOf:
+ - $ref: "#/components/schemas/ent.ItemTemplateEdges"
+ id:
+ description: ID of the ent.
+ type: string
+ include_purchase_fields:
+ description: Whether to include purchase fields in items created from this
+ template
+ type: boolean
+ include_sold_fields:
+ description: Whether to include sold fields in items created from this template
+ type: boolean
+ include_warranty_fields:
+ description: Whether to include warranty fields in items created from this
+ template
+ type: boolean
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ notes:
+ description: Notes holds the value of the "notes" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ ent.ItemTemplateEdges:
+ type: object
+ properties:
+ fields:
+ description: Fields holds the value of the fields edge.
+ type: array
+ items:
+ $ref: "#/components/schemas/ent.TemplateField"
+ group:
+ description: Group holds the value of the group edge.
+ allOf:
+ - $ref: "#/components/schemas/ent.Group"
+ location:
+ description: Location holds the value of the location edge.
+ allOf:
+ - $ref: "#/components/schemas/ent.Location"
ent.Label:
type: object
properties:
@@ -1998,6 +2253,45 @@ components:
description: User holds the value of the user edge.
allOf:
- $ref: "#/components/schemas/ent.User"
+ ent.TemplateField:
+ type: object
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ description: >-
+ Edges holds the relations/edges for other nodes in the graph.
+
+ The values are being populated by the TemplateFieldQuery when eager-loading is set.
+ allOf:
+ - $ref: "#/components/schemas/ent.TemplateFieldEdges"
+ id:
+ description: ID of the ent.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ text_value:
+ description: TextValue holds the value of the "text_value" field.
+ type: string
+ type:
+ description: Type holds the value of the "type" field.
+ allOf:
+ - $ref: "#/components/schemas/templatefield.Type"
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ ent.TemplateFieldEdges:
+ type: object
+ properties:
+ item_template:
+ description: ItemTemplate holds the value of the item_template edge.
+ allOf:
+ - $ref: "#/components/schemas/ent.ItemTemplate"
ent.User:
type: object
properties:
@@ -2026,6 +2320,12 @@ components:
name:
description: Name holds the value of the "name" field.
type: string
+ oidc_issuer:
+ description: OidcIssuer holds the value of the "oidc_issuer" field.
+ type: string
+ oidc_subject:
+ description: OidcSubject holds the value of the "oidc_subject" field.
+ type: string
role:
description: Role holds the value of the "role" field.
allOf:
@@ -2361,6 +2661,201 @@ components:
nullable: true
updatedAt:
type: string
+ repo.ItemTemplateCreate:
+ type: object
+ required:
+ - name
+ properties:
+ defaultDescription:
+ type: string
+ maxLength: 1000
+ nullable: true
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ type: array
+ items:
+ type: string
+ nullable: true
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ nullable: true
+ defaultManufacturer:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultModelNumber:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultName:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ nullable: true
+ defaultWarrantyDetails:
+ type: string
+ maxLength: 1000
+ nullable: true
+ description:
+ type: string
+ maxLength: 1000
+ fields:
+ description: Custom fields
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.TemplateField"
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ type: string
+ maxLength: 255
+ minLength: 1
+ notes:
+ type: string
+ maxLength: 1000
+ repo.ItemTemplateOut:
+ type: object
+ properties:
+ createdAt:
+ type: string
+ defaultDescription:
+ type: string
+ defaultInsured:
+ type: boolean
+ defaultLabels:
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.TemplateLabelSummary"
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocation:
+ description: Default location and labels
+ allOf:
+ - $ref: "#/components/schemas/repo.TemplateLocationSummary"
+ defaultManufacturer:
+ type: string
+ defaultModelNumber:
+ type: string
+ defaultName:
+ type: string
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ defaultWarrantyDetails:
+ type: string
+ description:
+ type: string
+ fields:
+ description: Custom fields
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.TemplateField"
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ type: string
+ notes:
+ type: string
+ updatedAt:
+ type: string
+ repo.ItemTemplateSummary:
+ type: object
+ properties:
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ updatedAt:
+ type: string
+ repo.ItemTemplateUpdate:
+ type: object
+ required:
+ - name
+ properties:
+ defaultDescription:
+ type: string
+ maxLength: 1000
+ nullable: true
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ type: array
+ items:
+ type: string
+ nullable: true
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ nullable: true
+ defaultManufacturer:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultModelNumber:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultName:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ nullable: true
+ defaultWarrantyDetails:
+ type: string
+ maxLength: 1000
+ nullable: true
+ description:
+ type: string
+ maxLength: 1000
+ fields:
+ description: Custom fields
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.TemplateField"
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ type: string
+ maxLength: 255
+ minLength: 1
+ notes:
+ type: string
+ maxLength: 1000
repo.ItemType:
type: string
enum:
@@ -2698,6 +3193,31 @@ components:
type: integer
total:
type: integer
+ repo.TemplateField:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ textValue:
+ type: string
+ type:
+ type: string
+ repo.TemplateLabelSummary:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ repo.TemplateLocationSummary:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
repo.TotalsByOrganizer:
type: object
properties:
@@ -2737,6 +3257,10 @@ components:
type: boolean
name:
type: string
+ oidcIssuer:
+ type: string
+ oidcSubject:
+ type: string
repo.UserUpdate:
type: object
properties:
@@ -2786,6 +3310,12 @@ components:
type: string
token:
type: string
+ templatefield.Type:
+ type: string
+ enum:
+ - text
+ x-enum-varnames:
+ - TypeText
user.Role:
type: string
enum:
@@ -2813,6 +3343,8 @@ components:
$ref: "#/components/schemas/services.Latest"
message:
type: string
+ oidc:
+ $ref: "#/components/schemas/v1.OIDCStatus"
title:
type: string
versions:
@@ -2865,6 +3397,27 @@ components:
properties:
token:
type: string
+ v1.ItemTemplateCreateItemRequest:
+ type: object
+ required:
+ - locationId
+ - name
+ properties:
+ description:
+ type: string
+ maxLength: 1000
+ labelIds:
+ type: array
+ items:
+ type: string
+ locationId:
+ type: string
+ name:
+ type: string
+ maxLength: 255
+ minLength: 1
+ quantity:
+ type: integer
v1.LoginForm:
type: object
properties:
@@ -2876,6 +3429,17 @@ components:
username:
type: string
+ v1.OIDCStatus:
+ type: object
+ properties:
+ allowLocal:
+ type: boolean
+ autoRedirect:
+ type: boolean
+ buttonText:
+ type: string
+ enabled:
+ type: boolean
v1.TokenResponse:
type: object
properties:
diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json
index 3fd96322..61b8612a 100644
--- a/backend/app/api/static/docs/swagger.json
+++ b/backend/app/api/static/docs/swagger.json
@@ -1961,6 +1961,209 @@
}
}
},
+ "/v1/templates": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get All Item Templates",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ItemTemplateSummary"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item Template",
+ "parameters": [
+ {
+ "description": "Template Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateCreate"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Update Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Template Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Delete Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}/create-item": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item from Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Item Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v1.ItemTemplateCreateItemRequest"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ }
+ }
+ }
+ },
"/v1/users/change-password": {
"put": {
"security": [
@@ -2030,6 +2233,51 @@
}
}
},
+ "/v1/users/login/oidc": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Login Initiation",
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
+ "/v1/users/login/oidc/callback": {
+ "get": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Callback Handler",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Authorization code",
+ "name": "code",
+ "in": "query",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "State parameter",
+ "name": "state",
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
"/v1/users/logout": {
"post": {
"security": [
@@ -2090,6 +2338,12 @@
"responses": {
"204": {
"description": "No Content"
+ },
+ "403": {
+ "description": "Local login is not enabled",
+ "schema": {
+ "type": "string"
+ }
}
}
}
@@ -2460,6 +2714,13 @@
"$ref": "#/definitions/ent.GroupInvitationToken"
}
},
+ "item_templates": {
+ "description": "ItemTemplates holds the value of the item_templates edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.ItemTemplate"
+ }
+ },
"items": {
"description": "Items holds the value of the items edge.",
"type": "array",
@@ -2797,26 +3058,61 @@
}
}
},
- "ent.Label": {
+ "ent.ItemTemplate": {
"type": "object",
"properties": {
- "color": {
- "description": "Color holds the value of the \"color\" field.",
- "type": "string"
- },
"created_at": {
"description": "CreatedAt holds the value of the \"created_at\" field.",
"type": "string"
},
+ "default_description": {
+ "description": "Default description for items created from this template",
+ "type": "string"
+ },
+ "default_insured": {
+ "description": "DefaultInsured holds the value of the \"default_insured\" field.",
+ "type": "boolean"
+ },
+ "default_label_ids": {
+ "description": "Default label IDs for items created from this template",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "default_lifetime_warranty": {
+ "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.",
+ "type": "boolean"
+ },
+ "default_manufacturer": {
+ "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.",
+ "type": "string"
+ },
+ "default_model_number": {
+ "description": "Default model number for items created from this template",
+ "type": "string"
+ },
+ "default_name": {
+ "description": "Default name template for items (can use placeholders)",
+ "type": "string"
+ },
+ "default_quantity": {
+ "description": "DefaultQuantity holds the value of the \"default_quantity\" field.",
+ "type": "integer"
+ },
+ "default_warranty_details": {
+ "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.",
+ "type": "string"
+ },
"description": {
"description": "Description holds the value of the \"description\" field.",
"type": "string"
},
"edges": {
- "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.",
"allOf": [
{
- "$ref": "#/definitions/ent.LabelEdges"
+ "$ref": "#/definitions/ent.ItemTemplateEdges"
}
]
},
@@ -2824,20 +3120,101 @@
"description": "ID of the ent.",
"type": "string"
},
+ "include_purchase_fields": {
+ "description": "Whether to include purchase fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_sold_fields": {
+ "description": "Whether to include sold fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_warranty_fields": {
+ "description": "Whether to include warranty fields in items created from this template",
+ "type": "boolean"
+ },
"name": {
"description": "Name holds the value of the \"name\" field.",
"type": "string"
},
+ "notes": {
+ "description": "Notes holds the value of the \"notes\" field.",
+ "type": "string"
+ },
"updated_at": {
"description": "UpdatedAt holds the value of the \"updated_at\" field.",
"type": "string"
}
}
},
- "ent.LabelEdges": {
+ "ent.ItemTemplateEdges": {
"type": "object",
"properties": {
- "group": {
+ "fields": {
+ "description": "Fields holds the value of the fields edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.TemplateField"
+ }
+ },
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ },
+ "location": {
+ "description": "Location holds the value of the location edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Location"
+ }
+ ]
+ }
+ }
+ },
+ "ent.Label": {
+ "type": "object",
+ "properties": {
+ "color": {
+ "description": "Color holds the value of the \"color\" field.",
+ "type": "string"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.LabelEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.LabelEdges": {
+ "type": "object",
+ "properties": {
+ "group": {
"description": "Group holds the value of the group edge.",
"allOf": [
{
@@ -3046,6 +3423,64 @@
}
}
},
+ "ent.TemplateField": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.TemplateFieldEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "text_value": {
+ "description": "TextValue holds the value of the \"text_value\" field.",
+ "type": "string"
+ },
+ "type": {
+ "description": "Type holds the value of the \"type\" field.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/templatefield.Type"
+ }
+ ]
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.TemplateFieldEdges": {
+ "type": "object",
+ "properties": {
+ "item_template": {
+ "description": "ItemTemplate holds the value of the item_template edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.ItemTemplate"
+ }
+ ]
+ }
+ }
+ },
"ent.User": {
"type": "object",
"properties": {
@@ -3081,6 +3516,14 @@
"description": "Name holds the value of the \"name\" field.",
"type": "string"
},
+ "oidc_issuer": {
+ "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.",
+ "type": "string"
+ },
+ "oidc_subject": {
+ "description": "OidcSubject holds the value of the \"oidc_subject\" field.",
+ "type": "string"
+ },
"role": {
"description": "Role holds the value of the \"role\" field.",
"allOf": [
@@ -3581,6 +4024,280 @@
}
}
},
+ "repo.ItemTemplateCreate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "x-nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "x-nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
+ "repo.ItemTemplateOut": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "defaultDescription": {
+ "type": "string"
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabels": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateLabelSummary"
+ }
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocation": {
+ "description": "Default location and labels",
+ "allOf": [
+ {
+ "$ref": "#/definitions/repo.TemplateLocationSummary"
+ }
+ ]
+ },
+ "defaultManufacturer": {
+ "type": "string"
+ },
+ "defaultModelNumber": {
+ "type": "string"
+ },
+ "defaultName": {
+ "type": "string"
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer"
+ },
+ "defaultWarrantyDetails": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "notes": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateSummary": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateUpdate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "x-nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "x-nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
"repo.ItemType": {
"type": "string",
"enum": [
@@ -4076,6 +4793,45 @@
}
}
},
+ "repo.TemplateField": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "textValue": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLabelSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLocationSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
"repo.TotalsByOrganizer": {
"type": "object",
"properties": {
@@ -4133,6 +4889,12 @@
},
"name": {
"type": "string"
+ },
+ "oidcIssuer": {
+ "type": "string"
+ },
+ "oidcSubject": {
+ "type": "string"
}
}
},
@@ -4212,6 +4974,15 @@
}
}
},
+ "templatefield.Type": {
+ "type": "string",
+ "enum": [
+ "text"
+ ],
+ "x-enum-varnames": [
+ "TypeText"
+ ]
+ },
"user.Role": {
"type": "string",
"enum": [
@@ -4249,6 +5020,9 @@
"message": {
"type": "string"
},
+ "oidc": {
+ "$ref": "#/definitions/v1.OIDCStatus"
+ },
"title": {
"type": "string"
},
@@ -4331,6 +5105,36 @@
}
}
},
+ "v1.ItemTemplateCreateItemRequest": {
+ "type": "object",
+ "required": [
+ "locationId",
+ "name"
+ ],
+ "properties": {
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "labelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "locationId": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "quantity": {
+ "type": "integer"
+ }
+ }
+ },
"v1.LoginForm": {
"type": "object",
"properties": {
@@ -4347,6 +5151,23 @@
}
}
},
+ "v1.OIDCStatus": {
+ "type": "object",
+ "properties": {
+ "allowLocal": {
+ "type": "boolean"
+ },
+ "autoRedirect": {
+ "type": "boolean"
+ },
+ "buttonText": {
+ "type": "string"
+ },
+ "enabled": {
+ "type": "boolean"
+ }
+ }
+ },
"v1.TokenResponse": {
"type": "object",
"properties": {
diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml
index 1fc5f05e..d18a8f45 100644
--- a/backend/app/api/static/docs/swagger.yaml
+++ b/backend/app/api/static/docs/swagger.yaml
@@ -179,6 +179,11 @@ definitions:
items:
$ref: '#/definitions/ent.GroupInvitationToken'
type: array
+ item_templates:
+ description: ItemTemplates holds the value of the item_templates edge.
+ items:
+ $ref: '#/definitions/ent.ItemTemplate'
+ type: array
items:
description: Items holds the value of the items edge.
items:
@@ -414,6 +419,92 @@ definitions:
- $ref: '#/definitions/ent.Item'
description: Item holds the value of the item edge.
type: object
+ ent.ItemTemplate:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ default_description:
+ description: Default description for items created from this template
+ type: string
+ default_insured:
+ description: DefaultInsured holds the value of the "default_insured" field.
+ type: boolean
+ default_label_ids:
+ description: Default label IDs for items created from this template
+ items:
+ type: string
+ type: array
+ default_lifetime_warranty:
+ description: DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty"
+ field.
+ type: boolean
+ default_manufacturer:
+ description: DefaultManufacturer holds the value of the "default_manufacturer"
+ field.
+ type: string
+ default_model_number:
+ description: Default model number for items created from this template
+ type: string
+ default_name:
+ description: Default name template for items (can use placeholders)
+ type: string
+ default_quantity:
+ description: DefaultQuantity holds the value of the "default_quantity" field.
+ type: integer
+ default_warranty_details:
+ description: DefaultWarrantyDetails holds the value of the "default_warranty_details"
+ field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.ItemTemplateEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the ItemTemplateQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ include_purchase_fields:
+ description: Whether to include purchase fields in items created from this
+ template
+ type: boolean
+ include_sold_fields:
+ description: Whether to include sold fields in items created from this template
+ type: boolean
+ include_warranty_fields:
+ description: Whether to include warranty fields in items created from this
+ template
+ type: boolean
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ notes:
+ description: Notes holds the value of the "notes" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.ItemTemplateEdges:
+ properties:
+ fields:
+ description: Fields holds the value of the fields edge.
+ items:
+ $ref: '#/definitions/ent.TemplateField'
+ type: array
+ group:
+ allOf:
+ - $ref: '#/definitions/ent.Group'
+ description: Group holds the value of the group edge.
+ location:
+ allOf:
+ - $ref: '#/definitions/ent.Location'
+ description: Location holds the value of the location edge.
+ type: object
ent.Label:
properties:
color:
@@ -582,6 +673,44 @@ definitions:
- $ref: '#/definitions/ent.User'
description: User holds the value of the user edge.
type: object
+ ent.TemplateField:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.TemplateFieldEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the TemplateFieldQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ text_value:
+ description: TextValue holds the value of the "text_value" field.
+ type: string
+ type:
+ allOf:
+ - $ref: '#/definitions/templatefield.Type'
+ description: Type holds the value of the "type" field.
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.TemplateFieldEdges:
+ properties:
+ item_template:
+ allOf:
+ - $ref: '#/definitions/ent.ItemTemplate'
+ description: ItemTemplate holds the value of the item_template edge.
+ type: object
ent.User:
properties:
activated_on:
@@ -608,6 +737,12 @@ definitions:
name:
description: Name holds the value of the "name" field.
type: string
+ oidc_issuer:
+ description: OidcIssuer holds the value of the "oidc_issuer" field.
+ type: string
+ oidc_subject:
+ description: OidcSubject holds the value of the "oidc_subject" field.
+ type: string
role:
allOf:
- $ref: '#/definitions/user.Role'
@@ -944,6 +1079,201 @@ definitions:
updatedAt:
type: string
type: object
+ repo.ItemTemplateCreate:
+ properties:
+ defaultDescription:
+ maxLength: 1000
+ type: string
+ x-nullable: true
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ items:
+ type: string
+ type: array
+ x-nullable: true
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ x-nullable: true
+ defaultManufacturer:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultModelNumber:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultName:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ x-nullable: true
+ defaultWarrantyDetails:
+ maxLength: 1000
+ type: string
+ x-nullable: true
+ description:
+ maxLength: 1000
+ type: string
+ fields:
+ description: Custom fields
+ items:
+ $ref: '#/definitions/repo.TemplateField'
+ type: array
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ notes:
+ maxLength: 1000
+ type: string
+ required:
+ - name
+ type: object
+ repo.ItemTemplateOut:
+ properties:
+ createdAt:
+ type: string
+ defaultDescription:
+ type: string
+ defaultInsured:
+ type: boolean
+ defaultLabels:
+ items:
+ $ref: '#/definitions/repo.TemplateLabelSummary'
+ type: array
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocation:
+ allOf:
+ - $ref: '#/definitions/repo.TemplateLocationSummary'
+ description: Default location and labels
+ defaultManufacturer:
+ type: string
+ defaultModelNumber:
+ type: string
+ defaultName:
+ type: string
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ defaultWarrantyDetails:
+ type: string
+ description:
+ type: string
+ fields:
+ description: Custom fields
+ items:
+ $ref: '#/definitions/repo.TemplateField'
+ type: array
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ type: string
+ notes:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.ItemTemplateSummary:
+ properties:
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.ItemTemplateUpdate:
+ properties:
+ defaultDescription:
+ maxLength: 1000
+ type: string
+ x-nullable: true
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ items:
+ type: string
+ type: array
+ x-nullable: true
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ x-nullable: true
+ defaultManufacturer:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultModelNumber:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultName:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ x-nullable: true
+ defaultWarrantyDetails:
+ maxLength: 1000
+ type: string
+ x-nullable: true
+ description:
+ maxLength: 1000
+ type: string
+ fields:
+ description: Custom fields
+ items:
+ $ref: '#/definitions/repo.TemplateField'
+ type: array
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ notes:
+ maxLength: 1000
+ type: string
+ required:
+ - name
+ type: object
repo.ItemType:
enum:
- location
@@ -1281,6 +1611,31 @@ definitions:
total:
type: integer
type: object
+ repo.TemplateField:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ textValue:
+ type: string
+ type:
+ type: string
+ type: object
+ repo.TemplateLabelSummary:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ type: object
+ repo.TemplateLocationSummary:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ type: object
repo.TotalsByOrganizer:
properties:
id:
@@ -1319,6 +1674,10 @@ definitions:
type: boolean
name:
type: string
+ oidcIssuer:
+ type: string
+ oidcSubject:
+ type: string
type: object
repo.UserUpdate:
properties:
@@ -1369,6 +1728,12 @@ definitions:
token:
type: string
type: object
+ templatefield.Type:
+ enum:
+ - text
+ type: string
+ x-enum-varnames:
+ - TypeText
user.Role:
enum:
- user
@@ -1395,6 +1760,8 @@ definitions:
$ref: '#/definitions/services.Latest'
message:
type: string
+ oidc:
+ $ref: '#/definitions/v1.OIDCStatus'
title:
type: string
versions:
@@ -1448,6 +1815,27 @@ definitions:
token:
type: string
type: object
+ v1.ItemTemplateCreateItemRequest:
+ properties:
+ description:
+ maxLength: 1000
+ type: string
+ labelIds:
+ items:
+ type: string
+ type: array
+ locationId:
+ type: string
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ quantity:
+ type: integer
+ required:
+ - locationId
+ - name
+ type: object
v1.LoginForm:
properties:
password:
@@ -1459,6 +1847,17 @@ definitions:
type: string
type: object
+ v1.OIDCStatus:
+ properties:
+ allowLocal:
+ type: boolean
+ autoRedirect:
+ type: boolean
+ buttonText:
+ type: string
+ enabled:
+ type: boolean
+ type: object
v1.TokenResponse:
properties:
attachmentToken:
@@ -2679,6 +3078,130 @@ paths:
summary: Application Info
tags:
- Base
+ /v1/templates:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.ItemTemplateSummary'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get All Item Templates
+ tags:
+ - Item Templates
+ post:
+ parameters:
+ - description: Template Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateCreate'
+ produces:
+ - application/json
+ responses:
+ "201":
+ description: Created
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateOut'
+ security:
+ - Bearer: []
+ summary: Create Item Template
+ tags:
+ - Item Templates
+ /v1/templates/{id}:
+ delete:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Delete Item Template
+ tags:
+ - Item Templates
+ get:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateOut'
+ security:
+ - Bearer: []
+ summary: Get Item Template
+ tags:
+ - Item Templates
+ put:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Template Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateUpdate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateOut'
+ security:
+ - Bearer: []
+ summary: Update Item Template
+ tags:
+ - Item Templates
+ /v1/templates/{id}/create-item:
+ post:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Item Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/v1.ItemTemplateCreateItemRequest'
+ produces:
+ - application/json
+ responses:
+ "201":
+ description: Created
+ schema:
+ $ref: '#/definitions/repo.ItemOut'
+ security:
+ - Bearer: []
+ summary: Create Item from Template
+ tags:
+ - Item Templates
/v1/users/change-password:
put:
parameters:
@@ -2722,6 +3245,35 @@ paths:
summary: User Login
tags:
- Authentication
+ /v1/users/login/oidc:
+ get:
+ produces:
+ - application/json
+ responses:
+ "302":
+ description: Found
+ summary: OIDC Login Initiation
+ tags:
+ - Authentication
+ /v1/users/login/oidc/callback:
+ get:
+ parameters:
+ - description: Authorization code
+ in: query
+ name: code
+ required: true
+ type: string
+ - description: State parameter
+ in: query
+ name: state
+ required: true
+ type: string
+ responses:
+ "302":
+ description: Found
+ summary: OIDC Callback Handler
+ tags:
+ - Authentication
/v1/users/logout:
post:
responses:
@@ -2759,6 +3311,10 @@ paths:
responses:
"204":
description: No Content
+ "403":
+ description: Local login is not enabled
+ schema:
+ type: string
summary: Register New User
tags:
- User
diff --git a/backend/internal/data/ent/client.go b/backend/internal/data/ent/client.go
index 6c6c30b9..7cd5830c 100644
--- a/backend/internal/data/ent/client.go
+++ b/backend/internal/data/ent/client.go
@@ -23,10 +23,12 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -49,6 +51,8 @@ type Client struct {
Item *ItemClient
// ItemField is the client for interacting with the ItemField builders.
ItemField *ItemFieldClient
+ // ItemTemplate is the client for interacting with the ItemTemplate builders.
+ ItemTemplate *ItemTemplateClient
// Label is the client for interacting with the Label builders.
Label *LabelClient
// Location is the client for interacting with the Location builders.
@@ -57,6 +61,8 @@ type Client struct {
MaintenanceEntry *MaintenanceEntryClient
// Notifier is the client for interacting with the Notifier builders.
Notifier *NotifierClient
+ // TemplateField is the client for interacting with the TemplateField builders.
+ TemplateField *TemplateFieldClient
// User is the client for interacting with the User builders.
User *UserClient
}
@@ -77,10 +83,12 @@ func (c *Client) init() {
c.GroupInvitationToken = NewGroupInvitationTokenClient(c.config)
c.Item = NewItemClient(c.config)
c.ItemField = NewItemFieldClient(c.config)
+ c.ItemTemplate = NewItemTemplateClient(c.config)
c.Label = NewLabelClient(c.config)
c.Location = NewLocationClient(c.config)
c.MaintenanceEntry = NewMaintenanceEntryClient(c.config)
c.Notifier = NewNotifierClient(c.config)
+ c.TemplateField = NewTemplateFieldClient(c.config)
c.User = NewUserClient(c.config)
}
@@ -181,10 +189,12 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
Item: NewItemClient(cfg),
ItemField: NewItemFieldClient(cfg),
+ ItemTemplate: NewItemTemplateClient(cfg),
Label: NewLabelClient(cfg),
Location: NewLocationClient(cfg),
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
Notifier: NewNotifierClient(cfg),
+ TemplateField: NewTemplateFieldClient(cfg),
User: NewUserClient(cfg),
}, nil
}
@@ -212,10 +222,12 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
Item: NewItemClient(cfg),
ItemField: NewItemFieldClient(cfg),
+ ItemTemplate: NewItemTemplateClient(cfg),
Label: NewLabelClient(cfg),
Location: NewLocationClient(cfg),
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
Notifier: NewNotifierClient(cfg),
+ TemplateField: NewTemplateFieldClient(cfg),
User: NewUserClient(cfg),
}, nil
}
@@ -247,8 +259,8 @@ func (c *Client) Close() error {
func (c *Client) Use(hooks ...Hook) {
for _, n := range []interface{ Use(...Hook) }{
c.Attachment, c.AuthRoles, c.AuthTokens, c.Group, c.GroupInvitationToken,
- c.Item, c.ItemField, c.Label, c.Location, c.MaintenanceEntry, c.Notifier,
- c.User,
+ c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry,
+ c.Notifier, c.TemplateField, c.User,
} {
n.Use(hooks...)
}
@@ -259,8 +271,8 @@ func (c *Client) Use(hooks ...Hook) {
func (c *Client) Intercept(interceptors ...Interceptor) {
for _, n := range []interface{ Intercept(...Interceptor) }{
c.Attachment, c.AuthRoles, c.AuthTokens, c.Group, c.GroupInvitationToken,
- c.Item, c.ItemField, c.Label, c.Location, c.MaintenanceEntry, c.Notifier,
- c.User,
+ c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry,
+ c.Notifier, c.TemplateField, c.User,
} {
n.Intercept(interceptors...)
}
@@ -283,6 +295,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
return c.Item.mutate(ctx, m)
case *ItemFieldMutation:
return c.ItemField.mutate(ctx, m)
+ case *ItemTemplateMutation:
+ return c.ItemTemplate.mutate(ctx, m)
case *LabelMutation:
return c.Label.mutate(ctx, m)
case *LocationMutation:
@@ -291,6 +305,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
return c.MaintenanceEntry.mutate(ctx, m)
case *NotifierMutation:
return c.Notifier.mutate(ctx, m)
+ case *TemplateFieldMutation:
+ return c.TemplateField.mutate(ctx, m)
case *UserMutation:
return c.User.mutate(ctx, m)
default:
@@ -981,6 +997,22 @@ func (c *GroupClient) QueryNotifiers(_m *Group) *NotifierQuery {
return query
}
+// QueryItemTemplates queries the item_templates edge of a Group.
+func (c *GroupClient) QueryItemTemplates(_m *Group) *ItemTemplateQuery {
+ query := (&ItemTemplateClient{config: c.config}).Query()
+ query.path = func(context.Context) (fromV *sql.Selector, _ error) {
+ id := _m.ID
+ step := sqlgraph.NewStep(
+ sqlgraph.From(group.Table, group.FieldID, id),
+ sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
+ sqlgraph.Edge(sqlgraph.O2M, false, group.ItemTemplatesTable, group.ItemTemplatesColumn),
+ )
+ fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
+ return fromV, nil
+ }
+ return query
+}
+
// Hooks returns the client hooks.
func (c *GroupClient) Hooks() []Hook {
return c.hooks.Group
@@ -1565,6 +1597,187 @@ func (c *ItemFieldClient) mutate(ctx context.Context, m *ItemFieldMutation) (Val
}
}
+// ItemTemplateClient is a client for the ItemTemplate schema.
+type ItemTemplateClient struct {
+ config
+}
+
+// NewItemTemplateClient returns a client for the ItemTemplate from the given config.
+func NewItemTemplateClient(c config) *ItemTemplateClient {
+ return &ItemTemplateClient{config: c}
+}
+
+// Use adds a list of mutation hooks to the hooks stack.
+// A call to `Use(f, g, h)` equals to `itemtemplate.Hooks(f(g(h())))`.
+func (c *ItemTemplateClient) Use(hooks ...Hook) {
+ c.hooks.ItemTemplate = append(c.hooks.ItemTemplate, hooks...)
+}
+
+// Intercept adds a list of query interceptors to the interceptors stack.
+// A call to `Intercept(f, g, h)` equals to `itemtemplate.Intercept(f(g(h())))`.
+func (c *ItemTemplateClient) Intercept(interceptors ...Interceptor) {
+ c.inters.ItemTemplate = append(c.inters.ItemTemplate, interceptors...)
+}
+
+// Create returns a builder for creating a ItemTemplate entity.
+func (c *ItemTemplateClient) Create() *ItemTemplateCreate {
+ mutation := newItemTemplateMutation(c.config, OpCreate)
+ return &ItemTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// CreateBulk returns a builder for creating a bulk of ItemTemplate entities.
+func (c *ItemTemplateClient) CreateBulk(builders ...*ItemTemplateCreate) *ItemTemplateCreateBulk {
+ return &ItemTemplateCreateBulk{config: c.config, builders: builders}
+}
+
+// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
+// a builder and applies setFunc on it.
+func (c *ItemTemplateClient) MapCreateBulk(slice any, setFunc func(*ItemTemplateCreate, int)) *ItemTemplateCreateBulk {
+ rv := reflect.ValueOf(slice)
+ if rv.Kind() != reflect.Slice {
+ return &ItemTemplateCreateBulk{err: fmt.Errorf("calling to ItemTemplateClient.MapCreateBulk with wrong type %T, need slice", slice)}
+ }
+ builders := make([]*ItemTemplateCreate, rv.Len())
+ for i := 0; i < rv.Len(); i++ {
+ builders[i] = c.Create()
+ setFunc(builders[i], i)
+ }
+ return &ItemTemplateCreateBulk{config: c.config, builders: builders}
+}
+
+// Update returns an update builder for ItemTemplate.
+func (c *ItemTemplateClient) Update() *ItemTemplateUpdate {
+ mutation := newItemTemplateMutation(c.config, OpUpdate)
+ return &ItemTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOne returns an update builder for the given entity.
+func (c *ItemTemplateClient) UpdateOne(_m *ItemTemplate) *ItemTemplateUpdateOne {
+ mutation := newItemTemplateMutation(c.config, OpUpdateOne, withItemTemplate(_m))
+ return &ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOneID returns an update builder for the given id.
+func (c *ItemTemplateClient) UpdateOneID(id uuid.UUID) *ItemTemplateUpdateOne {
+ mutation := newItemTemplateMutation(c.config, OpUpdateOne, withItemTemplateID(id))
+ return &ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// Delete returns a delete builder for ItemTemplate.
+func (c *ItemTemplateClient) Delete() *ItemTemplateDelete {
+ mutation := newItemTemplateMutation(c.config, OpDelete)
+ return &ItemTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// DeleteOne returns a builder for deleting the given entity.
+func (c *ItemTemplateClient) DeleteOne(_m *ItemTemplate) *ItemTemplateDeleteOne {
+ return c.DeleteOneID(_m.ID)
+}
+
+// DeleteOneID returns a builder for deleting the given entity by its id.
+func (c *ItemTemplateClient) DeleteOneID(id uuid.UUID) *ItemTemplateDeleteOne {
+ builder := c.Delete().Where(itemtemplate.ID(id))
+ builder.mutation.id = &id
+ builder.mutation.op = OpDeleteOne
+ return &ItemTemplateDeleteOne{builder}
+}
+
+// Query returns a query builder for ItemTemplate.
+func (c *ItemTemplateClient) Query() *ItemTemplateQuery {
+ return &ItemTemplateQuery{
+ config: c.config,
+ ctx: &QueryContext{Type: TypeItemTemplate},
+ inters: c.Interceptors(),
+ }
+}
+
+// Get returns a ItemTemplate entity by its id.
+func (c *ItemTemplateClient) Get(ctx context.Context, id uuid.UUID) (*ItemTemplate, error) {
+ return c.Query().Where(itemtemplate.ID(id)).Only(ctx)
+}
+
+// GetX is like Get, but panics if an error occurs.
+func (c *ItemTemplateClient) GetX(ctx context.Context, id uuid.UUID) *ItemTemplate {
+ obj, err := c.Get(ctx, id)
+ if err != nil {
+ panic(err)
+ }
+ return obj
+}
+
+// QueryGroup queries the group edge of a ItemTemplate.
+func (c *ItemTemplateClient) QueryGroup(_m *ItemTemplate) *GroupQuery {
+ query := (&GroupClient{config: c.config}).Query()
+ query.path = func(context.Context) (fromV *sql.Selector, _ error) {
+ id := _m.ID
+ step := sqlgraph.NewStep(
+ sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id),
+ sqlgraph.To(group.Table, group.FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, true, itemtemplate.GroupTable, itemtemplate.GroupColumn),
+ )
+ fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
+ return fromV, nil
+ }
+ return query
+}
+
+// QueryFields queries the fields edge of a ItemTemplate.
+func (c *ItemTemplateClient) QueryFields(_m *ItemTemplate) *TemplateFieldQuery {
+ query := (&TemplateFieldClient{config: c.config}).Query()
+ query.path = func(context.Context) (fromV *sql.Selector, _ error) {
+ id := _m.ID
+ step := sqlgraph.NewStep(
+ sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id),
+ sqlgraph.To(templatefield.Table, templatefield.FieldID),
+ sqlgraph.Edge(sqlgraph.O2M, false, itemtemplate.FieldsTable, itemtemplate.FieldsColumn),
+ )
+ fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
+ return fromV, nil
+ }
+ return query
+}
+
+// QueryLocation queries the location edge of a ItemTemplate.
+func (c *ItemTemplateClient) QueryLocation(_m *ItemTemplate) *LocationQuery {
+ query := (&LocationClient{config: c.config}).Query()
+ query.path = func(context.Context) (fromV *sql.Selector, _ error) {
+ id := _m.ID
+ step := sqlgraph.NewStep(
+ sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id),
+ sqlgraph.To(location.Table, location.FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn),
+ )
+ fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
+ return fromV, nil
+ }
+ return query
+}
+
+// Hooks returns the client hooks.
+func (c *ItemTemplateClient) Hooks() []Hook {
+ return c.hooks.ItemTemplate
+}
+
+// Interceptors returns the client interceptors.
+func (c *ItemTemplateClient) Interceptors() []Interceptor {
+ return c.inters.ItemTemplate
+}
+
+func (c *ItemTemplateClient) mutate(ctx context.Context, m *ItemTemplateMutation) (Value, error) {
+ switch m.Op() {
+ case OpCreate:
+ return (&ItemTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+ case OpUpdate:
+ return (&ItemTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+ case OpUpdateOne:
+ return (&ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+ case OpDelete, OpDeleteOne:
+ return (&ItemTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
+ default:
+ return nil, fmt.Errorf("ent: unknown ItemTemplate mutation op: %q", m.Op())
+ }
+}
+
// LabelClient is a client for the Label schema.
type LabelClient struct {
config
@@ -2241,6 +2454,155 @@ func (c *NotifierClient) mutate(ctx context.Context, m *NotifierMutation) (Value
}
}
+// TemplateFieldClient is a client for the TemplateField schema.
+type TemplateFieldClient struct {
+ config
+}
+
+// NewTemplateFieldClient returns a client for the TemplateField from the given config.
+func NewTemplateFieldClient(c config) *TemplateFieldClient {
+ return &TemplateFieldClient{config: c}
+}
+
+// Use adds a list of mutation hooks to the hooks stack.
+// A call to `Use(f, g, h)` equals to `templatefield.Hooks(f(g(h())))`.
+func (c *TemplateFieldClient) Use(hooks ...Hook) {
+ c.hooks.TemplateField = append(c.hooks.TemplateField, hooks...)
+}
+
+// Intercept adds a list of query interceptors to the interceptors stack.
+// A call to `Intercept(f, g, h)` equals to `templatefield.Intercept(f(g(h())))`.
+func (c *TemplateFieldClient) Intercept(interceptors ...Interceptor) {
+ c.inters.TemplateField = append(c.inters.TemplateField, interceptors...)
+}
+
+// Create returns a builder for creating a TemplateField entity.
+func (c *TemplateFieldClient) Create() *TemplateFieldCreate {
+ mutation := newTemplateFieldMutation(c.config, OpCreate)
+ return &TemplateFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// CreateBulk returns a builder for creating a bulk of TemplateField entities.
+func (c *TemplateFieldClient) CreateBulk(builders ...*TemplateFieldCreate) *TemplateFieldCreateBulk {
+ return &TemplateFieldCreateBulk{config: c.config, builders: builders}
+}
+
+// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
+// a builder and applies setFunc on it.
+func (c *TemplateFieldClient) MapCreateBulk(slice any, setFunc func(*TemplateFieldCreate, int)) *TemplateFieldCreateBulk {
+ rv := reflect.ValueOf(slice)
+ if rv.Kind() != reflect.Slice {
+ return &TemplateFieldCreateBulk{err: fmt.Errorf("calling to TemplateFieldClient.MapCreateBulk with wrong type %T, need slice", slice)}
+ }
+ builders := make([]*TemplateFieldCreate, rv.Len())
+ for i := 0; i < rv.Len(); i++ {
+ builders[i] = c.Create()
+ setFunc(builders[i], i)
+ }
+ return &TemplateFieldCreateBulk{config: c.config, builders: builders}
+}
+
+// Update returns an update builder for TemplateField.
+func (c *TemplateFieldClient) Update() *TemplateFieldUpdate {
+ mutation := newTemplateFieldMutation(c.config, OpUpdate)
+ return &TemplateFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOne returns an update builder for the given entity.
+func (c *TemplateFieldClient) UpdateOne(_m *TemplateField) *TemplateFieldUpdateOne {
+ mutation := newTemplateFieldMutation(c.config, OpUpdateOne, withTemplateField(_m))
+ return &TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOneID returns an update builder for the given id.
+func (c *TemplateFieldClient) UpdateOneID(id uuid.UUID) *TemplateFieldUpdateOne {
+ mutation := newTemplateFieldMutation(c.config, OpUpdateOne, withTemplateFieldID(id))
+ return &TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// Delete returns a delete builder for TemplateField.
+func (c *TemplateFieldClient) Delete() *TemplateFieldDelete {
+ mutation := newTemplateFieldMutation(c.config, OpDelete)
+ return &TemplateFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// DeleteOne returns a builder for deleting the given entity.
+func (c *TemplateFieldClient) DeleteOne(_m *TemplateField) *TemplateFieldDeleteOne {
+ return c.DeleteOneID(_m.ID)
+}
+
+// DeleteOneID returns a builder for deleting the given entity by its id.
+func (c *TemplateFieldClient) DeleteOneID(id uuid.UUID) *TemplateFieldDeleteOne {
+ builder := c.Delete().Where(templatefield.ID(id))
+ builder.mutation.id = &id
+ builder.mutation.op = OpDeleteOne
+ return &TemplateFieldDeleteOne{builder}
+}
+
+// Query returns a query builder for TemplateField.
+func (c *TemplateFieldClient) Query() *TemplateFieldQuery {
+ return &TemplateFieldQuery{
+ config: c.config,
+ ctx: &QueryContext{Type: TypeTemplateField},
+ inters: c.Interceptors(),
+ }
+}
+
+// Get returns a TemplateField entity by its id.
+func (c *TemplateFieldClient) Get(ctx context.Context, id uuid.UUID) (*TemplateField, error) {
+ return c.Query().Where(templatefield.ID(id)).Only(ctx)
+}
+
+// GetX is like Get, but panics if an error occurs.
+func (c *TemplateFieldClient) GetX(ctx context.Context, id uuid.UUID) *TemplateField {
+ obj, err := c.Get(ctx, id)
+ if err != nil {
+ panic(err)
+ }
+ return obj
+}
+
+// QueryItemTemplate queries the item_template edge of a TemplateField.
+func (c *TemplateFieldClient) QueryItemTemplate(_m *TemplateField) *ItemTemplateQuery {
+ query := (&ItemTemplateClient{config: c.config}).Query()
+ query.path = func(context.Context) (fromV *sql.Selector, _ error) {
+ id := _m.ID
+ step := sqlgraph.NewStep(
+ sqlgraph.From(templatefield.Table, templatefield.FieldID, id),
+ sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, true, templatefield.ItemTemplateTable, templatefield.ItemTemplateColumn),
+ )
+ fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
+ return fromV, nil
+ }
+ return query
+}
+
+// Hooks returns the client hooks.
+func (c *TemplateFieldClient) Hooks() []Hook {
+ return c.hooks.TemplateField
+}
+
+// Interceptors returns the client interceptors.
+func (c *TemplateFieldClient) Interceptors() []Interceptor {
+ return c.inters.TemplateField
+}
+
+func (c *TemplateFieldClient) mutate(ctx context.Context, m *TemplateFieldMutation) (Value, error) {
+ switch m.Op() {
+ case OpCreate:
+ return (&TemplateFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+ case OpUpdate:
+ return (&TemplateFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+ case OpUpdateOne:
+ return (&TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+ case OpDelete, OpDeleteOne:
+ return (&TemplateFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
+ default:
+ return nil, fmt.Errorf("ent: unknown TemplateField mutation op: %q", m.Op())
+ }
+}
+
// UserClient is a client for the User schema.
type UserClient struct {
config
@@ -2426,10 +2788,12 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error)
type (
hooks struct {
Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField,
- Label, Location, MaintenanceEntry, Notifier, User []ent.Hook
+ ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField,
+ User []ent.Hook
}
inters struct {
Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField,
- Label, Location, MaintenanceEntry, Notifier, User []ent.Interceptor
+ ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField,
+ User []ent.Interceptor
}
)
diff --git a/backend/internal/data/ent/ent.go b/backend/internal/data/ent/ent.go
index 173be97f..ee3abfa7 100644
--- a/backend/internal/data/ent/ent.go
+++ b/backend/internal/data/ent/ent.go
@@ -19,10 +19,12 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -91,10 +93,12 @@ func checkColumn(t, c string) error {
groupinvitationtoken.Table: groupinvitationtoken.ValidColumn,
item.Table: item.ValidColumn,
itemfield.Table: itemfield.ValidColumn,
+ itemtemplate.Table: itemtemplate.ValidColumn,
label.Table: label.ValidColumn,
location.Table: location.ValidColumn,
maintenanceentry.Table: maintenanceentry.ValidColumn,
notifier.Table: notifier.ValidColumn,
+ templatefield.Table: templatefield.ValidColumn,
user.Table: user.ValidColumn,
})
})
diff --git a/backend/internal/data/ent/group.go b/backend/internal/data/ent/group.go
index 9bb043aa..d20782b9 100644
--- a/backend/internal/data/ent/group.go
+++ b/backend/internal/data/ent/group.go
@@ -46,9 +46,11 @@ type GroupEdges struct {
InvitationTokens []*GroupInvitationToken `json:"invitation_tokens,omitempty"`
// Notifiers holds the value of the notifiers edge.
Notifiers []*Notifier `json:"notifiers,omitempty"`
+ // ItemTemplates holds the value of the item_templates edge.
+ ItemTemplates []*ItemTemplate `json:"item_templates,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
- loadedTypes [6]bool
+ loadedTypes [7]bool
}
// UsersOrErr returns the Users value or an error if the edge
@@ -105,6 +107,15 @@ func (e GroupEdges) NotifiersOrErr() ([]*Notifier, error) {
return nil, &NotLoadedError{edge: "notifiers"}
}
+// ItemTemplatesOrErr returns the ItemTemplates value or an error if the edge
+// was not loaded in eager-loading.
+func (e GroupEdges) ItemTemplatesOrErr() ([]*ItemTemplate, error) {
+ if e.loadedTypes[6] {
+ return e.ItemTemplates, nil
+ }
+ return nil, &NotLoadedError{edge: "item_templates"}
+}
+
// scanValues returns the types for scanning values from sql.Rows.
func (*Group) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
@@ -204,6 +215,11 @@ func (_m *Group) QueryNotifiers() *NotifierQuery {
return NewGroupClient(_m.config).QueryNotifiers(_m)
}
+// QueryItemTemplates queries the "item_templates" edge of the Group entity.
+func (_m *Group) QueryItemTemplates() *ItemTemplateQuery {
+ return NewGroupClient(_m.config).QueryItemTemplates(_m)
+}
+
// Update returns a builder for updating this Group.
// Note that you need to call Group.Unwrap() before calling this method if this Group
// was returned from a transaction, and the transaction was committed or rolled back.
diff --git a/backend/internal/data/ent/group/group.go b/backend/internal/data/ent/group/group.go
index 422d2b13..80dc3398 100644
--- a/backend/internal/data/ent/group/group.go
+++ b/backend/internal/data/ent/group/group.go
@@ -35,6 +35,8 @@ const (
EdgeInvitationTokens = "invitation_tokens"
// EdgeNotifiers holds the string denoting the notifiers edge name in mutations.
EdgeNotifiers = "notifiers"
+ // EdgeItemTemplates holds the string denoting the item_templates edge name in mutations.
+ EdgeItemTemplates = "item_templates"
// Table holds the table name of the group in the database.
Table = "groups"
// UsersTable is the table that holds the users relation/edge.
@@ -79,6 +81,13 @@ const (
NotifiersInverseTable = "notifiers"
// NotifiersColumn is the table column denoting the notifiers relation/edge.
NotifiersColumn = "group_id"
+ // ItemTemplatesTable is the table that holds the item_templates relation/edge.
+ ItemTemplatesTable = "item_templates"
+ // ItemTemplatesInverseTable is the table name for the ItemTemplate entity.
+ // It exists in this package in order to avoid circular dependency with the "itemtemplate" package.
+ ItemTemplatesInverseTable = "item_templates"
+ // ItemTemplatesColumn is the table column denoting the item_templates relation/edge.
+ ItemTemplatesColumn = "group_item_templates"
)
// Columns holds all SQL columns for group fields.
@@ -226,6 +235,20 @@ func ByNotifiers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
sqlgraph.OrderByNeighborTerms(s, newNotifiersStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
+
+// ByItemTemplatesCount orders the results by item_templates count.
+func ByItemTemplatesCount(opts ...sql.OrderTermOption) OrderOption {
+ return func(s *sql.Selector) {
+ sqlgraph.OrderByNeighborsCount(s, newItemTemplatesStep(), opts...)
+ }
+}
+
+// ByItemTemplates orders the results by item_templates terms.
+func ByItemTemplates(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
+ return func(s *sql.Selector) {
+ sqlgraph.OrderByNeighborTerms(s, newItemTemplatesStep(), append([]sql.OrderTerm{term}, terms...)...)
+ }
+}
func newUsersStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
@@ -268,3 +291,10 @@ func newNotifiersStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.O2M, false, NotifiersTable, NotifiersColumn),
)
}
+func newItemTemplatesStep() *sqlgraph.Step {
+ return sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.To(ItemTemplatesInverseTable, FieldID),
+ sqlgraph.Edge(sqlgraph.O2M, false, ItemTemplatesTable, ItemTemplatesColumn),
+ )
+}
diff --git a/backend/internal/data/ent/group/where.go b/backend/internal/data/ent/group/where.go
index d3205524..fec4b27c 100644
--- a/backend/internal/data/ent/group/where.go
+++ b/backend/internal/data/ent/group/where.go
@@ -424,6 +424,29 @@ func HasNotifiersWith(preds ...predicate.Notifier) predicate.Group {
})
}
+// HasItemTemplates applies the HasEdge predicate on the "item_templates" edge.
+func HasItemTemplates() predicate.Group {
+ return predicate.Group(func(s *sql.Selector) {
+ step := sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.Edge(sqlgraph.O2M, false, ItemTemplatesTable, ItemTemplatesColumn),
+ )
+ sqlgraph.HasNeighbors(s, step)
+ })
+}
+
+// HasItemTemplatesWith applies the HasEdge predicate on the "item_templates" edge with a given conditions (other predicates).
+func HasItemTemplatesWith(preds ...predicate.ItemTemplate) predicate.Group {
+ return predicate.Group(func(s *sql.Selector) {
+ step := newItemTemplatesStep()
+ sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
+ for _, p := range preds {
+ p(s)
+ }
+ })
+ })
+}
+
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Group) predicate.Group {
return predicate.Group(sql.AndPredicates(predicates...))
diff --git a/backend/internal/data/ent/group_create.go b/backend/internal/data/ent/group_create.go
index 978220cd..9eb4bac1 100644
--- a/backend/internal/data/ent/group_create.go
+++ b/backend/internal/data/ent/group_create.go
@@ -14,6 +14,7 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
@@ -179,6 +180,21 @@ func (_c *GroupCreate) AddNotifiers(v ...*Notifier) *GroupCreate {
return _c.AddNotifierIDs(ids...)
}
+// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
+func (_c *GroupCreate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupCreate {
+ _c.mutation.AddItemTemplateIDs(ids...)
+ return _c
+}
+
+// AddItemTemplates adds the "item_templates" edges to the ItemTemplate entity.
+func (_c *GroupCreate) AddItemTemplates(v ...*ItemTemplate) *GroupCreate {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _c.AddItemTemplateIDs(ids...)
+}
+
// Mutation returns the GroupMutation object of the builder.
func (_c *GroupCreate) Mutation() *GroupMutation {
return _c.mutation
@@ -398,6 +414,22 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
}
_spec.Edges = append(_spec.Edges, edge)
}
+ if nodes := _c.mutation.ItemTemplatesIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: group.ItemTemplatesTable,
+ Columns: []string{group.ItemTemplatesColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges = append(_spec.Edges, edge)
+ }
return _node, _spec
}
diff --git a/backend/internal/data/ent/group_query.go b/backend/internal/data/ent/group_query.go
index 69d4e4a4..20124988 100644
--- a/backend/internal/data/ent/group_query.go
+++ b/backend/internal/data/ent/group_query.go
@@ -16,6 +16,7 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
@@ -36,6 +37,7 @@ type GroupQuery struct {
withLabels *LabelQuery
withInvitationTokens *GroupInvitationTokenQuery
withNotifiers *NotifierQuery
+ withItemTemplates *ItemTemplateQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -204,6 +206,28 @@ func (_q *GroupQuery) QueryNotifiers() *NotifierQuery {
return query
}
+// QueryItemTemplates chains the current query on the "item_templates" edge.
+func (_q *GroupQuery) QueryItemTemplates() *ItemTemplateQuery {
+ query := (&ItemTemplateClient{config: _q.config}).Query()
+ query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
+ if err := _q.prepareQuery(ctx); err != nil {
+ return nil, err
+ }
+ selector := _q.sqlQuery(ctx)
+ if err := selector.Err(); err != nil {
+ return nil, err
+ }
+ step := sqlgraph.NewStep(
+ sqlgraph.From(group.Table, group.FieldID, selector),
+ sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
+ sqlgraph.Edge(sqlgraph.O2M, false, group.ItemTemplatesTable, group.ItemTemplatesColumn),
+ )
+ fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
+ return fromU, nil
+ }
+ return query
+}
+
// First returns the first Group entity from the query.
// Returns a *NotFoundError when no Group was found.
func (_q *GroupQuery) First(ctx context.Context) (*Group, error) {
@@ -402,6 +426,7 @@ func (_q *GroupQuery) Clone() *GroupQuery {
withLabels: _q.withLabels.Clone(),
withInvitationTokens: _q.withInvitationTokens.Clone(),
withNotifiers: _q.withNotifiers.Clone(),
+ withItemTemplates: _q.withItemTemplates.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
@@ -474,6 +499,17 @@ func (_q *GroupQuery) WithNotifiers(opts ...func(*NotifierQuery)) *GroupQuery {
return _q
}
+// WithItemTemplates tells the query-builder to eager-load the nodes that are connected to
+// the "item_templates" edge. The optional arguments are used to configure the query builder of the edge.
+func (_q *GroupQuery) WithItemTemplates(opts ...func(*ItemTemplateQuery)) *GroupQuery {
+ query := (&ItemTemplateClient{config: _q.config}).Query()
+ for _, opt := range opts {
+ opt(query)
+ }
+ _q.withItemTemplates = query
+ return _q
+}
+
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
@@ -552,13 +588,14 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
var (
nodes = []*Group{}
_spec = _q.querySpec()
- loadedTypes = [6]bool{
+ loadedTypes = [7]bool{
_q.withUsers != nil,
_q.withLocations != nil,
_q.withItems != nil,
_q.withLabels != nil,
_q.withInvitationTokens != nil,
_q.withNotifiers != nil,
+ _q.withItemTemplates != nil,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
@@ -623,6 +660,13 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
return nil, err
}
}
+ if query := _q.withItemTemplates; query != nil {
+ if err := _q.loadItemTemplates(ctx, query, nodes,
+ func(n *Group) { n.Edges.ItemTemplates = []*ItemTemplate{} },
+ func(n *Group, e *ItemTemplate) { n.Edges.ItemTemplates = append(n.Edges.ItemTemplates, e) }); err != nil {
+ return nil, err
+ }
+ }
return nodes, nil
}
@@ -811,6 +855,37 @@ func (_q *GroupQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, n
}
return nil
}
+func (_q *GroupQuery) loadItemTemplates(ctx context.Context, query *ItemTemplateQuery, nodes []*Group, init func(*Group), assign func(*Group, *ItemTemplate)) error {
+ fks := make([]driver.Value, 0, len(nodes))
+ nodeids := make(map[uuid.UUID]*Group)
+ for i := range nodes {
+ fks = append(fks, nodes[i].ID)
+ nodeids[nodes[i].ID] = nodes[i]
+ if init != nil {
+ init(nodes[i])
+ }
+ }
+ query.withFKs = true
+ query.Where(predicate.ItemTemplate(func(s *sql.Selector) {
+ s.Where(sql.InValues(s.C(group.ItemTemplatesColumn), fks...))
+ }))
+ neighbors, err := query.All(ctx)
+ if err != nil {
+ return err
+ }
+ for _, n := range neighbors {
+ fk := n.group_item_templates
+ if fk == nil {
+ return fmt.Errorf(`foreign-key "group_item_templates" is nil for node %v`, n.ID)
+ }
+ node, ok := nodeids[*fk]
+ if !ok {
+ return fmt.Errorf(`unexpected referenced foreign-key "group_item_templates" returned %v for node %v`, *fk, n.ID)
+ }
+ assign(node, n)
+ }
+ return nil
+}
func (_q *GroupQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
diff --git a/backend/internal/data/ent/group_update.go b/backend/internal/data/ent/group_update.go
index c0acecfe..d0190d49 100644
--- a/backend/internal/data/ent/group_update.go
+++ b/backend/internal/data/ent/group_update.go
@@ -15,6 +15,7 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
@@ -159,6 +160,21 @@ func (_u *GroupUpdate) AddNotifiers(v ...*Notifier) *GroupUpdate {
return _u.AddNotifierIDs(ids...)
}
+// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
+func (_u *GroupUpdate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdate {
+ _u.mutation.AddItemTemplateIDs(ids...)
+ return _u
+}
+
+// AddItemTemplates adds the "item_templates" edges to the ItemTemplate entity.
+func (_u *GroupUpdate) AddItemTemplates(v ...*ItemTemplate) *GroupUpdate {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _u.AddItemTemplateIDs(ids...)
+}
+
// Mutation returns the GroupMutation object of the builder.
func (_u *GroupUpdate) Mutation() *GroupMutation {
return _u.mutation
@@ -290,6 +306,27 @@ func (_u *GroupUpdate) RemoveNotifiers(v ...*Notifier) *GroupUpdate {
return _u.RemoveNotifierIDs(ids...)
}
+// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity.
+func (_u *GroupUpdate) ClearItemTemplates() *GroupUpdate {
+ _u.mutation.ClearItemTemplates()
+ return _u
+}
+
+// RemoveItemTemplateIDs removes the "item_templates" edge to ItemTemplate entities by IDs.
+func (_u *GroupUpdate) RemoveItemTemplateIDs(ids ...uuid.UUID) *GroupUpdate {
+ _u.mutation.RemoveItemTemplateIDs(ids...)
+ return _u
+}
+
+// RemoveItemTemplates removes "item_templates" edges to ItemTemplate entities.
+func (_u *GroupUpdate) RemoveItemTemplates(v ...*ItemTemplate) *GroupUpdate {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _u.RemoveItemTemplateIDs(ids...)
+}
+
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *GroupUpdate) Save(ctx context.Context) (int, error) {
_u.defaults()
@@ -627,6 +664,51 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
+ if _u.mutation.ItemTemplatesCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: group.ItemTemplatesTable,
+ Columns: []string{group.ItemTemplatesColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.RemovedItemTemplatesIDs(); len(nodes) > 0 && !_u.mutation.ItemTemplatesCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: group.ItemTemplatesTable,
+ Columns: []string{group.ItemTemplatesColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.ItemTemplatesIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: group.ItemTemplatesTable,
+ Columns: []string{group.ItemTemplatesColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{group.Label}
@@ -771,6 +853,21 @@ func (_u *GroupUpdateOne) AddNotifiers(v ...*Notifier) *GroupUpdateOne {
return _u.AddNotifierIDs(ids...)
}
+// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
+func (_u *GroupUpdateOne) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdateOne {
+ _u.mutation.AddItemTemplateIDs(ids...)
+ return _u
+}
+
+// AddItemTemplates adds the "item_templates" edges to the ItemTemplate entity.
+func (_u *GroupUpdateOne) AddItemTemplates(v ...*ItemTemplate) *GroupUpdateOne {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _u.AddItemTemplateIDs(ids...)
+}
+
// Mutation returns the GroupMutation object of the builder.
func (_u *GroupUpdateOne) Mutation() *GroupMutation {
return _u.mutation
@@ -902,6 +999,27 @@ func (_u *GroupUpdateOne) RemoveNotifiers(v ...*Notifier) *GroupUpdateOne {
return _u.RemoveNotifierIDs(ids...)
}
+// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity.
+func (_u *GroupUpdateOne) ClearItemTemplates() *GroupUpdateOne {
+ _u.mutation.ClearItemTemplates()
+ return _u
+}
+
+// RemoveItemTemplateIDs removes the "item_templates" edge to ItemTemplate entities by IDs.
+func (_u *GroupUpdateOne) RemoveItemTemplateIDs(ids ...uuid.UUID) *GroupUpdateOne {
+ _u.mutation.RemoveItemTemplateIDs(ids...)
+ return _u
+}
+
+// RemoveItemTemplates removes "item_templates" edges to ItemTemplate entities.
+func (_u *GroupUpdateOne) RemoveItemTemplates(v ...*ItemTemplate) *GroupUpdateOne {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _u.RemoveItemTemplateIDs(ids...)
+}
+
// Where appends a list predicates to the GroupUpdate builder.
func (_u *GroupUpdateOne) Where(ps ...predicate.Group) *GroupUpdateOne {
_u.mutation.Where(ps...)
@@ -1269,6 +1387,51 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
+ if _u.mutation.ItemTemplatesCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: group.ItemTemplatesTable,
+ Columns: []string{group.ItemTemplatesColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.RemovedItemTemplatesIDs(); len(nodes) > 0 && !_u.mutation.ItemTemplatesCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: group.ItemTemplatesTable,
+ Columns: []string{group.ItemTemplatesColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.ItemTemplatesIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: group.ItemTemplatesTable,
+ Columns: []string{group.ItemTemplatesColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
_node = &Group{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/backend/internal/data/ent/has_id.go b/backend/internal/data/ent/has_id.go
index 758b3145..faf28d4e 100644
--- a/backend/internal/data/ent/has_id.go
+++ b/backend/internal/data/ent/has_id.go
@@ -32,6 +32,10 @@ func (_m *ItemField) GetID() uuid.UUID {
return _m.ID
}
+func (_m *ItemTemplate) GetID() uuid.UUID {
+ return _m.ID
+}
+
func (_m *Label) GetID() uuid.UUID {
return _m.ID
}
@@ -48,6 +52,10 @@ func (_m *Notifier) GetID() uuid.UUID {
return _m.ID
}
+func (_m *TemplateField) GetID() uuid.UUID {
+ return _m.ID
+}
+
func (_m *User) GetID() uuid.UUID {
return _m.ID
}
diff --git a/backend/internal/data/ent/hook/hook.go b/backend/internal/data/ent/hook/hook.go
index 2a078c19..6859da52 100644
--- a/backend/internal/data/ent/hook/hook.go
+++ b/backend/internal/data/ent/hook/hook.go
@@ -93,6 +93,18 @@ func (f ItemFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, e
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemFieldMutation", m)
}
+// The ItemTemplateFunc type is an adapter to allow the use of ordinary
+// function as ItemTemplate mutator.
+type ItemTemplateFunc func(context.Context, *ent.ItemTemplateMutation) (ent.Value, error)
+
+// Mutate calls f(ctx, m).
+func (f ItemTemplateFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
+ if mv, ok := m.(*ent.ItemTemplateMutation); ok {
+ return f(ctx, mv)
+ }
+ return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemTemplateMutation", m)
+}
+
// The LabelFunc type is an adapter to allow the use of ordinary
// function as Label mutator.
type LabelFunc func(context.Context, *ent.LabelMutation) (ent.Value, error)
@@ -141,6 +153,18 @@ func (f NotifierFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, er
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NotifierMutation", m)
}
+// The TemplateFieldFunc type is an adapter to allow the use of ordinary
+// function as TemplateField mutator.
+type TemplateFieldFunc func(context.Context, *ent.TemplateFieldMutation) (ent.Value, error)
+
+// Mutate calls f(ctx, m).
+func (f TemplateFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
+ if mv, ok := m.(*ent.TemplateFieldMutation); ok {
+ return f(ctx, mv)
+ }
+ return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.TemplateFieldMutation", m)
+}
+
// The UserFunc type is an adapter to allow the use of ordinary
// function as User mutator.
type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)
diff --git a/backend/internal/data/ent/itemtemplate.go b/backend/internal/data/ent/itemtemplate.go
new file mode 100644
index 00000000..0d9f1f2f
--- /dev/null
+++ b/backend/internal/data/ent/itemtemplate.go
@@ -0,0 +1,376 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "encoding/json"
+ "fmt"
+ "strings"
+ "time"
+
+ "entgo.io/ent"
+ "entgo.io/ent/dialect/sql"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
+)
+
+// ItemTemplate is the model entity for the ItemTemplate schema.
+type ItemTemplate struct {
+ config `json:"-"`
+ // ID of the ent.
+ ID uuid.UUID `json:"id,omitempty"`
+ // CreatedAt holds the value of the "created_at" field.
+ CreatedAt time.Time `json:"created_at,omitempty"`
+ // UpdatedAt holds the value of the "updated_at" field.
+ UpdatedAt time.Time `json:"updated_at,omitempty"`
+ // Name holds the value of the "name" field.
+ Name string `json:"name,omitempty"`
+ // Description holds the value of the "description" field.
+ Description string `json:"description,omitempty"`
+ // Notes holds the value of the "notes" field.
+ Notes string `json:"notes,omitempty"`
+ // DefaultQuantity holds the value of the "default_quantity" field.
+ DefaultQuantity int `json:"default_quantity,omitempty"`
+ // DefaultInsured holds the value of the "default_insured" field.
+ DefaultInsured bool `json:"default_insured,omitempty"`
+ // Default name template for items (can use placeholders)
+ DefaultName string `json:"default_name,omitempty"`
+ // Default description for items created from this template
+ DefaultDescription string `json:"default_description,omitempty"`
+ // DefaultManufacturer holds the value of the "default_manufacturer" field.
+ DefaultManufacturer string `json:"default_manufacturer,omitempty"`
+ // Default model number for items created from this template
+ DefaultModelNumber string `json:"default_model_number,omitempty"`
+ // DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty" field.
+ DefaultLifetimeWarranty bool `json:"default_lifetime_warranty,omitempty"`
+ // DefaultWarrantyDetails holds the value of the "default_warranty_details" field.
+ DefaultWarrantyDetails string `json:"default_warranty_details,omitempty"`
+ // Whether to include warranty fields in items created from this template
+ IncludeWarrantyFields bool `json:"include_warranty_fields,omitempty"`
+ // Whether to include purchase fields in items created from this template
+ IncludePurchaseFields bool `json:"include_purchase_fields,omitempty"`
+ // Whether to include sold fields in items created from this template
+ IncludeSoldFields bool `json:"include_sold_fields,omitempty"`
+ // Default label IDs for items created from this template
+ DefaultLabelIds []uuid.UUID `json:"default_label_ids,omitempty"`
+ // Edges holds the relations/edges for other nodes in the graph.
+ // The values are being populated by the ItemTemplateQuery when eager-loading is set.
+ Edges ItemTemplateEdges `json:"edges"`
+ group_item_templates *uuid.UUID
+ item_template_location *uuid.UUID
+ selectValues sql.SelectValues
+}
+
+// ItemTemplateEdges holds the relations/edges for other nodes in the graph.
+type ItemTemplateEdges struct {
+ // Group holds the value of the group edge.
+ Group *Group `json:"group,omitempty"`
+ // Fields holds the value of the fields edge.
+ Fields []*TemplateField `json:"fields,omitempty"`
+ // Location holds the value of the location edge.
+ Location *Location `json:"location,omitempty"`
+ // loadedTypes holds the information for reporting if a
+ // type was loaded (or requested) in eager-loading or not.
+ loadedTypes [3]bool
+}
+
+// GroupOrErr returns the Group value or an error if the edge
+// was not loaded in eager-loading, or loaded but was not found.
+func (e ItemTemplateEdges) GroupOrErr() (*Group, error) {
+ if e.Group != nil {
+ return e.Group, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: group.Label}
+ }
+ return nil, &NotLoadedError{edge: "group"}
+}
+
+// FieldsOrErr returns the Fields value or an error if the edge
+// was not loaded in eager-loading.
+func (e ItemTemplateEdges) FieldsOrErr() ([]*TemplateField, error) {
+ if e.loadedTypes[1] {
+ return e.Fields, nil
+ }
+ return nil, &NotLoadedError{edge: "fields"}
+}
+
+// LocationOrErr returns the Location value or an error if the edge
+// was not loaded in eager-loading, or loaded but was not found.
+func (e ItemTemplateEdges) LocationOrErr() (*Location, error) {
+ if e.Location != nil {
+ return e.Location, nil
+ } else if e.loadedTypes[2] {
+ return nil, &NotFoundError{label: location.Label}
+ }
+ return nil, &NotLoadedError{edge: "location"}
+}
+
+// scanValues returns the types for scanning values from sql.Rows.
+func (*ItemTemplate) scanValues(columns []string) ([]any, error) {
+ values := make([]any, len(columns))
+ for i := range columns {
+ switch columns[i] {
+ case itemtemplate.FieldDefaultLabelIds:
+ values[i] = new([]byte)
+ case itemtemplate.FieldDefaultInsured, itemtemplate.FieldDefaultLifetimeWarranty, itemtemplate.FieldIncludeWarrantyFields, itemtemplate.FieldIncludePurchaseFields, itemtemplate.FieldIncludeSoldFields:
+ values[i] = new(sql.NullBool)
+ case itemtemplate.FieldDefaultQuantity:
+ values[i] = new(sql.NullInt64)
+ case itemtemplate.FieldName, itemtemplate.FieldDescription, itemtemplate.FieldNotes, itemtemplate.FieldDefaultName, itemtemplate.FieldDefaultDescription, itemtemplate.FieldDefaultManufacturer, itemtemplate.FieldDefaultModelNumber, itemtemplate.FieldDefaultWarrantyDetails:
+ values[i] = new(sql.NullString)
+ case itemtemplate.FieldCreatedAt, itemtemplate.FieldUpdatedAt:
+ values[i] = new(sql.NullTime)
+ case itemtemplate.FieldID:
+ values[i] = new(uuid.UUID)
+ case itemtemplate.ForeignKeys[0]: // group_item_templates
+ values[i] = &sql.NullScanner{S: new(uuid.UUID)}
+ case itemtemplate.ForeignKeys[1]: // item_template_location
+ values[i] = &sql.NullScanner{S: new(uuid.UUID)}
+ default:
+ values[i] = new(sql.UnknownType)
+ }
+ }
+ return values, nil
+}
+
+// assignValues assigns the values that were returned from sql.Rows (after scanning)
+// to the ItemTemplate fields.
+func (_m *ItemTemplate) assignValues(columns []string, values []any) error {
+ if m, n := len(values), len(columns); m < n {
+ return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
+ }
+ for i := range columns {
+ switch columns[i] {
+ case itemtemplate.FieldID:
+ if value, ok := values[i].(*uuid.UUID); !ok {
+ return fmt.Errorf("unexpected type %T for field id", values[i])
+ } else if value != nil {
+ _m.ID = *value
+ }
+ case itemtemplate.FieldCreatedAt:
+ if value, ok := values[i].(*sql.NullTime); !ok {
+ return fmt.Errorf("unexpected type %T for field created_at", values[i])
+ } else if value.Valid {
+ _m.CreatedAt = value.Time
+ }
+ case itemtemplate.FieldUpdatedAt:
+ if value, ok := values[i].(*sql.NullTime); !ok {
+ return fmt.Errorf("unexpected type %T for field updated_at", values[i])
+ } else if value.Valid {
+ _m.UpdatedAt = value.Time
+ }
+ case itemtemplate.FieldName:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field name", values[i])
+ } else if value.Valid {
+ _m.Name = value.String
+ }
+ case itemtemplate.FieldDescription:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field description", values[i])
+ } else if value.Valid {
+ _m.Description = value.String
+ }
+ case itemtemplate.FieldNotes:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field notes", values[i])
+ } else if value.Valid {
+ _m.Notes = value.String
+ }
+ case itemtemplate.FieldDefaultQuantity:
+ if value, ok := values[i].(*sql.NullInt64); !ok {
+ return fmt.Errorf("unexpected type %T for field default_quantity", values[i])
+ } else if value.Valid {
+ _m.DefaultQuantity = int(value.Int64)
+ }
+ case itemtemplate.FieldDefaultInsured:
+ if value, ok := values[i].(*sql.NullBool); !ok {
+ return fmt.Errorf("unexpected type %T for field default_insured", values[i])
+ } else if value.Valid {
+ _m.DefaultInsured = value.Bool
+ }
+ case itemtemplate.FieldDefaultName:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field default_name", values[i])
+ } else if value.Valid {
+ _m.DefaultName = value.String
+ }
+ case itemtemplate.FieldDefaultDescription:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field default_description", values[i])
+ } else if value.Valid {
+ _m.DefaultDescription = value.String
+ }
+ case itemtemplate.FieldDefaultManufacturer:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field default_manufacturer", values[i])
+ } else if value.Valid {
+ _m.DefaultManufacturer = value.String
+ }
+ case itemtemplate.FieldDefaultModelNumber:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field default_model_number", values[i])
+ } else if value.Valid {
+ _m.DefaultModelNumber = value.String
+ }
+ case itemtemplate.FieldDefaultLifetimeWarranty:
+ if value, ok := values[i].(*sql.NullBool); !ok {
+ return fmt.Errorf("unexpected type %T for field default_lifetime_warranty", values[i])
+ } else if value.Valid {
+ _m.DefaultLifetimeWarranty = value.Bool
+ }
+ case itemtemplate.FieldDefaultWarrantyDetails:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field default_warranty_details", values[i])
+ } else if value.Valid {
+ _m.DefaultWarrantyDetails = value.String
+ }
+ case itemtemplate.FieldIncludeWarrantyFields:
+ if value, ok := values[i].(*sql.NullBool); !ok {
+ return fmt.Errorf("unexpected type %T for field include_warranty_fields", values[i])
+ } else if value.Valid {
+ _m.IncludeWarrantyFields = value.Bool
+ }
+ case itemtemplate.FieldIncludePurchaseFields:
+ if value, ok := values[i].(*sql.NullBool); !ok {
+ return fmt.Errorf("unexpected type %T for field include_purchase_fields", values[i])
+ } else if value.Valid {
+ _m.IncludePurchaseFields = value.Bool
+ }
+ case itemtemplate.FieldIncludeSoldFields:
+ if value, ok := values[i].(*sql.NullBool); !ok {
+ return fmt.Errorf("unexpected type %T for field include_sold_fields", values[i])
+ } else if value.Valid {
+ _m.IncludeSoldFields = value.Bool
+ }
+ case itemtemplate.FieldDefaultLabelIds:
+ if value, ok := values[i].(*[]byte); !ok {
+ return fmt.Errorf("unexpected type %T for field default_label_ids", values[i])
+ } else if value != nil && len(*value) > 0 {
+ if err := json.Unmarshal(*value, &_m.DefaultLabelIds); err != nil {
+ return fmt.Errorf("unmarshal field default_label_ids: %w", err)
+ }
+ }
+ case itemtemplate.ForeignKeys[0]:
+ if value, ok := values[i].(*sql.NullScanner); !ok {
+ return fmt.Errorf("unexpected type %T for field group_item_templates", values[i])
+ } else if value.Valid {
+ _m.group_item_templates = new(uuid.UUID)
+ *_m.group_item_templates = *value.S.(*uuid.UUID)
+ }
+ case itemtemplate.ForeignKeys[1]:
+ if value, ok := values[i].(*sql.NullScanner); !ok {
+ return fmt.Errorf("unexpected type %T for field item_template_location", values[i])
+ } else if value.Valid {
+ _m.item_template_location = new(uuid.UUID)
+ *_m.item_template_location = *value.S.(*uuid.UUID)
+ }
+ default:
+ _m.selectValues.Set(columns[i], values[i])
+ }
+ }
+ return nil
+}
+
+// Value returns the ent.Value that was dynamically selected and assigned to the ItemTemplate.
+// This includes values selected through modifiers, order, etc.
+func (_m *ItemTemplate) Value(name string) (ent.Value, error) {
+ return _m.selectValues.Get(name)
+}
+
+// QueryGroup queries the "group" edge of the ItemTemplate entity.
+func (_m *ItemTemplate) QueryGroup() *GroupQuery {
+ return NewItemTemplateClient(_m.config).QueryGroup(_m)
+}
+
+// QueryFields queries the "fields" edge of the ItemTemplate entity.
+func (_m *ItemTemplate) QueryFields() *TemplateFieldQuery {
+ return NewItemTemplateClient(_m.config).QueryFields(_m)
+}
+
+// QueryLocation queries the "location" edge of the ItemTemplate entity.
+func (_m *ItemTemplate) QueryLocation() *LocationQuery {
+ return NewItemTemplateClient(_m.config).QueryLocation(_m)
+}
+
+// Update returns a builder for updating this ItemTemplate.
+// Note that you need to call ItemTemplate.Unwrap() before calling this method if this ItemTemplate
+// was returned from a transaction, and the transaction was committed or rolled back.
+func (_m *ItemTemplate) Update() *ItemTemplateUpdateOne {
+ return NewItemTemplateClient(_m.config).UpdateOne(_m)
+}
+
+// Unwrap unwraps the ItemTemplate entity that was returned from a transaction after it was closed,
+// so that all future queries will be executed through the driver which created the transaction.
+func (_m *ItemTemplate) Unwrap() *ItemTemplate {
+ _tx, ok := _m.config.driver.(*txDriver)
+ if !ok {
+ panic("ent: ItemTemplate is not a transactional entity")
+ }
+ _m.config.driver = _tx.drv
+ return _m
+}
+
+// String implements the fmt.Stringer.
+func (_m *ItemTemplate) String() string {
+ var builder strings.Builder
+ builder.WriteString("ItemTemplate(")
+ builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
+ builder.WriteString("created_at=")
+ builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
+ builder.WriteString(", ")
+ builder.WriteString("updated_at=")
+ builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
+ builder.WriteString(", ")
+ builder.WriteString("name=")
+ builder.WriteString(_m.Name)
+ builder.WriteString(", ")
+ builder.WriteString("description=")
+ builder.WriteString(_m.Description)
+ builder.WriteString(", ")
+ builder.WriteString("notes=")
+ builder.WriteString(_m.Notes)
+ builder.WriteString(", ")
+ builder.WriteString("default_quantity=")
+ builder.WriteString(fmt.Sprintf("%v", _m.DefaultQuantity))
+ builder.WriteString(", ")
+ builder.WriteString("default_insured=")
+ builder.WriteString(fmt.Sprintf("%v", _m.DefaultInsured))
+ builder.WriteString(", ")
+ builder.WriteString("default_name=")
+ builder.WriteString(_m.DefaultName)
+ builder.WriteString(", ")
+ builder.WriteString("default_description=")
+ builder.WriteString(_m.DefaultDescription)
+ builder.WriteString(", ")
+ builder.WriteString("default_manufacturer=")
+ builder.WriteString(_m.DefaultManufacturer)
+ builder.WriteString(", ")
+ builder.WriteString("default_model_number=")
+ builder.WriteString(_m.DefaultModelNumber)
+ builder.WriteString(", ")
+ builder.WriteString("default_lifetime_warranty=")
+ builder.WriteString(fmt.Sprintf("%v", _m.DefaultLifetimeWarranty))
+ builder.WriteString(", ")
+ builder.WriteString("default_warranty_details=")
+ builder.WriteString(_m.DefaultWarrantyDetails)
+ builder.WriteString(", ")
+ builder.WriteString("include_warranty_fields=")
+ builder.WriteString(fmt.Sprintf("%v", _m.IncludeWarrantyFields))
+ builder.WriteString(", ")
+ builder.WriteString("include_purchase_fields=")
+ builder.WriteString(fmt.Sprintf("%v", _m.IncludePurchaseFields))
+ builder.WriteString(", ")
+ builder.WriteString("include_sold_fields=")
+ builder.WriteString(fmt.Sprintf("%v", _m.IncludeSoldFields))
+ builder.WriteString(", ")
+ builder.WriteString("default_label_ids=")
+ builder.WriteString(fmt.Sprintf("%v", _m.DefaultLabelIds))
+ builder.WriteByte(')')
+ return builder.String()
+}
+
+// ItemTemplates is a parsable slice of ItemTemplate.
+type ItemTemplates []*ItemTemplate
diff --git a/backend/internal/data/ent/itemtemplate/itemtemplate.go b/backend/internal/data/ent/itemtemplate/itemtemplate.go
new file mode 100644
index 00000000..ac308b9d
--- /dev/null
+++ b/backend/internal/data/ent/itemtemplate/itemtemplate.go
@@ -0,0 +1,301 @@
+// Code generated by ent, DO NOT EDIT.
+
+package itemtemplate
+
+import (
+ "time"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/google/uuid"
+)
+
+const (
+ // Label holds the string label denoting the itemtemplate type in the database.
+ Label = "item_template"
+ // FieldID holds the string denoting the id field in the database.
+ FieldID = "id"
+ // FieldCreatedAt holds the string denoting the created_at field in the database.
+ FieldCreatedAt = "created_at"
+ // FieldUpdatedAt holds the string denoting the updated_at field in the database.
+ FieldUpdatedAt = "updated_at"
+ // FieldName holds the string denoting the name field in the database.
+ FieldName = "name"
+ // FieldDescription holds the string denoting the description field in the database.
+ FieldDescription = "description"
+ // FieldNotes holds the string denoting the notes field in the database.
+ FieldNotes = "notes"
+ // FieldDefaultQuantity holds the string denoting the default_quantity field in the database.
+ FieldDefaultQuantity = "default_quantity"
+ // FieldDefaultInsured holds the string denoting the default_insured field in the database.
+ FieldDefaultInsured = "default_insured"
+ // FieldDefaultName holds the string denoting the default_name field in the database.
+ FieldDefaultName = "default_name"
+ // FieldDefaultDescription holds the string denoting the default_description field in the database.
+ FieldDefaultDescription = "default_description"
+ // FieldDefaultManufacturer holds the string denoting the default_manufacturer field in the database.
+ FieldDefaultManufacturer = "default_manufacturer"
+ // FieldDefaultModelNumber holds the string denoting the default_model_number field in the database.
+ FieldDefaultModelNumber = "default_model_number"
+ // FieldDefaultLifetimeWarranty holds the string denoting the default_lifetime_warranty field in the database.
+ FieldDefaultLifetimeWarranty = "default_lifetime_warranty"
+ // FieldDefaultWarrantyDetails holds the string denoting the default_warranty_details field in the database.
+ FieldDefaultWarrantyDetails = "default_warranty_details"
+ // FieldIncludeWarrantyFields holds the string denoting the include_warranty_fields field in the database.
+ FieldIncludeWarrantyFields = "include_warranty_fields"
+ // FieldIncludePurchaseFields holds the string denoting the include_purchase_fields field in the database.
+ FieldIncludePurchaseFields = "include_purchase_fields"
+ // FieldIncludeSoldFields holds the string denoting the include_sold_fields field in the database.
+ FieldIncludeSoldFields = "include_sold_fields"
+ // FieldDefaultLabelIds holds the string denoting the default_label_ids field in the database.
+ FieldDefaultLabelIds = "default_label_ids"
+ // EdgeGroup holds the string denoting the group edge name in mutations.
+ EdgeGroup = "group"
+ // EdgeFields holds the string denoting the fields edge name in mutations.
+ EdgeFields = "fields"
+ // EdgeLocation holds the string denoting the location edge name in mutations.
+ EdgeLocation = "location"
+ // Table holds the table name of the itemtemplate in the database.
+ Table = "item_templates"
+ // GroupTable is the table that holds the group relation/edge.
+ GroupTable = "item_templates"
+ // GroupInverseTable is the table name for the Group entity.
+ // It exists in this package in order to avoid circular dependency with the "group" package.
+ GroupInverseTable = "groups"
+ // GroupColumn is the table column denoting the group relation/edge.
+ GroupColumn = "group_item_templates"
+ // FieldsTable is the table that holds the fields relation/edge.
+ FieldsTable = "template_fields"
+ // FieldsInverseTable is the table name for the TemplateField entity.
+ // It exists in this package in order to avoid circular dependency with the "templatefield" package.
+ FieldsInverseTable = "template_fields"
+ // FieldsColumn is the table column denoting the fields relation/edge.
+ FieldsColumn = "item_template_fields"
+ // LocationTable is the table that holds the location relation/edge.
+ LocationTable = "item_templates"
+ // LocationInverseTable is the table name for the Location entity.
+ // It exists in this package in order to avoid circular dependency with the "location" package.
+ LocationInverseTable = "locations"
+ // LocationColumn is the table column denoting the location relation/edge.
+ LocationColumn = "item_template_location"
+)
+
+// Columns holds all SQL columns for itemtemplate fields.
+var Columns = []string{
+ FieldID,
+ FieldCreatedAt,
+ FieldUpdatedAt,
+ FieldName,
+ FieldDescription,
+ FieldNotes,
+ FieldDefaultQuantity,
+ FieldDefaultInsured,
+ FieldDefaultName,
+ FieldDefaultDescription,
+ FieldDefaultManufacturer,
+ FieldDefaultModelNumber,
+ FieldDefaultLifetimeWarranty,
+ FieldDefaultWarrantyDetails,
+ FieldIncludeWarrantyFields,
+ FieldIncludePurchaseFields,
+ FieldIncludeSoldFields,
+ FieldDefaultLabelIds,
+}
+
+// ForeignKeys holds the SQL foreign-keys that are owned by the "item_templates"
+// table and are not defined as standalone fields in the schema.
+var ForeignKeys = []string{
+ "group_item_templates",
+ "item_template_location",
+}
+
+// ValidColumn reports if the column name is valid (part of the table columns).
+func ValidColumn(column string) bool {
+ for i := range Columns {
+ if column == Columns[i] {
+ return true
+ }
+ }
+ for i := range ForeignKeys {
+ if column == ForeignKeys[i] {
+ return true
+ }
+ }
+ return false
+}
+
+var (
+ // DefaultCreatedAt holds the default value on creation for the "created_at" field.
+ DefaultCreatedAt func() time.Time
+ // DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
+ DefaultUpdatedAt func() time.Time
+ // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
+ UpdateDefaultUpdatedAt func() time.Time
+ // NameValidator is a validator for the "name" field. It is called by the builders before save.
+ NameValidator func(string) error
+ // DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
+ DescriptionValidator func(string) error
+ // NotesValidator is a validator for the "notes" field. It is called by the builders before save.
+ NotesValidator func(string) error
+ // DefaultDefaultQuantity holds the default value on creation for the "default_quantity" field.
+ DefaultDefaultQuantity int
+ // DefaultDefaultInsured holds the default value on creation for the "default_insured" field.
+ DefaultDefaultInsured bool
+ // DefaultNameValidator is a validator for the "default_name" field. It is called by the builders before save.
+ DefaultNameValidator func(string) error
+ // DefaultDescriptionValidator is a validator for the "default_description" field. It is called by the builders before save.
+ DefaultDescriptionValidator func(string) error
+ // DefaultManufacturerValidator is a validator for the "default_manufacturer" field. It is called by the builders before save.
+ DefaultManufacturerValidator func(string) error
+ // DefaultModelNumberValidator is a validator for the "default_model_number" field. It is called by the builders before save.
+ DefaultModelNumberValidator func(string) error
+ // DefaultDefaultLifetimeWarranty holds the default value on creation for the "default_lifetime_warranty" field.
+ DefaultDefaultLifetimeWarranty bool
+ // DefaultWarrantyDetailsValidator is a validator for the "default_warranty_details" field. It is called by the builders before save.
+ DefaultWarrantyDetailsValidator func(string) error
+ // DefaultIncludeWarrantyFields holds the default value on creation for the "include_warranty_fields" field.
+ DefaultIncludeWarrantyFields bool
+ // DefaultIncludePurchaseFields holds the default value on creation for the "include_purchase_fields" field.
+ DefaultIncludePurchaseFields bool
+ // DefaultIncludeSoldFields holds the default value on creation for the "include_sold_fields" field.
+ DefaultIncludeSoldFields bool
+ // DefaultID holds the default value on creation for the "id" field.
+ DefaultID func() uuid.UUID
+)
+
+// OrderOption defines the ordering options for the ItemTemplate queries.
+type OrderOption func(*sql.Selector)
+
+// ByID orders the results by the id field.
+func ByID(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldID, opts...).ToFunc()
+}
+
+// ByCreatedAt orders the results by the created_at field.
+func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
+}
+
+// ByUpdatedAt orders the results by the updated_at field.
+func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
+}
+
+// ByName orders the results by the name field.
+func ByName(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldName, opts...).ToFunc()
+}
+
+// ByDescription orders the results by the description field.
+func ByDescription(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDescription, opts...).ToFunc()
+}
+
+// ByNotes orders the results by the notes field.
+func ByNotes(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldNotes, opts...).ToFunc()
+}
+
+// ByDefaultQuantity orders the results by the default_quantity field.
+func ByDefaultQuantity(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDefaultQuantity, opts...).ToFunc()
+}
+
+// ByDefaultInsured orders the results by the default_insured field.
+func ByDefaultInsured(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDefaultInsured, opts...).ToFunc()
+}
+
+// ByDefaultName orders the results by the default_name field.
+func ByDefaultName(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDefaultName, opts...).ToFunc()
+}
+
+// ByDefaultDescription orders the results by the default_description field.
+func ByDefaultDescription(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDefaultDescription, opts...).ToFunc()
+}
+
+// ByDefaultManufacturer orders the results by the default_manufacturer field.
+func ByDefaultManufacturer(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDefaultManufacturer, opts...).ToFunc()
+}
+
+// ByDefaultModelNumber orders the results by the default_model_number field.
+func ByDefaultModelNumber(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDefaultModelNumber, opts...).ToFunc()
+}
+
+// ByDefaultLifetimeWarranty orders the results by the default_lifetime_warranty field.
+func ByDefaultLifetimeWarranty(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDefaultLifetimeWarranty, opts...).ToFunc()
+}
+
+// ByDefaultWarrantyDetails orders the results by the default_warranty_details field.
+func ByDefaultWarrantyDetails(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDefaultWarrantyDetails, opts...).ToFunc()
+}
+
+// ByIncludeWarrantyFields orders the results by the include_warranty_fields field.
+func ByIncludeWarrantyFields(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldIncludeWarrantyFields, opts...).ToFunc()
+}
+
+// ByIncludePurchaseFields orders the results by the include_purchase_fields field.
+func ByIncludePurchaseFields(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldIncludePurchaseFields, opts...).ToFunc()
+}
+
+// ByIncludeSoldFields orders the results by the include_sold_fields field.
+func ByIncludeSoldFields(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldIncludeSoldFields, opts...).ToFunc()
+}
+
+// ByGroupField orders the results by group field.
+func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
+ return func(s *sql.Selector) {
+ sqlgraph.OrderByNeighborTerms(s, newGroupStep(), sql.OrderByField(field, opts...))
+ }
+}
+
+// ByFieldsCount orders the results by fields count.
+func ByFieldsCount(opts ...sql.OrderTermOption) OrderOption {
+ return func(s *sql.Selector) {
+ sqlgraph.OrderByNeighborsCount(s, newFieldsStep(), opts...)
+ }
+}
+
+// ByFields orders the results by fields terms.
+func ByFields(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
+ return func(s *sql.Selector) {
+ sqlgraph.OrderByNeighborTerms(s, newFieldsStep(), append([]sql.OrderTerm{term}, terms...)...)
+ }
+}
+
+// ByLocationField orders the results by location field.
+func ByLocationField(field string, opts ...sql.OrderTermOption) OrderOption {
+ return func(s *sql.Selector) {
+ sqlgraph.OrderByNeighborTerms(s, newLocationStep(), sql.OrderByField(field, opts...))
+ }
+}
+func newGroupStep() *sqlgraph.Step {
+ return sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.To(GroupInverseTable, FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
+ )
+}
+func newFieldsStep() *sqlgraph.Step {
+ return sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.To(FieldsInverseTable, FieldID),
+ sqlgraph.Edge(sqlgraph.O2M, false, FieldsTable, FieldsColumn),
+ )
+}
+func newLocationStep() *sqlgraph.Step {
+ return sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.To(LocationInverseTable, FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, false, LocationTable, LocationColumn),
+ )
+}
diff --git a/backend/internal/data/ent/itemtemplate/where.go b/backend/internal/data/ent/itemtemplate/where.go
new file mode 100644
index 00000000..1ade7376
--- /dev/null
+++ b/backend/internal/data/ent/itemtemplate/where.go
@@ -0,0 +1,991 @@
+// Code generated by ent, DO NOT EDIT.
+
+package itemtemplate
+
+import (
+ "time"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
+)
+
+// ID filters vertices based on their ID field.
+func ID(id uuid.UUID) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldID, id))
+}
+
+// IDEQ applies the EQ predicate on the ID field.
+func IDEQ(id uuid.UUID) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldID, id))
+}
+
+// IDNEQ applies the NEQ predicate on the ID field.
+func IDNEQ(id uuid.UUID) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldID, id))
+}
+
+// IDIn applies the In predicate on the ID field.
+func IDIn(ids ...uuid.UUID) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldID, ids...))
+}
+
+// IDNotIn applies the NotIn predicate on the ID field.
+func IDNotIn(ids ...uuid.UUID) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldID, ids...))
+}
+
+// IDGT applies the GT predicate on the ID field.
+func IDGT(id uuid.UUID) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldID, id))
+}
+
+// IDGTE applies the GTE predicate on the ID field.
+func IDGTE(id uuid.UUID) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldID, id))
+}
+
+// IDLT applies the LT predicate on the ID field.
+func IDLT(id uuid.UUID) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldID, id))
+}
+
+// IDLTE applies the LTE predicate on the ID field.
+func IDLTE(id uuid.UUID) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldID, id))
+}
+
+// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
+func CreatedAt(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
+func UpdatedAt(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
+func Name(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldName, v))
+}
+
+// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
+func Description(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDescription, v))
+}
+
+// Notes applies equality check predicate on the "notes" field. It's identical to NotesEQ.
+func Notes(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldNotes, v))
+}
+
+// DefaultQuantity applies equality check predicate on the "default_quantity" field. It's identical to DefaultQuantityEQ.
+func DefaultQuantity(v int) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultQuantity, v))
+}
+
+// DefaultInsured applies equality check predicate on the "default_insured" field. It's identical to DefaultInsuredEQ.
+func DefaultInsured(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultInsured, v))
+}
+
+// DefaultName applies equality check predicate on the "default_name" field. It's identical to DefaultNameEQ.
+func DefaultName(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultName, v))
+}
+
+// DefaultDescription applies equality check predicate on the "default_description" field. It's identical to DefaultDescriptionEQ.
+func DefaultDescription(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultDescription, v))
+}
+
+// DefaultManufacturer applies equality check predicate on the "default_manufacturer" field. It's identical to DefaultManufacturerEQ.
+func DefaultManufacturer(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultManufacturer, v))
+}
+
+// DefaultModelNumber applies equality check predicate on the "default_model_number" field. It's identical to DefaultModelNumberEQ.
+func DefaultModelNumber(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultModelNumber, v))
+}
+
+// DefaultLifetimeWarranty applies equality check predicate on the "default_lifetime_warranty" field. It's identical to DefaultLifetimeWarrantyEQ.
+func DefaultLifetimeWarranty(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultLifetimeWarranty, v))
+}
+
+// DefaultWarrantyDetails applies equality check predicate on the "default_warranty_details" field. It's identical to DefaultWarrantyDetailsEQ.
+func DefaultWarrantyDetails(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultWarrantyDetails, v))
+}
+
+// IncludeWarrantyFields applies equality check predicate on the "include_warranty_fields" field. It's identical to IncludeWarrantyFieldsEQ.
+func IncludeWarrantyFields(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeWarrantyFields, v))
+}
+
+// IncludePurchaseFields applies equality check predicate on the "include_purchase_fields" field. It's identical to IncludePurchaseFieldsEQ.
+func IncludePurchaseFields(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldIncludePurchaseFields, v))
+}
+
+// IncludeSoldFields applies equality check predicate on the "include_sold_fields" field. It's identical to IncludeSoldFieldsEQ.
+func IncludeSoldFields(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeSoldFields, v))
+}
+
+// CreatedAtEQ applies the EQ predicate on the "created_at" field.
+func CreatedAtEQ(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
+func CreatedAtNEQ(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtIn applies the In predicate on the "created_at" field.
+func CreatedAtIn(vs ...time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
+func CreatedAtNotIn(vs ...time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtGT applies the GT predicate on the "created_at" field.
+func CreatedAtGT(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldCreatedAt, v))
+}
+
+// CreatedAtGTE applies the GTE predicate on the "created_at" field.
+func CreatedAtGTE(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldCreatedAt, v))
+}
+
+// CreatedAtLT applies the LT predicate on the "created_at" field.
+func CreatedAtLT(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldCreatedAt, v))
+}
+
+// CreatedAtLTE applies the LTE predicate on the "created_at" field.
+func CreatedAtLTE(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldCreatedAt, v))
+}
+
+// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
+func UpdatedAtEQ(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
+func UpdatedAtNEQ(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtIn applies the In predicate on the "updated_at" field.
+func UpdatedAtIn(vs ...time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
+func UpdatedAtNotIn(vs ...time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtGT applies the GT predicate on the "updated_at" field.
+func UpdatedAtGT(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
+func UpdatedAtGTE(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLT applies the LT predicate on the "updated_at" field.
+func UpdatedAtLT(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
+func UpdatedAtLTE(v time.Time) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldUpdatedAt, v))
+}
+
+// NameEQ applies the EQ predicate on the "name" field.
+func NameEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldName, v))
+}
+
+// NameNEQ applies the NEQ predicate on the "name" field.
+func NameNEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldName, v))
+}
+
+// NameIn applies the In predicate on the "name" field.
+func NameIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldName, vs...))
+}
+
+// NameNotIn applies the NotIn predicate on the "name" field.
+func NameNotIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldName, vs...))
+}
+
+// NameGT applies the GT predicate on the "name" field.
+func NameGT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldName, v))
+}
+
+// NameGTE applies the GTE predicate on the "name" field.
+func NameGTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldName, v))
+}
+
+// NameLT applies the LT predicate on the "name" field.
+func NameLT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldName, v))
+}
+
+// NameLTE applies the LTE predicate on the "name" field.
+func NameLTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldName, v))
+}
+
+// NameContains applies the Contains predicate on the "name" field.
+func NameContains(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContains(FieldName, v))
+}
+
+// NameHasPrefix applies the HasPrefix predicate on the "name" field.
+func NameHasPrefix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasPrefix(FieldName, v))
+}
+
+// NameHasSuffix applies the HasSuffix predicate on the "name" field.
+func NameHasSuffix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasSuffix(FieldName, v))
+}
+
+// NameEqualFold applies the EqualFold predicate on the "name" field.
+func NameEqualFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEqualFold(FieldName, v))
+}
+
+// NameContainsFold applies the ContainsFold predicate on the "name" field.
+func NameContainsFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContainsFold(FieldName, v))
+}
+
+// DescriptionEQ applies the EQ predicate on the "description" field.
+func DescriptionEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDescription, v))
+}
+
+// DescriptionNEQ applies the NEQ predicate on the "description" field.
+func DescriptionNEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldDescription, v))
+}
+
+// DescriptionIn applies the In predicate on the "description" field.
+func DescriptionIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldDescription, vs...))
+}
+
+// DescriptionNotIn applies the NotIn predicate on the "description" field.
+func DescriptionNotIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldDescription, vs...))
+}
+
+// DescriptionGT applies the GT predicate on the "description" field.
+func DescriptionGT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldDescription, v))
+}
+
+// DescriptionGTE applies the GTE predicate on the "description" field.
+func DescriptionGTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldDescription, v))
+}
+
+// DescriptionLT applies the LT predicate on the "description" field.
+func DescriptionLT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldDescription, v))
+}
+
+// DescriptionLTE applies the LTE predicate on the "description" field.
+func DescriptionLTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldDescription, v))
+}
+
+// DescriptionContains applies the Contains predicate on the "description" field.
+func DescriptionContains(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContains(FieldDescription, v))
+}
+
+// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
+func DescriptionHasPrefix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDescription, v))
+}
+
+// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
+func DescriptionHasSuffix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDescription, v))
+}
+
+// DescriptionIsNil applies the IsNil predicate on the "description" field.
+func DescriptionIsNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIsNull(FieldDescription))
+}
+
+// DescriptionNotNil applies the NotNil predicate on the "description" field.
+func DescriptionNotNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotNull(FieldDescription))
+}
+
+// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
+func DescriptionEqualFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEqualFold(FieldDescription, v))
+}
+
+// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
+func DescriptionContainsFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContainsFold(FieldDescription, v))
+}
+
+// NotesEQ applies the EQ predicate on the "notes" field.
+func NotesEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldNotes, v))
+}
+
+// NotesNEQ applies the NEQ predicate on the "notes" field.
+func NotesNEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldNotes, v))
+}
+
+// NotesIn applies the In predicate on the "notes" field.
+func NotesIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldNotes, vs...))
+}
+
+// NotesNotIn applies the NotIn predicate on the "notes" field.
+func NotesNotIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldNotes, vs...))
+}
+
+// NotesGT applies the GT predicate on the "notes" field.
+func NotesGT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldNotes, v))
+}
+
+// NotesGTE applies the GTE predicate on the "notes" field.
+func NotesGTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldNotes, v))
+}
+
+// NotesLT applies the LT predicate on the "notes" field.
+func NotesLT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldNotes, v))
+}
+
+// NotesLTE applies the LTE predicate on the "notes" field.
+func NotesLTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldNotes, v))
+}
+
+// NotesContains applies the Contains predicate on the "notes" field.
+func NotesContains(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContains(FieldNotes, v))
+}
+
+// NotesHasPrefix applies the HasPrefix predicate on the "notes" field.
+func NotesHasPrefix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasPrefix(FieldNotes, v))
+}
+
+// NotesHasSuffix applies the HasSuffix predicate on the "notes" field.
+func NotesHasSuffix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasSuffix(FieldNotes, v))
+}
+
+// NotesIsNil applies the IsNil predicate on the "notes" field.
+func NotesIsNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIsNull(FieldNotes))
+}
+
+// NotesNotNil applies the NotNil predicate on the "notes" field.
+func NotesNotNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotNull(FieldNotes))
+}
+
+// NotesEqualFold applies the EqualFold predicate on the "notes" field.
+func NotesEqualFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEqualFold(FieldNotes, v))
+}
+
+// NotesContainsFold applies the ContainsFold predicate on the "notes" field.
+func NotesContainsFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContainsFold(FieldNotes, v))
+}
+
+// DefaultQuantityEQ applies the EQ predicate on the "default_quantity" field.
+func DefaultQuantityEQ(v int) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultQuantity, v))
+}
+
+// DefaultQuantityNEQ applies the NEQ predicate on the "default_quantity" field.
+func DefaultQuantityNEQ(v int) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultQuantity, v))
+}
+
+// DefaultQuantityIn applies the In predicate on the "default_quantity" field.
+func DefaultQuantityIn(vs ...int) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldDefaultQuantity, vs...))
+}
+
+// DefaultQuantityNotIn applies the NotIn predicate on the "default_quantity" field.
+func DefaultQuantityNotIn(vs ...int) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultQuantity, vs...))
+}
+
+// DefaultQuantityGT applies the GT predicate on the "default_quantity" field.
+func DefaultQuantityGT(v int) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldDefaultQuantity, v))
+}
+
+// DefaultQuantityGTE applies the GTE predicate on the "default_quantity" field.
+func DefaultQuantityGTE(v int) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultQuantity, v))
+}
+
+// DefaultQuantityLT applies the LT predicate on the "default_quantity" field.
+func DefaultQuantityLT(v int) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldDefaultQuantity, v))
+}
+
+// DefaultQuantityLTE applies the LTE predicate on the "default_quantity" field.
+func DefaultQuantityLTE(v int) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultQuantity, v))
+}
+
+// DefaultInsuredEQ applies the EQ predicate on the "default_insured" field.
+func DefaultInsuredEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultInsured, v))
+}
+
+// DefaultInsuredNEQ applies the NEQ predicate on the "default_insured" field.
+func DefaultInsuredNEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultInsured, v))
+}
+
+// DefaultNameEQ applies the EQ predicate on the "default_name" field.
+func DefaultNameEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultName, v))
+}
+
+// DefaultNameNEQ applies the NEQ predicate on the "default_name" field.
+func DefaultNameNEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultName, v))
+}
+
+// DefaultNameIn applies the In predicate on the "default_name" field.
+func DefaultNameIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldDefaultName, vs...))
+}
+
+// DefaultNameNotIn applies the NotIn predicate on the "default_name" field.
+func DefaultNameNotIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultName, vs...))
+}
+
+// DefaultNameGT applies the GT predicate on the "default_name" field.
+func DefaultNameGT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldDefaultName, v))
+}
+
+// DefaultNameGTE applies the GTE predicate on the "default_name" field.
+func DefaultNameGTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultName, v))
+}
+
+// DefaultNameLT applies the LT predicate on the "default_name" field.
+func DefaultNameLT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldDefaultName, v))
+}
+
+// DefaultNameLTE applies the LTE predicate on the "default_name" field.
+func DefaultNameLTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultName, v))
+}
+
+// DefaultNameContains applies the Contains predicate on the "default_name" field.
+func DefaultNameContains(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContains(FieldDefaultName, v))
+}
+
+// DefaultNameHasPrefix applies the HasPrefix predicate on the "default_name" field.
+func DefaultNameHasPrefix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultName, v))
+}
+
+// DefaultNameHasSuffix applies the HasSuffix predicate on the "default_name" field.
+func DefaultNameHasSuffix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultName, v))
+}
+
+// DefaultNameIsNil applies the IsNil predicate on the "default_name" field.
+func DefaultNameIsNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultName))
+}
+
+// DefaultNameNotNil applies the NotNil predicate on the "default_name" field.
+func DefaultNameNotNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultName))
+}
+
+// DefaultNameEqualFold applies the EqualFold predicate on the "default_name" field.
+func DefaultNameEqualFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultName, v))
+}
+
+// DefaultNameContainsFold applies the ContainsFold predicate on the "default_name" field.
+func DefaultNameContainsFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultName, v))
+}
+
+// DefaultDescriptionEQ applies the EQ predicate on the "default_description" field.
+func DefaultDescriptionEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionNEQ applies the NEQ predicate on the "default_description" field.
+func DefaultDescriptionNEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionIn applies the In predicate on the "default_description" field.
+func DefaultDescriptionIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldDefaultDescription, vs...))
+}
+
+// DefaultDescriptionNotIn applies the NotIn predicate on the "default_description" field.
+func DefaultDescriptionNotIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultDescription, vs...))
+}
+
+// DefaultDescriptionGT applies the GT predicate on the "default_description" field.
+func DefaultDescriptionGT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionGTE applies the GTE predicate on the "default_description" field.
+func DefaultDescriptionGTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionLT applies the LT predicate on the "default_description" field.
+func DefaultDescriptionLT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionLTE applies the LTE predicate on the "default_description" field.
+func DefaultDescriptionLTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionContains applies the Contains predicate on the "default_description" field.
+func DefaultDescriptionContains(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContains(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionHasPrefix applies the HasPrefix predicate on the "default_description" field.
+func DefaultDescriptionHasPrefix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionHasSuffix applies the HasSuffix predicate on the "default_description" field.
+func DefaultDescriptionHasSuffix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionIsNil applies the IsNil predicate on the "default_description" field.
+func DefaultDescriptionIsNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultDescription))
+}
+
+// DefaultDescriptionNotNil applies the NotNil predicate on the "default_description" field.
+func DefaultDescriptionNotNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultDescription))
+}
+
+// DefaultDescriptionEqualFold applies the EqualFold predicate on the "default_description" field.
+func DefaultDescriptionEqualFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultDescription, v))
+}
+
+// DefaultDescriptionContainsFold applies the ContainsFold predicate on the "default_description" field.
+func DefaultDescriptionContainsFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultDescription, v))
+}
+
+// DefaultManufacturerEQ applies the EQ predicate on the "default_manufacturer" field.
+func DefaultManufacturerEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerNEQ applies the NEQ predicate on the "default_manufacturer" field.
+func DefaultManufacturerNEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerIn applies the In predicate on the "default_manufacturer" field.
+func DefaultManufacturerIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldDefaultManufacturer, vs...))
+}
+
+// DefaultManufacturerNotIn applies the NotIn predicate on the "default_manufacturer" field.
+func DefaultManufacturerNotIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultManufacturer, vs...))
+}
+
+// DefaultManufacturerGT applies the GT predicate on the "default_manufacturer" field.
+func DefaultManufacturerGT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerGTE applies the GTE predicate on the "default_manufacturer" field.
+func DefaultManufacturerGTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerLT applies the LT predicate on the "default_manufacturer" field.
+func DefaultManufacturerLT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerLTE applies the LTE predicate on the "default_manufacturer" field.
+func DefaultManufacturerLTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerContains applies the Contains predicate on the "default_manufacturer" field.
+func DefaultManufacturerContains(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContains(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerHasPrefix applies the HasPrefix predicate on the "default_manufacturer" field.
+func DefaultManufacturerHasPrefix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerHasSuffix applies the HasSuffix predicate on the "default_manufacturer" field.
+func DefaultManufacturerHasSuffix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerIsNil applies the IsNil predicate on the "default_manufacturer" field.
+func DefaultManufacturerIsNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultManufacturer))
+}
+
+// DefaultManufacturerNotNil applies the NotNil predicate on the "default_manufacturer" field.
+func DefaultManufacturerNotNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultManufacturer))
+}
+
+// DefaultManufacturerEqualFold applies the EqualFold predicate on the "default_manufacturer" field.
+func DefaultManufacturerEqualFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultManufacturer, v))
+}
+
+// DefaultManufacturerContainsFold applies the ContainsFold predicate on the "default_manufacturer" field.
+func DefaultManufacturerContainsFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultManufacturer, v))
+}
+
+// DefaultModelNumberEQ applies the EQ predicate on the "default_model_number" field.
+func DefaultModelNumberEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberNEQ applies the NEQ predicate on the "default_model_number" field.
+func DefaultModelNumberNEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberIn applies the In predicate on the "default_model_number" field.
+func DefaultModelNumberIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldDefaultModelNumber, vs...))
+}
+
+// DefaultModelNumberNotIn applies the NotIn predicate on the "default_model_number" field.
+func DefaultModelNumberNotIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultModelNumber, vs...))
+}
+
+// DefaultModelNumberGT applies the GT predicate on the "default_model_number" field.
+func DefaultModelNumberGT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberGTE applies the GTE predicate on the "default_model_number" field.
+func DefaultModelNumberGTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberLT applies the LT predicate on the "default_model_number" field.
+func DefaultModelNumberLT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberLTE applies the LTE predicate on the "default_model_number" field.
+func DefaultModelNumberLTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberContains applies the Contains predicate on the "default_model_number" field.
+func DefaultModelNumberContains(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContains(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberHasPrefix applies the HasPrefix predicate on the "default_model_number" field.
+func DefaultModelNumberHasPrefix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberHasSuffix applies the HasSuffix predicate on the "default_model_number" field.
+func DefaultModelNumberHasSuffix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberIsNil applies the IsNil predicate on the "default_model_number" field.
+func DefaultModelNumberIsNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultModelNumber))
+}
+
+// DefaultModelNumberNotNil applies the NotNil predicate on the "default_model_number" field.
+func DefaultModelNumberNotNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultModelNumber))
+}
+
+// DefaultModelNumberEqualFold applies the EqualFold predicate on the "default_model_number" field.
+func DefaultModelNumberEqualFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultModelNumber, v))
+}
+
+// DefaultModelNumberContainsFold applies the ContainsFold predicate on the "default_model_number" field.
+func DefaultModelNumberContainsFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultModelNumber, v))
+}
+
+// DefaultLifetimeWarrantyEQ applies the EQ predicate on the "default_lifetime_warranty" field.
+func DefaultLifetimeWarrantyEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultLifetimeWarranty, v))
+}
+
+// DefaultLifetimeWarrantyNEQ applies the NEQ predicate on the "default_lifetime_warranty" field.
+func DefaultLifetimeWarrantyNEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultLifetimeWarranty, v))
+}
+
+// DefaultWarrantyDetailsEQ applies the EQ predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsNEQ applies the NEQ predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsNEQ(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsIn applies the In predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIn(FieldDefaultWarrantyDetails, vs...))
+}
+
+// DefaultWarrantyDetailsNotIn applies the NotIn predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsNotIn(vs ...string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultWarrantyDetails, vs...))
+}
+
+// DefaultWarrantyDetailsGT applies the GT predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsGT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGT(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsGTE applies the GTE predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsGTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsLT applies the LT predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsLT(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLT(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsLTE applies the LTE predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsLTE(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsContains applies the Contains predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsContains(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContains(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsHasPrefix applies the HasPrefix predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsHasPrefix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsHasSuffix applies the HasSuffix predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsHasSuffix(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsIsNil applies the IsNil predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsIsNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultWarrantyDetails))
+}
+
+// DefaultWarrantyDetailsNotNil applies the NotNil predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsNotNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultWarrantyDetails))
+}
+
+// DefaultWarrantyDetailsEqualFold applies the EqualFold predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsEqualFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultWarrantyDetails, v))
+}
+
+// DefaultWarrantyDetailsContainsFold applies the ContainsFold predicate on the "default_warranty_details" field.
+func DefaultWarrantyDetailsContainsFold(v string) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultWarrantyDetails, v))
+}
+
+// IncludeWarrantyFieldsEQ applies the EQ predicate on the "include_warranty_fields" field.
+func IncludeWarrantyFieldsEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeWarrantyFields, v))
+}
+
+// IncludeWarrantyFieldsNEQ applies the NEQ predicate on the "include_warranty_fields" field.
+func IncludeWarrantyFieldsNEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludeWarrantyFields, v))
+}
+
+// IncludePurchaseFieldsEQ applies the EQ predicate on the "include_purchase_fields" field.
+func IncludePurchaseFieldsEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldIncludePurchaseFields, v))
+}
+
+// IncludePurchaseFieldsNEQ applies the NEQ predicate on the "include_purchase_fields" field.
+func IncludePurchaseFieldsNEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludePurchaseFields, v))
+}
+
+// IncludeSoldFieldsEQ applies the EQ predicate on the "include_sold_fields" field.
+func IncludeSoldFieldsEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeSoldFields, v))
+}
+
+// IncludeSoldFieldsNEQ applies the NEQ predicate on the "include_sold_fields" field.
+func IncludeSoldFieldsNEQ(v bool) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludeSoldFields, v))
+}
+
+// DefaultLabelIdsIsNil applies the IsNil predicate on the "default_label_ids" field.
+func DefaultLabelIdsIsNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultLabelIds))
+}
+
+// DefaultLabelIdsNotNil applies the NotNil predicate on the "default_label_ids" field.
+func DefaultLabelIdsNotNil() predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultLabelIds))
+}
+
+// HasGroup applies the HasEdge predicate on the "group" edge.
+func HasGroup() predicate.ItemTemplate {
+ return predicate.ItemTemplate(func(s *sql.Selector) {
+ step := sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
+ )
+ sqlgraph.HasNeighbors(s, step)
+ })
+}
+
+// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates).
+func HasGroupWith(preds ...predicate.Group) predicate.ItemTemplate {
+ return predicate.ItemTemplate(func(s *sql.Selector) {
+ step := newGroupStep()
+ sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
+ for _, p := range preds {
+ p(s)
+ }
+ })
+ })
+}
+
+// HasFields applies the HasEdge predicate on the "fields" edge.
+func HasFields() predicate.ItemTemplate {
+ return predicate.ItemTemplate(func(s *sql.Selector) {
+ step := sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.Edge(sqlgraph.O2M, false, FieldsTable, FieldsColumn),
+ )
+ sqlgraph.HasNeighbors(s, step)
+ })
+}
+
+// HasFieldsWith applies the HasEdge predicate on the "fields" edge with a given conditions (other predicates).
+func HasFieldsWith(preds ...predicate.TemplateField) predicate.ItemTemplate {
+ return predicate.ItemTemplate(func(s *sql.Selector) {
+ step := newFieldsStep()
+ sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
+ for _, p := range preds {
+ p(s)
+ }
+ })
+ })
+}
+
+// HasLocation applies the HasEdge predicate on the "location" edge.
+func HasLocation() predicate.ItemTemplate {
+ return predicate.ItemTemplate(func(s *sql.Selector) {
+ step := sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, false, LocationTable, LocationColumn),
+ )
+ sqlgraph.HasNeighbors(s, step)
+ })
+}
+
+// HasLocationWith applies the HasEdge predicate on the "location" edge with a given conditions (other predicates).
+func HasLocationWith(preds ...predicate.Location) predicate.ItemTemplate {
+ return predicate.ItemTemplate(func(s *sql.Selector) {
+ step := newLocationStep()
+ sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
+ for _, p := range preds {
+ p(s)
+ }
+ })
+ })
+}
+
+// And groups predicates with the AND operator between them.
+func And(predicates ...predicate.ItemTemplate) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.AndPredicates(predicates...))
+}
+
+// Or groups predicates with the OR operator between them.
+func Or(predicates ...predicate.ItemTemplate) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.OrPredicates(predicates...))
+}
+
+// Not applies the not operator on the given predicate.
+func Not(p predicate.ItemTemplate) predicate.ItemTemplate {
+ return predicate.ItemTemplate(sql.NotPredicates(p))
+}
diff --git a/backend/internal/data/ent/itemtemplate_create.go b/backend/internal/data/ent/itemtemplate_create.go
new file mode 100644
index 00000000..30abd074
--- /dev/null
+++ b/backend/internal/data/ent/itemtemplate_create.go
@@ -0,0 +1,691 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "time"
+
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
+)
+
+// ItemTemplateCreate is the builder for creating a ItemTemplate entity.
+type ItemTemplateCreate struct {
+ config
+ mutation *ItemTemplateMutation
+ hooks []Hook
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (_c *ItemTemplateCreate) SetCreatedAt(v time.Time) *ItemTemplateCreate {
+ _c.mutation.SetCreatedAt(v)
+ return _c
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableCreatedAt(v *time.Time) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetCreatedAt(*v)
+ }
+ return _c
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (_c *ItemTemplateCreate) SetUpdatedAt(v time.Time) *ItemTemplateCreate {
+ _c.mutation.SetUpdatedAt(v)
+ return _c
+}
+
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableUpdatedAt(v *time.Time) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetUpdatedAt(*v)
+ }
+ return _c
+}
+
+// SetName sets the "name" field.
+func (_c *ItemTemplateCreate) SetName(v string) *ItemTemplateCreate {
+ _c.mutation.SetName(v)
+ return _c
+}
+
+// SetDescription sets the "description" field.
+func (_c *ItemTemplateCreate) SetDescription(v string) *ItemTemplateCreate {
+ _c.mutation.SetDescription(v)
+ return _c
+}
+
+// SetNillableDescription sets the "description" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableDescription(v *string) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetDescription(*v)
+ }
+ return _c
+}
+
+// SetNotes sets the "notes" field.
+func (_c *ItemTemplateCreate) SetNotes(v string) *ItemTemplateCreate {
+ _c.mutation.SetNotes(v)
+ return _c
+}
+
+// SetNillableNotes sets the "notes" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableNotes(v *string) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetNotes(*v)
+ }
+ return _c
+}
+
+// SetDefaultQuantity sets the "default_quantity" field.
+func (_c *ItemTemplateCreate) SetDefaultQuantity(v int) *ItemTemplateCreate {
+ _c.mutation.SetDefaultQuantity(v)
+ return _c
+}
+
+// SetNillableDefaultQuantity sets the "default_quantity" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableDefaultQuantity(v *int) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetDefaultQuantity(*v)
+ }
+ return _c
+}
+
+// SetDefaultInsured sets the "default_insured" field.
+func (_c *ItemTemplateCreate) SetDefaultInsured(v bool) *ItemTemplateCreate {
+ _c.mutation.SetDefaultInsured(v)
+ return _c
+}
+
+// SetNillableDefaultInsured sets the "default_insured" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableDefaultInsured(v *bool) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetDefaultInsured(*v)
+ }
+ return _c
+}
+
+// SetDefaultName sets the "default_name" field.
+func (_c *ItemTemplateCreate) SetDefaultName(v string) *ItemTemplateCreate {
+ _c.mutation.SetDefaultName(v)
+ return _c
+}
+
+// SetNillableDefaultName sets the "default_name" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableDefaultName(v *string) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetDefaultName(*v)
+ }
+ return _c
+}
+
+// SetDefaultDescription sets the "default_description" field.
+func (_c *ItemTemplateCreate) SetDefaultDescription(v string) *ItemTemplateCreate {
+ _c.mutation.SetDefaultDescription(v)
+ return _c
+}
+
+// SetNillableDefaultDescription sets the "default_description" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableDefaultDescription(v *string) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetDefaultDescription(*v)
+ }
+ return _c
+}
+
+// SetDefaultManufacturer sets the "default_manufacturer" field.
+func (_c *ItemTemplateCreate) SetDefaultManufacturer(v string) *ItemTemplateCreate {
+ _c.mutation.SetDefaultManufacturer(v)
+ return _c
+}
+
+// SetNillableDefaultManufacturer sets the "default_manufacturer" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableDefaultManufacturer(v *string) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetDefaultManufacturer(*v)
+ }
+ return _c
+}
+
+// SetDefaultModelNumber sets the "default_model_number" field.
+func (_c *ItemTemplateCreate) SetDefaultModelNumber(v string) *ItemTemplateCreate {
+ _c.mutation.SetDefaultModelNumber(v)
+ return _c
+}
+
+// SetNillableDefaultModelNumber sets the "default_model_number" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableDefaultModelNumber(v *string) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetDefaultModelNumber(*v)
+ }
+ return _c
+}
+
+// SetDefaultLifetimeWarranty sets the "default_lifetime_warranty" field.
+func (_c *ItemTemplateCreate) SetDefaultLifetimeWarranty(v bool) *ItemTemplateCreate {
+ _c.mutation.SetDefaultLifetimeWarranty(v)
+ return _c
+}
+
+// SetNillableDefaultLifetimeWarranty sets the "default_lifetime_warranty" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableDefaultLifetimeWarranty(v *bool) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetDefaultLifetimeWarranty(*v)
+ }
+ return _c
+}
+
+// SetDefaultWarrantyDetails sets the "default_warranty_details" field.
+func (_c *ItemTemplateCreate) SetDefaultWarrantyDetails(v string) *ItemTemplateCreate {
+ _c.mutation.SetDefaultWarrantyDetails(v)
+ return _c
+}
+
+// SetNillableDefaultWarrantyDetails sets the "default_warranty_details" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableDefaultWarrantyDetails(v *string) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetDefaultWarrantyDetails(*v)
+ }
+ return _c
+}
+
+// SetIncludeWarrantyFields sets the "include_warranty_fields" field.
+func (_c *ItemTemplateCreate) SetIncludeWarrantyFields(v bool) *ItemTemplateCreate {
+ _c.mutation.SetIncludeWarrantyFields(v)
+ return _c
+}
+
+// SetNillableIncludeWarrantyFields sets the "include_warranty_fields" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableIncludeWarrantyFields(v *bool) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetIncludeWarrantyFields(*v)
+ }
+ return _c
+}
+
+// SetIncludePurchaseFields sets the "include_purchase_fields" field.
+func (_c *ItemTemplateCreate) SetIncludePurchaseFields(v bool) *ItemTemplateCreate {
+ _c.mutation.SetIncludePurchaseFields(v)
+ return _c
+}
+
+// SetNillableIncludePurchaseFields sets the "include_purchase_fields" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableIncludePurchaseFields(v *bool) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetIncludePurchaseFields(*v)
+ }
+ return _c
+}
+
+// SetIncludeSoldFields sets the "include_sold_fields" field.
+func (_c *ItemTemplateCreate) SetIncludeSoldFields(v bool) *ItemTemplateCreate {
+ _c.mutation.SetIncludeSoldFields(v)
+ return _c
+}
+
+// SetNillableIncludeSoldFields sets the "include_sold_fields" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableIncludeSoldFields(v *bool) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetIncludeSoldFields(*v)
+ }
+ return _c
+}
+
+// SetDefaultLabelIds sets the "default_label_ids" field.
+func (_c *ItemTemplateCreate) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateCreate {
+ _c.mutation.SetDefaultLabelIds(v)
+ return _c
+}
+
+// SetID sets the "id" field.
+func (_c *ItemTemplateCreate) SetID(v uuid.UUID) *ItemTemplateCreate {
+ _c.mutation.SetID(v)
+ return _c
+}
+
+// SetNillableID sets the "id" field if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableID(v *uuid.UUID) *ItemTemplateCreate {
+ if v != nil {
+ _c.SetID(*v)
+ }
+ return _c
+}
+
+// SetGroupID sets the "group" edge to the Group entity by ID.
+func (_c *ItemTemplateCreate) SetGroupID(id uuid.UUID) *ItemTemplateCreate {
+ _c.mutation.SetGroupID(id)
+ return _c
+}
+
+// SetGroup sets the "group" edge to the Group entity.
+func (_c *ItemTemplateCreate) SetGroup(v *Group) *ItemTemplateCreate {
+ return _c.SetGroupID(v.ID)
+}
+
+// AddFieldIDs adds the "fields" edge to the TemplateField entity by IDs.
+func (_c *ItemTemplateCreate) AddFieldIDs(ids ...uuid.UUID) *ItemTemplateCreate {
+ _c.mutation.AddFieldIDs(ids...)
+ return _c
+}
+
+// AddFields adds the "fields" edges to the TemplateField entity.
+func (_c *ItemTemplateCreate) AddFields(v ...*TemplateField) *ItemTemplateCreate {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _c.AddFieldIDs(ids...)
+}
+
+// SetLocationID sets the "location" edge to the Location entity by ID.
+func (_c *ItemTemplateCreate) SetLocationID(id uuid.UUID) *ItemTemplateCreate {
+ _c.mutation.SetLocationID(id)
+ return _c
+}
+
+// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
+func (_c *ItemTemplateCreate) SetNillableLocationID(id *uuid.UUID) *ItemTemplateCreate {
+ if id != nil {
+ _c = _c.SetLocationID(*id)
+ }
+ return _c
+}
+
+// SetLocation sets the "location" edge to the Location entity.
+func (_c *ItemTemplateCreate) SetLocation(v *Location) *ItemTemplateCreate {
+ return _c.SetLocationID(v.ID)
+}
+
+// Mutation returns the ItemTemplateMutation object of the builder.
+func (_c *ItemTemplateCreate) Mutation() *ItemTemplateMutation {
+ return _c.mutation
+}
+
+// Save creates the ItemTemplate in the database.
+func (_c *ItemTemplateCreate) Save(ctx context.Context) (*ItemTemplate, error) {
+ _c.defaults()
+ return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
+}
+
+// SaveX calls Save and panics if Save returns an error.
+func (_c *ItemTemplateCreate) SaveX(ctx context.Context) *ItemTemplate {
+ v, err := _c.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
+
+// Exec executes the query.
+func (_c *ItemTemplateCreate) Exec(ctx context.Context) error {
+ _, err := _c.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_c *ItemTemplateCreate) ExecX(ctx context.Context) {
+ if err := _c.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// defaults sets the default values of the builder before save.
+func (_c *ItemTemplateCreate) defaults() {
+ if _, ok := _c.mutation.CreatedAt(); !ok {
+ v := itemtemplate.DefaultCreatedAt()
+ _c.mutation.SetCreatedAt(v)
+ }
+ if _, ok := _c.mutation.UpdatedAt(); !ok {
+ v := itemtemplate.DefaultUpdatedAt()
+ _c.mutation.SetUpdatedAt(v)
+ }
+ if _, ok := _c.mutation.DefaultQuantity(); !ok {
+ v := itemtemplate.DefaultDefaultQuantity
+ _c.mutation.SetDefaultQuantity(v)
+ }
+ if _, ok := _c.mutation.DefaultInsured(); !ok {
+ v := itemtemplate.DefaultDefaultInsured
+ _c.mutation.SetDefaultInsured(v)
+ }
+ if _, ok := _c.mutation.DefaultLifetimeWarranty(); !ok {
+ v := itemtemplate.DefaultDefaultLifetimeWarranty
+ _c.mutation.SetDefaultLifetimeWarranty(v)
+ }
+ if _, ok := _c.mutation.IncludeWarrantyFields(); !ok {
+ v := itemtemplate.DefaultIncludeWarrantyFields
+ _c.mutation.SetIncludeWarrantyFields(v)
+ }
+ if _, ok := _c.mutation.IncludePurchaseFields(); !ok {
+ v := itemtemplate.DefaultIncludePurchaseFields
+ _c.mutation.SetIncludePurchaseFields(v)
+ }
+ if _, ok := _c.mutation.IncludeSoldFields(); !ok {
+ v := itemtemplate.DefaultIncludeSoldFields
+ _c.mutation.SetIncludeSoldFields(v)
+ }
+ if _, ok := _c.mutation.ID(); !ok {
+ v := itemtemplate.DefaultID()
+ _c.mutation.SetID(v)
+ }
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (_c *ItemTemplateCreate) check() error {
+ if _, ok := _c.mutation.CreatedAt(); !ok {
+ return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ItemTemplate.created_at"`)}
+ }
+ if _, ok := _c.mutation.UpdatedAt(); !ok {
+ return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ItemTemplate.updated_at"`)}
+ }
+ if _, ok := _c.mutation.Name(); !ok {
+ return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ItemTemplate.name"`)}
+ }
+ if v, ok := _c.mutation.Name(); ok {
+ if err := itemtemplate.NameValidator(v); err != nil {
+ return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.name": %w`, err)}
+ }
+ }
+ if v, ok := _c.mutation.Description(); ok {
+ if err := itemtemplate.DescriptionValidator(v); err != nil {
+ return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.description": %w`, err)}
+ }
+ }
+ if v, ok := _c.mutation.Notes(); ok {
+ if err := itemtemplate.NotesValidator(v); err != nil {
+ return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.notes": %w`, err)}
+ }
+ }
+ if _, ok := _c.mutation.DefaultQuantity(); !ok {
+ return &ValidationError{Name: "default_quantity", err: errors.New(`ent: missing required field "ItemTemplate.default_quantity"`)}
+ }
+ if _, ok := _c.mutation.DefaultInsured(); !ok {
+ return &ValidationError{Name: "default_insured", err: errors.New(`ent: missing required field "ItemTemplate.default_insured"`)}
+ }
+ if v, ok := _c.mutation.DefaultName(); ok {
+ if err := itemtemplate.DefaultNameValidator(v); err != nil {
+ return &ValidationError{Name: "default_name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_name": %w`, err)}
+ }
+ }
+ if v, ok := _c.mutation.DefaultDescription(); ok {
+ if err := itemtemplate.DefaultDescriptionValidator(v); err != nil {
+ return &ValidationError{Name: "default_description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_description": %w`, err)}
+ }
+ }
+ if v, ok := _c.mutation.DefaultManufacturer(); ok {
+ if err := itemtemplate.DefaultManufacturerValidator(v); err != nil {
+ return &ValidationError{Name: "default_manufacturer", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_manufacturer": %w`, err)}
+ }
+ }
+ if v, ok := _c.mutation.DefaultModelNumber(); ok {
+ if err := itemtemplate.DefaultModelNumberValidator(v); err != nil {
+ return &ValidationError{Name: "default_model_number", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_model_number": %w`, err)}
+ }
+ }
+ if _, ok := _c.mutation.DefaultLifetimeWarranty(); !ok {
+ return &ValidationError{Name: "default_lifetime_warranty", err: errors.New(`ent: missing required field "ItemTemplate.default_lifetime_warranty"`)}
+ }
+ if v, ok := _c.mutation.DefaultWarrantyDetails(); ok {
+ if err := itemtemplate.DefaultWarrantyDetailsValidator(v); err != nil {
+ return &ValidationError{Name: "default_warranty_details", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_warranty_details": %w`, err)}
+ }
+ }
+ if _, ok := _c.mutation.IncludeWarrantyFields(); !ok {
+ return &ValidationError{Name: "include_warranty_fields", err: errors.New(`ent: missing required field "ItemTemplate.include_warranty_fields"`)}
+ }
+ if _, ok := _c.mutation.IncludePurchaseFields(); !ok {
+ return &ValidationError{Name: "include_purchase_fields", err: errors.New(`ent: missing required field "ItemTemplate.include_purchase_fields"`)}
+ }
+ if _, ok := _c.mutation.IncludeSoldFields(); !ok {
+ return &ValidationError{Name: "include_sold_fields", err: errors.New(`ent: missing required field "ItemTemplate.include_sold_fields"`)}
+ }
+ if len(_c.mutation.GroupIDs()) == 0 {
+ return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "ItemTemplate.group"`)}
+ }
+ return nil
+}
+
+func (_c *ItemTemplateCreate) sqlSave(ctx context.Context) (*ItemTemplate, error) {
+ if err := _c.check(); err != nil {
+ return nil, err
+ }
+ _node, _spec := _c.createSpec()
+ if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
+ if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ return nil, err
+ }
+ if _spec.ID.Value != nil {
+ if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
+ _node.ID = *id
+ } else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
+ return nil, err
+ }
+ }
+ _c.mutation.id = &_node.ID
+ _c.mutation.done = true
+ return _node, nil
+}
+
+func (_c *ItemTemplateCreate) createSpec() (*ItemTemplate, *sqlgraph.CreateSpec) {
+ var (
+ _node = &ItemTemplate{config: _c.config}
+ _spec = sqlgraph.NewCreateSpec(itemtemplate.Table, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID))
+ )
+ if id, ok := _c.mutation.ID(); ok {
+ _node.ID = id
+ _spec.ID.Value = &id
+ }
+ if value, ok := _c.mutation.CreatedAt(); ok {
+ _spec.SetField(itemtemplate.FieldCreatedAt, field.TypeTime, value)
+ _node.CreatedAt = value
+ }
+ if value, ok := _c.mutation.UpdatedAt(); ok {
+ _spec.SetField(itemtemplate.FieldUpdatedAt, field.TypeTime, value)
+ _node.UpdatedAt = value
+ }
+ if value, ok := _c.mutation.Name(); ok {
+ _spec.SetField(itemtemplate.FieldName, field.TypeString, value)
+ _node.Name = value
+ }
+ if value, ok := _c.mutation.Description(); ok {
+ _spec.SetField(itemtemplate.FieldDescription, field.TypeString, value)
+ _node.Description = value
+ }
+ if value, ok := _c.mutation.Notes(); ok {
+ _spec.SetField(itemtemplate.FieldNotes, field.TypeString, value)
+ _node.Notes = value
+ }
+ if value, ok := _c.mutation.DefaultQuantity(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value)
+ _node.DefaultQuantity = value
+ }
+ if value, ok := _c.mutation.DefaultInsured(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultInsured, field.TypeBool, value)
+ _node.DefaultInsured = value
+ }
+ if value, ok := _c.mutation.DefaultName(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultName, field.TypeString, value)
+ _node.DefaultName = value
+ }
+ if value, ok := _c.mutation.DefaultDescription(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultDescription, field.TypeString, value)
+ _node.DefaultDescription = value
+ }
+ if value, ok := _c.mutation.DefaultManufacturer(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultManufacturer, field.TypeString, value)
+ _node.DefaultManufacturer = value
+ }
+ if value, ok := _c.mutation.DefaultModelNumber(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultModelNumber, field.TypeString, value)
+ _node.DefaultModelNumber = value
+ }
+ if value, ok := _c.mutation.DefaultLifetimeWarranty(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultLifetimeWarranty, field.TypeBool, value)
+ _node.DefaultLifetimeWarranty = value
+ }
+ if value, ok := _c.mutation.DefaultWarrantyDetails(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString, value)
+ _node.DefaultWarrantyDetails = value
+ }
+ if value, ok := _c.mutation.IncludeWarrantyFields(); ok {
+ _spec.SetField(itemtemplate.FieldIncludeWarrantyFields, field.TypeBool, value)
+ _node.IncludeWarrantyFields = value
+ }
+ if value, ok := _c.mutation.IncludePurchaseFields(); ok {
+ _spec.SetField(itemtemplate.FieldIncludePurchaseFields, field.TypeBool, value)
+ _node.IncludePurchaseFields = value
+ }
+ if value, ok := _c.mutation.IncludeSoldFields(); ok {
+ _spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value)
+ _node.IncludeSoldFields = value
+ }
+ if value, ok := _c.mutation.DefaultLabelIds(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value)
+ _node.DefaultLabelIds = value
+ }
+ if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: itemtemplate.GroupTable,
+ Columns: []string{itemtemplate.GroupColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _node.group_item_templates = &nodes[0]
+ _spec.Edges = append(_spec.Edges, edge)
+ }
+ if nodes := _c.mutation.FieldsIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: itemtemplate.FieldsTable,
+ Columns: []string{itemtemplate.FieldsColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges = append(_spec.Edges, edge)
+ }
+ if nodes := _c.mutation.LocationIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: false,
+ Table: itemtemplate.LocationTable,
+ Columns: []string{itemtemplate.LocationColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _node.item_template_location = &nodes[0]
+ _spec.Edges = append(_spec.Edges, edge)
+ }
+ return _node, _spec
+}
+
+// ItemTemplateCreateBulk is the builder for creating many ItemTemplate entities in bulk.
+type ItemTemplateCreateBulk struct {
+ config
+ err error
+ builders []*ItemTemplateCreate
+}
+
+// Save creates the ItemTemplate entities in the database.
+func (_c *ItemTemplateCreateBulk) Save(ctx context.Context) ([]*ItemTemplate, error) {
+ if _c.err != nil {
+ return nil, _c.err
+ }
+ specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
+ nodes := make([]*ItemTemplate, len(_c.builders))
+ mutators := make([]Mutator, len(_c.builders))
+ for i := range _c.builders {
+ func(i int, root context.Context) {
+ builder := _c.builders[i]
+ builder.defaults()
+ var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
+ mutation, ok := m.(*ItemTemplateMutation)
+ if !ok {
+ return nil, fmt.Errorf("unexpected mutation type %T", m)
+ }
+ if err := builder.check(); err != nil {
+ return nil, err
+ }
+ builder.mutation = mutation
+ var err error
+ nodes[i], specs[i] = builder.createSpec()
+ if i < len(mutators)-1 {
+ _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
+ } else {
+ spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
+ // Invoke the actual operation on the latest mutation in the chain.
+ if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
+ if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ }
+ }
+ if err != nil {
+ return nil, err
+ }
+ mutation.id = &nodes[i].ID
+ mutation.done = true
+ return nodes[i], nil
+ })
+ for i := len(builder.hooks) - 1; i >= 0; i-- {
+ mut = builder.hooks[i](mut)
+ }
+ mutators[i] = mut
+ }(i, ctx)
+ }
+ if len(mutators) > 0 {
+ if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
+ return nil, err
+ }
+ }
+ return nodes, nil
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (_c *ItemTemplateCreateBulk) SaveX(ctx context.Context) []*ItemTemplate {
+ v, err := _c.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
+
+// Exec executes the query.
+func (_c *ItemTemplateCreateBulk) Exec(ctx context.Context) error {
+ _, err := _c.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_c *ItemTemplateCreateBulk) ExecX(ctx context.Context) {
+ if err := _c.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
diff --git a/backend/internal/data/ent/itemtemplate_delete.go b/backend/internal/data/ent/itemtemplate_delete.go
new file mode 100644
index 00000000..843804df
--- /dev/null
+++ b/backend/internal/data/ent/itemtemplate_delete.go
@@ -0,0 +1,88 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "context"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
+)
+
+// ItemTemplateDelete is the builder for deleting a ItemTemplate entity.
+type ItemTemplateDelete struct {
+ config
+ hooks []Hook
+ mutation *ItemTemplateMutation
+}
+
+// Where appends a list predicates to the ItemTemplateDelete builder.
+func (_d *ItemTemplateDelete) Where(ps ...predicate.ItemTemplate) *ItemTemplateDelete {
+ _d.mutation.Where(ps...)
+ return _d
+}
+
+// Exec executes the deletion query and returns how many vertices were deleted.
+func (_d *ItemTemplateDelete) Exec(ctx context.Context) (int, error) {
+ return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_d *ItemTemplateDelete) ExecX(ctx context.Context) int {
+ n, err := _d.Exec(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return n
+}
+
+func (_d *ItemTemplateDelete) sqlExec(ctx context.Context) (int, error) {
+ _spec := sqlgraph.NewDeleteSpec(itemtemplate.Table, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID))
+ if ps := _d.mutation.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
+ if err != nil && sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ _d.mutation.done = true
+ return affected, err
+}
+
+// ItemTemplateDeleteOne is the builder for deleting a single ItemTemplate entity.
+type ItemTemplateDeleteOne struct {
+ _d *ItemTemplateDelete
+}
+
+// Where appends a list predicates to the ItemTemplateDelete builder.
+func (_d *ItemTemplateDeleteOne) Where(ps ...predicate.ItemTemplate) *ItemTemplateDeleteOne {
+ _d._d.mutation.Where(ps...)
+ return _d
+}
+
+// Exec executes the deletion query.
+func (_d *ItemTemplateDeleteOne) Exec(ctx context.Context) error {
+ n, err := _d._d.Exec(ctx)
+ switch {
+ case err != nil:
+ return err
+ case n == 0:
+ return &NotFoundError{itemtemplate.Label}
+ default:
+ return nil
+ }
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_d *ItemTemplateDeleteOne) ExecX(ctx context.Context) {
+ if err := _d.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
diff --git a/backend/internal/data/ent/itemtemplate_query.go b/backend/internal/data/ent/itemtemplate_query.go
new file mode 100644
index 00000000..5e339f1f
--- /dev/null
+++ b/backend/internal/data/ent/itemtemplate_query.go
@@ -0,0 +1,766 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "context"
+ "database/sql/driver"
+ "fmt"
+ "math"
+
+ "entgo.io/ent"
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
+)
+
+// ItemTemplateQuery is the builder for querying ItemTemplate entities.
+type ItemTemplateQuery struct {
+ config
+ ctx *QueryContext
+ order []itemtemplate.OrderOption
+ inters []Interceptor
+ predicates []predicate.ItemTemplate
+ withGroup *GroupQuery
+ withFields *TemplateFieldQuery
+ withLocation *LocationQuery
+ withFKs bool
+ // intermediate query (i.e. traversal path).
+ sql *sql.Selector
+ path func(context.Context) (*sql.Selector, error)
+}
+
+// Where adds a new predicate for the ItemTemplateQuery builder.
+func (_q *ItemTemplateQuery) Where(ps ...predicate.ItemTemplate) *ItemTemplateQuery {
+ _q.predicates = append(_q.predicates, ps...)
+ return _q
+}
+
+// Limit the number of records to be returned by this query.
+func (_q *ItemTemplateQuery) Limit(limit int) *ItemTemplateQuery {
+ _q.ctx.Limit = &limit
+ return _q
+}
+
+// Offset to start from.
+func (_q *ItemTemplateQuery) Offset(offset int) *ItemTemplateQuery {
+ _q.ctx.Offset = &offset
+ return _q
+}
+
+// Unique configures the query builder to filter duplicate records on query.
+// By default, unique is set to true, and can be disabled using this method.
+func (_q *ItemTemplateQuery) Unique(unique bool) *ItemTemplateQuery {
+ _q.ctx.Unique = &unique
+ return _q
+}
+
+// Order specifies how the records should be ordered.
+func (_q *ItemTemplateQuery) Order(o ...itemtemplate.OrderOption) *ItemTemplateQuery {
+ _q.order = append(_q.order, o...)
+ return _q
+}
+
+// QueryGroup chains the current query on the "group" edge.
+func (_q *ItemTemplateQuery) QueryGroup() *GroupQuery {
+ query := (&GroupClient{config: _q.config}).Query()
+ query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
+ if err := _q.prepareQuery(ctx); err != nil {
+ return nil, err
+ }
+ selector := _q.sqlQuery(ctx)
+ if err := selector.Err(); err != nil {
+ return nil, err
+ }
+ step := sqlgraph.NewStep(
+ sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector),
+ sqlgraph.To(group.Table, group.FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, true, itemtemplate.GroupTable, itemtemplate.GroupColumn),
+ )
+ fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
+ return fromU, nil
+ }
+ return query
+}
+
+// QueryFields chains the current query on the "fields" edge.
+func (_q *ItemTemplateQuery) QueryFields() *TemplateFieldQuery {
+ query := (&TemplateFieldClient{config: _q.config}).Query()
+ query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
+ if err := _q.prepareQuery(ctx); err != nil {
+ return nil, err
+ }
+ selector := _q.sqlQuery(ctx)
+ if err := selector.Err(); err != nil {
+ return nil, err
+ }
+ step := sqlgraph.NewStep(
+ sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector),
+ sqlgraph.To(templatefield.Table, templatefield.FieldID),
+ sqlgraph.Edge(sqlgraph.O2M, false, itemtemplate.FieldsTable, itemtemplate.FieldsColumn),
+ )
+ fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
+ return fromU, nil
+ }
+ return query
+}
+
+// QueryLocation chains the current query on the "location" edge.
+func (_q *ItemTemplateQuery) QueryLocation() *LocationQuery {
+ query := (&LocationClient{config: _q.config}).Query()
+ query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
+ if err := _q.prepareQuery(ctx); err != nil {
+ return nil, err
+ }
+ selector := _q.sqlQuery(ctx)
+ if err := selector.Err(); err != nil {
+ return nil, err
+ }
+ step := sqlgraph.NewStep(
+ sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector),
+ sqlgraph.To(location.Table, location.FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn),
+ )
+ fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
+ return fromU, nil
+ }
+ return query
+}
+
+// First returns the first ItemTemplate entity from the query.
+// Returns a *NotFoundError when no ItemTemplate was found.
+func (_q *ItemTemplateQuery) First(ctx context.Context) (*ItemTemplate, error) {
+ nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
+ if err != nil {
+ return nil, err
+ }
+ if len(nodes) == 0 {
+ return nil, &NotFoundError{itemtemplate.Label}
+ }
+ return nodes[0], nil
+}
+
+// FirstX is like First, but panics if an error occurs.
+func (_q *ItemTemplateQuery) FirstX(ctx context.Context) *ItemTemplate {
+ node, err := _q.First(ctx)
+ if err != nil && !IsNotFound(err) {
+ panic(err)
+ }
+ return node
+}
+
+// FirstID returns the first ItemTemplate ID from the query.
+// Returns a *NotFoundError when no ItemTemplate ID was found.
+func (_q *ItemTemplateQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
+ var ids []uuid.UUID
+ if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
+ return
+ }
+ if len(ids) == 0 {
+ err = &NotFoundError{itemtemplate.Label}
+ return
+ }
+ return ids[0], nil
+}
+
+// FirstIDX is like FirstID, but panics if an error occurs.
+func (_q *ItemTemplateQuery) FirstIDX(ctx context.Context) uuid.UUID {
+ id, err := _q.FirstID(ctx)
+ if err != nil && !IsNotFound(err) {
+ panic(err)
+ }
+ return id
+}
+
+// Only returns a single ItemTemplate entity found by the query, ensuring it only returns one.
+// Returns a *NotSingularError when more than one ItemTemplate entity is found.
+// Returns a *NotFoundError when no ItemTemplate entities are found.
+func (_q *ItemTemplateQuery) Only(ctx context.Context) (*ItemTemplate, error) {
+ nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
+ if err != nil {
+ return nil, err
+ }
+ switch len(nodes) {
+ case 1:
+ return nodes[0], nil
+ case 0:
+ return nil, &NotFoundError{itemtemplate.Label}
+ default:
+ return nil, &NotSingularError{itemtemplate.Label}
+ }
+}
+
+// OnlyX is like Only, but panics if an error occurs.
+func (_q *ItemTemplateQuery) OnlyX(ctx context.Context) *ItemTemplate {
+ node, err := _q.Only(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return node
+}
+
+// OnlyID is like Only, but returns the only ItemTemplate ID in the query.
+// Returns a *NotSingularError when more than one ItemTemplate ID is found.
+// Returns a *NotFoundError when no entities are found.
+func (_q *ItemTemplateQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
+ var ids []uuid.UUID
+ if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
+ return
+ }
+ switch len(ids) {
+ case 1:
+ id = ids[0]
+ case 0:
+ err = &NotFoundError{itemtemplate.Label}
+ default:
+ err = &NotSingularError{itemtemplate.Label}
+ }
+ return
+}
+
+// OnlyIDX is like OnlyID, but panics if an error occurs.
+func (_q *ItemTemplateQuery) OnlyIDX(ctx context.Context) uuid.UUID {
+ id, err := _q.OnlyID(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return id
+}
+
+// All executes the query and returns a list of ItemTemplates.
+func (_q *ItemTemplateQuery) All(ctx context.Context) ([]*ItemTemplate, error) {
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
+ if err := _q.prepareQuery(ctx); err != nil {
+ return nil, err
+ }
+ qr := querierAll[[]*ItemTemplate, *ItemTemplateQuery]()
+ return withInterceptors[[]*ItemTemplate](ctx, _q, qr, _q.inters)
+}
+
+// AllX is like All, but panics if an error occurs.
+func (_q *ItemTemplateQuery) AllX(ctx context.Context) []*ItemTemplate {
+ nodes, err := _q.All(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return nodes
+}
+
+// IDs executes the query and returns a list of ItemTemplate IDs.
+func (_q *ItemTemplateQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
+ if _q.ctx.Unique == nil && _q.path != nil {
+ _q.Unique(true)
+ }
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
+ if err = _q.Select(itemtemplate.FieldID).Scan(ctx, &ids); err != nil {
+ return nil, err
+ }
+ return ids, nil
+}
+
+// IDsX is like IDs, but panics if an error occurs.
+func (_q *ItemTemplateQuery) IDsX(ctx context.Context) []uuid.UUID {
+ ids, err := _q.IDs(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return ids
+}
+
+// Count returns the count of the given query.
+func (_q *ItemTemplateQuery) Count(ctx context.Context) (int, error) {
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
+ if err := _q.prepareQuery(ctx); err != nil {
+ return 0, err
+ }
+ return withInterceptors[int](ctx, _q, querierCount[*ItemTemplateQuery](), _q.inters)
+}
+
+// CountX is like Count, but panics if an error occurs.
+func (_q *ItemTemplateQuery) CountX(ctx context.Context) int {
+ count, err := _q.Count(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return count
+}
+
+// Exist returns true if the query has elements in the graph.
+func (_q *ItemTemplateQuery) Exist(ctx context.Context) (bool, error) {
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
+ switch _, err := _q.FirstID(ctx); {
+ case IsNotFound(err):
+ return false, nil
+ case err != nil:
+ return false, fmt.Errorf("ent: check existence: %w", err)
+ default:
+ return true, nil
+ }
+}
+
+// ExistX is like Exist, but panics if an error occurs.
+func (_q *ItemTemplateQuery) ExistX(ctx context.Context) bool {
+ exist, err := _q.Exist(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return exist
+}
+
+// Clone returns a duplicate of the ItemTemplateQuery builder, including all associated steps. It can be
+// used to prepare common query builders and use them differently after the clone is made.
+func (_q *ItemTemplateQuery) Clone() *ItemTemplateQuery {
+ if _q == nil {
+ return nil
+ }
+ return &ItemTemplateQuery{
+ config: _q.config,
+ ctx: _q.ctx.Clone(),
+ order: append([]itemtemplate.OrderOption{}, _q.order...),
+ inters: append([]Interceptor{}, _q.inters...),
+ predicates: append([]predicate.ItemTemplate{}, _q.predicates...),
+ withGroup: _q.withGroup.Clone(),
+ withFields: _q.withFields.Clone(),
+ withLocation: _q.withLocation.Clone(),
+ // clone intermediate query.
+ sql: _q.sql.Clone(),
+ path: _q.path,
+ }
+}
+
+// WithGroup tells the query-builder to eager-load the nodes that are connected to
+// the "group" edge. The optional arguments are used to configure the query builder of the edge.
+func (_q *ItemTemplateQuery) WithGroup(opts ...func(*GroupQuery)) *ItemTemplateQuery {
+ query := (&GroupClient{config: _q.config}).Query()
+ for _, opt := range opts {
+ opt(query)
+ }
+ _q.withGroup = query
+ return _q
+}
+
+// WithFields tells the query-builder to eager-load the nodes that are connected to
+// the "fields" edge. The optional arguments are used to configure the query builder of the edge.
+func (_q *ItemTemplateQuery) WithFields(opts ...func(*TemplateFieldQuery)) *ItemTemplateQuery {
+ query := (&TemplateFieldClient{config: _q.config}).Query()
+ for _, opt := range opts {
+ opt(query)
+ }
+ _q.withFields = query
+ return _q
+}
+
+// WithLocation tells the query-builder to eager-load the nodes that are connected to
+// the "location" edge. The optional arguments are used to configure the query builder of the edge.
+func (_q *ItemTemplateQuery) WithLocation(opts ...func(*LocationQuery)) *ItemTemplateQuery {
+ query := (&LocationClient{config: _q.config}).Query()
+ for _, opt := range opts {
+ opt(query)
+ }
+ _q.withLocation = query
+ return _q
+}
+
+// GroupBy is used to group vertices by one or more fields/columns.
+// It is often used with aggregate functions, like: count, max, mean, min, sum.
+//
+// Example:
+//
+// var v []struct {
+// CreatedAt time.Time `json:"created_at,omitempty"`
+// Count int `json:"count,omitempty"`
+// }
+//
+// client.ItemTemplate.Query().
+// GroupBy(itemtemplate.FieldCreatedAt).
+// Aggregate(ent.Count()).
+// Scan(ctx, &v)
+func (_q *ItemTemplateQuery) GroupBy(field string, fields ...string) *ItemTemplateGroupBy {
+ _q.ctx.Fields = append([]string{field}, fields...)
+ grbuild := &ItemTemplateGroupBy{build: _q}
+ grbuild.flds = &_q.ctx.Fields
+ grbuild.label = itemtemplate.Label
+ grbuild.scan = grbuild.Scan
+ return grbuild
+}
+
+// Select allows the selection one or more fields/columns for the given query,
+// instead of selecting all fields in the entity.
+//
+// Example:
+//
+// var v []struct {
+// CreatedAt time.Time `json:"created_at,omitempty"`
+// }
+//
+// client.ItemTemplate.Query().
+// Select(itemtemplate.FieldCreatedAt).
+// Scan(ctx, &v)
+func (_q *ItemTemplateQuery) Select(fields ...string) *ItemTemplateSelect {
+ _q.ctx.Fields = append(_q.ctx.Fields, fields...)
+ sbuild := &ItemTemplateSelect{ItemTemplateQuery: _q}
+ sbuild.label = itemtemplate.Label
+ sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
+ return sbuild
+}
+
+// Aggregate returns a ItemTemplateSelect configured with the given aggregations.
+func (_q *ItemTemplateQuery) Aggregate(fns ...AggregateFunc) *ItemTemplateSelect {
+ return _q.Select().Aggregate(fns...)
+}
+
+func (_q *ItemTemplateQuery) prepareQuery(ctx context.Context) error {
+ for _, inter := range _q.inters {
+ if inter == nil {
+ return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
+ }
+ if trv, ok := inter.(Traverser); ok {
+ if err := trv.Traverse(ctx, _q); err != nil {
+ return err
+ }
+ }
+ }
+ for _, f := range _q.ctx.Fields {
+ if !itemtemplate.ValidColumn(f) {
+ return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+ }
+ }
+ if _q.path != nil {
+ prev, err := _q.path(ctx)
+ if err != nil {
+ return err
+ }
+ _q.sql = prev
+ }
+ return nil
+}
+
+func (_q *ItemTemplateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ItemTemplate, error) {
+ var (
+ nodes = []*ItemTemplate{}
+ withFKs = _q.withFKs
+ _spec = _q.querySpec()
+ loadedTypes = [3]bool{
+ _q.withGroup != nil,
+ _q.withFields != nil,
+ _q.withLocation != nil,
+ }
+ )
+ if _q.withGroup != nil || _q.withLocation != nil {
+ withFKs = true
+ }
+ if withFKs {
+ _spec.Node.Columns = append(_spec.Node.Columns, itemtemplate.ForeignKeys...)
+ }
+ _spec.ScanValues = func(columns []string) ([]any, error) {
+ return (*ItemTemplate).scanValues(nil, columns)
+ }
+ _spec.Assign = func(columns []string, values []any) error {
+ node := &ItemTemplate{config: _q.config}
+ nodes = append(nodes, node)
+ node.Edges.loadedTypes = loadedTypes
+ return node.assignValues(columns, values)
+ }
+ for i := range hooks {
+ hooks[i](ctx, _spec)
+ }
+ if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
+ return nil, err
+ }
+ if len(nodes) == 0 {
+ return nodes, nil
+ }
+ if query := _q.withGroup; query != nil {
+ if err := _q.loadGroup(ctx, query, nodes, nil,
+ func(n *ItemTemplate, e *Group) { n.Edges.Group = e }); err != nil {
+ return nil, err
+ }
+ }
+ if query := _q.withFields; query != nil {
+ if err := _q.loadFields(ctx, query, nodes,
+ func(n *ItemTemplate) { n.Edges.Fields = []*TemplateField{} },
+ func(n *ItemTemplate, e *TemplateField) { n.Edges.Fields = append(n.Edges.Fields, e) }); err != nil {
+ return nil, err
+ }
+ }
+ if query := _q.withLocation; query != nil {
+ if err := _q.loadLocation(ctx, query, nodes, nil,
+ func(n *ItemTemplate, e *Location) { n.Edges.Location = e }); err != nil {
+ return nil, err
+ }
+ }
+ return nodes, nil
+}
+
+func (_q *ItemTemplateQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Group)) error {
+ ids := make([]uuid.UUID, 0, len(nodes))
+ nodeids := make(map[uuid.UUID][]*ItemTemplate)
+ for i := range nodes {
+ if nodes[i].group_item_templates == nil {
+ continue
+ }
+ fk := *nodes[i].group_item_templates
+ if _, ok := nodeids[fk]; !ok {
+ ids = append(ids, fk)
+ }
+ nodeids[fk] = append(nodeids[fk], nodes[i])
+ }
+ if len(ids) == 0 {
+ return nil
+ }
+ query.Where(group.IDIn(ids...))
+ neighbors, err := query.All(ctx)
+ if err != nil {
+ return err
+ }
+ for _, n := range neighbors {
+ nodes, ok := nodeids[n.ID]
+ if !ok {
+ return fmt.Errorf(`unexpected foreign-key "group_item_templates" returned %v`, n.ID)
+ }
+ for i := range nodes {
+ assign(nodes[i], n)
+ }
+ }
+ return nil
+}
+func (_q *ItemTemplateQuery) loadFields(ctx context.Context, query *TemplateFieldQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *TemplateField)) error {
+ fks := make([]driver.Value, 0, len(nodes))
+ nodeids := make(map[uuid.UUID]*ItemTemplate)
+ for i := range nodes {
+ fks = append(fks, nodes[i].ID)
+ nodeids[nodes[i].ID] = nodes[i]
+ if init != nil {
+ init(nodes[i])
+ }
+ }
+ query.withFKs = true
+ query.Where(predicate.TemplateField(func(s *sql.Selector) {
+ s.Where(sql.InValues(s.C(itemtemplate.FieldsColumn), fks...))
+ }))
+ neighbors, err := query.All(ctx)
+ if err != nil {
+ return err
+ }
+ for _, n := range neighbors {
+ fk := n.item_template_fields
+ if fk == nil {
+ return fmt.Errorf(`foreign-key "item_template_fields" is nil for node %v`, n.ID)
+ }
+ node, ok := nodeids[*fk]
+ if !ok {
+ return fmt.Errorf(`unexpected referenced foreign-key "item_template_fields" returned %v for node %v`, *fk, n.ID)
+ }
+ assign(node, n)
+ }
+ return nil
+}
+func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Location)) error {
+ ids := make([]uuid.UUID, 0, len(nodes))
+ nodeids := make(map[uuid.UUID][]*ItemTemplate)
+ for i := range nodes {
+ if nodes[i].item_template_location == nil {
+ continue
+ }
+ fk := *nodes[i].item_template_location
+ if _, ok := nodeids[fk]; !ok {
+ ids = append(ids, fk)
+ }
+ nodeids[fk] = append(nodeids[fk], nodes[i])
+ }
+ if len(ids) == 0 {
+ return nil
+ }
+ query.Where(location.IDIn(ids...))
+ neighbors, err := query.All(ctx)
+ if err != nil {
+ return err
+ }
+ for _, n := range neighbors {
+ nodes, ok := nodeids[n.ID]
+ if !ok {
+ return fmt.Errorf(`unexpected foreign-key "item_template_location" returned %v`, n.ID)
+ }
+ for i := range nodes {
+ assign(nodes[i], n)
+ }
+ }
+ return nil
+}
+
+func (_q *ItemTemplateQuery) sqlCount(ctx context.Context) (int, error) {
+ _spec := _q.querySpec()
+ _spec.Node.Columns = _q.ctx.Fields
+ if len(_q.ctx.Fields) > 0 {
+ _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
+ }
+ return sqlgraph.CountNodes(ctx, _q.driver, _spec)
+}
+
+func (_q *ItemTemplateQuery) querySpec() *sqlgraph.QuerySpec {
+ _spec := sqlgraph.NewQuerySpec(itemtemplate.Table, itemtemplate.Columns, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID))
+ _spec.From = _q.sql
+ if unique := _q.ctx.Unique; unique != nil {
+ _spec.Unique = *unique
+ } else if _q.path != nil {
+ _spec.Unique = true
+ }
+ if fields := _q.ctx.Fields; len(fields) > 0 {
+ _spec.Node.Columns = make([]string, 0, len(fields))
+ _spec.Node.Columns = append(_spec.Node.Columns, itemtemplate.FieldID)
+ for i := range fields {
+ if fields[i] != itemtemplate.FieldID {
+ _spec.Node.Columns = append(_spec.Node.Columns, fields[i])
+ }
+ }
+ }
+ if ps := _q.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ if limit := _q.ctx.Limit; limit != nil {
+ _spec.Limit = *limit
+ }
+ if offset := _q.ctx.Offset; offset != nil {
+ _spec.Offset = *offset
+ }
+ if ps := _q.order; len(ps) > 0 {
+ _spec.Order = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ return _spec
+}
+
+func (_q *ItemTemplateQuery) sqlQuery(ctx context.Context) *sql.Selector {
+ builder := sql.Dialect(_q.driver.Dialect())
+ t1 := builder.Table(itemtemplate.Table)
+ columns := _q.ctx.Fields
+ if len(columns) == 0 {
+ columns = itemtemplate.Columns
+ }
+ selector := builder.Select(t1.Columns(columns...)...).From(t1)
+ if _q.sql != nil {
+ selector = _q.sql
+ selector.Select(selector.Columns(columns...)...)
+ }
+ if _q.ctx.Unique != nil && *_q.ctx.Unique {
+ selector.Distinct()
+ }
+ for _, p := range _q.predicates {
+ p(selector)
+ }
+ for _, p := range _q.order {
+ p(selector)
+ }
+ if offset := _q.ctx.Offset; offset != nil {
+ // limit is mandatory for offset clause. We start
+ // with default value, and override it below if needed.
+ selector.Offset(*offset).Limit(math.MaxInt32)
+ }
+ if limit := _q.ctx.Limit; limit != nil {
+ selector.Limit(*limit)
+ }
+ return selector
+}
+
+// ItemTemplateGroupBy is the group-by builder for ItemTemplate entities.
+type ItemTemplateGroupBy struct {
+ selector
+ build *ItemTemplateQuery
+}
+
+// Aggregate adds the given aggregation functions to the group-by query.
+func (_g *ItemTemplateGroupBy) Aggregate(fns ...AggregateFunc) *ItemTemplateGroupBy {
+ _g.fns = append(_g.fns, fns...)
+ return _g
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (_g *ItemTemplateGroupBy) Scan(ctx context.Context, v any) error {
+ ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
+ if err := _g.build.prepareQuery(ctx); err != nil {
+ return err
+ }
+ return scanWithInterceptors[*ItemTemplateQuery, *ItemTemplateGroupBy](ctx, _g.build, _g, _g.build.inters, v)
+}
+
+func (_g *ItemTemplateGroupBy) sqlScan(ctx context.Context, root *ItemTemplateQuery, v any) error {
+ selector := root.sqlQuery(ctx).Select()
+ aggregation := make([]string, 0, len(_g.fns))
+ for _, fn := range _g.fns {
+ aggregation = append(aggregation, fn(selector))
+ }
+ if len(selector.SelectedColumns()) == 0 {
+ columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
+ for _, f := range *_g.flds {
+ columns = append(columns, selector.C(f))
+ }
+ columns = append(columns, aggregation...)
+ selector.Select(columns...)
+ }
+ selector.GroupBy(selector.Columns(*_g.flds...)...)
+ if err := selector.Err(); err != nil {
+ return err
+ }
+ rows := &sql.Rows{}
+ query, args := selector.Query()
+ if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
+ return err
+ }
+ defer rows.Close()
+ return sql.ScanSlice(rows, v)
+}
+
+// ItemTemplateSelect is the builder for selecting fields of ItemTemplate entities.
+type ItemTemplateSelect struct {
+ *ItemTemplateQuery
+ selector
+}
+
+// Aggregate adds the given aggregation functions to the selector query.
+func (_s *ItemTemplateSelect) Aggregate(fns ...AggregateFunc) *ItemTemplateSelect {
+ _s.fns = append(_s.fns, fns...)
+ return _s
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (_s *ItemTemplateSelect) Scan(ctx context.Context, v any) error {
+ ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
+ if err := _s.prepareQuery(ctx); err != nil {
+ return err
+ }
+ return scanWithInterceptors[*ItemTemplateQuery, *ItemTemplateSelect](ctx, _s.ItemTemplateQuery, _s, _s.inters, v)
+}
+
+func (_s *ItemTemplateSelect) sqlScan(ctx context.Context, root *ItemTemplateQuery, v any) error {
+ selector := root.sqlQuery(ctx)
+ aggregation := make([]string, 0, len(_s.fns))
+ for _, fn := range _s.fns {
+ aggregation = append(aggregation, fn(selector))
+ }
+ switch n := len(*_s.selector.flds); {
+ case n == 0 && len(aggregation) > 0:
+ selector.Select(aggregation...)
+ case n != 0 && len(aggregation) > 0:
+ selector.AppendSelect(aggregation...)
+ }
+ rows := &sql.Rows{}
+ query, args := selector.Query()
+ if err := _s.driver.Query(ctx, query, args, rows); err != nil {
+ return err
+ }
+ defer rows.Close()
+ return sql.ScanSlice(rows, v)
+}
diff --git a/backend/internal/data/ent/itemtemplate_update.go b/backend/internal/data/ent/itemtemplate_update.go
new file mode 100644
index 00000000..768505ba
--- /dev/null
+++ b/backend/internal/data/ent/itemtemplate_update.go
@@ -0,0 +1,1361 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "time"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/dialect/sql/sqljson"
+ "entgo.io/ent/schema/field"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
+)
+
+// ItemTemplateUpdate is the builder for updating ItemTemplate entities.
+type ItemTemplateUpdate struct {
+ config
+ hooks []Hook
+ mutation *ItemTemplateMutation
+}
+
+// Where appends a list predicates to the ItemTemplateUpdate builder.
+func (_u *ItemTemplateUpdate) Where(ps ...predicate.ItemTemplate) *ItemTemplateUpdate {
+ _u.mutation.Where(ps...)
+ return _u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (_u *ItemTemplateUpdate) SetUpdatedAt(v time.Time) *ItemTemplateUpdate {
+ _u.mutation.SetUpdatedAt(v)
+ return _u
+}
+
+// SetName sets the "name" field.
+func (_u *ItemTemplateUpdate) SetName(v string) *ItemTemplateUpdate {
+ _u.mutation.SetName(v)
+ return _u
+}
+
+// SetNillableName sets the "name" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableName(v *string) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetName(*v)
+ }
+ return _u
+}
+
+// SetDescription sets the "description" field.
+func (_u *ItemTemplateUpdate) SetDescription(v string) *ItemTemplateUpdate {
+ _u.mutation.SetDescription(v)
+ return _u
+}
+
+// SetNillableDescription sets the "description" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableDescription(v *string) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetDescription(*v)
+ }
+ return _u
+}
+
+// ClearDescription clears the value of the "description" field.
+func (_u *ItemTemplateUpdate) ClearDescription() *ItemTemplateUpdate {
+ _u.mutation.ClearDescription()
+ return _u
+}
+
+// SetNotes sets the "notes" field.
+func (_u *ItemTemplateUpdate) SetNotes(v string) *ItemTemplateUpdate {
+ _u.mutation.SetNotes(v)
+ return _u
+}
+
+// SetNillableNotes sets the "notes" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableNotes(v *string) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetNotes(*v)
+ }
+ return _u
+}
+
+// ClearNotes clears the value of the "notes" field.
+func (_u *ItemTemplateUpdate) ClearNotes() *ItemTemplateUpdate {
+ _u.mutation.ClearNotes()
+ return _u
+}
+
+// SetDefaultQuantity sets the "default_quantity" field.
+func (_u *ItemTemplateUpdate) SetDefaultQuantity(v int) *ItemTemplateUpdate {
+ _u.mutation.ResetDefaultQuantity()
+ _u.mutation.SetDefaultQuantity(v)
+ return _u
+}
+
+// SetNillableDefaultQuantity sets the "default_quantity" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableDefaultQuantity(v *int) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetDefaultQuantity(*v)
+ }
+ return _u
+}
+
+// AddDefaultQuantity adds value to the "default_quantity" field.
+func (_u *ItemTemplateUpdate) AddDefaultQuantity(v int) *ItemTemplateUpdate {
+ _u.mutation.AddDefaultQuantity(v)
+ return _u
+}
+
+// SetDefaultInsured sets the "default_insured" field.
+func (_u *ItemTemplateUpdate) SetDefaultInsured(v bool) *ItemTemplateUpdate {
+ _u.mutation.SetDefaultInsured(v)
+ return _u
+}
+
+// SetNillableDefaultInsured sets the "default_insured" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableDefaultInsured(v *bool) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetDefaultInsured(*v)
+ }
+ return _u
+}
+
+// SetDefaultName sets the "default_name" field.
+func (_u *ItemTemplateUpdate) SetDefaultName(v string) *ItemTemplateUpdate {
+ _u.mutation.SetDefaultName(v)
+ return _u
+}
+
+// SetNillableDefaultName sets the "default_name" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableDefaultName(v *string) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetDefaultName(*v)
+ }
+ return _u
+}
+
+// ClearDefaultName clears the value of the "default_name" field.
+func (_u *ItemTemplateUpdate) ClearDefaultName() *ItemTemplateUpdate {
+ _u.mutation.ClearDefaultName()
+ return _u
+}
+
+// SetDefaultDescription sets the "default_description" field.
+func (_u *ItemTemplateUpdate) SetDefaultDescription(v string) *ItemTemplateUpdate {
+ _u.mutation.SetDefaultDescription(v)
+ return _u
+}
+
+// SetNillableDefaultDescription sets the "default_description" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableDefaultDescription(v *string) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetDefaultDescription(*v)
+ }
+ return _u
+}
+
+// ClearDefaultDescription clears the value of the "default_description" field.
+func (_u *ItemTemplateUpdate) ClearDefaultDescription() *ItemTemplateUpdate {
+ _u.mutation.ClearDefaultDescription()
+ return _u
+}
+
+// SetDefaultManufacturer sets the "default_manufacturer" field.
+func (_u *ItemTemplateUpdate) SetDefaultManufacturer(v string) *ItemTemplateUpdate {
+ _u.mutation.SetDefaultManufacturer(v)
+ return _u
+}
+
+// SetNillableDefaultManufacturer sets the "default_manufacturer" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableDefaultManufacturer(v *string) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetDefaultManufacturer(*v)
+ }
+ return _u
+}
+
+// ClearDefaultManufacturer clears the value of the "default_manufacturer" field.
+func (_u *ItemTemplateUpdate) ClearDefaultManufacturer() *ItemTemplateUpdate {
+ _u.mutation.ClearDefaultManufacturer()
+ return _u
+}
+
+// SetDefaultModelNumber sets the "default_model_number" field.
+func (_u *ItemTemplateUpdate) SetDefaultModelNumber(v string) *ItemTemplateUpdate {
+ _u.mutation.SetDefaultModelNumber(v)
+ return _u
+}
+
+// SetNillableDefaultModelNumber sets the "default_model_number" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableDefaultModelNumber(v *string) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetDefaultModelNumber(*v)
+ }
+ return _u
+}
+
+// ClearDefaultModelNumber clears the value of the "default_model_number" field.
+func (_u *ItemTemplateUpdate) ClearDefaultModelNumber() *ItemTemplateUpdate {
+ _u.mutation.ClearDefaultModelNumber()
+ return _u
+}
+
+// SetDefaultLifetimeWarranty sets the "default_lifetime_warranty" field.
+func (_u *ItemTemplateUpdate) SetDefaultLifetimeWarranty(v bool) *ItemTemplateUpdate {
+ _u.mutation.SetDefaultLifetimeWarranty(v)
+ return _u
+}
+
+// SetNillableDefaultLifetimeWarranty sets the "default_lifetime_warranty" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableDefaultLifetimeWarranty(v *bool) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetDefaultLifetimeWarranty(*v)
+ }
+ return _u
+}
+
+// SetDefaultWarrantyDetails sets the "default_warranty_details" field.
+func (_u *ItemTemplateUpdate) SetDefaultWarrantyDetails(v string) *ItemTemplateUpdate {
+ _u.mutation.SetDefaultWarrantyDetails(v)
+ return _u
+}
+
+// SetNillableDefaultWarrantyDetails sets the "default_warranty_details" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableDefaultWarrantyDetails(v *string) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetDefaultWarrantyDetails(*v)
+ }
+ return _u
+}
+
+// ClearDefaultWarrantyDetails clears the value of the "default_warranty_details" field.
+func (_u *ItemTemplateUpdate) ClearDefaultWarrantyDetails() *ItemTemplateUpdate {
+ _u.mutation.ClearDefaultWarrantyDetails()
+ return _u
+}
+
+// SetIncludeWarrantyFields sets the "include_warranty_fields" field.
+func (_u *ItemTemplateUpdate) SetIncludeWarrantyFields(v bool) *ItemTemplateUpdate {
+ _u.mutation.SetIncludeWarrantyFields(v)
+ return _u
+}
+
+// SetNillableIncludeWarrantyFields sets the "include_warranty_fields" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableIncludeWarrantyFields(v *bool) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetIncludeWarrantyFields(*v)
+ }
+ return _u
+}
+
+// SetIncludePurchaseFields sets the "include_purchase_fields" field.
+func (_u *ItemTemplateUpdate) SetIncludePurchaseFields(v bool) *ItemTemplateUpdate {
+ _u.mutation.SetIncludePurchaseFields(v)
+ return _u
+}
+
+// SetNillableIncludePurchaseFields sets the "include_purchase_fields" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableIncludePurchaseFields(v *bool) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetIncludePurchaseFields(*v)
+ }
+ return _u
+}
+
+// SetIncludeSoldFields sets the "include_sold_fields" field.
+func (_u *ItemTemplateUpdate) SetIncludeSoldFields(v bool) *ItemTemplateUpdate {
+ _u.mutation.SetIncludeSoldFields(v)
+ return _u
+}
+
+// SetNillableIncludeSoldFields sets the "include_sold_fields" field if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableIncludeSoldFields(v *bool) *ItemTemplateUpdate {
+ if v != nil {
+ _u.SetIncludeSoldFields(*v)
+ }
+ return _u
+}
+
+// SetDefaultLabelIds sets the "default_label_ids" field.
+func (_u *ItemTemplateUpdate) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdate {
+ _u.mutation.SetDefaultLabelIds(v)
+ return _u
+}
+
+// AppendDefaultLabelIds appends value to the "default_label_ids" field.
+func (_u *ItemTemplateUpdate) AppendDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdate {
+ _u.mutation.AppendDefaultLabelIds(v)
+ return _u
+}
+
+// ClearDefaultLabelIds clears the value of the "default_label_ids" field.
+func (_u *ItemTemplateUpdate) ClearDefaultLabelIds() *ItemTemplateUpdate {
+ _u.mutation.ClearDefaultLabelIds()
+ return _u
+}
+
+// SetGroupID sets the "group" edge to the Group entity by ID.
+func (_u *ItemTemplateUpdate) SetGroupID(id uuid.UUID) *ItemTemplateUpdate {
+ _u.mutation.SetGroupID(id)
+ return _u
+}
+
+// SetGroup sets the "group" edge to the Group entity.
+func (_u *ItemTemplateUpdate) SetGroup(v *Group) *ItemTemplateUpdate {
+ return _u.SetGroupID(v.ID)
+}
+
+// AddFieldIDs adds the "fields" edge to the TemplateField entity by IDs.
+func (_u *ItemTemplateUpdate) AddFieldIDs(ids ...uuid.UUID) *ItemTemplateUpdate {
+ _u.mutation.AddFieldIDs(ids...)
+ return _u
+}
+
+// AddFields adds the "fields" edges to the TemplateField entity.
+func (_u *ItemTemplateUpdate) AddFields(v ...*TemplateField) *ItemTemplateUpdate {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _u.AddFieldIDs(ids...)
+}
+
+// SetLocationID sets the "location" edge to the Location entity by ID.
+func (_u *ItemTemplateUpdate) SetLocationID(id uuid.UUID) *ItemTemplateUpdate {
+ _u.mutation.SetLocationID(id)
+ return _u
+}
+
+// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
+func (_u *ItemTemplateUpdate) SetNillableLocationID(id *uuid.UUID) *ItemTemplateUpdate {
+ if id != nil {
+ _u = _u.SetLocationID(*id)
+ }
+ return _u
+}
+
+// SetLocation sets the "location" edge to the Location entity.
+func (_u *ItemTemplateUpdate) SetLocation(v *Location) *ItemTemplateUpdate {
+ return _u.SetLocationID(v.ID)
+}
+
+// Mutation returns the ItemTemplateMutation object of the builder.
+func (_u *ItemTemplateUpdate) Mutation() *ItemTemplateMutation {
+ return _u.mutation
+}
+
+// ClearGroup clears the "group" edge to the Group entity.
+func (_u *ItemTemplateUpdate) ClearGroup() *ItemTemplateUpdate {
+ _u.mutation.ClearGroup()
+ return _u
+}
+
+// ClearFields clears all "fields" edges to the TemplateField entity.
+func (_u *ItemTemplateUpdate) ClearFields() *ItemTemplateUpdate {
+ _u.mutation.ClearFields()
+ return _u
+}
+
+// RemoveFieldIDs removes the "fields" edge to TemplateField entities by IDs.
+func (_u *ItemTemplateUpdate) RemoveFieldIDs(ids ...uuid.UUID) *ItemTemplateUpdate {
+ _u.mutation.RemoveFieldIDs(ids...)
+ return _u
+}
+
+// RemoveFields removes "fields" edges to TemplateField entities.
+func (_u *ItemTemplateUpdate) RemoveFields(v ...*TemplateField) *ItemTemplateUpdate {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _u.RemoveFieldIDs(ids...)
+}
+
+// ClearLocation clears the "location" edge to the Location entity.
+func (_u *ItemTemplateUpdate) ClearLocation() *ItemTemplateUpdate {
+ _u.mutation.ClearLocation()
+ return _u
+}
+
+// Save executes the query and returns the number of nodes affected by the update operation.
+func (_u *ItemTemplateUpdate) Save(ctx context.Context) (int, error) {
+ _u.defaults()
+ return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (_u *ItemTemplateUpdate) SaveX(ctx context.Context) int {
+ affected, err := _u.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return affected
+}
+
+// Exec executes the query.
+func (_u *ItemTemplateUpdate) Exec(ctx context.Context) error {
+ _, err := _u.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_u *ItemTemplateUpdate) ExecX(ctx context.Context) {
+ if err := _u.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// defaults sets the default values of the builder before save.
+func (_u *ItemTemplateUpdate) defaults() {
+ if _, ok := _u.mutation.UpdatedAt(); !ok {
+ v := itemtemplate.UpdateDefaultUpdatedAt()
+ _u.mutation.SetUpdatedAt(v)
+ }
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (_u *ItemTemplateUpdate) check() error {
+ if v, ok := _u.mutation.Name(); ok {
+ if err := itemtemplate.NameValidator(v); err != nil {
+ return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.name": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.Description(); ok {
+ if err := itemtemplate.DescriptionValidator(v); err != nil {
+ return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.description": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.Notes(); ok {
+ if err := itemtemplate.NotesValidator(v); err != nil {
+ return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.notes": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultName(); ok {
+ if err := itemtemplate.DefaultNameValidator(v); err != nil {
+ return &ValidationError{Name: "default_name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_name": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultDescription(); ok {
+ if err := itemtemplate.DefaultDescriptionValidator(v); err != nil {
+ return &ValidationError{Name: "default_description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_description": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultManufacturer(); ok {
+ if err := itemtemplate.DefaultManufacturerValidator(v); err != nil {
+ return &ValidationError{Name: "default_manufacturer", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_manufacturer": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultModelNumber(); ok {
+ if err := itemtemplate.DefaultModelNumberValidator(v); err != nil {
+ return &ValidationError{Name: "default_model_number", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_model_number": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultWarrantyDetails(); ok {
+ if err := itemtemplate.DefaultWarrantyDetailsValidator(v); err != nil {
+ return &ValidationError{Name: "default_warranty_details", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_warranty_details": %w`, err)}
+ }
+ }
+ if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
+ return errors.New(`ent: clearing a required unique edge "ItemTemplate.group"`)
+ }
+ return nil
+}
+
+func (_u *ItemTemplateUpdate) sqlSave(ctx context.Context) (_node int, err error) {
+ if err := _u.check(); err != nil {
+ return _node, err
+ }
+ _spec := sqlgraph.NewUpdateSpec(itemtemplate.Table, itemtemplate.Columns, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID))
+ if ps := _u.mutation.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ if value, ok := _u.mutation.UpdatedAt(); ok {
+ _spec.SetField(itemtemplate.FieldUpdatedAt, field.TypeTime, value)
+ }
+ if value, ok := _u.mutation.Name(); ok {
+ _spec.SetField(itemtemplate.FieldName, field.TypeString, value)
+ }
+ if value, ok := _u.mutation.Description(); ok {
+ _spec.SetField(itemtemplate.FieldDescription, field.TypeString, value)
+ }
+ if _u.mutation.DescriptionCleared() {
+ _spec.ClearField(itemtemplate.FieldDescription, field.TypeString)
+ }
+ if value, ok := _u.mutation.Notes(); ok {
+ _spec.SetField(itemtemplate.FieldNotes, field.TypeString, value)
+ }
+ if _u.mutation.NotesCleared() {
+ _spec.ClearField(itemtemplate.FieldNotes, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultQuantity(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value)
+ }
+ if value, ok := _u.mutation.AddedDefaultQuantity(); ok {
+ _spec.AddField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value)
+ }
+ if value, ok := _u.mutation.DefaultInsured(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultInsured, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.DefaultName(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultName, field.TypeString, value)
+ }
+ if _u.mutation.DefaultNameCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultName, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultDescription(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultDescription, field.TypeString, value)
+ }
+ if _u.mutation.DefaultDescriptionCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultDescription, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultManufacturer(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultManufacturer, field.TypeString, value)
+ }
+ if _u.mutation.DefaultManufacturerCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultManufacturer, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultModelNumber(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultModelNumber, field.TypeString, value)
+ }
+ if _u.mutation.DefaultModelNumberCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultModelNumber, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultLifetimeWarranty(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultLifetimeWarranty, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.DefaultWarrantyDetails(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString, value)
+ }
+ if _u.mutation.DefaultWarrantyDetailsCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString)
+ }
+ if value, ok := _u.mutation.IncludeWarrantyFields(); ok {
+ _spec.SetField(itemtemplate.FieldIncludeWarrantyFields, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.IncludePurchaseFields(); ok {
+ _spec.SetField(itemtemplate.FieldIncludePurchaseFields, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.IncludeSoldFields(); ok {
+ _spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.DefaultLabelIds(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value)
+ }
+ if value, ok := _u.mutation.AppendedDefaultLabelIds(); ok {
+ _spec.AddModifier(func(u *sql.UpdateBuilder) {
+ sqljson.Append(u, itemtemplate.FieldDefaultLabelIds, value)
+ })
+ }
+ if _u.mutation.DefaultLabelIdsCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON)
+ }
+ if _u.mutation.GroupCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: itemtemplate.GroupTable,
+ Columns: []string{itemtemplate.GroupColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: itemtemplate.GroupTable,
+ Columns: []string{itemtemplate.GroupColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
+ if _u.mutation.FieldsCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: itemtemplate.FieldsTable,
+ Columns: []string{itemtemplate.FieldsColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.mutation.FieldsCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: itemtemplate.FieldsTable,
+ Columns: []string{itemtemplate.FieldsColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.FieldsIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: itemtemplate.FieldsTable,
+ Columns: []string{itemtemplate.FieldsColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
+ if _u.mutation.LocationCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: false,
+ Table: itemtemplate.LocationTable,
+ Columns: []string{itemtemplate.LocationColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.LocationIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: false,
+ Table: itemtemplate.LocationTable,
+ Columns: []string{itemtemplate.LocationColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
+ if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
+ if _, ok := err.(*sqlgraph.NotFoundError); ok {
+ err = &NotFoundError{itemtemplate.Label}
+ } else if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ return 0, err
+ }
+ _u.mutation.done = true
+ return _node, nil
+}
+
+// ItemTemplateUpdateOne is the builder for updating a single ItemTemplate entity.
+type ItemTemplateUpdateOne struct {
+ config
+ fields []string
+ hooks []Hook
+ mutation *ItemTemplateMutation
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (_u *ItemTemplateUpdateOne) SetUpdatedAt(v time.Time) *ItemTemplateUpdateOne {
+ _u.mutation.SetUpdatedAt(v)
+ return _u
+}
+
+// SetName sets the "name" field.
+func (_u *ItemTemplateUpdateOne) SetName(v string) *ItemTemplateUpdateOne {
+ _u.mutation.SetName(v)
+ return _u
+}
+
+// SetNillableName sets the "name" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableName(v *string) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetName(*v)
+ }
+ return _u
+}
+
+// SetDescription sets the "description" field.
+func (_u *ItemTemplateUpdateOne) SetDescription(v string) *ItemTemplateUpdateOne {
+ _u.mutation.SetDescription(v)
+ return _u
+}
+
+// SetNillableDescription sets the "description" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableDescription(v *string) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetDescription(*v)
+ }
+ return _u
+}
+
+// ClearDescription clears the value of the "description" field.
+func (_u *ItemTemplateUpdateOne) ClearDescription() *ItemTemplateUpdateOne {
+ _u.mutation.ClearDescription()
+ return _u
+}
+
+// SetNotes sets the "notes" field.
+func (_u *ItemTemplateUpdateOne) SetNotes(v string) *ItemTemplateUpdateOne {
+ _u.mutation.SetNotes(v)
+ return _u
+}
+
+// SetNillableNotes sets the "notes" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableNotes(v *string) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetNotes(*v)
+ }
+ return _u
+}
+
+// ClearNotes clears the value of the "notes" field.
+func (_u *ItemTemplateUpdateOne) ClearNotes() *ItemTemplateUpdateOne {
+ _u.mutation.ClearNotes()
+ return _u
+}
+
+// SetDefaultQuantity sets the "default_quantity" field.
+func (_u *ItemTemplateUpdateOne) SetDefaultQuantity(v int) *ItemTemplateUpdateOne {
+ _u.mutation.ResetDefaultQuantity()
+ _u.mutation.SetDefaultQuantity(v)
+ return _u
+}
+
+// SetNillableDefaultQuantity sets the "default_quantity" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableDefaultQuantity(v *int) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetDefaultQuantity(*v)
+ }
+ return _u
+}
+
+// AddDefaultQuantity adds value to the "default_quantity" field.
+func (_u *ItemTemplateUpdateOne) AddDefaultQuantity(v int) *ItemTemplateUpdateOne {
+ _u.mutation.AddDefaultQuantity(v)
+ return _u
+}
+
+// SetDefaultInsured sets the "default_insured" field.
+func (_u *ItemTemplateUpdateOne) SetDefaultInsured(v bool) *ItemTemplateUpdateOne {
+ _u.mutation.SetDefaultInsured(v)
+ return _u
+}
+
+// SetNillableDefaultInsured sets the "default_insured" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableDefaultInsured(v *bool) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetDefaultInsured(*v)
+ }
+ return _u
+}
+
+// SetDefaultName sets the "default_name" field.
+func (_u *ItemTemplateUpdateOne) SetDefaultName(v string) *ItemTemplateUpdateOne {
+ _u.mutation.SetDefaultName(v)
+ return _u
+}
+
+// SetNillableDefaultName sets the "default_name" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableDefaultName(v *string) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetDefaultName(*v)
+ }
+ return _u
+}
+
+// ClearDefaultName clears the value of the "default_name" field.
+func (_u *ItemTemplateUpdateOne) ClearDefaultName() *ItemTemplateUpdateOne {
+ _u.mutation.ClearDefaultName()
+ return _u
+}
+
+// SetDefaultDescription sets the "default_description" field.
+func (_u *ItemTemplateUpdateOne) SetDefaultDescription(v string) *ItemTemplateUpdateOne {
+ _u.mutation.SetDefaultDescription(v)
+ return _u
+}
+
+// SetNillableDefaultDescription sets the "default_description" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableDefaultDescription(v *string) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetDefaultDescription(*v)
+ }
+ return _u
+}
+
+// ClearDefaultDescription clears the value of the "default_description" field.
+func (_u *ItemTemplateUpdateOne) ClearDefaultDescription() *ItemTemplateUpdateOne {
+ _u.mutation.ClearDefaultDescription()
+ return _u
+}
+
+// SetDefaultManufacturer sets the "default_manufacturer" field.
+func (_u *ItemTemplateUpdateOne) SetDefaultManufacturer(v string) *ItemTemplateUpdateOne {
+ _u.mutation.SetDefaultManufacturer(v)
+ return _u
+}
+
+// SetNillableDefaultManufacturer sets the "default_manufacturer" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableDefaultManufacturer(v *string) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetDefaultManufacturer(*v)
+ }
+ return _u
+}
+
+// ClearDefaultManufacturer clears the value of the "default_manufacturer" field.
+func (_u *ItemTemplateUpdateOne) ClearDefaultManufacturer() *ItemTemplateUpdateOne {
+ _u.mutation.ClearDefaultManufacturer()
+ return _u
+}
+
+// SetDefaultModelNumber sets the "default_model_number" field.
+func (_u *ItemTemplateUpdateOne) SetDefaultModelNumber(v string) *ItemTemplateUpdateOne {
+ _u.mutation.SetDefaultModelNumber(v)
+ return _u
+}
+
+// SetNillableDefaultModelNumber sets the "default_model_number" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableDefaultModelNumber(v *string) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetDefaultModelNumber(*v)
+ }
+ return _u
+}
+
+// ClearDefaultModelNumber clears the value of the "default_model_number" field.
+func (_u *ItemTemplateUpdateOne) ClearDefaultModelNumber() *ItemTemplateUpdateOne {
+ _u.mutation.ClearDefaultModelNumber()
+ return _u
+}
+
+// SetDefaultLifetimeWarranty sets the "default_lifetime_warranty" field.
+func (_u *ItemTemplateUpdateOne) SetDefaultLifetimeWarranty(v bool) *ItemTemplateUpdateOne {
+ _u.mutation.SetDefaultLifetimeWarranty(v)
+ return _u
+}
+
+// SetNillableDefaultLifetimeWarranty sets the "default_lifetime_warranty" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableDefaultLifetimeWarranty(v *bool) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetDefaultLifetimeWarranty(*v)
+ }
+ return _u
+}
+
+// SetDefaultWarrantyDetails sets the "default_warranty_details" field.
+func (_u *ItemTemplateUpdateOne) SetDefaultWarrantyDetails(v string) *ItemTemplateUpdateOne {
+ _u.mutation.SetDefaultWarrantyDetails(v)
+ return _u
+}
+
+// SetNillableDefaultWarrantyDetails sets the "default_warranty_details" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableDefaultWarrantyDetails(v *string) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetDefaultWarrantyDetails(*v)
+ }
+ return _u
+}
+
+// ClearDefaultWarrantyDetails clears the value of the "default_warranty_details" field.
+func (_u *ItemTemplateUpdateOne) ClearDefaultWarrantyDetails() *ItemTemplateUpdateOne {
+ _u.mutation.ClearDefaultWarrantyDetails()
+ return _u
+}
+
+// SetIncludeWarrantyFields sets the "include_warranty_fields" field.
+func (_u *ItemTemplateUpdateOne) SetIncludeWarrantyFields(v bool) *ItemTemplateUpdateOne {
+ _u.mutation.SetIncludeWarrantyFields(v)
+ return _u
+}
+
+// SetNillableIncludeWarrantyFields sets the "include_warranty_fields" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableIncludeWarrantyFields(v *bool) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetIncludeWarrantyFields(*v)
+ }
+ return _u
+}
+
+// SetIncludePurchaseFields sets the "include_purchase_fields" field.
+func (_u *ItemTemplateUpdateOne) SetIncludePurchaseFields(v bool) *ItemTemplateUpdateOne {
+ _u.mutation.SetIncludePurchaseFields(v)
+ return _u
+}
+
+// SetNillableIncludePurchaseFields sets the "include_purchase_fields" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableIncludePurchaseFields(v *bool) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetIncludePurchaseFields(*v)
+ }
+ return _u
+}
+
+// SetIncludeSoldFields sets the "include_sold_fields" field.
+func (_u *ItemTemplateUpdateOne) SetIncludeSoldFields(v bool) *ItemTemplateUpdateOne {
+ _u.mutation.SetIncludeSoldFields(v)
+ return _u
+}
+
+// SetNillableIncludeSoldFields sets the "include_sold_fields" field if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableIncludeSoldFields(v *bool) *ItemTemplateUpdateOne {
+ if v != nil {
+ _u.SetIncludeSoldFields(*v)
+ }
+ return _u
+}
+
+// SetDefaultLabelIds sets the "default_label_ids" field.
+func (_u *ItemTemplateUpdateOne) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdateOne {
+ _u.mutation.SetDefaultLabelIds(v)
+ return _u
+}
+
+// AppendDefaultLabelIds appends value to the "default_label_ids" field.
+func (_u *ItemTemplateUpdateOne) AppendDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdateOne {
+ _u.mutation.AppendDefaultLabelIds(v)
+ return _u
+}
+
+// ClearDefaultLabelIds clears the value of the "default_label_ids" field.
+func (_u *ItemTemplateUpdateOne) ClearDefaultLabelIds() *ItemTemplateUpdateOne {
+ _u.mutation.ClearDefaultLabelIds()
+ return _u
+}
+
+// SetGroupID sets the "group" edge to the Group entity by ID.
+func (_u *ItemTemplateUpdateOne) SetGroupID(id uuid.UUID) *ItemTemplateUpdateOne {
+ _u.mutation.SetGroupID(id)
+ return _u
+}
+
+// SetGroup sets the "group" edge to the Group entity.
+func (_u *ItemTemplateUpdateOne) SetGroup(v *Group) *ItemTemplateUpdateOne {
+ return _u.SetGroupID(v.ID)
+}
+
+// AddFieldIDs adds the "fields" edge to the TemplateField entity by IDs.
+func (_u *ItemTemplateUpdateOne) AddFieldIDs(ids ...uuid.UUID) *ItemTemplateUpdateOne {
+ _u.mutation.AddFieldIDs(ids...)
+ return _u
+}
+
+// AddFields adds the "fields" edges to the TemplateField entity.
+func (_u *ItemTemplateUpdateOne) AddFields(v ...*TemplateField) *ItemTemplateUpdateOne {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _u.AddFieldIDs(ids...)
+}
+
+// SetLocationID sets the "location" edge to the Location entity by ID.
+func (_u *ItemTemplateUpdateOne) SetLocationID(id uuid.UUID) *ItemTemplateUpdateOne {
+ _u.mutation.SetLocationID(id)
+ return _u
+}
+
+// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
+func (_u *ItemTemplateUpdateOne) SetNillableLocationID(id *uuid.UUID) *ItemTemplateUpdateOne {
+ if id != nil {
+ _u = _u.SetLocationID(*id)
+ }
+ return _u
+}
+
+// SetLocation sets the "location" edge to the Location entity.
+func (_u *ItemTemplateUpdateOne) SetLocation(v *Location) *ItemTemplateUpdateOne {
+ return _u.SetLocationID(v.ID)
+}
+
+// Mutation returns the ItemTemplateMutation object of the builder.
+func (_u *ItemTemplateUpdateOne) Mutation() *ItemTemplateMutation {
+ return _u.mutation
+}
+
+// ClearGroup clears the "group" edge to the Group entity.
+func (_u *ItemTemplateUpdateOne) ClearGroup() *ItemTemplateUpdateOne {
+ _u.mutation.ClearGroup()
+ return _u
+}
+
+// ClearFields clears all "fields" edges to the TemplateField entity.
+func (_u *ItemTemplateUpdateOne) ClearFields() *ItemTemplateUpdateOne {
+ _u.mutation.ClearFields()
+ return _u
+}
+
+// RemoveFieldIDs removes the "fields" edge to TemplateField entities by IDs.
+func (_u *ItemTemplateUpdateOne) RemoveFieldIDs(ids ...uuid.UUID) *ItemTemplateUpdateOne {
+ _u.mutation.RemoveFieldIDs(ids...)
+ return _u
+}
+
+// RemoveFields removes "fields" edges to TemplateField entities.
+func (_u *ItemTemplateUpdateOne) RemoveFields(v ...*TemplateField) *ItemTemplateUpdateOne {
+ ids := make([]uuid.UUID, len(v))
+ for i := range v {
+ ids[i] = v[i].ID
+ }
+ return _u.RemoveFieldIDs(ids...)
+}
+
+// ClearLocation clears the "location" edge to the Location entity.
+func (_u *ItemTemplateUpdateOne) ClearLocation() *ItemTemplateUpdateOne {
+ _u.mutation.ClearLocation()
+ return _u
+}
+
+// Where appends a list predicates to the ItemTemplateUpdate builder.
+func (_u *ItemTemplateUpdateOne) Where(ps ...predicate.ItemTemplate) *ItemTemplateUpdateOne {
+ _u.mutation.Where(ps...)
+ return _u
+}
+
+// Select allows selecting one or more fields (columns) of the returned entity.
+// The default is selecting all fields defined in the entity schema.
+func (_u *ItemTemplateUpdateOne) Select(field string, fields ...string) *ItemTemplateUpdateOne {
+ _u.fields = append([]string{field}, fields...)
+ return _u
+}
+
+// Save executes the query and returns the updated ItemTemplate entity.
+func (_u *ItemTemplateUpdateOne) Save(ctx context.Context) (*ItemTemplate, error) {
+ _u.defaults()
+ return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (_u *ItemTemplateUpdateOne) SaveX(ctx context.Context) *ItemTemplate {
+ node, err := _u.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return node
+}
+
+// Exec executes the query on the entity.
+func (_u *ItemTemplateUpdateOne) Exec(ctx context.Context) error {
+ _, err := _u.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_u *ItemTemplateUpdateOne) ExecX(ctx context.Context) {
+ if err := _u.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// defaults sets the default values of the builder before save.
+func (_u *ItemTemplateUpdateOne) defaults() {
+ if _, ok := _u.mutation.UpdatedAt(); !ok {
+ v := itemtemplate.UpdateDefaultUpdatedAt()
+ _u.mutation.SetUpdatedAt(v)
+ }
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (_u *ItemTemplateUpdateOne) check() error {
+ if v, ok := _u.mutation.Name(); ok {
+ if err := itemtemplate.NameValidator(v); err != nil {
+ return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.name": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.Description(); ok {
+ if err := itemtemplate.DescriptionValidator(v); err != nil {
+ return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.description": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.Notes(); ok {
+ if err := itemtemplate.NotesValidator(v); err != nil {
+ return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.notes": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultName(); ok {
+ if err := itemtemplate.DefaultNameValidator(v); err != nil {
+ return &ValidationError{Name: "default_name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_name": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultDescription(); ok {
+ if err := itemtemplate.DefaultDescriptionValidator(v); err != nil {
+ return &ValidationError{Name: "default_description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_description": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultManufacturer(); ok {
+ if err := itemtemplate.DefaultManufacturerValidator(v); err != nil {
+ return &ValidationError{Name: "default_manufacturer", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_manufacturer": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultModelNumber(); ok {
+ if err := itemtemplate.DefaultModelNumberValidator(v); err != nil {
+ return &ValidationError{Name: "default_model_number", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_model_number": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.DefaultWarrantyDetails(); ok {
+ if err := itemtemplate.DefaultWarrantyDetailsValidator(v); err != nil {
+ return &ValidationError{Name: "default_warranty_details", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_warranty_details": %w`, err)}
+ }
+ }
+ if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
+ return errors.New(`ent: clearing a required unique edge "ItemTemplate.group"`)
+ }
+ return nil
+}
+
+func (_u *ItemTemplateUpdateOne) sqlSave(ctx context.Context) (_node *ItemTemplate, err error) {
+ if err := _u.check(); err != nil {
+ return _node, err
+ }
+ _spec := sqlgraph.NewUpdateSpec(itemtemplate.Table, itemtemplate.Columns, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID))
+ id, ok := _u.mutation.ID()
+ if !ok {
+ return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ItemTemplate.id" for update`)}
+ }
+ _spec.Node.ID.Value = id
+ if fields := _u.fields; len(fields) > 0 {
+ _spec.Node.Columns = make([]string, 0, len(fields))
+ _spec.Node.Columns = append(_spec.Node.Columns, itemtemplate.FieldID)
+ for _, f := range fields {
+ if !itemtemplate.ValidColumn(f) {
+ return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+ }
+ if f != itemtemplate.FieldID {
+ _spec.Node.Columns = append(_spec.Node.Columns, f)
+ }
+ }
+ }
+ if ps := _u.mutation.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ if value, ok := _u.mutation.UpdatedAt(); ok {
+ _spec.SetField(itemtemplate.FieldUpdatedAt, field.TypeTime, value)
+ }
+ if value, ok := _u.mutation.Name(); ok {
+ _spec.SetField(itemtemplate.FieldName, field.TypeString, value)
+ }
+ if value, ok := _u.mutation.Description(); ok {
+ _spec.SetField(itemtemplate.FieldDescription, field.TypeString, value)
+ }
+ if _u.mutation.DescriptionCleared() {
+ _spec.ClearField(itemtemplate.FieldDescription, field.TypeString)
+ }
+ if value, ok := _u.mutation.Notes(); ok {
+ _spec.SetField(itemtemplate.FieldNotes, field.TypeString, value)
+ }
+ if _u.mutation.NotesCleared() {
+ _spec.ClearField(itemtemplate.FieldNotes, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultQuantity(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value)
+ }
+ if value, ok := _u.mutation.AddedDefaultQuantity(); ok {
+ _spec.AddField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value)
+ }
+ if value, ok := _u.mutation.DefaultInsured(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultInsured, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.DefaultName(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultName, field.TypeString, value)
+ }
+ if _u.mutation.DefaultNameCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultName, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultDescription(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultDescription, field.TypeString, value)
+ }
+ if _u.mutation.DefaultDescriptionCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultDescription, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultManufacturer(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultManufacturer, field.TypeString, value)
+ }
+ if _u.mutation.DefaultManufacturerCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultManufacturer, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultModelNumber(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultModelNumber, field.TypeString, value)
+ }
+ if _u.mutation.DefaultModelNumberCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultModelNumber, field.TypeString)
+ }
+ if value, ok := _u.mutation.DefaultLifetimeWarranty(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultLifetimeWarranty, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.DefaultWarrantyDetails(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString, value)
+ }
+ if _u.mutation.DefaultWarrantyDetailsCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString)
+ }
+ if value, ok := _u.mutation.IncludeWarrantyFields(); ok {
+ _spec.SetField(itemtemplate.FieldIncludeWarrantyFields, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.IncludePurchaseFields(); ok {
+ _spec.SetField(itemtemplate.FieldIncludePurchaseFields, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.IncludeSoldFields(); ok {
+ _spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value)
+ }
+ if value, ok := _u.mutation.DefaultLabelIds(); ok {
+ _spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value)
+ }
+ if value, ok := _u.mutation.AppendedDefaultLabelIds(); ok {
+ _spec.AddModifier(func(u *sql.UpdateBuilder) {
+ sqljson.Append(u, itemtemplate.FieldDefaultLabelIds, value)
+ })
+ }
+ if _u.mutation.DefaultLabelIdsCleared() {
+ _spec.ClearField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON)
+ }
+ if _u.mutation.GroupCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: itemtemplate.GroupTable,
+ Columns: []string{itemtemplate.GroupColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: itemtemplate.GroupTable,
+ Columns: []string{itemtemplate.GroupColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
+ if _u.mutation.FieldsCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: itemtemplate.FieldsTable,
+ Columns: []string{itemtemplate.FieldsColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.mutation.FieldsCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: itemtemplate.FieldsTable,
+ Columns: []string{itemtemplate.FieldsColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.FieldsIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.O2M,
+ Inverse: false,
+ Table: itemtemplate.FieldsTable,
+ Columns: []string{itemtemplate.FieldsColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
+ if _u.mutation.LocationCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: false,
+ Table: itemtemplate.LocationTable,
+ Columns: []string{itemtemplate.LocationColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.LocationIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: false,
+ Table: itemtemplate.LocationTable,
+ Columns: []string{itemtemplate.LocationColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
+ _node = &ItemTemplate{config: _u.config}
+ _spec.Assign = _node.assignValues
+ _spec.ScanValues = _node.scanValues
+ if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
+ if _, ok := err.(*sqlgraph.NotFoundError); ok {
+ err = &NotFoundError{itemtemplate.Label}
+ } else if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ return nil, err
+ }
+ _u.mutation.done = true
+ return _node, nil
+}
diff --git a/backend/internal/data/ent/migrate/schema.go b/backend/internal/data/ent/migrate/schema.go
index 6669df41..ef6161d8 100644
--- a/backend/internal/data/ent/migrate/schema.go
+++ b/backend/internal/data/ent/migrate/schema.go
@@ -246,6 +246,56 @@ var (
},
},
}
+ // ItemTemplatesColumns holds the columns for the "item_templates" table.
+ ItemTemplatesColumns = []*schema.Column{
+ {Name: "id", Type: field.TypeUUID},
+ {Name: "created_at", Type: field.TypeTime},
+ {Name: "updated_at", Type: field.TypeTime},
+ {Name: "name", Type: field.TypeString, Size: 255},
+ {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
+ {Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000},
+ {Name: "default_quantity", Type: field.TypeInt, Default: 1},
+ {Name: "default_insured", Type: field.TypeBool, Default: false},
+ {Name: "default_name", Type: field.TypeString, Nullable: true, Size: 255},
+ {Name: "default_description", Type: field.TypeString, Nullable: true, Size: 1000},
+ {Name: "default_manufacturer", Type: field.TypeString, Nullable: true, Size: 255},
+ {Name: "default_model_number", Type: field.TypeString, Nullable: true, Size: 255},
+ {Name: "default_lifetime_warranty", Type: field.TypeBool, Default: false},
+ {Name: "default_warranty_details", Type: field.TypeString, Nullable: true, Size: 1000},
+ {Name: "include_warranty_fields", Type: field.TypeBool, Default: false},
+ {Name: "include_purchase_fields", Type: field.TypeBool, Default: false},
+ {Name: "include_sold_fields", Type: field.TypeBool, Default: false},
+ {Name: "default_label_ids", Type: field.TypeJSON, Nullable: true},
+ {Name: "group_item_templates", Type: field.TypeUUID},
+ {Name: "item_template_location", Type: field.TypeUUID, Nullable: true},
+ }
+ // ItemTemplatesTable holds the schema information for the "item_templates" table.
+ ItemTemplatesTable = &schema.Table{
+ Name: "item_templates",
+ Columns: ItemTemplatesColumns,
+ PrimaryKey: []*schema.Column{ItemTemplatesColumns[0]},
+ ForeignKeys: []*schema.ForeignKey{
+ {
+ Symbol: "item_templates_groups_item_templates",
+ Columns: []*schema.Column{ItemTemplatesColumns[18]},
+ RefColumns: []*schema.Column{GroupsColumns[0]},
+ OnDelete: schema.Cascade,
+ },
+ {
+ Symbol: "item_templates_locations_location",
+ Columns: []*schema.Column{ItemTemplatesColumns[19]},
+ RefColumns: []*schema.Column{LocationsColumns[0]},
+ OnDelete: schema.SetNull,
+ },
+ },
+ Indexes: []*schema.Index{
+ {
+ Name: "itemtemplate_name",
+ Unique: false,
+ Columns: []*schema.Column{ItemTemplatesColumns[3]},
+ },
+ },
+ }
// LabelsColumns holds the columns for the "labels" table.
LabelsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
@@ -379,6 +429,31 @@ var (
},
},
}
+ // TemplateFieldsColumns holds the columns for the "template_fields" table.
+ TemplateFieldsColumns = []*schema.Column{
+ {Name: "id", Type: field.TypeUUID},
+ {Name: "created_at", Type: field.TypeTime},
+ {Name: "updated_at", Type: field.TypeTime},
+ {Name: "name", Type: field.TypeString, Size: 255},
+ {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
+ {Name: "type", Type: field.TypeEnum, Enums: []string{"text"}},
+ {Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500},
+ {Name: "item_template_fields", Type: field.TypeUUID, Nullable: true},
+ }
+ // TemplateFieldsTable holds the schema information for the "template_fields" table.
+ TemplateFieldsTable = &schema.Table{
+ Name: "template_fields",
+ Columns: TemplateFieldsColumns,
+ PrimaryKey: []*schema.Column{TemplateFieldsColumns[0]},
+ ForeignKeys: []*schema.ForeignKey{
+ {
+ Symbol: "template_fields_item_templates_fields",
+ Columns: []*schema.Column{TemplateFieldsColumns[7]},
+ RefColumns: []*schema.Column{ItemTemplatesColumns[0]},
+ OnDelete: schema.Cascade,
+ },
+ },
+ }
// UsersColumns holds the columns for the "users" table.
UsersColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
@@ -450,10 +525,12 @@ var (
GroupInvitationTokensTable,
ItemsTable,
ItemFieldsTable,
+ ItemTemplatesTable,
LabelsTable,
LocationsTable,
MaintenanceEntriesTable,
NotifiersTable,
+ TemplateFieldsTable,
UsersTable,
LabelItemsTable,
}
@@ -469,12 +546,15 @@ func init() {
ItemsTable.ForeignKeys[1].RefTable = ItemsTable
ItemsTable.ForeignKeys[2].RefTable = LocationsTable
ItemFieldsTable.ForeignKeys[0].RefTable = ItemsTable
+ ItemTemplatesTable.ForeignKeys[0].RefTable = GroupsTable
+ ItemTemplatesTable.ForeignKeys[1].RefTable = LocationsTable
LabelsTable.ForeignKeys[0].RefTable = GroupsTable
LocationsTable.ForeignKeys[0].RefTable = GroupsTable
LocationsTable.ForeignKeys[1].RefTable = LocationsTable
MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable
NotifiersTable.ForeignKeys[0].RefTable = GroupsTable
NotifiersTable.ForeignKeys[1].RefTable = UsersTable
+ TemplateFieldsTable.ForeignKeys[0].RefTable = ItemTemplatesTable
UsersTable.ForeignKeys[0].RefTable = GroupsTable
LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable
LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable
diff --git a/backend/internal/data/ent/mutation.go b/backend/internal/data/ent/mutation.go
index 22908884..f5a1b13d 100644
--- a/backend/internal/data/ent/mutation.go
+++ b/backend/internal/data/ent/mutation.go
@@ -19,11 +19,13 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -43,10 +45,12 @@ const (
TypeGroupInvitationToken = "GroupInvitationToken"
TypeItem = "Item"
TypeItemField = "ItemField"
+ TypeItemTemplate = "ItemTemplate"
TypeLabel = "Label"
TypeLocation = "Location"
TypeMaintenanceEntry = "MaintenanceEntry"
TypeNotifier = "Notifier"
+ TypeTemplateField = "TemplateField"
TypeUser = "User"
)
@@ -1874,6 +1878,9 @@ type GroupMutation struct {
notifiers map[uuid.UUID]struct{}
removednotifiers map[uuid.UUID]struct{}
clearednotifiers bool
+ item_templates map[uuid.UUID]struct{}
+ removeditem_templates map[uuid.UUID]struct{}
+ cleareditem_templates bool
done bool
oldValue func(context.Context) (*Group, error)
predicates []predicate.Group
@@ -2451,6 +2458,60 @@ func (m *GroupMutation) ResetNotifiers() {
m.removednotifiers = nil
}
+// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by ids.
+func (m *GroupMutation) AddItemTemplateIDs(ids ...uuid.UUID) {
+ if m.item_templates == nil {
+ m.item_templates = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ m.item_templates[ids[i]] = struct{}{}
+ }
+}
+
+// ClearItemTemplates clears the "item_templates" edge to the ItemTemplate entity.
+func (m *GroupMutation) ClearItemTemplates() {
+ m.cleareditem_templates = true
+}
+
+// ItemTemplatesCleared reports if the "item_templates" edge to the ItemTemplate entity was cleared.
+func (m *GroupMutation) ItemTemplatesCleared() bool {
+ return m.cleareditem_templates
+}
+
+// RemoveItemTemplateIDs removes the "item_templates" edge to the ItemTemplate entity by IDs.
+func (m *GroupMutation) RemoveItemTemplateIDs(ids ...uuid.UUID) {
+ if m.removeditem_templates == nil {
+ m.removeditem_templates = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ delete(m.item_templates, ids[i])
+ m.removeditem_templates[ids[i]] = struct{}{}
+ }
+}
+
+// RemovedItemTemplates returns the removed IDs of the "item_templates" edge to the ItemTemplate entity.
+func (m *GroupMutation) RemovedItemTemplatesIDs() (ids []uuid.UUID) {
+ for id := range m.removeditem_templates {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// ItemTemplatesIDs returns the "item_templates" edge IDs in the mutation.
+func (m *GroupMutation) ItemTemplatesIDs() (ids []uuid.UUID) {
+ for id := range m.item_templates {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// ResetItemTemplates resets all changes to the "item_templates" edge.
+func (m *GroupMutation) ResetItemTemplates() {
+ m.item_templates = nil
+ m.cleareditem_templates = false
+ m.removeditem_templates = nil
+}
+
// Where appends a list predicates to the GroupMutation builder.
func (m *GroupMutation) Where(ps ...predicate.Group) {
m.predicates = append(m.predicates, ps...)
@@ -2635,7 +2696,7 @@ func (m *GroupMutation) ResetField(name string) error {
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *GroupMutation) AddedEdges() []string {
- edges := make([]string, 0, 6)
+ edges := make([]string, 0, 7)
if m.users != nil {
edges = append(edges, group.EdgeUsers)
}
@@ -2654,6 +2715,9 @@ func (m *GroupMutation) AddedEdges() []string {
if m.notifiers != nil {
edges = append(edges, group.EdgeNotifiers)
}
+ if m.item_templates != nil {
+ edges = append(edges, group.EdgeItemTemplates)
+ }
return edges
}
@@ -2697,13 +2761,19 @@ func (m *GroupMutation) AddedIDs(name string) []ent.Value {
ids = append(ids, id)
}
return ids
+ case group.EdgeItemTemplates:
+ ids := make([]ent.Value, 0, len(m.item_templates))
+ for id := range m.item_templates {
+ ids = append(ids, id)
+ }
+ return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *GroupMutation) RemovedEdges() []string {
- edges := make([]string, 0, 6)
+ edges := make([]string, 0, 7)
if m.removedusers != nil {
edges = append(edges, group.EdgeUsers)
}
@@ -2722,6 +2792,9 @@ func (m *GroupMutation) RemovedEdges() []string {
if m.removednotifiers != nil {
edges = append(edges, group.EdgeNotifiers)
}
+ if m.removeditem_templates != nil {
+ edges = append(edges, group.EdgeItemTemplates)
+ }
return edges
}
@@ -2765,13 +2838,19 @@ func (m *GroupMutation) RemovedIDs(name string) []ent.Value {
ids = append(ids, id)
}
return ids
+ case group.EdgeItemTemplates:
+ ids := make([]ent.Value, 0, len(m.removeditem_templates))
+ for id := range m.removeditem_templates {
+ ids = append(ids, id)
+ }
+ return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *GroupMutation) ClearedEdges() []string {
- edges := make([]string, 0, 6)
+ edges := make([]string, 0, 7)
if m.clearedusers {
edges = append(edges, group.EdgeUsers)
}
@@ -2790,6 +2869,9 @@ func (m *GroupMutation) ClearedEdges() []string {
if m.clearednotifiers {
edges = append(edges, group.EdgeNotifiers)
}
+ if m.cleareditem_templates {
+ edges = append(edges, group.EdgeItemTemplates)
+ }
return edges
}
@@ -2809,6 +2891,8 @@ func (m *GroupMutation) EdgeCleared(name string) bool {
return m.clearedinvitation_tokens
case group.EdgeNotifiers:
return m.clearednotifiers
+ case group.EdgeItemTemplates:
+ return m.cleareditem_templates
}
return false
}
@@ -2843,6 +2927,9 @@ func (m *GroupMutation) ResetEdge(name string) error {
case group.EdgeNotifiers:
m.ResetNotifiers()
return nil
+ case group.EdgeItemTemplates:
+ m.ResetItemTemplates()
+ return nil
}
return fmt.Errorf("unknown Group edge %s", name)
}
@@ -6987,39 +7074,55 @@ func (m *ItemFieldMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown ItemField edge %s", name)
}
-// LabelMutation represents an operation that mutates the Label nodes in the graph.
-type LabelMutation struct {
+// ItemTemplateMutation represents an operation that mutates the ItemTemplate nodes in the graph.
+type ItemTemplateMutation struct {
config
- op Op
- typ string
- id *uuid.UUID
- created_at *time.Time
- updated_at *time.Time
- name *string
- description *string
- color *string
- clearedFields map[string]struct{}
- group *uuid.UUID
- clearedgroup bool
- items map[uuid.UUID]struct{}
- removeditems map[uuid.UUID]struct{}
- cleareditems bool
- done bool
- oldValue func(context.Context) (*Label, error)
- predicates []predicate.Label
-}
-
-var _ ent.Mutation = (*LabelMutation)(nil)
-
-// labelOption allows management of the mutation configuration using functional options.
-type labelOption func(*LabelMutation)
-
-// newLabelMutation creates new mutation for the Label entity.
-func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
- m := &LabelMutation{
+ op Op
+ typ string
+ id *uuid.UUID
+ created_at *time.Time
+ updated_at *time.Time
+ name *string
+ description *string
+ notes *string
+ default_quantity *int
+ adddefault_quantity *int
+ default_insured *bool
+ default_name *string
+ default_description *string
+ default_manufacturer *string
+ default_model_number *string
+ default_lifetime_warranty *bool
+ default_warranty_details *string
+ include_warranty_fields *bool
+ include_purchase_fields *bool
+ include_sold_fields *bool
+ default_label_ids *[]uuid.UUID
+ appenddefault_label_ids []uuid.UUID
+ clearedFields map[string]struct{}
+ group *uuid.UUID
+ clearedgroup bool
+ fields map[uuid.UUID]struct{}
+ removedfields map[uuid.UUID]struct{}
+ clearedfields bool
+ location *uuid.UUID
+ clearedlocation bool
+ done bool
+ oldValue func(context.Context) (*ItemTemplate, error)
+ predicates []predicate.ItemTemplate
+}
+
+var _ ent.Mutation = (*ItemTemplateMutation)(nil)
+
+// itemtemplateOption allows management of the mutation configuration using functional options.
+type itemtemplateOption func(*ItemTemplateMutation)
+
+// newItemTemplateMutation creates new mutation for the ItemTemplate entity.
+func newItemTemplateMutation(c config, op Op, opts ...itemtemplateOption) *ItemTemplateMutation {
+ m := &ItemTemplateMutation{
config: c,
op: op,
- typ: TypeLabel,
+ typ: TypeItemTemplate,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
@@ -7028,20 +7131,20 @@ func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
return m
}
-// withLabelID sets the ID field of the mutation.
-func withLabelID(id uuid.UUID) labelOption {
- return func(m *LabelMutation) {
+// withItemTemplateID sets the ID field of the mutation.
+func withItemTemplateID(id uuid.UUID) itemtemplateOption {
+ return func(m *ItemTemplateMutation) {
var (
err error
once sync.Once
- value *Label
+ value *ItemTemplate
)
- m.oldValue = func(ctx context.Context) (*Label, error) {
+ m.oldValue = func(ctx context.Context) (*ItemTemplate, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
- value, err = m.Client().Label.Get(ctx, id)
+ value, err = m.Client().ItemTemplate.Get(ctx, id)
}
})
return value, err
@@ -7050,10 +7153,10 @@ func withLabelID(id uuid.UUID) labelOption {
}
}
-// withLabel sets the old Label of the mutation.
-func withLabel(node *Label) labelOption {
- return func(m *LabelMutation) {
- m.oldValue = func(context.Context) (*Label, error) {
+// withItemTemplate sets the old ItemTemplate of the mutation.
+func withItemTemplate(node *ItemTemplate) itemtemplateOption {
+ return func(m *ItemTemplateMutation) {
+ m.oldValue = func(context.Context) (*ItemTemplate, error) {
return node, nil
}
m.id = &node.ID
@@ -7062,7 +7165,7 @@ func withLabel(node *Label) labelOption {
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
-func (m LabelMutation) Client() *Client {
+func (m ItemTemplateMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
@@ -7070,7 +7173,7 @@ func (m LabelMutation) Client() *Client {
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
-func (m LabelMutation) Tx() (*Tx, error) {
+func (m ItemTemplateMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("ent: mutation is not running in a transaction")
}
@@ -7080,14 +7183,14 @@ func (m LabelMutation) Tx() (*Tx, error) {
}
// SetID sets the value of the id field. Note that this
-// operation is only accepted on creation of Label entities.
-func (m *LabelMutation) SetID(id uuid.UUID) {
+// operation is only accepted on creation of ItemTemplate entities.
+func (m *ItemTemplateMutation) SetID(id uuid.UUID) {
m.id = &id
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
-func (m *LabelMutation) ID() (id uuid.UUID, exists bool) {
+func (m *ItemTemplateMutation) ID() (id uuid.UUID, exists bool) {
if m.id == nil {
return
}
@@ -7098,7 +7201,7 @@ func (m *LabelMutation) ID() (id uuid.UUID, exists bool) {
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
-func (m *LabelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
+func (m *ItemTemplateMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
@@ -7107,19 +7210,19 @@ func (m *LabelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
+ return m.Client().ItemTemplate.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetCreatedAt sets the "created_at" field.
-func (m *LabelMutation) SetCreatedAt(t time.Time) {
+func (m *ItemTemplateMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
-func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
+func (m *ItemTemplateMutation) CreatedAt() (r time.Time, exists bool) {
v := m.created_at
if v == nil {
return
@@ -7127,10 +7230,10 @@ func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
return *v, true
}
-// OldCreatedAt returns the old "created_at" field's value of the Label entity.
-// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// OldCreatedAt returns the old "created_at" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
+func (m *ItemTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
}
@@ -7145,17 +7248,17 @@ func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err erro
}
// ResetCreatedAt resets all changes to the "created_at" field.
-func (m *LabelMutation) ResetCreatedAt() {
+func (m *ItemTemplateMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
-func (m *LabelMutation) SetUpdatedAt(t time.Time) {
+func (m *ItemTemplateMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
-func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
+func (m *ItemTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
v := m.updated_at
if v == nil {
return
@@ -7163,10 +7266,10 @@ func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
return *v, true
}
-// OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
-// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// OldUpdatedAt returns the old "updated_at" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
+func (m *ItemTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
}
@@ -7181,17 +7284,17 @@ func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err erro
}
// ResetUpdatedAt resets all changes to the "updated_at" field.
-func (m *LabelMutation) ResetUpdatedAt() {
+func (m *ItemTemplateMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// SetName sets the "name" field.
-func (m *LabelMutation) SetName(s string) {
+func (m *ItemTemplateMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
-func (m *LabelMutation) Name() (r string, exists bool) {
+func (m *ItemTemplateMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
@@ -7199,10 +7302,10 @@ func (m *LabelMutation) Name() (r string, exists bool) {
return *v, true
}
-// OldName returns the old "name" field's value of the Label entity.
-// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// OldName returns the old "name" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
+func (m *ItemTemplateMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
@@ -7217,17 +7320,17 @@ func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
}
// ResetName resets all changes to the "name" field.
-func (m *LabelMutation) ResetName() {
+func (m *ItemTemplateMutation) ResetName() {
m.name = nil
}
// SetDescription sets the "description" field.
-func (m *LabelMutation) SetDescription(s string) {
+func (m *ItemTemplateMutation) SetDescription(s string) {
m.description = &s
}
// Description returns the value of the "description" field in the mutation.
-func (m *LabelMutation) Description() (r string, exists bool) {
+func (m *ItemTemplateMutation) Description() (r string, exists bool) {
v := m.description
if v == nil {
return
@@ -7235,10 +7338,10 @@ func (m *LabelMutation) Description() (r string, exists bool) {
return *v, true
}
-// OldDescription returns the old "description" field's value of the Label entity.
-// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// OldDescription returns the old "description" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *LabelMutation) OldDescription(ctx context.Context) (v string, err error) {
+func (m *ItemTemplateMutation) OldDescription(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
}
@@ -7253,172 +7356,1771 @@ func (m *LabelMutation) OldDescription(ctx context.Context) (v string, err error
}
// ClearDescription clears the value of the "description" field.
-func (m *LabelMutation) ClearDescription() {
+func (m *ItemTemplateMutation) ClearDescription() {
m.description = nil
- m.clearedFields[label.FieldDescription] = struct{}{}
+ m.clearedFields[itemtemplate.FieldDescription] = struct{}{}
}
// DescriptionCleared returns if the "description" field was cleared in this mutation.
-func (m *LabelMutation) DescriptionCleared() bool {
- _, ok := m.clearedFields[label.FieldDescription]
+func (m *ItemTemplateMutation) DescriptionCleared() bool {
+ _, ok := m.clearedFields[itemtemplate.FieldDescription]
return ok
}
// ResetDescription resets all changes to the "description" field.
-func (m *LabelMutation) ResetDescription() {
+func (m *ItemTemplateMutation) ResetDescription() {
m.description = nil
- delete(m.clearedFields, label.FieldDescription)
+ delete(m.clearedFields, itemtemplate.FieldDescription)
}
-// SetColor sets the "color" field.
-func (m *LabelMutation) SetColor(s string) {
- m.color = &s
+// SetNotes sets the "notes" field.
+func (m *ItemTemplateMutation) SetNotes(s string) {
+ m.notes = &s
}
-// Color returns the value of the "color" field in the mutation.
-func (m *LabelMutation) Color() (r string, exists bool) {
- v := m.color
+// Notes returns the value of the "notes" field in the mutation.
+func (m *ItemTemplateMutation) Notes() (r string, exists bool) {
+ v := m.notes
if v == nil {
return
}
return *v, true
}
-// OldColor returns the old "color" field's value of the Label entity.
-// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// OldNotes returns the old "notes" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *LabelMutation) OldColor(ctx context.Context) (v string, err error) {
+func (m *ItemTemplateMutation) OldNotes(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldColor is only allowed on UpdateOne operations")
+ return v, errors.New("OldNotes is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldColor requires an ID field in the mutation")
+ return v, errors.New("OldNotes requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldColor: %w", err)
+ return v, fmt.Errorf("querying old value for OldNotes: %w", err)
}
- return oldValue.Color, nil
+ return oldValue.Notes, nil
}
-// ClearColor clears the value of the "color" field.
-func (m *LabelMutation) ClearColor() {
- m.color = nil
- m.clearedFields[label.FieldColor] = struct{}{}
+// ClearNotes clears the value of the "notes" field.
+func (m *ItemTemplateMutation) ClearNotes() {
+ m.notes = nil
+ m.clearedFields[itemtemplate.FieldNotes] = struct{}{}
}
-// ColorCleared returns if the "color" field was cleared in this mutation.
-func (m *LabelMutation) ColorCleared() bool {
- _, ok := m.clearedFields[label.FieldColor]
+// NotesCleared returns if the "notes" field was cleared in this mutation.
+func (m *ItemTemplateMutation) NotesCleared() bool {
+ _, ok := m.clearedFields[itemtemplate.FieldNotes]
return ok
}
-// ResetColor resets all changes to the "color" field.
-func (m *LabelMutation) ResetColor() {
- m.color = nil
- delete(m.clearedFields, label.FieldColor)
+// ResetNotes resets all changes to the "notes" field.
+func (m *ItemTemplateMutation) ResetNotes() {
+ m.notes = nil
+ delete(m.clearedFields, itemtemplate.FieldNotes)
}
-// SetGroupID sets the "group" edge to the Group entity by id.
-func (m *LabelMutation) SetGroupID(id uuid.UUID) {
- m.group = &id
+// SetDefaultQuantity sets the "default_quantity" field.
+func (m *ItemTemplateMutation) SetDefaultQuantity(i int) {
+ m.default_quantity = &i
+ m.adddefault_quantity = nil
}
-// ClearGroup clears the "group" edge to the Group entity.
-func (m *LabelMutation) ClearGroup() {
- m.clearedgroup = true
+// DefaultQuantity returns the value of the "default_quantity" field in the mutation.
+func (m *ItemTemplateMutation) DefaultQuantity() (r int, exists bool) {
+ v := m.default_quantity
+ if v == nil {
+ return
+ }
+ return *v, true
}
-// GroupCleared reports if the "group" edge to the Group entity was cleared.
-func (m *LabelMutation) GroupCleared() bool {
- return m.clearedgroup
+// OldDefaultQuantity returns the old "default_quantity" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldDefaultQuantity(ctx context.Context) (v int, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDefaultQuantity is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDefaultQuantity requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDefaultQuantity: %w", err)
+ }
+ return oldValue.DefaultQuantity, nil
}
-// GroupID returns the "group" edge ID in the mutation.
-func (m *LabelMutation) GroupID() (id uuid.UUID, exists bool) {
- if m.group != nil {
- return *m.group, true
+// AddDefaultQuantity adds i to the "default_quantity" field.
+func (m *ItemTemplateMutation) AddDefaultQuantity(i int) {
+ if m.adddefault_quantity != nil {
+ *m.adddefault_quantity += i
+ } else {
+ m.adddefault_quantity = &i
}
- return
}
-// GroupIDs returns the "group" edge IDs in the mutation.
-// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
-// GroupID instead. It exists only for internal usage by the builders.
-func (m *LabelMutation) GroupIDs() (ids []uuid.UUID) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
+// AddedDefaultQuantity returns the value that was added to the "default_quantity" field in this mutation.
+func (m *ItemTemplateMutation) AddedDefaultQuantity() (r int, exists bool) {
+ v := m.adddefault_quantity
+ if v == nil {
+ return
}
- return
+ return *v, true
}
-// ResetGroup resets all changes to the "group" edge.
-func (m *LabelMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
+// ResetDefaultQuantity resets all changes to the "default_quantity" field.
+func (m *ItemTemplateMutation) ResetDefaultQuantity() {
+ m.default_quantity = nil
+ m.adddefault_quantity = nil
}
-// AddItemIDs adds the "items" edge to the Item entity by ids.
-func (m *LabelMutation) AddItemIDs(ids ...uuid.UUID) {
- if m.items == nil {
- m.items = make(map[uuid.UUID]struct{})
+// SetDefaultInsured sets the "default_insured" field.
+func (m *ItemTemplateMutation) SetDefaultInsured(b bool) {
+ m.default_insured = &b
+}
+
+// DefaultInsured returns the value of the "default_insured" field in the mutation.
+func (m *ItemTemplateMutation) DefaultInsured() (r bool, exists bool) {
+ v := m.default_insured
+ if v == nil {
+ return
}
- for i := range ids {
- m.items[ids[i]] = struct{}{}
+ return *v, true
+}
+
+// OldDefaultInsured returns the old "default_insured" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldDefaultInsured(ctx context.Context) (v bool, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDefaultInsured is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDefaultInsured requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDefaultInsured: %w", err)
}
+ return oldValue.DefaultInsured, nil
}
-// ClearItems clears the "items" edge to the Item entity.
-func (m *LabelMutation) ClearItems() {
- m.cleareditems = true
+// ResetDefaultInsured resets all changes to the "default_insured" field.
+func (m *ItemTemplateMutation) ResetDefaultInsured() {
+ m.default_insured = nil
}
-// ItemsCleared reports if the "items" edge to the Item entity was cleared.
-func (m *LabelMutation) ItemsCleared() bool {
- return m.cleareditems
+// SetDefaultName sets the "default_name" field.
+func (m *ItemTemplateMutation) SetDefaultName(s string) {
+ m.default_name = &s
}
-// RemoveItemIDs removes the "items" edge to the Item entity by IDs.
-func (m *LabelMutation) RemoveItemIDs(ids ...uuid.UUID) {
- if m.removeditems == nil {
- m.removeditems = make(map[uuid.UUID]struct{})
- }
- for i := range ids {
- delete(m.items, ids[i])
- m.removeditems[ids[i]] = struct{}{}
+// DefaultName returns the value of the "default_name" field in the mutation.
+func (m *ItemTemplateMutation) DefaultName() (r string, exists bool) {
+ v := m.default_name
+ if v == nil {
+ return
}
+ return *v, true
}
-// RemovedItems returns the removed IDs of the "items" edge to the Item entity.
-func (m *LabelMutation) RemovedItemsIDs() (ids []uuid.UUID) {
- for id := range m.removeditems {
- ids = append(ids, id)
+// OldDefaultName returns the old "default_name" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldDefaultName(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDefaultName is only allowed on UpdateOne operations")
}
- return
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDefaultName requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDefaultName: %w", err)
+ }
+ return oldValue.DefaultName, nil
}
-// ItemsIDs returns the "items" edge IDs in the mutation.
-func (m *LabelMutation) ItemsIDs() (ids []uuid.UUID) {
- for id := range m.items {
- ids = append(ids, id)
- }
- return
+// ClearDefaultName clears the value of the "default_name" field.
+func (m *ItemTemplateMutation) ClearDefaultName() {
+ m.default_name = nil
+ m.clearedFields[itemtemplate.FieldDefaultName] = struct{}{}
}
-// ResetItems resets all changes to the "items" edge.
-func (m *LabelMutation) ResetItems() {
- m.items = nil
- m.cleareditems = false
- m.removeditems = nil
+// DefaultNameCleared returns if the "default_name" field was cleared in this mutation.
+func (m *ItemTemplateMutation) DefaultNameCleared() bool {
+ _, ok := m.clearedFields[itemtemplate.FieldDefaultName]
+ return ok
}
-// Where appends a list predicates to the LabelMutation builder.
-func (m *LabelMutation) Where(ps ...predicate.Label) {
- m.predicates = append(m.predicates, ps...)
+// ResetDefaultName resets all changes to the "default_name" field.
+func (m *ItemTemplateMutation) ResetDefaultName() {
+ m.default_name = nil
+ delete(m.clearedFields, itemtemplate.FieldDefaultName)
}
-// WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
-// users can use type-assertion to append predicates that do not depend on any generated package.
+// SetDefaultDescription sets the "default_description" field.
+func (m *ItemTemplateMutation) SetDefaultDescription(s string) {
+ m.default_description = &s
+}
+
+// DefaultDescription returns the value of the "default_description" field in the mutation.
+func (m *ItemTemplateMutation) DefaultDescription() (r string, exists bool) {
+ v := m.default_description
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldDefaultDescription returns the old "default_description" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldDefaultDescription(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDefaultDescription is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDefaultDescription requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDefaultDescription: %w", err)
+ }
+ return oldValue.DefaultDescription, nil
+}
+
+// ClearDefaultDescription clears the value of the "default_description" field.
+func (m *ItemTemplateMutation) ClearDefaultDescription() {
+ m.default_description = nil
+ m.clearedFields[itemtemplate.FieldDefaultDescription] = struct{}{}
+}
+
+// DefaultDescriptionCleared returns if the "default_description" field was cleared in this mutation.
+func (m *ItemTemplateMutation) DefaultDescriptionCleared() bool {
+ _, ok := m.clearedFields[itemtemplate.FieldDefaultDescription]
+ return ok
+}
+
+// ResetDefaultDescription resets all changes to the "default_description" field.
+func (m *ItemTemplateMutation) ResetDefaultDescription() {
+ m.default_description = nil
+ delete(m.clearedFields, itemtemplate.FieldDefaultDescription)
+}
+
+// SetDefaultManufacturer sets the "default_manufacturer" field.
+func (m *ItemTemplateMutation) SetDefaultManufacturer(s string) {
+ m.default_manufacturer = &s
+}
+
+// DefaultManufacturer returns the value of the "default_manufacturer" field in the mutation.
+func (m *ItemTemplateMutation) DefaultManufacturer() (r string, exists bool) {
+ v := m.default_manufacturer
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldDefaultManufacturer returns the old "default_manufacturer" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldDefaultManufacturer(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDefaultManufacturer is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDefaultManufacturer requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDefaultManufacturer: %w", err)
+ }
+ return oldValue.DefaultManufacturer, nil
+}
+
+// ClearDefaultManufacturer clears the value of the "default_manufacturer" field.
+func (m *ItemTemplateMutation) ClearDefaultManufacturer() {
+ m.default_manufacturer = nil
+ m.clearedFields[itemtemplate.FieldDefaultManufacturer] = struct{}{}
+}
+
+// DefaultManufacturerCleared returns if the "default_manufacturer" field was cleared in this mutation.
+func (m *ItemTemplateMutation) DefaultManufacturerCleared() bool {
+ _, ok := m.clearedFields[itemtemplate.FieldDefaultManufacturer]
+ return ok
+}
+
+// ResetDefaultManufacturer resets all changes to the "default_manufacturer" field.
+func (m *ItemTemplateMutation) ResetDefaultManufacturer() {
+ m.default_manufacturer = nil
+ delete(m.clearedFields, itemtemplate.FieldDefaultManufacturer)
+}
+
+// SetDefaultModelNumber sets the "default_model_number" field.
+func (m *ItemTemplateMutation) SetDefaultModelNumber(s string) {
+ m.default_model_number = &s
+}
+
+// DefaultModelNumber returns the value of the "default_model_number" field in the mutation.
+func (m *ItemTemplateMutation) DefaultModelNumber() (r string, exists bool) {
+ v := m.default_model_number
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldDefaultModelNumber returns the old "default_model_number" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldDefaultModelNumber(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDefaultModelNumber is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDefaultModelNumber requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDefaultModelNumber: %w", err)
+ }
+ return oldValue.DefaultModelNumber, nil
+}
+
+// ClearDefaultModelNumber clears the value of the "default_model_number" field.
+func (m *ItemTemplateMutation) ClearDefaultModelNumber() {
+ m.default_model_number = nil
+ m.clearedFields[itemtemplate.FieldDefaultModelNumber] = struct{}{}
+}
+
+// DefaultModelNumberCleared returns if the "default_model_number" field was cleared in this mutation.
+func (m *ItemTemplateMutation) DefaultModelNumberCleared() bool {
+ _, ok := m.clearedFields[itemtemplate.FieldDefaultModelNumber]
+ return ok
+}
+
+// ResetDefaultModelNumber resets all changes to the "default_model_number" field.
+func (m *ItemTemplateMutation) ResetDefaultModelNumber() {
+ m.default_model_number = nil
+ delete(m.clearedFields, itemtemplate.FieldDefaultModelNumber)
+}
+
+// SetDefaultLifetimeWarranty sets the "default_lifetime_warranty" field.
+func (m *ItemTemplateMutation) SetDefaultLifetimeWarranty(b bool) {
+ m.default_lifetime_warranty = &b
+}
+
+// DefaultLifetimeWarranty returns the value of the "default_lifetime_warranty" field in the mutation.
+func (m *ItemTemplateMutation) DefaultLifetimeWarranty() (r bool, exists bool) {
+ v := m.default_lifetime_warranty
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldDefaultLifetimeWarranty returns the old "default_lifetime_warranty" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldDefaultLifetimeWarranty(ctx context.Context) (v bool, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDefaultLifetimeWarranty is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDefaultLifetimeWarranty requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDefaultLifetimeWarranty: %w", err)
+ }
+ return oldValue.DefaultLifetimeWarranty, nil
+}
+
+// ResetDefaultLifetimeWarranty resets all changes to the "default_lifetime_warranty" field.
+func (m *ItemTemplateMutation) ResetDefaultLifetimeWarranty() {
+ m.default_lifetime_warranty = nil
+}
+
+// SetDefaultWarrantyDetails sets the "default_warranty_details" field.
+func (m *ItemTemplateMutation) SetDefaultWarrantyDetails(s string) {
+ m.default_warranty_details = &s
+}
+
+// DefaultWarrantyDetails returns the value of the "default_warranty_details" field in the mutation.
+func (m *ItemTemplateMutation) DefaultWarrantyDetails() (r string, exists bool) {
+ v := m.default_warranty_details
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldDefaultWarrantyDetails returns the old "default_warranty_details" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldDefaultWarrantyDetails(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDefaultWarrantyDetails is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDefaultWarrantyDetails requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDefaultWarrantyDetails: %w", err)
+ }
+ return oldValue.DefaultWarrantyDetails, nil
+}
+
+// ClearDefaultWarrantyDetails clears the value of the "default_warranty_details" field.
+func (m *ItemTemplateMutation) ClearDefaultWarrantyDetails() {
+ m.default_warranty_details = nil
+ m.clearedFields[itemtemplate.FieldDefaultWarrantyDetails] = struct{}{}
+}
+
+// DefaultWarrantyDetailsCleared returns if the "default_warranty_details" field was cleared in this mutation.
+func (m *ItemTemplateMutation) DefaultWarrantyDetailsCleared() bool {
+ _, ok := m.clearedFields[itemtemplate.FieldDefaultWarrantyDetails]
+ return ok
+}
+
+// ResetDefaultWarrantyDetails resets all changes to the "default_warranty_details" field.
+func (m *ItemTemplateMutation) ResetDefaultWarrantyDetails() {
+ m.default_warranty_details = nil
+ delete(m.clearedFields, itemtemplate.FieldDefaultWarrantyDetails)
+}
+
+// SetIncludeWarrantyFields sets the "include_warranty_fields" field.
+func (m *ItemTemplateMutation) SetIncludeWarrantyFields(b bool) {
+ m.include_warranty_fields = &b
+}
+
+// IncludeWarrantyFields returns the value of the "include_warranty_fields" field in the mutation.
+func (m *ItemTemplateMutation) IncludeWarrantyFields() (r bool, exists bool) {
+ v := m.include_warranty_fields
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldIncludeWarrantyFields returns the old "include_warranty_fields" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldIncludeWarrantyFields(ctx context.Context) (v bool, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldIncludeWarrantyFields is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldIncludeWarrantyFields requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldIncludeWarrantyFields: %w", err)
+ }
+ return oldValue.IncludeWarrantyFields, nil
+}
+
+// ResetIncludeWarrantyFields resets all changes to the "include_warranty_fields" field.
+func (m *ItemTemplateMutation) ResetIncludeWarrantyFields() {
+ m.include_warranty_fields = nil
+}
+
+// SetIncludePurchaseFields sets the "include_purchase_fields" field.
+func (m *ItemTemplateMutation) SetIncludePurchaseFields(b bool) {
+ m.include_purchase_fields = &b
+}
+
+// IncludePurchaseFields returns the value of the "include_purchase_fields" field in the mutation.
+func (m *ItemTemplateMutation) IncludePurchaseFields() (r bool, exists bool) {
+ v := m.include_purchase_fields
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldIncludePurchaseFields returns the old "include_purchase_fields" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldIncludePurchaseFields(ctx context.Context) (v bool, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldIncludePurchaseFields is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldIncludePurchaseFields requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldIncludePurchaseFields: %w", err)
+ }
+ return oldValue.IncludePurchaseFields, nil
+}
+
+// ResetIncludePurchaseFields resets all changes to the "include_purchase_fields" field.
+func (m *ItemTemplateMutation) ResetIncludePurchaseFields() {
+ m.include_purchase_fields = nil
+}
+
+// SetIncludeSoldFields sets the "include_sold_fields" field.
+func (m *ItemTemplateMutation) SetIncludeSoldFields(b bool) {
+ m.include_sold_fields = &b
+}
+
+// IncludeSoldFields returns the value of the "include_sold_fields" field in the mutation.
+func (m *ItemTemplateMutation) IncludeSoldFields() (r bool, exists bool) {
+ v := m.include_sold_fields
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldIncludeSoldFields returns the old "include_sold_fields" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldIncludeSoldFields(ctx context.Context) (v bool, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldIncludeSoldFields is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldIncludeSoldFields requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldIncludeSoldFields: %w", err)
+ }
+ return oldValue.IncludeSoldFields, nil
+}
+
+// ResetIncludeSoldFields resets all changes to the "include_sold_fields" field.
+func (m *ItemTemplateMutation) ResetIncludeSoldFields() {
+ m.include_sold_fields = nil
+}
+
+// SetDefaultLabelIds sets the "default_label_ids" field.
+func (m *ItemTemplateMutation) SetDefaultLabelIds(u []uuid.UUID) {
+ m.default_label_ids = &u
+ m.appenddefault_label_ids = nil
+}
+
+// DefaultLabelIds returns the value of the "default_label_ids" field in the mutation.
+func (m *ItemTemplateMutation) DefaultLabelIds() (r []uuid.UUID, exists bool) {
+ v := m.default_label_ids
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldDefaultLabelIds returns the old "default_label_ids" field's value of the ItemTemplate entity.
+// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *ItemTemplateMutation) OldDefaultLabelIds(ctx context.Context) (v []uuid.UUID, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDefaultLabelIds is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDefaultLabelIds requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDefaultLabelIds: %w", err)
+ }
+ return oldValue.DefaultLabelIds, nil
+}
+
+// AppendDefaultLabelIds adds u to the "default_label_ids" field.
+func (m *ItemTemplateMutation) AppendDefaultLabelIds(u []uuid.UUID) {
+ m.appenddefault_label_ids = append(m.appenddefault_label_ids, u...)
+}
+
+// AppendedDefaultLabelIds returns the list of values that were appended to the "default_label_ids" field in this mutation.
+func (m *ItemTemplateMutation) AppendedDefaultLabelIds() ([]uuid.UUID, bool) {
+ if len(m.appenddefault_label_ids) == 0 {
+ return nil, false
+ }
+ return m.appenddefault_label_ids, true
+}
+
+// ClearDefaultLabelIds clears the value of the "default_label_ids" field.
+func (m *ItemTemplateMutation) ClearDefaultLabelIds() {
+ m.default_label_ids = nil
+ m.appenddefault_label_ids = nil
+ m.clearedFields[itemtemplate.FieldDefaultLabelIds] = struct{}{}
+}
+
+// DefaultLabelIdsCleared returns if the "default_label_ids" field was cleared in this mutation.
+func (m *ItemTemplateMutation) DefaultLabelIdsCleared() bool {
+ _, ok := m.clearedFields[itemtemplate.FieldDefaultLabelIds]
+ return ok
+}
+
+// ResetDefaultLabelIds resets all changes to the "default_label_ids" field.
+func (m *ItemTemplateMutation) ResetDefaultLabelIds() {
+ m.default_label_ids = nil
+ m.appenddefault_label_ids = nil
+ delete(m.clearedFields, itemtemplate.FieldDefaultLabelIds)
+}
+
+// SetGroupID sets the "group" edge to the Group entity by id.
+func (m *ItemTemplateMutation) SetGroupID(id uuid.UUID) {
+ m.group = &id
+}
+
+// ClearGroup clears the "group" edge to the Group entity.
+func (m *ItemTemplateMutation) ClearGroup() {
+ m.clearedgroup = true
+}
+
+// GroupCleared reports if the "group" edge to the Group entity was cleared.
+func (m *ItemTemplateMutation) GroupCleared() bool {
+ return m.clearedgroup
+}
+
+// GroupID returns the "group" edge ID in the mutation.
+func (m *ItemTemplateMutation) GroupID() (id uuid.UUID, exists bool) {
+ if m.group != nil {
+ return *m.group, true
+ }
+ return
+}
+
+// GroupIDs returns the "group" edge IDs in the mutation.
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
+// GroupID instead. It exists only for internal usage by the builders.
+func (m *ItemTemplateMutation) GroupIDs() (ids []uuid.UUID) {
+ if id := m.group; id != nil {
+ ids = append(ids, *id)
+ }
+ return
+}
+
+// ResetGroup resets all changes to the "group" edge.
+func (m *ItemTemplateMutation) ResetGroup() {
+ m.group = nil
+ m.clearedgroup = false
+}
+
+// AddFieldIDs adds the "fields" edge to the TemplateField entity by ids.
+func (m *ItemTemplateMutation) AddFieldIDs(ids ...uuid.UUID) {
+ if m.fields == nil {
+ m.fields = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ m.fields[ids[i]] = struct{}{}
+ }
+}
+
+// ClearFields clears the "fields" edge to the TemplateField entity.
+func (m *ItemTemplateMutation) ClearFields() {
+ m.clearedfields = true
+}
+
+// FieldsCleared reports if the "fields" edge to the TemplateField entity was cleared.
+func (m *ItemTemplateMutation) FieldsCleared() bool {
+ return m.clearedfields
+}
+
+// RemoveFieldIDs removes the "fields" edge to the TemplateField entity by IDs.
+func (m *ItemTemplateMutation) RemoveFieldIDs(ids ...uuid.UUID) {
+ if m.removedfields == nil {
+ m.removedfields = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ delete(m.fields, ids[i])
+ m.removedfields[ids[i]] = struct{}{}
+ }
+}
+
+// RemovedFields returns the removed IDs of the "fields" edge to the TemplateField entity.
+func (m *ItemTemplateMutation) RemovedFieldsIDs() (ids []uuid.UUID) {
+ for id := range m.removedfields {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// FieldsIDs returns the "fields" edge IDs in the mutation.
+func (m *ItemTemplateMutation) FieldsIDs() (ids []uuid.UUID) {
+ for id := range m.fields {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// ResetFields resets all changes to the "fields" edge.
+func (m *ItemTemplateMutation) ResetFields() {
+ m.fields = nil
+ m.clearedfields = false
+ m.removedfields = nil
+}
+
+// SetLocationID sets the "location" edge to the Location entity by id.
+func (m *ItemTemplateMutation) SetLocationID(id uuid.UUID) {
+ m.location = &id
+}
+
+// ClearLocation clears the "location" edge to the Location entity.
+func (m *ItemTemplateMutation) ClearLocation() {
+ m.clearedlocation = true
+}
+
+// LocationCleared reports if the "location" edge to the Location entity was cleared.
+func (m *ItemTemplateMutation) LocationCleared() bool {
+ return m.clearedlocation
+}
+
+// LocationID returns the "location" edge ID in the mutation.
+func (m *ItemTemplateMutation) LocationID() (id uuid.UUID, exists bool) {
+ if m.location != nil {
+ return *m.location, true
+ }
+ return
+}
+
+// LocationIDs returns the "location" edge IDs in the mutation.
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
+// LocationID instead. It exists only for internal usage by the builders.
+func (m *ItemTemplateMutation) LocationIDs() (ids []uuid.UUID) {
+ if id := m.location; id != nil {
+ ids = append(ids, *id)
+ }
+ return
+}
+
+// ResetLocation resets all changes to the "location" edge.
+func (m *ItemTemplateMutation) ResetLocation() {
+ m.location = nil
+ m.clearedlocation = false
+}
+
+// Where appends a list predicates to the ItemTemplateMutation builder.
+func (m *ItemTemplateMutation) Where(ps ...predicate.ItemTemplate) {
+ m.predicates = append(m.predicates, ps...)
+}
+
+// WhereP appends storage-level predicates to the ItemTemplateMutation builder. Using this method,
+// users can use type-assertion to append predicates that do not depend on any generated package.
+func (m *ItemTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
+ p := make([]predicate.ItemTemplate, len(ps))
+ for i := range ps {
+ p[i] = ps[i]
+ }
+ m.Where(p...)
+}
+
+// Op returns the operation name.
+func (m *ItemTemplateMutation) Op() Op {
+ return m.op
+}
+
+// SetOp allows setting the mutation operation.
+func (m *ItemTemplateMutation) SetOp(op Op) {
+ m.op = op
+}
+
+// Type returns the node type of this mutation (ItemTemplate).
+func (m *ItemTemplateMutation) Type() string {
+ return m.typ
+}
+
+// Fields returns all fields that were changed during this mutation. Note that in
+// order to get all numeric fields that were incremented/decremented, call
+// AddedFields().
+func (m *ItemTemplateMutation) Fields() []string {
+ fields := make([]string, 0, 17)
+ if m.created_at != nil {
+ fields = append(fields, itemtemplate.FieldCreatedAt)
+ }
+ if m.updated_at != nil {
+ fields = append(fields, itemtemplate.FieldUpdatedAt)
+ }
+ if m.name != nil {
+ fields = append(fields, itemtemplate.FieldName)
+ }
+ if m.description != nil {
+ fields = append(fields, itemtemplate.FieldDescription)
+ }
+ if m.notes != nil {
+ fields = append(fields, itemtemplate.FieldNotes)
+ }
+ if m.default_quantity != nil {
+ fields = append(fields, itemtemplate.FieldDefaultQuantity)
+ }
+ if m.default_insured != nil {
+ fields = append(fields, itemtemplate.FieldDefaultInsured)
+ }
+ if m.default_name != nil {
+ fields = append(fields, itemtemplate.FieldDefaultName)
+ }
+ if m.default_description != nil {
+ fields = append(fields, itemtemplate.FieldDefaultDescription)
+ }
+ if m.default_manufacturer != nil {
+ fields = append(fields, itemtemplate.FieldDefaultManufacturer)
+ }
+ if m.default_model_number != nil {
+ fields = append(fields, itemtemplate.FieldDefaultModelNumber)
+ }
+ if m.default_lifetime_warranty != nil {
+ fields = append(fields, itemtemplate.FieldDefaultLifetimeWarranty)
+ }
+ if m.default_warranty_details != nil {
+ fields = append(fields, itemtemplate.FieldDefaultWarrantyDetails)
+ }
+ if m.include_warranty_fields != nil {
+ fields = append(fields, itemtemplate.FieldIncludeWarrantyFields)
+ }
+ if m.include_purchase_fields != nil {
+ fields = append(fields, itemtemplate.FieldIncludePurchaseFields)
+ }
+ if m.include_sold_fields != nil {
+ fields = append(fields, itemtemplate.FieldIncludeSoldFields)
+ }
+ if m.default_label_ids != nil {
+ fields = append(fields, itemtemplate.FieldDefaultLabelIds)
+ }
+ return fields
+}
+
+// Field returns the value of a field with the given name. The second boolean
+// return value indicates that this field was not set, or was not defined in the
+// schema.
+func (m *ItemTemplateMutation) Field(name string) (ent.Value, bool) {
+ switch name {
+ case itemtemplate.FieldCreatedAt:
+ return m.CreatedAt()
+ case itemtemplate.FieldUpdatedAt:
+ return m.UpdatedAt()
+ case itemtemplate.FieldName:
+ return m.Name()
+ case itemtemplate.FieldDescription:
+ return m.Description()
+ case itemtemplate.FieldNotes:
+ return m.Notes()
+ case itemtemplate.FieldDefaultQuantity:
+ return m.DefaultQuantity()
+ case itemtemplate.FieldDefaultInsured:
+ return m.DefaultInsured()
+ case itemtemplate.FieldDefaultName:
+ return m.DefaultName()
+ case itemtemplate.FieldDefaultDescription:
+ return m.DefaultDescription()
+ case itemtemplate.FieldDefaultManufacturer:
+ return m.DefaultManufacturer()
+ case itemtemplate.FieldDefaultModelNumber:
+ return m.DefaultModelNumber()
+ case itemtemplate.FieldDefaultLifetimeWarranty:
+ return m.DefaultLifetimeWarranty()
+ case itemtemplate.FieldDefaultWarrantyDetails:
+ return m.DefaultWarrantyDetails()
+ case itemtemplate.FieldIncludeWarrantyFields:
+ return m.IncludeWarrantyFields()
+ case itemtemplate.FieldIncludePurchaseFields:
+ return m.IncludePurchaseFields()
+ case itemtemplate.FieldIncludeSoldFields:
+ return m.IncludeSoldFields()
+ case itemtemplate.FieldDefaultLabelIds:
+ return m.DefaultLabelIds()
+ }
+ return nil, false
+}
+
+// OldField returns the old value of the field from the database. An error is
+// returned if the mutation operation is not UpdateOne, or the query to the
+// database failed.
+func (m *ItemTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
+ switch name {
+ case itemtemplate.FieldCreatedAt:
+ return m.OldCreatedAt(ctx)
+ case itemtemplate.FieldUpdatedAt:
+ return m.OldUpdatedAt(ctx)
+ case itemtemplate.FieldName:
+ return m.OldName(ctx)
+ case itemtemplate.FieldDescription:
+ return m.OldDescription(ctx)
+ case itemtemplate.FieldNotes:
+ return m.OldNotes(ctx)
+ case itemtemplate.FieldDefaultQuantity:
+ return m.OldDefaultQuantity(ctx)
+ case itemtemplate.FieldDefaultInsured:
+ return m.OldDefaultInsured(ctx)
+ case itemtemplate.FieldDefaultName:
+ return m.OldDefaultName(ctx)
+ case itemtemplate.FieldDefaultDescription:
+ return m.OldDefaultDescription(ctx)
+ case itemtemplate.FieldDefaultManufacturer:
+ return m.OldDefaultManufacturer(ctx)
+ case itemtemplate.FieldDefaultModelNumber:
+ return m.OldDefaultModelNumber(ctx)
+ case itemtemplate.FieldDefaultLifetimeWarranty:
+ return m.OldDefaultLifetimeWarranty(ctx)
+ case itemtemplate.FieldDefaultWarrantyDetails:
+ return m.OldDefaultWarrantyDetails(ctx)
+ case itemtemplate.FieldIncludeWarrantyFields:
+ return m.OldIncludeWarrantyFields(ctx)
+ case itemtemplate.FieldIncludePurchaseFields:
+ return m.OldIncludePurchaseFields(ctx)
+ case itemtemplate.FieldIncludeSoldFields:
+ return m.OldIncludeSoldFields(ctx)
+ case itemtemplate.FieldDefaultLabelIds:
+ return m.OldDefaultLabelIds(ctx)
+ }
+ return nil, fmt.Errorf("unknown ItemTemplate field %s", name)
+}
+
+// SetField sets the value of a field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *ItemTemplateMutation) SetField(name string, value ent.Value) error {
+ switch name {
+ case itemtemplate.FieldCreatedAt:
+ v, ok := value.(time.Time)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetCreatedAt(v)
+ return nil
+ case itemtemplate.FieldUpdatedAt:
+ v, ok := value.(time.Time)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetUpdatedAt(v)
+ return nil
+ case itemtemplate.FieldName:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetName(v)
+ return nil
+ case itemtemplate.FieldDescription:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDescription(v)
+ return nil
+ case itemtemplate.FieldNotes:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetNotes(v)
+ return nil
+ case itemtemplate.FieldDefaultQuantity:
+ v, ok := value.(int)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDefaultQuantity(v)
+ return nil
+ case itemtemplate.FieldDefaultInsured:
+ v, ok := value.(bool)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDefaultInsured(v)
+ return nil
+ case itemtemplate.FieldDefaultName:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDefaultName(v)
+ return nil
+ case itemtemplate.FieldDefaultDescription:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDefaultDescription(v)
+ return nil
+ case itemtemplate.FieldDefaultManufacturer:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDefaultManufacturer(v)
+ return nil
+ case itemtemplate.FieldDefaultModelNumber:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDefaultModelNumber(v)
+ return nil
+ case itemtemplate.FieldDefaultLifetimeWarranty:
+ v, ok := value.(bool)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDefaultLifetimeWarranty(v)
+ return nil
+ case itemtemplate.FieldDefaultWarrantyDetails:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDefaultWarrantyDetails(v)
+ return nil
+ case itemtemplate.FieldIncludeWarrantyFields:
+ v, ok := value.(bool)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetIncludeWarrantyFields(v)
+ return nil
+ case itemtemplate.FieldIncludePurchaseFields:
+ v, ok := value.(bool)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetIncludePurchaseFields(v)
+ return nil
+ case itemtemplate.FieldIncludeSoldFields:
+ v, ok := value.(bool)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetIncludeSoldFields(v)
+ return nil
+ case itemtemplate.FieldDefaultLabelIds:
+ v, ok := value.([]uuid.UUID)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDefaultLabelIds(v)
+ return nil
+ }
+ return fmt.Errorf("unknown ItemTemplate field %s", name)
+}
+
+// AddedFields returns all numeric fields that were incremented/decremented during
+// this mutation.
+func (m *ItemTemplateMutation) AddedFields() []string {
+ var fields []string
+ if m.adddefault_quantity != nil {
+ fields = append(fields, itemtemplate.FieldDefaultQuantity)
+ }
+ return fields
+}
+
+// AddedField returns the numeric value that was incremented/decremented on a field
+// with the given name. The second boolean return value indicates that this field
+// was not set, or was not defined in the schema.
+func (m *ItemTemplateMutation) AddedField(name string) (ent.Value, bool) {
+ switch name {
+ case itemtemplate.FieldDefaultQuantity:
+ return m.AddedDefaultQuantity()
+ }
+ return nil, false
+}
+
+// AddField adds the value to the field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *ItemTemplateMutation) AddField(name string, value ent.Value) error {
+ switch name {
+ case itemtemplate.FieldDefaultQuantity:
+ v, ok := value.(int)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.AddDefaultQuantity(v)
+ return nil
+ }
+ return fmt.Errorf("unknown ItemTemplate numeric field %s", name)
+}
+
+// ClearedFields returns all nullable fields that were cleared during this
+// mutation.
+func (m *ItemTemplateMutation) ClearedFields() []string {
+ var fields []string
+ if m.FieldCleared(itemtemplate.FieldDescription) {
+ fields = append(fields, itemtemplate.FieldDescription)
+ }
+ if m.FieldCleared(itemtemplate.FieldNotes) {
+ fields = append(fields, itemtemplate.FieldNotes)
+ }
+ if m.FieldCleared(itemtemplate.FieldDefaultName) {
+ fields = append(fields, itemtemplate.FieldDefaultName)
+ }
+ if m.FieldCleared(itemtemplate.FieldDefaultDescription) {
+ fields = append(fields, itemtemplate.FieldDefaultDescription)
+ }
+ if m.FieldCleared(itemtemplate.FieldDefaultManufacturer) {
+ fields = append(fields, itemtemplate.FieldDefaultManufacturer)
+ }
+ if m.FieldCleared(itemtemplate.FieldDefaultModelNumber) {
+ fields = append(fields, itemtemplate.FieldDefaultModelNumber)
+ }
+ if m.FieldCleared(itemtemplate.FieldDefaultWarrantyDetails) {
+ fields = append(fields, itemtemplate.FieldDefaultWarrantyDetails)
+ }
+ if m.FieldCleared(itemtemplate.FieldDefaultLabelIds) {
+ fields = append(fields, itemtemplate.FieldDefaultLabelIds)
+ }
+ return fields
+}
+
+// FieldCleared returns a boolean indicating if a field with the given name was
+// cleared in this mutation.
+func (m *ItemTemplateMutation) FieldCleared(name string) bool {
+ _, ok := m.clearedFields[name]
+ return ok
+}
+
+// ClearField clears the value of the field with the given name. It returns an
+// error if the field is not defined in the schema.
+func (m *ItemTemplateMutation) ClearField(name string) error {
+ switch name {
+ case itemtemplate.FieldDescription:
+ m.ClearDescription()
+ return nil
+ case itemtemplate.FieldNotes:
+ m.ClearNotes()
+ return nil
+ case itemtemplate.FieldDefaultName:
+ m.ClearDefaultName()
+ return nil
+ case itemtemplate.FieldDefaultDescription:
+ m.ClearDefaultDescription()
+ return nil
+ case itemtemplate.FieldDefaultManufacturer:
+ m.ClearDefaultManufacturer()
+ return nil
+ case itemtemplate.FieldDefaultModelNumber:
+ m.ClearDefaultModelNumber()
+ return nil
+ case itemtemplate.FieldDefaultWarrantyDetails:
+ m.ClearDefaultWarrantyDetails()
+ return nil
+ case itemtemplate.FieldDefaultLabelIds:
+ m.ClearDefaultLabelIds()
+ return nil
+ }
+ return fmt.Errorf("unknown ItemTemplate nullable field %s", name)
+}
+
+// ResetField resets all changes in the mutation for the field with the given name.
+// It returns an error if the field is not defined in the schema.
+func (m *ItemTemplateMutation) ResetField(name string) error {
+ switch name {
+ case itemtemplate.FieldCreatedAt:
+ m.ResetCreatedAt()
+ return nil
+ case itemtemplate.FieldUpdatedAt:
+ m.ResetUpdatedAt()
+ return nil
+ case itemtemplate.FieldName:
+ m.ResetName()
+ return nil
+ case itemtemplate.FieldDescription:
+ m.ResetDescription()
+ return nil
+ case itemtemplate.FieldNotes:
+ m.ResetNotes()
+ return nil
+ case itemtemplate.FieldDefaultQuantity:
+ m.ResetDefaultQuantity()
+ return nil
+ case itemtemplate.FieldDefaultInsured:
+ m.ResetDefaultInsured()
+ return nil
+ case itemtemplate.FieldDefaultName:
+ m.ResetDefaultName()
+ return nil
+ case itemtemplate.FieldDefaultDescription:
+ m.ResetDefaultDescription()
+ return nil
+ case itemtemplate.FieldDefaultManufacturer:
+ m.ResetDefaultManufacturer()
+ return nil
+ case itemtemplate.FieldDefaultModelNumber:
+ m.ResetDefaultModelNumber()
+ return nil
+ case itemtemplate.FieldDefaultLifetimeWarranty:
+ m.ResetDefaultLifetimeWarranty()
+ return nil
+ case itemtemplate.FieldDefaultWarrantyDetails:
+ m.ResetDefaultWarrantyDetails()
+ return nil
+ case itemtemplate.FieldIncludeWarrantyFields:
+ m.ResetIncludeWarrantyFields()
+ return nil
+ case itemtemplate.FieldIncludePurchaseFields:
+ m.ResetIncludePurchaseFields()
+ return nil
+ case itemtemplate.FieldIncludeSoldFields:
+ m.ResetIncludeSoldFields()
+ return nil
+ case itemtemplate.FieldDefaultLabelIds:
+ m.ResetDefaultLabelIds()
+ return nil
+ }
+ return fmt.Errorf("unknown ItemTemplate field %s", name)
+}
+
+// AddedEdges returns all edge names that were set/added in this mutation.
+func (m *ItemTemplateMutation) AddedEdges() []string {
+ edges := make([]string, 0, 3)
+ if m.group != nil {
+ edges = append(edges, itemtemplate.EdgeGroup)
+ }
+ if m.fields != nil {
+ edges = append(edges, itemtemplate.EdgeFields)
+ }
+ if m.location != nil {
+ edges = append(edges, itemtemplate.EdgeLocation)
+ }
+ return edges
+}
+
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
+// name in this mutation.
+func (m *ItemTemplateMutation) AddedIDs(name string) []ent.Value {
+ switch name {
+ case itemtemplate.EdgeGroup:
+ if id := m.group; id != nil {
+ return []ent.Value{*id}
+ }
+ case itemtemplate.EdgeFields:
+ ids := make([]ent.Value, 0, len(m.fields))
+ for id := range m.fields {
+ ids = append(ids, id)
+ }
+ return ids
+ case itemtemplate.EdgeLocation:
+ if id := m.location; id != nil {
+ return []ent.Value{*id}
+ }
+ }
+ return nil
+}
+
+// RemovedEdges returns all edge names that were removed in this mutation.
+func (m *ItemTemplateMutation) RemovedEdges() []string {
+ edges := make([]string, 0, 3)
+ if m.removedfields != nil {
+ edges = append(edges, itemtemplate.EdgeFields)
+ }
+ return edges
+}
+
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
+// the given name in this mutation.
+func (m *ItemTemplateMutation) RemovedIDs(name string) []ent.Value {
+ switch name {
+ case itemtemplate.EdgeFields:
+ ids := make([]ent.Value, 0, len(m.removedfields))
+ for id := range m.removedfields {
+ ids = append(ids, id)
+ }
+ return ids
+ }
+ return nil
+}
+
+// ClearedEdges returns all edge names that were cleared in this mutation.
+func (m *ItemTemplateMutation) ClearedEdges() []string {
+ edges := make([]string, 0, 3)
+ if m.clearedgroup {
+ edges = append(edges, itemtemplate.EdgeGroup)
+ }
+ if m.clearedfields {
+ edges = append(edges, itemtemplate.EdgeFields)
+ }
+ if m.clearedlocation {
+ edges = append(edges, itemtemplate.EdgeLocation)
+ }
+ return edges
+}
+
+// EdgeCleared returns a boolean which indicates if the edge with the given name
+// was cleared in this mutation.
+func (m *ItemTemplateMutation) EdgeCleared(name string) bool {
+ switch name {
+ case itemtemplate.EdgeGroup:
+ return m.clearedgroup
+ case itemtemplate.EdgeFields:
+ return m.clearedfields
+ case itemtemplate.EdgeLocation:
+ return m.clearedlocation
+ }
+ return false
+}
+
+// ClearEdge clears the value of the edge with the given name. It returns an error
+// if that edge is not defined in the schema.
+func (m *ItemTemplateMutation) ClearEdge(name string) error {
+ switch name {
+ case itemtemplate.EdgeGroup:
+ m.ClearGroup()
+ return nil
+ case itemtemplate.EdgeLocation:
+ m.ClearLocation()
+ return nil
+ }
+ return fmt.Errorf("unknown ItemTemplate unique edge %s", name)
+}
+
+// ResetEdge resets all changes to the edge with the given name in this mutation.
+// It returns an error if the edge is not defined in the schema.
+func (m *ItemTemplateMutation) ResetEdge(name string) error {
+ switch name {
+ case itemtemplate.EdgeGroup:
+ m.ResetGroup()
+ return nil
+ case itemtemplate.EdgeFields:
+ m.ResetFields()
+ return nil
+ case itemtemplate.EdgeLocation:
+ m.ResetLocation()
+ return nil
+ }
+ return fmt.Errorf("unknown ItemTemplate edge %s", name)
+}
+
+// LabelMutation represents an operation that mutates the Label nodes in the graph.
+type LabelMutation struct {
+ config
+ op Op
+ typ string
+ id *uuid.UUID
+ created_at *time.Time
+ updated_at *time.Time
+ name *string
+ description *string
+ color *string
+ clearedFields map[string]struct{}
+ group *uuid.UUID
+ clearedgroup bool
+ items map[uuid.UUID]struct{}
+ removeditems map[uuid.UUID]struct{}
+ cleareditems bool
+ done bool
+ oldValue func(context.Context) (*Label, error)
+ predicates []predicate.Label
+}
+
+var _ ent.Mutation = (*LabelMutation)(nil)
+
+// labelOption allows management of the mutation configuration using functional options.
+type labelOption func(*LabelMutation)
+
+// newLabelMutation creates new mutation for the Label entity.
+func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
+ m := &LabelMutation{
+ config: c,
+ op: op,
+ typ: TypeLabel,
+ clearedFields: make(map[string]struct{}),
+ }
+ for _, opt := range opts {
+ opt(m)
+ }
+ return m
+}
+
+// withLabelID sets the ID field of the mutation.
+func withLabelID(id uuid.UUID) labelOption {
+ return func(m *LabelMutation) {
+ var (
+ err error
+ once sync.Once
+ value *Label
+ )
+ m.oldValue = func(ctx context.Context) (*Label, error) {
+ once.Do(func() {
+ if m.done {
+ err = errors.New("querying old values post mutation is not allowed")
+ } else {
+ value, err = m.Client().Label.Get(ctx, id)
+ }
+ })
+ return value, err
+ }
+ m.id = &id
+ }
+}
+
+// withLabel sets the old Label of the mutation.
+func withLabel(node *Label) labelOption {
+ return func(m *LabelMutation) {
+ m.oldValue = func(context.Context) (*Label, error) {
+ return node, nil
+ }
+ m.id = &node.ID
+ }
+}
+
+// Client returns a new `ent.Client` from the mutation. If the mutation was
+// executed in a transaction (ent.Tx), a transactional client is returned.
+func (m LabelMutation) Client() *Client {
+ client := &Client{config: m.config}
+ client.init()
+ return client
+}
+
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
+// it returns an error otherwise.
+func (m LabelMutation) Tx() (*Tx, error) {
+ if _, ok := m.driver.(*txDriver); !ok {
+ return nil, errors.New("ent: mutation is not running in a transaction")
+ }
+ tx := &Tx{config: m.config}
+ tx.init()
+ return tx, nil
+}
+
+// SetID sets the value of the id field. Note that this
+// operation is only accepted on creation of Label entities.
+func (m *LabelMutation) SetID(id uuid.UUID) {
+ m.id = &id
+}
+
+// ID returns the ID value in the mutation. Note that the ID is only available
+// if it was provided to the builder or after it was returned from the database.
+func (m *LabelMutation) ID() (id uuid.UUID, exists bool) {
+ if m.id == nil {
+ return
+ }
+ return *m.id, true
+}
+
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
+// That means, if the mutation is applied within a transaction with an isolation level such
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
+// or updated by the mutation.
+func (m *LabelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
+ switch {
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
+ id, exists := m.ID()
+ if exists {
+ return []uuid.UUID{id}, nil
+ }
+ fallthrough
+ case m.op.Is(OpUpdate | OpDelete):
+ return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
+ default:
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
+ }
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (m *LabelMutation) SetCreatedAt(t time.Time) {
+ m.created_at = &t
+}
+
+// CreatedAt returns the value of the "created_at" field in the mutation.
+func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
+ v := m.created_at
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldCreatedAt returns the old "created_at" field's value of the Label entity.
+// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
+ }
+ return oldValue.CreatedAt, nil
+}
+
+// ResetCreatedAt resets all changes to the "created_at" field.
+func (m *LabelMutation) ResetCreatedAt() {
+ m.created_at = nil
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (m *LabelMutation) SetUpdatedAt(t time.Time) {
+ m.updated_at = &t
+}
+
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
+func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
+ v := m.updated_at
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
+// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
+ }
+ return oldValue.UpdatedAt, nil
+}
+
+// ResetUpdatedAt resets all changes to the "updated_at" field.
+func (m *LabelMutation) ResetUpdatedAt() {
+ m.updated_at = nil
+}
+
+// SetName sets the "name" field.
+func (m *LabelMutation) SetName(s string) {
+ m.name = &s
+}
+
+// Name returns the value of the "name" field in the mutation.
+func (m *LabelMutation) Name() (r string, exists bool) {
+ v := m.name
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldName returns the old "name" field's value of the Label entity.
+// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldName is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldName requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldName: %w", err)
+ }
+ return oldValue.Name, nil
+}
+
+// ResetName resets all changes to the "name" field.
+func (m *LabelMutation) ResetName() {
+ m.name = nil
+}
+
+// SetDescription sets the "description" field.
+func (m *LabelMutation) SetDescription(s string) {
+ m.description = &s
+}
+
+// Description returns the value of the "description" field in the mutation.
+func (m *LabelMutation) Description() (r string, exists bool) {
+ v := m.description
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldDescription returns the old "description" field's value of the Label entity.
+// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *LabelMutation) OldDescription(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDescription is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDescription requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDescription: %w", err)
+ }
+ return oldValue.Description, nil
+}
+
+// ClearDescription clears the value of the "description" field.
+func (m *LabelMutation) ClearDescription() {
+ m.description = nil
+ m.clearedFields[label.FieldDescription] = struct{}{}
+}
+
+// DescriptionCleared returns if the "description" field was cleared in this mutation.
+func (m *LabelMutation) DescriptionCleared() bool {
+ _, ok := m.clearedFields[label.FieldDescription]
+ return ok
+}
+
+// ResetDescription resets all changes to the "description" field.
+func (m *LabelMutation) ResetDescription() {
+ m.description = nil
+ delete(m.clearedFields, label.FieldDescription)
+}
+
+// SetColor sets the "color" field.
+func (m *LabelMutation) SetColor(s string) {
+ m.color = &s
+}
+
+// Color returns the value of the "color" field in the mutation.
+func (m *LabelMutation) Color() (r string, exists bool) {
+ v := m.color
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldColor returns the old "color" field's value of the Label entity.
+// If the Label object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *LabelMutation) OldColor(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldColor is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldColor requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldColor: %w", err)
+ }
+ return oldValue.Color, nil
+}
+
+// ClearColor clears the value of the "color" field.
+func (m *LabelMutation) ClearColor() {
+ m.color = nil
+ m.clearedFields[label.FieldColor] = struct{}{}
+}
+
+// ColorCleared returns if the "color" field was cleared in this mutation.
+func (m *LabelMutation) ColorCleared() bool {
+ _, ok := m.clearedFields[label.FieldColor]
+ return ok
+}
+
+// ResetColor resets all changes to the "color" field.
+func (m *LabelMutation) ResetColor() {
+ m.color = nil
+ delete(m.clearedFields, label.FieldColor)
+}
+
+// SetGroupID sets the "group" edge to the Group entity by id.
+func (m *LabelMutation) SetGroupID(id uuid.UUID) {
+ m.group = &id
+}
+
+// ClearGroup clears the "group" edge to the Group entity.
+func (m *LabelMutation) ClearGroup() {
+ m.clearedgroup = true
+}
+
+// GroupCleared reports if the "group" edge to the Group entity was cleared.
+func (m *LabelMutation) GroupCleared() bool {
+ return m.clearedgroup
+}
+
+// GroupID returns the "group" edge ID in the mutation.
+func (m *LabelMutation) GroupID() (id uuid.UUID, exists bool) {
+ if m.group != nil {
+ return *m.group, true
+ }
+ return
+}
+
+// GroupIDs returns the "group" edge IDs in the mutation.
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
+// GroupID instead. It exists only for internal usage by the builders.
+func (m *LabelMutation) GroupIDs() (ids []uuid.UUID) {
+ if id := m.group; id != nil {
+ ids = append(ids, *id)
+ }
+ return
+}
+
+// ResetGroup resets all changes to the "group" edge.
+func (m *LabelMutation) ResetGroup() {
+ m.group = nil
+ m.clearedgroup = false
+}
+
+// AddItemIDs adds the "items" edge to the Item entity by ids.
+func (m *LabelMutation) AddItemIDs(ids ...uuid.UUID) {
+ if m.items == nil {
+ m.items = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ m.items[ids[i]] = struct{}{}
+ }
+}
+
+// ClearItems clears the "items" edge to the Item entity.
+func (m *LabelMutation) ClearItems() {
+ m.cleareditems = true
+}
+
+// ItemsCleared reports if the "items" edge to the Item entity was cleared.
+func (m *LabelMutation) ItemsCleared() bool {
+ return m.cleareditems
+}
+
+// RemoveItemIDs removes the "items" edge to the Item entity by IDs.
+func (m *LabelMutation) RemoveItemIDs(ids ...uuid.UUID) {
+ if m.removeditems == nil {
+ m.removeditems = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ delete(m.items, ids[i])
+ m.removeditems[ids[i]] = struct{}{}
+ }
+}
+
+// RemovedItems returns the removed IDs of the "items" edge to the Item entity.
+func (m *LabelMutation) RemovedItemsIDs() (ids []uuid.UUID) {
+ for id := range m.removeditems {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// ItemsIDs returns the "items" edge IDs in the mutation.
+func (m *LabelMutation) ItemsIDs() (ids []uuid.UUID) {
+ for id := range m.items {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// ResetItems resets all changes to the "items" edge.
+func (m *LabelMutation) ResetItems() {
+ m.items = nil
+ m.cleareditems = false
+ m.removeditems = nil
+}
+
+// Where appends a list predicates to the LabelMutation builder.
+func (m *LabelMutation) Where(ps ...predicate.Label) {
+ m.predicates = append(m.predicates, ps...)
+}
+
+// WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
+// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Label, len(ps))
for i := range ps {
@@ -7428,39 +9130,825 @@ func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
}
// Op returns the operation name.
-func (m *LabelMutation) Op() Op {
+func (m *LabelMutation) Op() Op {
+ return m.op
+}
+
+// SetOp allows setting the mutation operation.
+func (m *LabelMutation) SetOp(op Op) {
+ m.op = op
+}
+
+// Type returns the node type of this mutation (Label).
+func (m *LabelMutation) Type() string {
+ return m.typ
+}
+
+// Fields returns all fields that were changed during this mutation. Note that in
+// order to get all numeric fields that were incremented/decremented, call
+// AddedFields().
+func (m *LabelMutation) Fields() []string {
+ fields := make([]string, 0, 5)
+ if m.created_at != nil {
+ fields = append(fields, label.FieldCreatedAt)
+ }
+ if m.updated_at != nil {
+ fields = append(fields, label.FieldUpdatedAt)
+ }
+ if m.name != nil {
+ fields = append(fields, label.FieldName)
+ }
+ if m.description != nil {
+ fields = append(fields, label.FieldDescription)
+ }
+ if m.color != nil {
+ fields = append(fields, label.FieldColor)
+ }
+ return fields
+}
+
+// Field returns the value of a field with the given name. The second boolean
+// return value indicates that this field was not set, or was not defined in the
+// schema.
+func (m *LabelMutation) Field(name string) (ent.Value, bool) {
+ switch name {
+ case label.FieldCreatedAt:
+ return m.CreatedAt()
+ case label.FieldUpdatedAt:
+ return m.UpdatedAt()
+ case label.FieldName:
+ return m.Name()
+ case label.FieldDescription:
+ return m.Description()
+ case label.FieldColor:
+ return m.Color()
+ }
+ return nil, false
+}
+
+// OldField returns the old value of the field from the database. An error is
+// returned if the mutation operation is not UpdateOne, or the query to the
+// database failed.
+func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
+ switch name {
+ case label.FieldCreatedAt:
+ return m.OldCreatedAt(ctx)
+ case label.FieldUpdatedAt:
+ return m.OldUpdatedAt(ctx)
+ case label.FieldName:
+ return m.OldName(ctx)
+ case label.FieldDescription:
+ return m.OldDescription(ctx)
+ case label.FieldColor:
+ return m.OldColor(ctx)
+ }
+ return nil, fmt.Errorf("unknown Label field %s", name)
+}
+
+// SetField sets the value of a field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *LabelMutation) SetField(name string, value ent.Value) error {
+ switch name {
+ case label.FieldCreatedAt:
+ v, ok := value.(time.Time)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetCreatedAt(v)
+ return nil
+ case label.FieldUpdatedAt:
+ v, ok := value.(time.Time)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetUpdatedAt(v)
+ return nil
+ case label.FieldName:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetName(v)
+ return nil
+ case label.FieldDescription:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDescription(v)
+ return nil
+ case label.FieldColor:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetColor(v)
+ return nil
+ }
+ return fmt.Errorf("unknown Label field %s", name)
+}
+
+// AddedFields returns all numeric fields that were incremented/decremented during
+// this mutation.
+func (m *LabelMutation) AddedFields() []string {
+ return nil
+}
+
+// AddedField returns the numeric value that was incremented/decremented on a field
+// with the given name. The second boolean return value indicates that this field
+// was not set, or was not defined in the schema.
+func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
+ return nil, false
+}
+
+// AddField adds the value to the field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *LabelMutation) AddField(name string, value ent.Value) error {
+ switch name {
+ }
+ return fmt.Errorf("unknown Label numeric field %s", name)
+}
+
+// ClearedFields returns all nullable fields that were cleared during this
+// mutation.
+func (m *LabelMutation) ClearedFields() []string {
+ var fields []string
+ if m.FieldCleared(label.FieldDescription) {
+ fields = append(fields, label.FieldDescription)
+ }
+ if m.FieldCleared(label.FieldColor) {
+ fields = append(fields, label.FieldColor)
+ }
+ return fields
+}
+
+// FieldCleared returns a boolean indicating if a field with the given name was
+// cleared in this mutation.
+func (m *LabelMutation) FieldCleared(name string) bool {
+ _, ok := m.clearedFields[name]
+ return ok
+}
+
+// ClearField clears the value of the field with the given name. It returns an
+// error if the field is not defined in the schema.
+func (m *LabelMutation) ClearField(name string) error {
+ switch name {
+ case label.FieldDescription:
+ m.ClearDescription()
+ return nil
+ case label.FieldColor:
+ m.ClearColor()
+ return nil
+ }
+ return fmt.Errorf("unknown Label nullable field %s", name)
+}
+
+// ResetField resets all changes in the mutation for the field with the given name.
+// It returns an error if the field is not defined in the schema.
+func (m *LabelMutation) ResetField(name string) error {
+ switch name {
+ case label.FieldCreatedAt:
+ m.ResetCreatedAt()
+ return nil
+ case label.FieldUpdatedAt:
+ m.ResetUpdatedAt()
+ return nil
+ case label.FieldName:
+ m.ResetName()
+ return nil
+ case label.FieldDescription:
+ m.ResetDescription()
+ return nil
+ case label.FieldColor:
+ m.ResetColor()
+ return nil
+ }
+ return fmt.Errorf("unknown Label field %s", name)
+}
+
+// AddedEdges returns all edge names that were set/added in this mutation.
+func (m *LabelMutation) AddedEdges() []string {
+ edges := make([]string, 0, 2)
+ if m.group != nil {
+ edges = append(edges, label.EdgeGroup)
+ }
+ if m.items != nil {
+ edges = append(edges, label.EdgeItems)
+ }
+ return edges
+}
+
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
+// name in this mutation.
+func (m *LabelMutation) AddedIDs(name string) []ent.Value {
+ switch name {
+ case label.EdgeGroup:
+ if id := m.group; id != nil {
+ return []ent.Value{*id}
+ }
+ case label.EdgeItems:
+ ids := make([]ent.Value, 0, len(m.items))
+ for id := range m.items {
+ ids = append(ids, id)
+ }
+ return ids
+ }
+ return nil
+}
+
+// RemovedEdges returns all edge names that were removed in this mutation.
+func (m *LabelMutation) RemovedEdges() []string {
+ edges := make([]string, 0, 2)
+ if m.removeditems != nil {
+ edges = append(edges, label.EdgeItems)
+ }
+ return edges
+}
+
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
+// the given name in this mutation.
+func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
+ switch name {
+ case label.EdgeItems:
+ ids := make([]ent.Value, 0, len(m.removeditems))
+ for id := range m.removeditems {
+ ids = append(ids, id)
+ }
+ return ids
+ }
+ return nil
+}
+
+// ClearedEdges returns all edge names that were cleared in this mutation.
+func (m *LabelMutation) ClearedEdges() []string {
+ edges := make([]string, 0, 2)
+ if m.clearedgroup {
+ edges = append(edges, label.EdgeGroup)
+ }
+ if m.cleareditems {
+ edges = append(edges, label.EdgeItems)
+ }
+ return edges
+}
+
+// EdgeCleared returns a boolean which indicates if the edge with the given name
+// was cleared in this mutation.
+func (m *LabelMutation) EdgeCleared(name string) bool {
+ switch name {
+ case label.EdgeGroup:
+ return m.clearedgroup
+ case label.EdgeItems:
+ return m.cleareditems
+ }
+ return false
+}
+
+// ClearEdge clears the value of the edge with the given name. It returns an error
+// if that edge is not defined in the schema.
+func (m *LabelMutation) ClearEdge(name string) error {
+ switch name {
+ case label.EdgeGroup:
+ m.ClearGroup()
+ return nil
+ }
+ return fmt.Errorf("unknown Label unique edge %s", name)
+}
+
+// ResetEdge resets all changes to the edge with the given name in this mutation.
+// It returns an error if the edge is not defined in the schema.
+func (m *LabelMutation) ResetEdge(name string) error {
+ switch name {
+ case label.EdgeGroup:
+ m.ResetGroup()
+ return nil
+ case label.EdgeItems:
+ m.ResetItems()
+ return nil
+ }
+ return fmt.Errorf("unknown Label edge %s", name)
+}
+
+// LocationMutation represents an operation that mutates the Location nodes in the graph.
+type LocationMutation struct {
+ config
+ op Op
+ typ string
+ id *uuid.UUID
+ created_at *time.Time
+ updated_at *time.Time
+ name *string
+ description *string
+ clearedFields map[string]struct{}
+ group *uuid.UUID
+ clearedgroup bool
+ parent *uuid.UUID
+ clearedparent bool
+ children map[uuid.UUID]struct{}
+ removedchildren map[uuid.UUID]struct{}
+ clearedchildren bool
+ items map[uuid.UUID]struct{}
+ removeditems map[uuid.UUID]struct{}
+ cleareditems bool
+ done bool
+ oldValue func(context.Context) (*Location, error)
+ predicates []predicate.Location
+}
+
+var _ ent.Mutation = (*LocationMutation)(nil)
+
+// locationOption allows management of the mutation configuration using functional options.
+type locationOption func(*LocationMutation)
+
+// newLocationMutation creates new mutation for the Location entity.
+func newLocationMutation(c config, op Op, opts ...locationOption) *LocationMutation {
+ m := &LocationMutation{
+ config: c,
+ op: op,
+ typ: TypeLocation,
+ clearedFields: make(map[string]struct{}),
+ }
+ for _, opt := range opts {
+ opt(m)
+ }
+ return m
+}
+
+// withLocationID sets the ID field of the mutation.
+func withLocationID(id uuid.UUID) locationOption {
+ return func(m *LocationMutation) {
+ var (
+ err error
+ once sync.Once
+ value *Location
+ )
+ m.oldValue = func(ctx context.Context) (*Location, error) {
+ once.Do(func() {
+ if m.done {
+ err = errors.New("querying old values post mutation is not allowed")
+ } else {
+ value, err = m.Client().Location.Get(ctx, id)
+ }
+ })
+ return value, err
+ }
+ m.id = &id
+ }
+}
+
+// withLocation sets the old Location of the mutation.
+func withLocation(node *Location) locationOption {
+ return func(m *LocationMutation) {
+ m.oldValue = func(context.Context) (*Location, error) {
+ return node, nil
+ }
+ m.id = &node.ID
+ }
+}
+
+// Client returns a new `ent.Client` from the mutation. If the mutation was
+// executed in a transaction (ent.Tx), a transactional client is returned.
+func (m LocationMutation) Client() *Client {
+ client := &Client{config: m.config}
+ client.init()
+ return client
+}
+
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
+// it returns an error otherwise.
+func (m LocationMutation) Tx() (*Tx, error) {
+ if _, ok := m.driver.(*txDriver); !ok {
+ return nil, errors.New("ent: mutation is not running in a transaction")
+ }
+ tx := &Tx{config: m.config}
+ tx.init()
+ return tx, nil
+}
+
+// SetID sets the value of the id field. Note that this
+// operation is only accepted on creation of Location entities.
+func (m *LocationMutation) SetID(id uuid.UUID) {
+ m.id = &id
+}
+
+// ID returns the ID value in the mutation. Note that the ID is only available
+// if it was provided to the builder or after it was returned from the database.
+func (m *LocationMutation) ID() (id uuid.UUID, exists bool) {
+ if m.id == nil {
+ return
+ }
+ return *m.id, true
+}
+
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
+// That means, if the mutation is applied within a transaction with an isolation level such
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
+// or updated by the mutation.
+func (m *LocationMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
+ switch {
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
+ id, exists := m.ID()
+ if exists {
+ return []uuid.UUID{id}, nil
+ }
+ fallthrough
+ case m.op.Is(OpUpdate | OpDelete):
+ return m.Client().Location.Query().Where(m.predicates...).IDs(ctx)
+ default:
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
+ }
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (m *LocationMutation) SetCreatedAt(t time.Time) {
+ m.created_at = &t
+}
+
+// CreatedAt returns the value of the "created_at" field in the mutation.
+func (m *LocationMutation) CreatedAt() (r time.Time, exists bool) {
+ v := m.created_at
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldCreatedAt returns the old "created_at" field's value of the Location entity.
+// If the Location object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *LocationMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
+ }
+ return oldValue.CreatedAt, nil
+}
+
+// ResetCreatedAt resets all changes to the "created_at" field.
+func (m *LocationMutation) ResetCreatedAt() {
+ m.created_at = nil
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (m *LocationMutation) SetUpdatedAt(t time.Time) {
+ m.updated_at = &t
+}
+
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
+func (m *LocationMutation) UpdatedAt() (r time.Time, exists bool) {
+ v := m.updated_at
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldUpdatedAt returns the old "updated_at" field's value of the Location entity.
+// If the Location object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *LocationMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
+ }
+ return oldValue.UpdatedAt, nil
+}
+
+// ResetUpdatedAt resets all changes to the "updated_at" field.
+func (m *LocationMutation) ResetUpdatedAt() {
+ m.updated_at = nil
+}
+
+// SetName sets the "name" field.
+func (m *LocationMutation) SetName(s string) {
+ m.name = &s
+}
+
+// Name returns the value of the "name" field in the mutation.
+func (m *LocationMutation) Name() (r string, exists bool) {
+ v := m.name
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldName returns the old "name" field's value of the Location entity.
+// If the Location object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *LocationMutation) OldName(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldName is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldName requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldName: %w", err)
+ }
+ return oldValue.Name, nil
+}
+
+// ResetName resets all changes to the "name" field.
+func (m *LocationMutation) ResetName() {
+ m.name = nil
+}
+
+// SetDescription sets the "description" field.
+func (m *LocationMutation) SetDescription(s string) {
+ m.description = &s
+}
+
+// Description returns the value of the "description" field in the mutation.
+func (m *LocationMutation) Description() (r string, exists bool) {
+ v := m.description
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldDescription returns the old "description" field's value of the Location entity.
+// If the Location object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *LocationMutation) OldDescription(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDescription is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDescription requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDescription: %w", err)
+ }
+ return oldValue.Description, nil
+}
+
+// ClearDescription clears the value of the "description" field.
+func (m *LocationMutation) ClearDescription() {
+ m.description = nil
+ m.clearedFields[location.FieldDescription] = struct{}{}
+}
+
+// DescriptionCleared returns if the "description" field was cleared in this mutation.
+func (m *LocationMutation) DescriptionCleared() bool {
+ _, ok := m.clearedFields[location.FieldDescription]
+ return ok
+}
+
+// ResetDescription resets all changes to the "description" field.
+func (m *LocationMutation) ResetDescription() {
+ m.description = nil
+ delete(m.clearedFields, location.FieldDescription)
+}
+
+// SetGroupID sets the "group" edge to the Group entity by id.
+func (m *LocationMutation) SetGroupID(id uuid.UUID) {
+ m.group = &id
+}
+
+// ClearGroup clears the "group" edge to the Group entity.
+func (m *LocationMutation) ClearGroup() {
+ m.clearedgroup = true
+}
+
+// GroupCleared reports if the "group" edge to the Group entity was cleared.
+func (m *LocationMutation) GroupCleared() bool {
+ return m.clearedgroup
+}
+
+// GroupID returns the "group" edge ID in the mutation.
+func (m *LocationMutation) GroupID() (id uuid.UUID, exists bool) {
+ if m.group != nil {
+ return *m.group, true
+ }
+ return
+}
+
+// GroupIDs returns the "group" edge IDs in the mutation.
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
+// GroupID instead. It exists only for internal usage by the builders.
+func (m *LocationMutation) GroupIDs() (ids []uuid.UUID) {
+ if id := m.group; id != nil {
+ ids = append(ids, *id)
+ }
+ return
+}
+
+// ResetGroup resets all changes to the "group" edge.
+func (m *LocationMutation) ResetGroup() {
+ m.group = nil
+ m.clearedgroup = false
+}
+
+// SetParentID sets the "parent" edge to the Location entity by id.
+func (m *LocationMutation) SetParentID(id uuid.UUID) {
+ m.parent = &id
+}
+
+// ClearParent clears the "parent" edge to the Location entity.
+func (m *LocationMutation) ClearParent() {
+ m.clearedparent = true
+}
+
+// ParentCleared reports if the "parent" edge to the Location entity was cleared.
+func (m *LocationMutation) ParentCleared() bool {
+ return m.clearedparent
+}
+
+// ParentID returns the "parent" edge ID in the mutation.
+func (m *LocationMutation) ParentID() (id uuid.UUID, exists bool) {
+ if m.parent != nil {
+ return *m.parent, true
+ }
+ return
+}
+
+// ParentIDs returns the "parent" edge IDs in the mutation.
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
+// ParentID instead. It exists only for internal usage by the builders.
+func (m *LocationMutation) ParentIDs() (ids []uuid.UUID) {
+ if id := m.parent; id != nil {
+ ids = append(ids, *id)
+ }
+ return
+}
+
+// ResetParent resets all changes to the "parent" edge.
+func (m *LocationMutation) ResetParent() {
+ m.parent = nil
+ m.clearedparent = false
+}
+
+// AddChildIDs adds the "children" edge to the Location entity by ids.
+func (m *LocationMutation) AddChildIDs(ids ...uuid.UUID) {
+ if m.children == nil {
+ m.children = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ m.children[ids[i]] = struct{}{}
+ }
+}
+
+// ClearChildren clears the "children" edge to the Location entity.
+func (m *LocationMutation) ClearChildren() {
+ m.clearedchildren = true
+}
+
+// ChildrenCleared reports if the "children" edge to the Location entity was cleared.
+func (m *LocationMutation) ChildrenCleared() bool {
+ return m.clearedchildren
+}
+
+// RemoveChildIDs removes the "children" edge to the Location entity by IDs.
+func (m *LocationMutation) RemoveChildIDs(ids ...uuid.UUID) {
+ if m.removedchildren == nil {
+ m.removedchildren = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ delete(m.children, ids[i])
+ m.removedchildren[ids[i]] = struct{}{}
+ }
+}
+
+// RemovedChildren returns the removed IDs of the "children" edge to the Location entity.
+func (m *LocationMutation) RemovedChildrenIDs() (ids []uuid.UUID) {
+ for id := range m.removedchildren {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// ChildrenIDs returns the "children" edge IDs in the mutation.
+func (m *LocationMutation) ChildrenIDs() (ids []uuid.UUID) {
+ for id := range m.children {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// ResetChildren resets all changes to the "children" edge.
+func (m *LocationMutation) ResetChildren() {
+ m.children = nil
+ m.clearedchildren = false
+ m.removedchildren = nil
+}
+
+// AddItemIDs adds the "items" edge to the Item entity by ids.
+func (m *LocationMutation) AddItemIDs(ids ...uuid.UUID) {
+ if m.items == nil {
+ m.items = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ m.items[ids[i]] = struct{}{}
+ }
+}
+
+// ClearItems clears the "items" edge to the Item entity.
+func (m *LocationMutation) ClearItems() {
+ m.cleareditems = true
+}
+
+// ItemsCleared reports if the "items" edge to the Item entity was cleared.
+func (m *LocationMutation) ItemsCleared() bool {
+ return m.cleareditems
+}
+
+// RemoveItemIDs removes the "items" edge to the Item entity by IDs.
+func (m *LocationMutation) RemoveItemIDs(ids ...uuid.UUID) {
+ if m.removeditems == nil {
+ m.removeditems = make(map[uuid.UUID]struct{})
+ }
+ for i := range ids {
+ delete(m.items, ids[i])
+ m.removeditems[ids[i]] = struct{}{}
+ }
+}
+
+// RemovedItems returns the removed IDs of the "items" edge to the Item entity.
+func (m *LocationMutation) RemovedItemsIDs() (ids []uuid.UUID) {
+ for id := range m.removeditems {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// ItemsIDs returns the "items" edge IDs in the mutation.
+func (m *LocationMutation) ItemsIDs() (ids []uuid.UUID) {
+ for id := range m.items {
+ ids = append(ids, id)
+ }
+ return
+}
+
+// ResetItems resets all changes to the "items" edge.
+func (m *LocationMutation) ResetItems() {
+ m.items = nil
+ m.cleareditems = false
+ m.removeditems = nil
+}
+
+// Where appends a list predicates to the LocationMutation builder.
+func (m *LocationMutation) Where(ps ...predicate.Location) {
+ m.predicates = append(m.predicates, ps...)
+}
+
+// WhereP appends storage-level predicates to the LocationMutation builder. Using this method,
+// users can use type-assertion to append predicates that do not depend on any generated package.
+func (m *LocationMutation) WhereP(ps ...func(*sql.Selector)) {
+ p := make([]predicate.Location, len(ps))
+ for i := range ps {
+ p[i] = ps[i]
+ }
+ m.Where(p...)
+}
+
+// Op returns the operation name.
+func (m *LocationMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
-func (m *LabelMutation) SetOp(op Op) {
+func (m *LocationMutation) SetOp(op Op) {
m.op = op
}
-// Type returns the node type of this mutation (Label).
-func (m *LabelMutation) Type() string {
+// Type returns the node type of this mutation (Location).
+func (m *LocationMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
-func (m *LabelMutation) Fields() []string {
- fields := make([]string, 0, 5)
+func (m *LocationMutation) Fields() []string {
+ fields := make([]string, 0, 4)
if m.created_at != nil {
- fields = append(fields, label.FieldCreatedAt)
+ fields = append(fields, location.FieldCreatedAt)
}
if m.updated_at != nil {
- fields = append(fields, label.FieldUpdatedAt)
+ fields = append(fields, location.FieldUpdatedAt)
}
if m.name != nil {
- fields = append(fields, label.FieldName)
+ fields = append(fields, location.FieldName)
}
if m.description != nil {
- fields = append(fields, label.FieldDescription)
- }
- if m.color != nil {
- fields = append(fields, label.FieldColor)
+ fields = append(fields, location.FieldDescription)
}
return fields
}
@@ -7468,18 +9956,16 @@ func (m *LabelMutation) Fields() []string {
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
-func (m *LabelMutation) Field(name string) (ent.Value, bool) {
+func (m *LocationMutation) Field(name string) (ent.Value, bool) {
switch name {
- case label.FieldCreatedAt:
+ case location.FieldCreatedAt:
return m.CreatedAt()
- case label.FieldUpdatedAt:
+ case location.FieldUpdatedAt:
return m.UpdatedAt()
- case label.FieldName:
+ case location.FieldName:
return m.Name()
- case label.FieldDescription:
+ case location.FieldDescription:
return m.Description()
- case label.FieldColor:
- return m.Color()
}
return nil, false
}
@@ -7487,166 +9973,164 @@ func (m *LabelMutation) Field(name string) (ent.Value, bool) {
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
-func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
+func (m *LocationMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
- case label.FieldCreatedAt:
+ case location.FieldCreatedAt:
return m.OldCreatedAt(ctx)
- case label.FieldUpdatedAt:
+ case location.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
- case label.FieldName:
+ case location.FieldName:
return m.OldName(ctx)
- case label.FieldDescription:
+ case location.FieldDescription:
return m.OldDescription(ctx)
- case label.FieldColor:
- return m.OldColor(ctx)
}
- return nil, fmt.Errorf("unknown Label field %s", name)
+ return nil, fmt.Errorf("unknown Location field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
-func (m *LabelMutation) SetField(name string, value ent.Value) error {
+func (m *LocationMutation) SetField(name string, value ent.Value) error {
switch name {
- case label.FieldCreatedAt:
+ case location.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
- case label.FieldUpdatedAt:
+ case location.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
- case label.FieldName:
+ case location.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
- case label.FieldDescription:
+ case location.FieldDescription:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDescription(v)
return nil
- case label.FieldColor:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetColor(v)
- return nil
}
- return fmt.Errorf("unknown Label field %s", name)
+ return fmt.Errorf("unknown Location field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
-func (m *LabelMutation) AddedFields() []string {
+func (m *LocationMutation) AddedFields() []string {
return nil
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
-func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
+func (m *LocationMutation) AddedField(name string) (ent.Value, bool) {
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
-func (m *LabelMutation) AddField(name string, value ent.Value) error {
+func (m *LocationMutation) AddField(name string, value ent.Value) error {
switch name {
}
- return fmt.Errorf("unknown Label numeric field %s", name)
+ return fmt.Errorf("unknown Location numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
-func (m *LabelMutation) ClearedFields() []string {
+func (m *LocationMutation) ClearedFields() []string {
var fields []string
- if m.FieldCleared(label.FieldDescription) {
- fields = append(fields, label.FieldDescription)
- }
- if m.FieldCleared(label.FieldColor) {
- fields = append(fields, label.FieldColor)
+ if m.FieldCleared(location.FieldDescription) {
+ fields = append(fields, location.FieldDescription)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
-func (m *LabelMutation) FieldCleared(name string) bool {
+func (m *LocationMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
-func (m *LabelMutation) ClearField(name string) error {
+func (m *LocationMutation) ClearField(name string) error {
switch name {
- case label.FieldDescription:
+ case location.FieldDescription:
m.ClearDescription()
return nil
- case label.FieldColor:
- m.ClearColor()
- return nil
}
- return fmt.Errorf("unknown Label nullable field %s", name)
+ return fmt.Errorf("unknown Location nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
-func (m *LabelMutation) ResetField(name string) error {
+func (m *LocationMutation) ResetField(name string) error {
switch name {
- case label.FieldCreatedAt:
+ case location.FieldCreatedAt:
m.ResetCreatedAt()
return nil
- case label.FieldUpdatedAt:
+ case location.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
- case label.FieldName:
+ case location.FieldName:
m.ResetName()
return nil
- case label.FieldDescription:
+ case location.FieldDescription:
m.ResetDescription()
return nil
- case label.FieldColor:
- m.ResetColor()
- return nil
}
- return fmt.Errorf("unknown Label field %s", name)
+ return fmt.Errorf("unknown Location field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
-func (m *LabelMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
+func (m *LocationMutation) AddedEdges() []string {
+ edges := make([]string, 0, 4)
if m.group != nil {
- edges = append(edges, label.EdgeGroup)
+ edges = append(edges, location.EdgeGroup)
+ }
+ if m.parent != nil {
+ edges = append(edges, location.EdgeParent)
+ }
+ if m.children != nil {
+ edges = append(edges, location.EdgeChildren)
}
if m.items != nil {
- edges = append(edges, label.EdgeItems)
+ edges = append(edges, location.EdgeItems)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
-func (m *LabelMutation) AddedIDs(name string) []ent.Value {
+func (m *LocationMutation) AddedIDs(name string) []ent.Value {
switch name {
- case label.EdgeGroup:
+ case location.EdgeGroup:
if id := m.group; id != nil {
return []ent.Value{*id}
}
- case label.EdgeItems:
+ case location.EdgeParent:
+ if id := m.parent; id != nil {
+ return []ent.Value{*id}
+ }
+ case location.EdgeChildren:
+ ids := make([]ent.Value, 0, len(m.children))
+ for id := range m.children {
+ ids = append(ids, id)
+ }
+ return ids
+ case location.EdgeItems:
ids := make([]ent.Value, 0, len(m.items))
for id := range m.items {
ids = append(ids, id)
@@ -7657,19 +10141,28 @@ func (m *LabelMutation) AddedIDs(name string) []ent.Value {
}
// RemovedEdges returns all edge names that were removed in this mutation.
-func (m *LabelMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
+func (m *LocationMutation) RemovedEdges() []string {
+ edges := make([]string, 0, 4)
+ if m.removedchildren != nil {
+ edges = append(edges, location.EdgeChildren)
+ }
if m.removeditems != nil {
- edges = append(edges, label.EdgeItems)
+ edges = append(edges, location.EdgeItems)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
-func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
+func (m *LocationMutation) RemovedIDs(name string) []ent.Value {
switch name {
- case label.EdgeItems:
+ case location.EdgeChildren:
+ ids := make([]ent.Value, 0, len(m.removedchildren))
+ for id := range m.removedchildren {
+ ids = append(ids, id)
+ }
+ return ids
+ case location.EdgeItems:
ids := make([]ent.Value, 0, len(m.removeditems))
for id := range m.removeditems {
ids = append(ids, id)
@@ -7680,24 +10173,34 @@ func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
}
// ClearedEdges returns all edge names that were cleared in this mutation.
-func (m *LabelMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
+func (m *LocationMutation) ClearedEdges() []string {
+ edges := make([]string, 0, 4)
if m.clearedgroup {
- edges = append(edges, label.EdgeGroup)
+ edges = append(edges, location.EdgeGroup)
+ }
+ if m.clearedparent {
+ edges = append(edges, location.EdgeParent)
+ }
+ if m.clearedchildren {
+ edges = append(edges, location.EdgeChildren)
}
if m.cleareditems {
- edges = append(edges, label.EdgeItems)
+ edges = append(edges, location.EdgeItems)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
-func (m *LabelMutation) EdgeCleared(name string) bool {
+func (m *LocationMutation) EdgeCleared(name string) bool {
switch name {
- case label.EdgeGroup:
+ case location.EdgeGroup:
return m.clearedgroup
- case label.EdgeItems:
+ case location.EdgeParent:
+ return m.clearedparent
+ case location.EdgeChildren:
+ return m.clearedchildren
+ case location.EdgeItems:
return m.cleareditems
}
return false
@@ -7705,66 +10208,71 @@ func (m *LabelMutation) EdgeCleared(name string) bool {
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
-func (m *LabelMutation) ClearEdge(name string) error {
+func (m *LocationMutation) ClearEdge(name string) error {
switch name {
- case label.EdgeGroup:
+ case location.EdgeGroup:
m.ClearGroup()
return nil
+ case location.EdgeParent:
+ m.ClearParent()
+ return nil
}
- return fmt.Errorf("unknown Label unique edge %s", name)
+ return fmt.Errorf("unknown Location unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
-func (m *LabelMutation) ResetEdge(name string) error {
+func (m *LocationMutation) ResetEdge(name string) error {
switch name {
- case label.EdgeGroup:
+ case location.EdgeGroup:
m.ResetGroup()
return nil
- case label.EdgeItems:
+ case location.EdgeParent:
+ m.ResetParent()
+ return nil
+ case location.EdgeChildren:
+ m.ResetChildren()
+ return nil
+ case location.EdgeItems:
m.ResetItems()
return nil
}
- return fmt.Errorf("unknown Label edge %s", name)
+ return fmt.Errorf("unknown Location edge %s", name)
}
-// LocationMutation represents an operation that mutates the Location nodes in the graph.
-type LocationMutation struct {
+// MaintenanceEntryMutation represents an operation that mutates the MaintenanceEntry nodes in the graph.
+type MaintenanceEntryMutation struct {
config
- op Op
- typ string
- id *uuid.UUID
- created_at *time.Time
- updated_at *time.Time
- name *string
- description *string
- clearedFields map[string]struct{}
- group *uuid.UUID
- clearedgroup bool
- parent *uuid.UUID
- clearedparent bool
- children map[uuid.UUID]struct{}
- removedchildren map[uuid.UUID]struct{}
- clearedchildren bool
- items map[uuid.UUID]struct{}
- removeditems map[uuid.UUID]struct{}
- cleareditems bool
- done bool
- oldValue func(context.Context) (*Location, error)
- predicates []predicate.Location
+ op Op
+ typ string
+ id *uuid.UUID
+ created_at *time.Time
+ updated_at *time.Time
+ date *time.Time
+ scheduled_date *time.Time
+ name *string
+ description *string
+ cost *float64
+ addcost *float64
+ clearedFields map[string]struct{}
+ item *uuid.UUID
+ cleareditem bool
+ done bool
+ oldValue func(context.Context) (*MaintenanceEntry, error)
+ predicates []predicate.MaintenanceEntry
}
-var _ ent.Mutation = (*LocationMutation)(nil)
+var _ ent.Mutation = (*MaintenanceEntryMutation)(nil)
-// locationOption allows management of the mutation configuration using functional options.
-type locationOption func(*LocationMutation)
+// maintenanceentryOption allows management of the mutation configuration using functional options.
+type maintenanceentryOption func(*MaintenanceEntryMutation)
-// newLocationMutation creates new mutation for the Location entity.
-func newLocationMutation(c config, op Op, opts ...locationOption) *LocationMutation {
- m := &LocationMutation{
+// newMaintenanceEntryMutation creates new mutation for the MaintenanceEntry entity.
+func newMaintenanceEntryMutation(c config, op Op, opts ...maintenanceentryOption) *MaintenanceEntryMutation {
+ m := &MaintenanceEntryMutation{
config: c,
op: op,
- typ: TypeLocation,
+ typ: TypeMaintenanceEntry,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
@@ -7773,20 +10281,20 @@ func newLocationMutation(c config, op Op, opts ...locationOption) *LocationMutat
return m
}
-// withLocationID sets the ID field of the mutation.
-func withLocationID(id uuid.UUID) locationOption {
- return func(m *LocationMutation) {
+// withMaintenanceEntryID sets the ID field of the mutation.
+func withMaintenanceEntryID(id uuid.UUID) maintenanceentryOption {
+ return func(m *MaintenanceEntryMutation) {
var (
err error
once sync.Once
- value *Location
+ value *MaintenanceEntry
)
- m.oldValue = func(ctx context.Context) (*Location, error) {
+ m.oldValue = func(ctx context.Context) (*MaintenanceEntry, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
- value, err = m.Client().Location.Get(ctx, id)
+ value, err = m.Client().MaintenanceEntry.Get(ctx, id)
}
})
return value, err
@@ -7795,10 +10303,10 @@ func withLocationID(id uuid.UUID) locationOption {
}
}
-// withLocation sets the old Location of the mutation.
-func withLocation(node *Location) locationOption {
- return func(m *LocationMutation) {
- m.oldValue = func(context.Context) (*Location, error) {
+// withMaintenanceEntry sets the old MaintenanceEntry of the mutation.
+func withMaintenanceEntry(node *MaintenanceEntry) maintenanceentryOption {
+ return func(m *MaintenanceEntryMutation) {
+ m.oldValue = func(context.Context) (*MaintenanceEntry, error) {
return node, nil
}
m.id = &node.ID
@@ -7807,7 +10315,7 @@ func withLocation(node *Location) locationOption {
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
-func (m LocationMutation) Client() *Client {
+func (m MaintenanceEntryMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
@@ -7815,7 +10323,7 @@ func (m LocationMutation) Client() *Client {
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
-func (m LocationMutation) Tx() (*Tx, error) {
+func (m MaintenanceEntryMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("ent: mutation is not running in a transaction")
}
@@ -7825,118 +10333,252 @@ func (m LocationMutation) Tx() (*Tx, error) {
}
// SetID sets the value of the id field. Note that this
-// operation is only accepted on creation of Location entities.
-func (m *LocationMutation) SetID(id uuid.UUID) {
+// operation is only accepted on creation of MaintenanceEntry entities.
+func (m *MaintenanceEntryMutation) SetID(id uuid.UUID) {
m.id = &id
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
-func (m *LocationMutation) ID() (id uuid.UUID, exists bool) {
+func (m *MaintenanceEntryMutation) ID() (id uuid.UUID, exists bool) {
if m.id == nil {
return
}
- return *m.id, true
+ return *m.id, true
+}
+
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
+// That means, if the mutation is applied within a transaction with an isolation level such
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
+// or updated by the mutation.
+func (m *MaintenanceEntryMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
+ switch {
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
+ id, exists := m.ID()
+ if exists {
+ return []uuid.UUID{id}, nil
+ }
+ fallthrough
+ case m.op.Is(OpUpdate | OpDelete):
+ return m.Client().MaintenanceEntry.Query().Where(m.predicates...).IDs(ctx)
+ default:
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
+ }
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (m *MaintenanceEntryMutation) SetCreatedAt(t time.Time) {
+ m.created_at = &t
+}
+
+// CreatedAt returns the value of the "created_at" field in the mutation.
+func (m *MaintenanceEntryMutation) CreatedAt() (r time.Time, exists bool) {
+ v := m.created_at
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldCreatedAt returns the old "created_at" field's value of the MaintenanceEntry entity.
+// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MaintenanceEntryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
+ }
+ return oldValue.CreatedAt, nil
+}
+
+// ResetCreatedAt resets all changes to the "created_at" field.
+func (m *MaintenanceEntryMutation) ResetCreatedAt() {
+ m.created_at = nil
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (m *MaintenanceEntryMutation) SetUpdatedAt(t time.Time) {
+ m.updated_at = &t
+}
+
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
+func (m *MaintenanceEntryMutation) UpdatedAt() (r time.Time, exists bool) {
+ v := m.updated_at
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldUpdatedAt returns the old "updated_at" field's value of the MaintenanceEntry entity.
+// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MaintenanceEntryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
+ }
+ return oldValue.UpdatedAt, nil
+}
+
+// ResetUpdatedAt resets all changes to the "updated_at" field.
+func (m *MaintenanceEntryMutation) ResetUpdatedAt() {
+ m.updated_at = nil
+}
+
+// SetItemID sets the "item_id" field.
+func (m *MaintenanceEntryMutation) SetItemID(u uuid.UUID) {
+ m.item = &u
+}
+
+// ItemID returns the value of the "item_id" field in the mutation.
+func (m *MaintenanceEntryMutation) ItemID() (r uuid.UUID, exists bool) {
+ v := m.item
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldItemID returns the old "item_id" field's value of the MaintenanceEntry entity.
+// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MaintenanceEntryMutation) OldItemID(ctx context.Context) (v uuid.UUID, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldItemID is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldItemID requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldItemID: %w", err)
+ }
+ return oldValue.ItemID, nil
}
-// IDs queries the database and returns the entity ids that match the mutation's predicate.
-// That means, if the mutation is applied within a transaction with an isolation level such
-// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
-// or updated by the mutation.
-func (m *LocationMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []uuid.UUID{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Location.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
+// ResetItemID resets all changes to the "item_id" field.
+func (m *MaintenanceEntryMutation) ResetItemID() {
+ m.item = nil
}
-// SetCreatedAt sets the "created_at" field.
-func (m *LocationMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
+// SetDate sets the "date" field.
+func (m *MaintenanceEntryMutation) SetDate(t time.Time) {
+ m.date = &t
}
-// CreatedAt returns the value of the "created_at" field in the mutation.
-func (m *LocationMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
+// Date returns the value of the "date" field in the mutation.
+func (m *MaintenanceEntryMutation) Date() (r time.Time, exists bool) {
+ v := m.date
if v == nil {
return
}
return *v, true
}
-// OldCreatedAt returns the old "created_at" field's value of the Location entity.
-// If the Location object wasn't provided to the builder, the object is fetched from the database.
+// OldDate returns the old "date" field's value of the MaintenanceEntry entity.
+// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *LocationMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
+func (m *MaintenanceEntryMutation) OldDate(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
+ return v, errors.New("OldDate is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
+ return v, errors.New("OldDate requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
+ return v, fmt.Errorf("querying old value for OldDate: %w", err)
}
- return oldValue.CreatedAt, nil
+ return oldValue.Date, nil
}
-// ResetCreatedAt resets all changes to the "created_at" field.
-func (m *LocationMutation) ResetCreatedAt() {
- m.created_at = nil
+// ClearDate clears the value of the "date" field.
+func (m *MaintenanceEntryMutation) ClearDate() {
+ m.date = nil
+ m.clearedFields[maintenanceentry.FieldDate] = struct{}{}
}
-// SetUpdatedAt sets the "updated_at" field.
-func (m *LocationMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
+// DateCleared returns if the "date" field was cleared in this mutation.
+func (m *MaintenanceEntryMutation) DateCleared() bool {
+ _, ok := m.clearedFields[maintenanceentry.FieldDate]
+ return ok
}
-// UpdatedAt returns the value of the "updated_at" field in the mutation.
-func (m *LocationMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
+// ResetDate resets all changes to the "date" field.
+func (m *MaintenanceEntryMutation) ResetDate() {
+ m.date = nil
+ delete(m.clearedFields, maintenanceentry.FieldDate)
+}
+
+// SetScheduledDate sets the "scheduled_date" field.
+func (m *MaintenanceEntryMutation) SetScheduledDate(t time.Time) {
+ m.scheduled_date = &t
+}
+
+// ScheduledDate returns the value of the "scheduled_date" field in the mutation.
+func (m *MaintenanceEntryMutation) ScheduledDate() (r time.Time, exists bool) {
+ v := m.scheduled_date
if v == nil {
return
}
return *v, true
}
-// OldUpdatedAt returns the old "updated_at" field's value of the Location entity.
-// If the Location object wasn't provided to the builder, the object is fetched from the database.
+// OldScheduledDate returns the old "scheduled_date" field's value of the MaintenanceEntry entity.
+// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *LocationMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
+func (m *MaintenanceEntryMutation) OldScheduledDate(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
+ return v, errors.New("OldScheduledDate is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
+ return v, errors.New("OldScheduledDate requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
+ return v, fmt.Errorf("querying old value for OldScheduledDate: %w", err)
}
- return oldValue.UpdatedAt, nil
+ return oldValue.ScheduledDate, nil
}
-// ResetUpdatedAt resets all changes to the "updated_at" field.
-func (m *LocationMutation) ResetUpdatedAt() {
- m.updated_at = nil
+// ClearScheduledDate clears the value of the "scheduled_date" field.
+func (m *MaintenanceEntryMutation) ClearScheduledDate() {
+ m.scheduled_date = nil
+ m.clearedFields[maintenanceentry.FieldScheduledDate] = struct{}{}
+}
+
+// ScheduledDateCleared returns if the "scheduled_date" field was cleared in this mutation.
+func (m *MaintenanceEntryMutation) ScheduledDateCleared() bool {
+ _, ok := m.clearedFields[maintenanceentry.FieldScheduledDate]
+ return ok
+}
+
+// ResetScheduledDate resets all changes to the "scheduled_date" field.
+func (m *MaintenanceEntryMutation) ResetScheduledDate() {
+ m.scheduled_date = nil
+ delete(m.clearedFields, maintenanceentry.FieldScheduledDate)
}
// SetName sets the "name" field.
-func (m *LocationMutation) SetName(s string) {
+func (m *MaintenanceEntryMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
-func (m *LocationMutation) Name() (r string, exists bool) {
+func (m *MaintenanceEntryMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
@@ -7944,10 +10586,10 @@ func (m *LocationMutation) Name() (r string, exists bool) {
return *v, true
}
-// OldName returns the old "name" field's value of the Location entity.
-// If the Location object wasn't provided to the builder, the object is fetched from the database.
+// OldName returns the old "name" field's value of the MaintenanceEntry entity.
+// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *LocationMutation) OldName(ctx context.Context) (v string, err error) {
+func (m *MaintenanceEntryMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
@@ -7962,17 +10604,17 @@ func (m *LocationMutation) OldName(ctx context.Context) (v string, err error) {
}
// ResetName resets all changes to the "name" field.
-func (m *LocationMutation) ResetName() {
+func (m *MaintenanceEntryMutation) ResetName() {
m.name = nil
}
// SetDescription sets the "description" field.
-func (m *LocationMutation) SetDescription(s string) {
+func (m *MaintenanceEntryMutation) SetDescription(s string) {
m.description = &s
}
// Description returns the value of the "description" field in the mutation.
-func (m *LocationMutation) Description() (r string, exists bool) {
+func (m *MaintenanceEntryMutation) Description() (r string, exists bool) {
v := m.description
if v == nil {
return
@@ -7980,10 +10622,10 @@ func (m *LocationMutation) Description() (r string, exists bool) {
return *v, true
}
-// OldDescription returns the old "description" field's value of the Location entity.
-// If the Location object wasn't provided to the builder, the object is fetched from the database.
+// OldDescription returns the old "description" field's value of the MaintenanceEntry entity.
+// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *LocationMutation) OldDescription(ctx context.Context) (v string, err error) {
+func (m *MaintenanceEntryMutation) OldDescription(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
}
@@ -7998,218 +10640,115 @@ func (m *LocationMutation) OldDescription(ctx context.Context) (v string, err er
}
// ClearDescription clears the value of the "description" field.
-func (m *LocationMutation) ClearDescription() {
+func (m *MaintenanceEntryMutation) ClearDescription() {
m.description = nil
- m.clearedFields[location.FieldDescription] = struct{}{}
+ m.clearedFields[maintenanceentry.FieldDescription] = struct{}{}
}
// DescriptionCleared returns if the "description" field was cleared in this mutation.
-func (m *LocationMutation) DescriptionCleared() bool {
- _, ok := m.clearedFields[location.FieldDescription]
+func (m *MaintenanceEntryMutation) DescriptionCleared() bool {
+ _, ok := m.clearedFields[maintenanceentry.FieldDescription]
return ok
}
// ResetDescription resets all changes to the "description" field.
-func (m *LocationMutation) ResetDescription() {
+func (m *MaintenanceEntryMutation) ResetDescription() {
m.description = nil
- delete(m.clearedFields, location.FieldDescription)
-}
-
-// SetGroupID sets the "group" edge to the Group entity by id.
-func (m *LocationMutation) SetGroupID(id uuid.UUID) {
- m.group = &id
-}
-
-// ClearGroup clears the "group" edge to the Group entity.
-func (m *LocationMutation) ClearGroup() {
- m.clearedgroup = true
-}
-
-// GroupCleared reports if the "group" edge to the Group entity was cleared.
-func (m *LocationMutation) GroupCleared() bool {
- return m.clearedgroup
-}
-
-// GroupID returns the "group" edge ID in the mutation.
-func (m *LocationMutation) GroupID() (id uuid.UUID, exists bool) {
- if m.group != nil {
- return *m.group, true
- }
- return
-}
-
-// GroupIDs returns the "group" edge IDs in the mutation.
-// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
-// GroupID instead. It exists only for internal usage by the builders.
-func (m *LocationMutation) GroupIDs() (ids []uuid.UUID) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
-}
-
-// ResetGroup resets all changes to the "group" edge.
-func (m *LocationMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
-}
-
-// SetParentID sets the "parent" edge to the Location entity by id.
-func (m *LocationMutation) SetParentID(id uuid.UUID) {
- m.parent = &id
-}
-
-// ClearParent clears the "parent" edge to the Location entity.
-func (m *LocationMutation) ClearParent() {
- m.clearedparent = true
-}
-
-// ParentCleared reports if the "parent" edge to the Location entity was cleared.
-func (m *LocationMutation) ParentCleared() bool {
- return m.clearedparent
-}
-
-// ParentID returns the "parent" edge ID in the mutation.
-func (m *LocationMutation) ParentID() (id uuid.UUID, exists bool) {
- if m.parent != nil {
- return *m.parent, true
- }
- return
-}
-
-// ParentIDs returns the "parent" edge IDs in the mutation.
-// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
-// ParentID instead. It exists only for internal usage by the builders.
-func (m *LocationMutation) ParentIDs() (ids []uuid.UUID) {
- if id := m.parent; id != nil {
- ids = append(ids, *id)
- }
- return
-}
-
-// ResetParent resets all changes to the "parent" edge.
-func (m *LocationMutation) ResetParent() {
- m.parent = nil
- m.clearedparent = false
-}
-
-// AddChildIDs adds the "children" edge to the Location entity by ids.
-func (m *LocationMutation) AddChildIDs(ids ...uuid.UUID) {
- if m.children == nil {
- m.children = make(map[uuid.UUID]struct{})
- }
- for i := range ids {
- m.children[ids[i]] = struct{}{}
- }
-}
-
-// ClearChildren clears the "children" edge to the Location entity.
-func (m *LocationMutation) ClearChildren() {
- m.clearedchildren = true
-}
-
-// ChildrenCleared reports if the "children" edge to the Location entity was cleared.
-func (m *LocationMutation) ChildrenCleared() bool {
- return m.clearedchildren
+ delete(m.clearedFields, maintenanceentry.FieldDescription)
}
-// RemoveChildIDs removes the "children" edge to the Location entity by IDs.
-func (m *LocationMutation) RemoveChildIDs(ids ...uuid.UUID) {
- if m.removedchildren == nil {
- m.removedchildren = make(map[uuid.UUID]struct{})
- }
- for i := range ids {
- delete(m.children, ids[i])
- m.removedchildren[ids[i]] = struct{}{}
- }
+// SetCost sets the "cost" field.
+func (m *MaintenanceEntryMutation) SetCost(f float64) {
+ m.cost = &f
+ m.addcost = nil
}
-// RemovedChildren returns the removed IDs of the "children" edge to the Location entity.
-func (m *LocationMutation) RemovedChildrenIDs() (ids []uuid.UUID) {
- for id := range m.removedchildren {
- ids = append(ids, id)
+// Cost returns the value of the "cost" field in the mutation.
+func (m *MaintenanceEntryMutation) Cost() (r float64, exists bool) {
+ v := m.cost
+ if v == nil {
+ return
}
- return
+ return *v, true
}
-// ChildrenIDs returns the "children" edge IDs in the mutation.
-func (m *LocationMutation) ChildrenIDs() (ids []uuid.UUID) {
- for id := range m.children {
- ids = append(ids, id)
+// OldCost returns the old "cost" field's value of the MaintenanceEntry entity.
+// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MaintenanceEntryMutation) OldCost(ctx context.Context) (v float64, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldCost is only allowed on UpdateOne operations")
}
- return
-}
-
-// ResetChildren resets all changes to the "children" edge.
-func (m *LocationMutation) ResetChildren() {
- m.children = nil
- m.clearedchildren = false
- m.removedchildren = nil
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldCost requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldCost: %w", err)
+ }
+ return oldValue.Cost, nil
}
-// AddItemIDs adds the "items" edge to the Item entity by ids.
-func (m *LocationMutation) AddItemIDs(ids ...uuid.UUID) {
- if m.items == nil {
- m.items = make(map[uuid.UUID]struct{})
- }
- for i := range ids {
- m.items[ids[i]] = struct{}{}
+// AddCost adds f to the "cost" field.
+func (m *MaintenanceEntryMutation) AddCost(f float64) {
+ if m.addcost != nil {
+ *m.addcost += f
+ } else {
+ m.addcost = &f
}
}
-// ClearItems clears the "items" edge to the Item entity.
-func (m *LocationMutation) ClearItems() {
- m.cleareditems = true
+// AddedCost returns the value that was added to the "cost" field in this mutation.
+func (m *MaintenanceEntryMutation) AddedCost() (r float64, exists bool) {
+ v := m.addcost
+ if v == nil {
+ return
+ }
+ return *v, true
}
-// ItemsCleared reports if the "items" edge to the Item entity was cleared.
-func (m *LocationMutation) ItemsCleared() bool {
- return m.cleareditems
+// ResetCost resets all changes to the "cost" field.
+func (m *MaintenanceEntryMutation) ResetCost() {
+ m.cost = nil
+ m.addcost = nil
}
-// RemoveItemIDs removes the "items" edge to the Item entity by IDs.
-func (m *LocationMutation) RemoveItemIDs(ids ...uuid.UUID) {
- if m.removeditems == nil {
- m.removeditems = make(map[uuid.UUID]struct{})
- }
- for i := range ids {
- delete(m.items, ids[i])
- m.removeditems[ids[i]] = struct{}{}
- }
+// ClearItem clears the "item" edge to the Item entity.
+func (m *MaintenanceEntryMutation) ClearItem() {
+ m.cleareditem = true
+ m.clearedFields[maintenanceentry.FieldItemID] = struct{}{}
}
-// RemovedItems returns the removed IDs of the "items" edge to the Item entity.
-func (m *LocationMutation) RemovedItemsIDs() (ids []uuid.UUID) {
- for id := range m.removeditems {
- ids = append(ids, id)
- }
- return
+// ItemCleared reports if the "item" edge to the Item entity was cleared.
+func (m *MaintenanceEntryMutation) ItemCleared() bool {
+ return m.cleareditem
}
-// ItemsIDs returns the "items" edge IDs in the mutation.
-func (m *LocationMutation) ItemsIDs() (ids []uuid.UUID) {
- for id := range m.items {
- ids = append(ids, id)
+// ItemIDs returns the "item" edge IDs in the mutation.
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
+// ItemID instead. It exists only for internal usage by the builders.
+func (m *MaintenanceEntryMutation) ItemIDs() (ids []uuid.UUID) {
+ if id := m.item; id != nil {
+ ids = append(ids, *id)
}
return
}
-// ResetItems resets all changes to the "items" edge.
-func (m *LocationMutation) ResetItems() {
- m.items = nil
- m.cleareditems = false
- m.removeditems = nil
+// ResetItem resets all changes to the "item" edge.
+func (m *MaintenanceEntryMutation) ResetItem() {
+ m.item = nil
+ m.cleareditem = false
}
-// Where appends a list predicates to the LocationMutation builder.
-func (m *LocationMutation) Where(ps ...predicate.Location) {
+// Where appends a list predicates to the MaintenanceEntryMutation builder.
+func (m *MaintenanceEntryMutation) Where(ps ...predicate.MaintenanceEntry) {
m.predicates = append(m.predicates, ps...)
}
-// WhereP appends storage-level predicates to the LocationMutation builder. Using this method,
+// WhereP appends storage-level predicates to the MaintenanceEntryMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
-func (m *LocationMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Location, len(ps))
+func (m *MaintenanceEntryMutation) WhereP(ps ...func(*sql.Selector)) {
+ p := make([]predicate.MaintenanceEntry, len(ps))
for i := range ps {
p[i] = ps[i]
}
@@ -8217,36 +10756,48 @@ func (m *LocationMutation) WhereP(ps ...func(*sql.Selector)) {
}
// Op returns the operation name.
-func (m *LocationMutation) Op() Op {
+func (m *MaintenanceEntryMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
-func (m *LocationMutation) SetOp(op Op) {
+func (m *MaintenanceEntryMutation) SetOp(op Op) {
m.op = op
}
-// Type returns the node type of this mutation (Location).
-func (m *LocationMutation) Type() string {
+// Type returns the node type of this mutation (MaintenanceEntry).
+func (m *MaintenanceEntryMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
-func (m *LocationMutation) Fields() []string {
- fields := make([]string, 0, 4)
+func (m *MaintenanceEntryMutation) Fields() []string {
+ fields := make([]string, 0, 8)
if m.created_at != nil {
- fields = append(fields, location.FieldCreatedAt)
+ fields = append(fields, maintenanceentry.FieldCreatedAt)
}
if m.updated_at != nil {
- fields = append(fields, location.FieldUpdatedAt)
+ fields = append(fields, maintenanceentry.FieldUpdatedAt)
+ }
+ if m.item != nil {
+ fields = append(fields, maintenanceentry.FieldItemID)
+ }
+ if m.date != nil {
+ fields = append(fields, maintenanceentry.FieldDate)
+ }
+ if m.scheduled_date != nil {
+ fields = append(fields, maintenanceentry.FieldScheduledDate)
}
if m.name != nil {
- fields = append(fields, location.FieldName)
+ fields = append(fields, maintenanceentry.FieldName)
}
if m.description != nil {
- fields = append(fields, location.FieldDescription)
+ fields = append(fields, maintenanceentry.FieldDescription)
+ }
+ if m.cost != nil {
+ fields = append(fields, maintenanceentry.FieldCost)
}
return fields
}
@@ -8254,16 +10805,24 @@ func (m *LocationMutation) Fields() []string {
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
-func (m *LocationMutation) Field(name string) (ent.Value, bool) {
+func (m *MaintenanceEntryMutation) Field(name string) (ent.Value, bool) {
switch name {
- case location.FieldCreatedAt:
+ case maintenanceentry.FieldCreatedAt:
return m.CreatedAt()
- case location.FieldUpdatedAt:
+ case maintenanceentry.FieldUpdatedAt:
return m.UpdatedAt()
- case location.FieldName:
+ case maintenanceentry.FieldItemID:
+ return m.ItemID()
+ case maintenanceentry.FieldDate:
+ return m.Date()
+ case maintenanceentry.FieldScheduledDate:
+ return m.ScheduledDate()
+ case maintenanceentry.FieldName:
return m.Name()
- case location.FieldDescription:
+ case maintenanceentry.FieldDescription:
return m.Description()
+ case maintenanceentry.FieldCost:
+ return m.Cost()
}
return nil, false
}
@@ -8271,306 +10830,308 @@ func (m *LocationMutation) Field(name string) (ent.Value, bool) {
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
-func (m *LocationMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
+func (m *MaintenanceEntryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
- case location.FieldCreatedAt:
+ case maintenanceentry.FieldCreatedAt:
return m.OldCreatedAt(ctx)
- case location.FieldUpdatedAt:
+ case maintenanceentry.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
- case location.FieldName:
+ case maintenanceentry.FieldItemID:
+ return m.OldItemID(ctx)
+ case maintenanceentry.FieldDate:
+ return m.OldDate(ctx)
+ case maintenanceentry.FieldScheduledDate:
+ return m.OldScheduledDate(ctx)
+ case maintenanceentry.FieldName:
return m.OldName(ctx)
- case location.FieldDescription:
+ case maintenanceentry.FieldDescription:
return m.OldDescription(ctx)
+ case maintenanceentry.FieldCost:
+ return m.OldCost(ctx)
}
- return nil, fmt.Errorf("unknown Location field %s", name)
+ return nil, fmt.Errorf("unknown MaintenanceEntry field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
-func (m *LocationMutation) SetField(name string, value ent.Value) error {
+func (m *MaintenanceEntryMutation) SetField(name string, value ent.Value) error {
switch name {
- case location.FieldCreatedAt:
+ case maintenanceentry.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
- case location.FieldUpdatedAt:
+ case maintenanceentry.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
- case location.FieldName:
+ case maintenanceentry.FieldItemID:
+ v, ok := value.(uuid.UUID)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetItemID(v)
+ return nil
+ case maintenanceentry.FieldDate:
+ v, ok := value.(time.Time)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDate(v)
+ return nil
+ case maintenanceentry.FieldScheduledDate:
+ v, ok := value.(time.Time)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetScheduledDate(v)
+ return nil
+ case maintenanceentry.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
- case location.FieldDescription:
+ case maintenanceentry.FieldDescription:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDescription(v)
return nil
+ case maintenanceentry.FieldCost:
+ v, ok := value.(float64)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetCost(v)
+ return nil
}
- return fmt.Errorf("unknown Location field %s", name)
+ return fmt.Errorf("unknown MaintenanceEntry field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
-func (m *LocationMutation) AddedFields() []string {
- return nil
+func (m *MaintenanceEntryMutation) AddedFields() []string {
+ var fields []string
+ if m.addcost != nil {
+ fields = append(fields, maintenanceentry.FieldCost)
+ }
+ return fields
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
-func (m *LocationMutation) AddedField(name string) (ent.Value, bool) {
+func (m *MaintenanceEntryMutation) AddedField(name string) (ent.Value, bool) {
+ switch name {
+ case maintenanceentry.FieldCost:
+ return m.AddedCost()
+ }
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
-func (m *LocationMutation) AddField(name string, value ent.Value) error {
+func (m *MaintenanceEntryMutation) AddField(name string, value ent.Value) error {
switch name {
+ case maintenanceentry.FieldCost:
+ v, ok := value.(float64)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.AddCost(v)
+ return nil
}
- return fmt.Errorf("unknown Location numeric field %s", name)
+ return fmt.Errorf("unknown MaintenanceEntry numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
-func (m *LocationMutation) ClearedFields() []string {
+func (m *MaintenanceEntryMutation) ClearedFields() []string {
var fields []string
- if m.FieldCleared(location.FieldDescription) {
- fields = append(fields, location.FieldDescription)
+ if m.FieldCleared(maintenanceentry.FieldDate) {
+ fields = append(fields, maintenanceentry.FieldDate)
+ }
+ if m.FieldCleared(maintenanceentry.FieldScheduledDate) {
+ fields = append(fields, maintenanceentry.FieldScheduledDate)
+ }
+ if m.FieldCleared(maintenanceentry.FieldDescription) {
+ fields = append(fields, maintenanceentry.FieldDescription)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
-func (m *LocationMutation) FieldCleared(name string) bool {
+func (m *MaintenanceEntryMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
-func (m *LocationMutation) ClearField(name string) error {
+func (m *MaintenanceEntryMutation) ClearField(name string) error {
switch name {
- case location.FieldDescription:
+ case maintenanceentry.FieldDate:
+ m.ClearDate()
+ return nil
+ case maintenanceentry.FieldScheduledDate:
+ m.ClearScheduledDate()
+ return nil
+ case maintenanceentry.FieldDescription:
m.ClearDescription()
return nil
}
- return fmt.Errorf("unknown Location nullable field %s", name)
+ return fmt.Errorf("unknown MaintenanceEntry nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
-func (m *LocationMutation) ResetField(name string) error {
+func (m *MaintenanceEntryMutation) ResetField(name string) error {
switch name {
- case location.FieldCreatedAt:
+ case maintenanceentry.FieldCreatedAt:
m.ResetCreatedAt()
return nil
- case location.FieldUpdatedAt:
+ case maintenanceentry.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
- case location.FieldName:
+ case maintenanceentry.FieldItemID:
+ m.ResetItemID()
+ return nil
+ case maintenanceentry.FieldDate:
+ m.ResetDate()
+ return nil
+ case maintenanceentry.FieldScheduledDate:
+ m.ResetScheduledDate()
+ return nil
+ case maintenanceentry.FieldName:
m.ResetName()
return nil
- case location.FieldDescription:
+ case maintenanceentry.FieldDescription:
m.ResetDescription()
return nil
+ case maintenanceentry.FieldCost:
+ m.ResetCost()
+ return nil
}
- return fmt.Errorf("unknown Location field %s", name)
+ return fmt.Errorf("unknown MaintenanceEntry field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
-func (m *LocationMutation) AddedEdges() []string {
- edges := make([]string, 0, 4)
- if m.group != nil {
- edges = append(edges, location.EdgeGroup)
- }
- if m.parent != nil {
- edges = append(edges, location.EdgeParent)
- }
- if m.children != nil {
- edges = append(edges, location.EdgeChildren)
- }
- if m.items != nil {
- edges = append(edges, location.EdgeItems)
+func (m *MaintenanceEntryMutation) AddedEdges() []string {
+ edges := make([]string, 0, 1)
+ if m.item != nil {
+ edges = append(edges, maintenanceentry.EdgeItem)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
-func (m *LocationMutation) AddedIDs(name string) []ent.Value {
+func (m *MaintenanceEntryMutation) AddedIDs(name string) []ent.Value {
switch name {
- case location.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- case location.EdgeParent:
- if id := m.parent; id != nil {
+ case maintenanceentry.EdgeItem:
+ if id := m.item; id != nil {
return []ent.Value{*id}
}
- case location.EdgeChildren:
- ids := make([]ent.Value, 0, len(m.children))
- for id := range m.children {
- ids = append(ids, id)
- }
- return ids
- case location.EdgeItems:
- ids := make([]ent.Value, 0, len(m.items))
- for id := range m.items {
- ids = append(ids, id)
- }
- return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
-func (m *LocationMutation) RemovedEdges() []string {
- edges := make([]string, 0, 4)
- if m.removedchildren != nil {
- edges = append(edges, location.EdgeChildren)
- }
- if m.removeditems != nil {
- edges = append(edges, location.EdgeItems)
- }
+func (m *MaintenanceEntryMutation) RemovedEdges() []string {
+ edges := make([]string, 0, 1)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
-func (m *LocationMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case location.EdgeChildren:
- ids := make([]ent.Value, 0, len(m.removedchildren))
- for id := range m.removedchildren {
- ids = append(ids, id)
- }
- return ids
- case location.EdgeItems:
- ids := make([]ent.Value, 0, len(m.removeditems))
- for id := range m.removeditems {
- ids = append(ids, id)
- }
- return ids
- }
+func (m *MaintenanceEntryMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
-func (m *LocationMutation) ClearedEdges() []string {
- edges := make([]string, 0, 4)
- if m.clearedgroup {
- edges = append(edges, location.EdgeGroup)
- }
- if m.clearedparent {
- edges = append(edges, location.EdgeParent)
- }
- if m.clearedchildren {
- edges = append(edges, location.EdgeChildren)
- }
- if m.cleareditems {
- edges = append(edges, location.EdgeItems)
+func (m *MaintenanceEntryMutation) ClearedEdges() []string {
+ edges := make([]string, 0, 1)
+ if m.cleareditem {
+ edges = append(edges, maintenanceentry.EdgeItem)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
-func (m *LocationMutation) EdgeCleared(name string) bool {
+func (m *MaintenanceEntryMutation) EdgeCleared(name string) bool {
switch name {
- case location.EdgeGroup:
- return m.clearedgroup
- case location.EdgeParent:
- return m.clearedparent
- case location.EdgeChildren:
- return m.clearedchildren
- case location.EdgeItems:
- return m.cleareditems
+ case maintenanceentry.EdgeItem:
+ return m.cleareditem
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
-func (m *LocationMutation) ClearEdge(name string) error {
+func (m *MaintenanceEntryMutation) ClearEdge(name string) error {
switch name {
- case location.EdgeGroup:
- m.ClearGroup()
- return nil
- case location.EdgeParent:
- m.ClearParent()
+ case maintenanceentry.EdgeItem:
+ m.ClearItem()
return nil
}
- return fmt.Errorf("unknown Location unique edge %s", name)
+ return fmt.Errorf("unknown MaintenanceEntry unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
-func (m *LocationMutation) ResetEdge(name string) error {
+func (m *MaintenanceEntryMutation) ResetEdge(name string) error {
switch name {
- case location.EdgeGroup:
- m.ResetGroup()
- return nil
- case location.EdgeParent:
- m.ResetParent()
- return nil
- case location.EdgeChildren:
- m.ResetChildren()
- return nil
- case location.EdgeItems:
- m.ResetItems()
+ case maintenanceentry.EdgeItem:
+ m.ResetItem()
return nil
}
- return fmt.Errorf("unknown Location edge %s", name)
+ return fmt.Errorf("unknown MaintenanceEntry edge %s", name)
}
-// MaintenanceEntryMutation represents an operation that mutates the MaintenanceEntry nodes in the graph.
-type MaintenanceEntryMutation struct {
+// NotifierMutation represents an operation that mutates the Notifier nodes in the graph.
+type NotifierMutation struct {
config
- op Op
- typ string
- id *uuid.UUID
- created_at *time.Time
- updated_at *time.Time
- date *time.Time
- scheduled_date *time.Time
- name *string
- description *string
- cost *float64
- addcost *float64
- clearedFields map[string]struct{}
- item *uuid.UUID
- cleareditem bool
- done bool
- oldValue func(context.Context) (*MaintenanceEntry, error)
- predicates []predicate.MaintenanceEntry
+ op Op
+ typ string
+ id *uuid.UUID
+ created_at *time.Time
+ updated_at *time.Time
+ name *string
+ url *string
+ is_active *bool
+ clearedFields map[string]struct{}
+ group *uuid.UUID
+ clearedgroup bool
+ user *uuid.UUID
+ cleareduser bool
+ done bool
+ oldValue func(context.Context) (*Notifier, error)
+ predicates []predicate.Notifier
}
-var _ ent.Mutation = (*MaintenanceEntryMutation)(nil)
+var _ ent.Mutation = (*NotifierMutation)(nil)
-// maintenanceentryOption allows management of the mutation configuration using functional options.
-type maintenanceentryOption func(*MaintenanceEntryMutation)
+// notifierOption allows management of the mutation configuration using functional options.
+type notifierOption func(*NotifierMutation)
-// newMaintenanceEntryMutation creates new mutation for the MaintenanceEntry entity.
-func newMaintenanceEntryMutation(c config, op Op, opts ...maintenanceentryOption) *MaintenanceEntryMutation {
- m := &MaintenanceEntryMutation{
+// newNotifierMutation creates new mutation for the Notifier entity.
+func newNotifierMutation(c config, op Op, opts ...notifierOption) *NotifierMutation {
+ m := &NotifierMutation{
config: c,
op: op,
- typ: TypeMaintenanceEntry,
+ typ: TypeNotifier,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
@@ -8579,20 +11140,20 @@ func newMaintenanceEntryMutation(c config, op Op, opts ...maintenanceentryOption
return m
}
-// withMaintenanceEntryID sets the ID field of the mutation.
-func withMaintenanceEntryID(id uuid.UUID) maintenanceentryOption {
- return func(m *MaintenanceEntryMutation) {
+// withNotifierID sets the ID field of the mutation.
+func withNotifierID(id uuid.UUID) notifierOption {
+ return func(m *NotifierMutation) {
var (
err error
once sync.Once
- value *MaintenanceEntry
+ value *Notifier
)
- m.oldValue = func(ctx context.Context) (*MaintenanceEntry, error) {
+ m.oldValue = func(ctx context.Context) (*Notifier, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
- value, err = m.Client().MaintenanceEntry.Get(ctx, id)
+ value, err = m.Client().Notifier.Get(ctx, id)
}
})
return value, err
@@ -8601,10 +11162,10 @@ func withMaintenanceEntryID(id uuid.UUID) maintenanceentryOption {
}
}
-// withMaintenanceEntry sets the old MaintenanceEntry of the mutation.
-func withMaintenanceEntry(node *MaintenanceEntry) maintenanceentryOption {
- return func(m *MaintenanceEntryMutation) {
- m.oldValue = func(context.Context) (*MaintenanceEntry, error) {
+// withNotifier sets the old Notifier of the mutation.
+func withNotifier(node *Notifier) notifierOption {
+ return func(m *NotifierMutation) {
+ m.oldValue = func(context.Context) (*Notifier, error) {
return node, nil
}
m.id = &node.ID
@@ -8613,7 +11174,7 @@ func withMaintenanceEntry(node *MaintenanceEntry) maintenanceentryOption {
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
-func (m MaintenanceEntryMutation) Client() *Client {
+func (m NotifierMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
@@ -8621,7 +11182,7 @@ func (m MaintenanceEntryMutation) Client() *Client {
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
-func (m MaintenanceEntryMutation) Tx() (*Tx, error) {
+func (m NotifierMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("ent: mutation is not running in a transaction")
}
@@ -8631,14 +11192,14 @@ func (m MaintenanceEntryMutation) Tx() (*Tx, error) {
}
// SetID sets the value of the id field. Note that this
-// operation is only accepted on creation of MaintenanceEntry entities.
-func (m *MaintenanceEntryMutation) SetID(id uuid.UUID) {
+// operation is only accepted on creation of Notifier entities.
+func (m *NotifierMutation) SetID(id uuid.UUID) {
m.id = &id
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
-func (m *MaintenanceEntryMutation) ID() (id uuid.UUID, exists bool) {
+func (m *NotifierMutation) ID() (id uuid.UUID, exists bool) {
if m.id == nil {
return
}
@@ -8649,7 +11210,7 @@ func (m *MaintenanceEntryMutation) ID() (id uuid.UUID, exists bool) {
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
-func (m *MaintenanceEntryMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
+func (m *NotifierMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
@@ -8658,19 +11219,19 @@ func (m *MaintenanceEntryMutation) IDs(ctx context.Context) ([]uuid.UUID, error)
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
- return m.Client().MaintenanceEntry.Query().Where(m.predicates...).IDs(ctx)
+ return m.Client().Notifier.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetCreatedAt sets the "created_at" field.
-func (m *MaintenanceEntryMutation) SetCreatedAt(t time.Time) {
+func (m *NotifierMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
-func (m *MaintenanceEntryMutation) CreatedAt() (r time.Time, exists bool) {
+func (m *NotifierMutation) CreatedAt() (r time.Time, exists bool) {
v := m.created_at
if v == nil {
return
@@ -8678,10 +11239,10 @@ func (m *MaintenanceEntryMutation) CreatedAt() (r time.Time, exists bool) {
return *v, true
}
-// OldCreatedAt returns the old "created_at" field's value of the MaintenanceEntry entity.
-// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// OldCreatedAt returns the old "created_at" field's value of the Notifier entity.
+// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *MaintenanceEntryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
+func (m *NotifierMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
}
@@ -8696,17 +11257,17 @@ func (m *MaintenanceEntryMutation) OldCreatedAt(ctx context.Context) (v time.Tim
}
// ResetCreatedAt resets all changes to the "created_at" field.
-func (m *MaintenanceEntryMutation) ResetCreatedAt() {
+func (m *NotifierMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
-func (m *MaintenanceEntryMutation) SetUpdatedAt(t time.Time) {
+func (m *NotifierMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
-func (m *MaintenanceEntryMutation) UpdatedAt() (r time.Time, exists bool) {
+func (m *NotifierMutation) UpdatedAt() (r time.Time, exists bool) {
v := m.updated_at
if v == nil {
return
@@ -8714,10 +11275,10 @@ func (m *MaintenanceEntryMutation) UpdatedAt() (r time.Time, exists bool) {
return *v, true
}
-// OldUpdatedAt returns the old "updated_at" field's value of the MaintenanceEntry entity.
-// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// OldUpdatedAt returns the old "updated_at" field's value of the Notifier entity.
+// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *MaintenanceEntryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
+func (m *NotifierMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
}
@@ -8732,151 +11293,89 @@ func (m *MaintenanceEntryMutation) OldUpdatedAt(ctx context.Context) (v time.Tim
}
// ResetUpdatedAt resets all changes to the "updated_at" field.
-func (m *MaintenanceEntryMutation) ResetUpdatedAt() {
+func (m *NotifierMutation) ResetUpdatedAt() {
m.updated_at = nil
}
-// SetItemID sets the "item_id" field.
-func (m *MaintenanceEntryMutation) SetItemID(u uuid.UUID) {
- m.item = &u
-}
-
-// ItemID returns the value of the "item_id" field in the mutation.
-func (m *MaintenanceEntryMutation) ItemID() (r uuid.UUID, exists bool) {
- v := m.item
- if v == nil {
- return
- }
- return *v, true
-}
-
-// OldItemID returns the old "item_id" field's value of the MaintenanceEntry entity.
-// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
-// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *MaintenanceEntryMutation) OldItemID(ctx context.Context) (v uuid.UUID, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldItemID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldItemID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldItemID: %w", err)
- }
- return oldValue.ItemID, nil
-}
-
-// ResetItemID resets all changes to the "item_id" field.
-func (m *MaintenanceEntryMutation) ResetItemID() {
- m.item = nil
-}
-
-// SetDate sets the "date" field.
-func (m *MaintenanceEntryMutation) SetDate(t time.Time) {
- m.date = &t
+// SetGroupID sets the "group_id" field.
+func (m *NotifierMutation) SetGroupID(u uuid.UUID) {
+ m.group = &u
}
-// Date returns the value of the "date" field in the mutation.
-func (m *MaintenanceEntryMutation) Date() (r time.Time, exists bool) {
- v := m.date
+// GroupID returns the value of the "group_id" field in the mutation.
+func (m *NotifierMutation) GroupID() (r uuid.UUID, exists bool) {
+ v := m.group
if v == nil {
return
}
return *v, true
}
-// OldDate returns the old "date" field's value of the MaintenanceEntry entity.
-// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// OldGroupID returns the old "group_id" field's value of the Notifier entity.
+// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *MaintenanceEntryMutation) OldDate(ctx context.Context) (v time.Time, err error) {
+func (m *NotifierMutation) OldGroupID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDate is only allowed on UpdateOne operations")
+ return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDate requires an ID field in the mutation")
+ return v, errors.New("OldGroupID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldDate: %w", err)
+ return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
}
- return oldValue.Date, nil
-}
-
-// ClearDate clears the value of the "date" field.
-func (m *MaintenanceEntryMutation) ClearDate() {
- m.date = nil
- m.clearedFields[maintenanceentry.FieldDate] = struct{}{}
-}
-
-// DateCleared returns if the "date" field was cleared in this mutation.
-func (m *MaintenanceEntryMutation) DateCleared() bool {
- _, ok := m.clearedFields[maintenanceentry.FieldDate]
- return ok
+ return oldValue.GroupID, nil
}
-// ResetDate resets all changes to the "date" field.
-func (m *MaintenanceEntryMutation) ResetDate() {
- m.date = nil
- delete(m.clearedFields, maintenanceentry.FieldDate)
+// ResetGroupID resets all changes to the "group_id" field.
+func (m *NotifierMutation) ResetGroupID() {
+ m.group = nil
}
-// SetScheduledDate sets the "scheduled_date" field.
-func (m *MaintenanceEntryMutation) SetScheduledDate(t time.Time) {
- m.scheduled_date = &t
+// SetUserID sets the "user_id" field.
+func (m *NotifierMutation) SetUserID(u uuid.UUID) {
+ m.user = &u
}
-// ScheduledDate returns the value of the "scheduled_date" field in the mutation.
-func (m *MaintenanceEntryMutation) ScheduledDate() (r time.Time, exists bool) {
- v := m.scheduled_date
+// UserID returns the value of the "user_id" field in the mutation.
+func (m *NotifierMutation) UserID() (r uuid.UUID, exists bool) {
+ v := m.user
if v == nil {
return
}
return *v, true
}
-// OldScheduledDate returns the old "scheduled_date" field's value of the MaintenanceEntry entity.
-// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// OldUserID returns the old "user_id" field's value of the Notifier entity.
+// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *MaintenanceEntryMutation) OldScheduledDate(ctx context.Context) (v time.Time, err error) {
+func (m *NotifierMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldScheduledDate is only allowed on UpdateOne operations")
+ return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldScheduledDate requires an ID field in the mutation")
+ return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldScheduledDate: %w", err)
+ return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
- return oldValue.ScheduledDate, nil
-}
-
-// ClearScheduledDate clears the value of the "scheduled_date" field.
-func (m *MaintenanceEntryMutation) ClearScheduledDate() {
- m.scheduled_date = nil
- m.clearedFields[maintenanceentry.FieldScheduledDate] = struct{}{}
-}
-
-// ScheduledDateCleared returns if the "scheduled_date" field was cleared in this mutation.
-func (m *MaintenanceEntryMutation) ScheduledDateCleared() bool {
- _, ok := m.clearedFields[maintenanceentry.FieldScheduledDate]
- return ok
+ return oldValue.UserID, nil
}
-// ResetScheduledDate resets all changes to the "scheduled_date" field.
-func (m *MaintenanceEntryMutation) ResetScheduledDate() {
- m.scheduled_date = nil
- delete(m.clearedFields, maintenanceentry.FieldScheduledDate)
+// ResetUserID resets all changes to the "user_id" field.
+func (m *NotifierMutation) ResetUserID() {
+ m.user = nil
}
// SetName sets the "name" field.
-func (m *MaintenanceEntryMutation) SetName(s string) {
+func (m *NotifierMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
-func (m *MaintenanceEntryMutation) Name() (r string, exists bool) {
+func (m *NotifierMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
@@ -8884,10 +11383,10 @@ func (m *MaintenanceEntryMutation) Name() (r string, exists bool) {
return *v, true
}
-// OldName returns the old "name" field's value of the MaintenanceEntry entity.
-// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// OldName returns the old "name" field's value of the Notifier entity.
+// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *MaintenanceEntryMutation) OldName(ctx context.Context) (v string, err error) {
+func (m *NotifierMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
@@ -8902,151 +11401,145 @@ func (m *MaintenanceEntryMutation) OldName(ctx context.Context) (v string, err e
}
// ResetName resets all changes to the "name" field.
-func (m *MaintenanceEntryMutation) ResetName() {
+func (m *NotifierMutation) ResetName() {
m.name = nil
}
-// SetDescription sets the "description" field.
-func (m *MaintenanceEntryMutation) SetDescription(s string) {
- m.description = &s
+// SetURL sets the "url" field.
+func (m *NotifierMutation) SetURL(s string) {
+ m.url = &s
}
-// Description returns the value of the "description" field in the mutation.
-func (m *MaintenanceEntryMutation) Description() (r string, exists bool) {
- v := m.description
+// URL returns the value of the "url" field in the mutation.
+func (m *NotifierMutation) URL() (r string, exists bool) {
+ v := m.url
if v == nil {
return
}
return *v, true
}
-// OldDescription returns the old "description" field's value of the MaintenanceEntry entity.
-// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// OldURL returns the old "url" field's value of the Notifier entity.
+// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *MaintenanceEntryMutation) OldDescription(ctx context.Context) (v string, err error) {
+func (m *NotifierMutation) OldURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDescription is only allowed on UpdateOne operations")
+ return v, errors.New("OldURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDescription requires an ID field in the mutation")
+ return v, errors.New("OldURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldDescription: %w", err)
+ return v, fmt.Errorf("querying old value for OldURL: %w", err)
}
- return oldValue.Description, nil
-}
-
-// ClearDescription clears the value of the "description" field.
-func (m *MaintenanceEntryMutation) ClearDescription() {
- m.description = nil
- m.clearedFields[maintenanceentry.FieldDescription] = struct{}{}
-}
-
-// DescriptionCleared returns if the "description" field was cleared in this mutation.
-func (m *MaintenanceEntryMutation) DescriptionCleared() bool {
- _, ok := m.clearedFields[maintenanceentry.FieldDescription]
- return ok
+ return oldValue.URL, nil
}
-// ResetDescription resets all changes to the "description" field.
-func (m *MaintenanceEntryMutation) ResetDescription() {
- m.description = nil
- delete(m.clearedFields, maintenanceentry.FieldDescription)
+// ResetURL resets all changes to the "url" field.
+func (m *NotifierMutation) ResetURL() {
+ m.url = nil
}
-// SetCost sets the "cost" field.
-func (m *MaintenanceEntryMutation) SetCost(f float64) {
- m.cost = &f
- m.addcost = nil
+// SetIsActive sets the "is_active" field.
+func (m *NotifierMutation) SetIsActive(b bool) {
+ m.is_active = &b
}
-// Cost returns the value of the "cost" field in the mutation.
-func (m *MaintenanceEntryMutation) Cost() (r float64, exists bool) {
- v := m.cost
+// IsActive returns the value of the "is_active" field in the mutation.
+func (m *NotifierMutation) IsActive() (r bool, exists bool) {
+ v := m.is_active
if v == nil {
return
}
return *v, true
}
-// OldCost returns the old "cost" field's value of the MaintenanceEntry entity.
-// If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database.
+// OldIsActive returns the old "is_active" field's value of the Notifier entity.
+// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *MaintenanceEntryMutation) OldCost(ctx context.Context) (v float64, err error) {
+func (m *NotifierMutation) OldIsActive(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCost is only allowed on UpdateOne operations")
+ return v, errors.New("OldIsActive is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCost requires an ID field in the mutation")
+ return v, errors.New("OldIsActive requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldCost: %w", err)
+ return v, fmt.Errorf("querying old value for OldIsActive: %w", err)
}
- return oldValue.Cost, nil
+ return oldValue.IsActive, nil
+}
+
+// ResetIsActive resets all changes to the "is_active" field.
+func (m *NotifierMutation) ResetIsActive() {
+ m.is_active = nil
+}
+
+// ClearGroup clears the "group" edge to the Group entity.
+func (m *NotifierMutation) ClearGroup() {
+ m.clearedgroup = true
+ m.clearedFields[notifier.FieldGroupID] = struct{}{}
}
-// AddCost adds f to the "cost" field.
-func (m *MaintenanceEntryMutation) AddCost(f float64) {
- if m.addcost != nil {
- *m.addcost += f
- } else {
- m.addcost = &f
- }
+// GroupCleared reports if the "group" edge to the Group entity was cleared.
+func (m *NotifierMutation) GroupCleared() bool {
+ return m.clearedgroup
}
-// AddedCost returns the value that was added to the "cost" field in this mutation.
-func (m *MaintenanceEntryMutation) AddedCost() (r float64, exists bool) {
- v := m.addcost
- if v == nil {
- return
+// GroupIDs returns the "group" edge IDs in the mutation.
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
+// GroupID instead. It exists only for internal usage by the builders.
+func (m *NotifierMutation) GroupIDs() (ids []uuid.UUID) {
+ if id := m.group; id != nil {
+ ids = append(ids, *id)
}
- return *v, true
+ return
}
-// ResetCost resets all changes to the "cost" field.
-func (m *MaintenanceEntryMutation) ResetCost() {
- m.cost = nil
- m.addcost = nil
+// ResetGroup resets all changes to the "group" edge.
+func (m *NotifierMutation) ResetGroup() {
+ m.group = nil
+ m.clearedgroup = false
}
-// ClearItem clears the "item" edge to the Item entity.
-func (m *MaintenanceEntryMutation) ClearItem() {
- m.cleareditem = true
- m.clearedFields[maintenanceentry.FieldItemID] = struct{}{}
+// ClearUser clears the "user" edge to the User entity.
+func (m *NotifierMutation) ClearUser() {
+ m.cleareduser = true
+ m.clearedFields[notifier.FieldUserID] = struct{}{}
}
-// ItemCleared reports if the "item" edge to the Item entity was cleared.
-func (m *MaintenanceEntryMutation) ItemCleared() bool {
- return m.cleareditem
+// UserCleared reports if the "user" edge to the User entity was cleared.
+func (m *NotifierMutation) UserCleared() bool {
+ return m.cleareduser
}
-// ItemIDs returns the "item" edge IDs in the mutation.
+// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
-// ItemID instead. It exists only for internal usage by the builders.
-func (m *MaintenanceEntryMutation) ItemIDs() (ids []uuid.UUID) {
- if id := m.item; id != nil {
+// UserID instead. It exists only for internal usage by the builders.
+func (m *NotifierMutation) UserIDs() (ids []uuid.UUID) {
+ if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
-// ResetItem resets all changes to the "item" edge.
-func (m *MaintenanceEntryMutation) ResetItem() {
- m.item = nil
- m.cleareditem = false
+// ResetUser resets all changes to the "user" edge.
+func (m *NotifierMutation) ResetUser() {
+ m.user = nil
+ m.cleareduser = false
}
-// Where appends a list predicates to the MaintenanceEntryMutation builder.
-func (m *MaintenanceEntryMutation) Where(ps ...predicate.MaintenanceEntry) {
+// Where appends a list predicates to the NotifierMutation builder.
+func (m *NotifierMutation) Where(ps ...predicate.Notifier) {
m.predicates = append(m.predicates, ps...)
}
-// WhereP appends storage-level predicates to the MaintenanceEntryMutation builder. Using this method,
+// WhereP appends storage-level predicates to the NotifierMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
-func (m *MaintenanceEntryMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.MaintenanceEntry, len(ps))
+func (m *NotifierMutation) WhereP(ps ...func(*sql.Selector)) {
+ p := make([]predicate.Notifier, len(ps))
for i := range ps {
p[i] = ps[i]
}
@@ -9054,48 +11547,45 @@ func (m *MaintenanceEntryMutation) WhereP(ps ...func(*sql.Selector)) {
}
// Op returns the operation name.
-func (m *MaintenanceEntryMutation) Op() Op {
+func (m *NotifierMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
-func (m *MaintenanceEntryMutation) SetOp(op Op) {
+func (m *NotifierMutation) SetOp(op Op) {
m.op = op
}
-// Type returns the node type of this mutation (MaintenanceEntry).
-func (m *MaintenanceEntryMutation) Type() string {
+// Type returns the node type of this mutation (Notifier).
+func (m *NotifierMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
-func (m *MaintenanceEntryMutation) Fields() []string {
- fields := make([]string, 0, 8)
+func (m *NotifierMutation) Fields() []string {
+ fields := make([]string, 0, 7)
if m.created_at != nil {
- fields = append(fields, maintenanceentry.FieldCreatedAt)
+ fields = append(fields, notifier.FieldCreatedAt)
}
if m.updated_at != nil {
- fields = append(fields, maintenanceentry.FieldUpdatedAt)
- }
- if m.item != nil {
- fields = append(fields, maintenanceentry.FieldItemID)
+ fields = append(fields, notifier.FieldUpdatedAt)
}
- if m.date != nil {
- fields = append(fields, maintenanceentry.FieldDate)
+ if m.group != nil {
+ fields = append(fields, notifier.FieldGroupID)
}
- if m.scheduled_date != nil {
- fields = append(fields, maintenanceentry.FieldScheduledDate)
+ if m.user != nil {
+ fields = append(fields, notifier.FieldUserID)
}
if m.name != nil {
- fields = append(fields, maintenanceentry.FieldName)
+ fields = append(fields, notifier.FieldName)
}
- if m.description != nil {
- fields = append(fields, maintenanceentry.FieldDescription)
+ if m.url != nil {
+ fields = append(fields, notifier.FieldURL)
}
- if m.cost != nil {
- fields = append(fields, maintenanceentry.FieldCost)
+ if m.is_active != nil {
+ fields = append(fields, notifier.FieldIsActive)
}
return fields
}
@@ -9103,24 +11593,22 @@ func (m *MaintenanceEntryMutation) Fields() []string {
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
-func (m *MaintenanceEntryMutation) Field(name string) (ent.Value, bool) {
+func (m *NotifierMutation) Field(name string) (ent.Value, bool) {
switch name {
- case maintenanceentry.FieldCreatedAt:
+ case notifier.FieldCreatedAt:
return m.CreatedAt()
- case maintenanceentry.FieldUpdatedAt:
+ case notifier.FieldUpdatedAt:
return m.UpdatedAt()
- case maintenanceentry.FieldItemID:
- return m.ItemID()
- case maintenanceentry.FieldDate:
- return m.Date()
- case maintenanceentry.FieldScheduledDate:
- return m.ScheduledDate()
- case maintenanceentry.FieldName:
+ case notifier.FieldGroupID:
+ return m.GroupID()
+ case notifier.FieldUserID:
+ return m.UserID()
+ case notifier.FieldName:
return m.Name()
- case maintenanceentry.FieldDescription:
- return m.Description()
- case maintenanceentry.FieldCost:
- return m.Cost()
+ case notifier.FieldURL:
+ return m.URL()
+ case notifier.FieldIsActive:
+ return m.IsActive()
}
return nil, false
}
@@ -9128,217 +11616,176 @@ func (m *MaintenanceEntryMutation) Field(name string) (ent.Value, bool) {
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
-func (m *MaintenanceEntryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
+func (m *NotifierMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
- case maintenanceentry.FieldCreatedAt:
+ case notifier.FieldCreatedAt:
return m.OldCreatedAt(ctx)
- case maintenanceentry.FieldUpdatedAt:
+ case notifier.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
- case maintenanceentry.FieldItemID:
- return m.OldItemID(ctx)
- case maintenanceentry.FieldDate:
- return m.OldDate(ctx)
- case maintenanceentry.FieldScheduledDate:
- return m.OldScheduledDate(ctx)
- case maintenanceentry.FieldName:
+ case notifier.FieldGroupID:
+ return m.OldGroupID(ctx)
+ case notifier.FieldUserID:
+ return m.OldUserID(ctx)
+ case notifier.FieldName:
return m.OldName(ctx)
- case maintenanceentry.FieldDescription:
- return m.OldDescription(ctx)
- case maintenanceentry.FieldCost:
- return m.OldCost(ctx)
+ case notifier.FieldURL:
+ return m.OldURL(ctx)
+ case notifier.FieldIsActive:
+ return m.OldIsActive(ctx)
}
- return nil, fmt.Errorf("unknown MaintenanceEntry field %s", name)
+ return nil, fmt.Errorf("unknown Notifier field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
-func (m *MaintenanceEntryMutation) SetField(name string, value ent.Value) error {
+func (m *NotifierMutation) SetField(name string, value ent.Value) error {
switch name {
- case maintenanceentry.FieldCreatedAt:
+ case notifier.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
- case maintenanceentry.FieldUpdatedAt:
+ case notifier.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
- case maintenanceentry.FieldItemID:
+ case notifier.FieldGroupID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
- m.SetItemID(v)
- return nil
- case maintenanceentry.FieldDate:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDate(v)
+ m.SetGroupID(v)
return nil
- case maintenanceentry.FieldScheduledDate:
- v, ok := value.(time.Time)
+ case notifier.FieldUserID:
+ v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
- m.SetScheduledDate(v)
+ m.SetUserID(v)
return nil
- case maintenanceentry.FieldName:
+ case notifier.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
- case maintenanceentry.FieldDescription:
+ case notifier.FieldURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
- m.SetDescription(v)
+ m.SetURL(v)
return nil
- case maintenanceentry.FieldCost:
- v, ok := value.(float64)
+ case notifier.FieldIsActive:
+ v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
- m.SetCost(v)
+ m.SetIsActive(v)
return nil
}
- return fmt.Errorf("unknown MaintenanceEntry field %s", name)
+ return fmt.Errorf("unknown Notifier field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
-func (m *MaintenanceEntryMutation) AddedFields() []string {
- var fields []string
- if m.addcost != nil {
- fields = append(fields, maintenanceentry.FieldCost)
- }
- return fields
+func (m *NotifierMutation) AddedFields() []string {
+ return nil
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
-func (m *MaintenanceEntryMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case maintenanceentry.FieldCost:
- return m.AddedCost()
- }
+func (m *NotifierMutation) AddedField(name string) (ent.Value, bool) {
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
-func (m *MaintenanceEntryMutation) AddField(name string, value ent.Value) error {
+func (m *NotifierMutation) AddField(name string, value ent.Value) error {
switch name {
- case maintenanceentry.FieldCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCost(v)
- return nil
}
- return fmt.Errorf("unknown MaintenanceEntry numeric field %s", name)
+ return fmt.Errorf("unknown Notifier numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
-func (m *MaintenanceEntryMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(maintenanceentry.FieldDate) {
- fields = append(fields, maintenanceentry.FieldDate)
- }
- if m.FieldCleared(maintenanceentry.FieldScheduledDate) {
- fields = append(fields, maintenanceentry.FieldScheduledDate)
- }
- if m.FieldCleared(maintenanceentry.FieldDescription) {
- fields = append(fields, maintenanceentry.FieldDescription)
- }
- return fields
+func (m *NotifierMutation) ClearedFields() []string {
+ return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
-func (m *MaintenanceEntryMutation) FieldCleared(name string) bool {
+func (m *NotifierMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
-
-// ClearField clears the value of the field with the given name. It returns an
-// error if the field is not defined in the schema.
-func (m *MaintenanceEntryMutation) ClearField(name string) error {
- switch name {
- case maintenanceentry.FieldDate:
- m.ClearDate()
- return nil
- case maintenanceentry.FieldScheduledDate:
- m.ClearScheduledDate()
- return nil
- case maintenanceentry.FieldDescription:
- m.ClearDescription()
- return nil
- }
- return fmt.Errorf("unknown MaintenanceEntry nullable field %s", name)
+
+// ClearField clears the value of the field with the given name. It returns an
+// error if the field is not defined in the schema.
+func (m *NotifierMutation) ClearField(name string) error {
+ return fmt.Errorf("unknown Notifier nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
-func (m *MaintenanceEntryMutation) ResetField(name string) error {
+func (m *NotifierMutation) ResetField(name string) error {
switch name {
- case maintenanceentry.FieldCreatedAt:
+ case notifier.FieldCreatedAt:
m.ResetCreatedAt()
return nil
- case maintenanceentry.FieldUpdatedAt:
+ case notifier.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
- case maintenanceentry.FieldItemID:
- m.ResetItemID()
- return nil
- case maintenanceentry.FieldDate:
- m.ResetDate()
+ case notifier.FieldGroupID:
+ m.ResetGroupID()
return nil
- case maintenanceentry.FieldScheduledDate:
- m.ResetScheduledDate()
+ case notifier.FieldUserID:
+ m.ResetUserID()
return nil
- case maintenanceentry.FieldName:
+ case notifier.FieldName:
m.ResetName()
return nil
- case maintenanceentry.FieldDescription:
- m.ResetDescription()
+ case notifier.FieldURL:
+ m.ResetURL()
return nil
- case maintenanceentry.FieldCost:
- m.ResetCost()
+ case notifier.FieldIsActive:
+ m.ResetIsActive()
return nil
}
- return fmt.Errorf("unknown MaintenanceEntry field %s", name)
+ return fmt.Errorf("unknown Notifier field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
-func (m *MaintenanceEntryMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.item != nil {
- edges = append(edges, maintenanceentry.EdgeItem)
+func (m *NotifierMutation) AddedEdges() []string {
+ edges := make([]string, 0, 2)
+ if m.group != nil {
+ edges = append(edges, notifier.EdgeGroup)
+ }
+ if m.user != nil {
+ edges = append(edges, notifier.EdgeUser)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
-func (m *MaintenanceEntryMutation) AddedIDs(name string) []ent.Value {
+func (m *NotifierMutation) AddedIDs(name string) []ent.Value {
switch name {
- case maintenanceentry.EdgeItem:
- if id := m.item; id != nil {
+ case notifier.EdgeGroup:
+ if id := m.group; id != nil {
+ return []ent.Value{*id}
+ }
+ case notifier.EdgeUser:
+ if id := m.user; id != nil {
return []ent.Value{*id}
}
}
@@ -9346,90 +11793,100 @@ func (m *MaintenanceEntryMutation) AddedIDs(name string) []ent.Value {
}
// RemovedEdges returns all edge names that were removed in this mutation.
-func (m *MaintenanceEntryMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
+func (m *NotifierMutation) RemovedEdges() []string {
+ edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
-func (m *MaintenanceEntryMutation) RemovedIDs(name string) []ent.Value {
+func (m *NotifierMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
-func (m *MaintenanceEntryMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.cleareditem {
- edges = append(edges, maintenanceentry.EdgeItem)
+func (m *NotifierMutation) ClearedEdges() []string {
+ edges := make([]string, 0, 2)
+ if m.clearedgroup {
+ edges = append(edges, notifier.EdgeGroup)
+ }
+ if m.cleareduser {
+ edges = append(edges, notifier.EdgeUser)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
-func (m *MaintenanceEntryMutation) EdgeCleared(name string) bool {
+func (m *NotifierMutation) EdgeCleared(name string) bool {
switch name {
- case maintenanceentry.EdgeItem:
- return m.cleareditem
+ case notifier.EdgeGroup:
+ return m.clearedgroup
+ case notifier.EdgeUser:
+ return m.cleareduser
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
-func (m *MaintenanceEntryMutation) ClearEdge(name string) error {
+func (m *NotifierMutation) ClearEdge(name string) error {
switch name {
- case maintenanceentry.EdgeItem:
- m.ClearItem()
+ case notifier.EdgeGroup:
+ m.ClearGroup()
+ return nil
+ case notifier.EdgeUser:
+ m.ClearUser()
return nil
}
- return fmt.Errorf("unknown MaintenanceEntry unique edge %s", name)
+ return fmt.Errorf("unknown Notifier unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
-func (m *MaintenanceEntryMutation) ResetEdge(name string) error {
+func (m *NotifierMutation) ResetEdge(name string) error {
switch name {
- case maintenanceentry.EdgeItem:
- m.ResetItem()
+ case notifier.EdgeGroup:
+ m.ResetGroup()
+ return nil
+ case notifier.EdgeUser:
+ m.ResetUser()
return nil
}
- return fmt.Errorf("unknown MaintenanceEntry edge %s", name)
+ return fmt.Errorf("unknown Notifier edge %s", name)
}
-// NotifierMutation represents an operation that mutates the Notifier nodes in the graph.
-type NotifierMutation struct {
+// TemplateFieldMutation represents an operation that mutates the TemplateField nodes in the graph.
+type TemplateFieldMutation struct {
config
- op Op
- typ string
- id *uuid.UUID
- created_at *time.Time
- updated_at *time.Time
- name *string
- url *string
- is_active *bool
- clearedFields map[string]struct{}
- group *uuid.UUID
- clearedgroup bool
- user *uuid.UUID
- cleareduser bool
- done bool
- oldValue func(context.Context) (*Notifier, error)
- predicates []predicate.Notifier
-}
-
-var _ ent.Mutation = (*NotifierMutation)(nil)
-
-// notifierOption allows management of the mutation configuration using functional options.
-type notifierOption func(*NotifierMutation)
-
-// newNotifierMutation creates new mutation for the Notifier entity.
-func newNotifierMutation(c config, op Op, opts ...notifierOption) *NotifierMutation {
- m := &NotifierMutation{
+ op Op
+ typ string
+ id *uuid.UUID
+ created_at *time.Time
+ updated_at *time.Time
+ name *string
+ description *string
+ _type *templatefield.Type
+ text_value *string
+ clearedFields map[string]struct{}
+ item_template *uuid.UUID
+ cleareditem_template bool
+ done bool
+ oldValue func(context.Context) (*TemplateField, error)
+ predicates []predicate.TemplateField
+}
+
+var _ ent.Mutation = (*TemplateFieldMutation)(nil)
+
+// templatefieldOption allows management of the mutation configuration using functional options.
+type templatefieldOption func(*TemplateFieldMutation)
+
+// newTemplateFieldMutation creates new mutation for the TemplateField entity.
+func newTemplateFieldMutation(c config, op Op, opts ...templatefieldOption) *TemplateFieldMutation {
+ m := &TemplateFieldMutation{
config: c,
op: op,
- typ: TypeNotifier,
+ typ: TypeTemplateField,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
@@ -9438,20 +11895,20 @@ func newNotifierMutation(c config, op Op, opts ...notifierOption) *NotifierMutat
return m
}
-// withNotifierID sets the ID field of the mutation.
-func withNotifierID(id uuid.UUID) notifierOption {
- return func(m *NotifierMutation) {
+// withTemplateFieldID sets the ID field of the mutation.
+func withTemplateFieldID(id uuid.UUID) templatefieldOption {
+ return func(m *TemplateFieldMutation) {
var (
err error
once sync.Once
- value *Notifier
+ value *TemplateField
)
- m.oldValue = func(ctx context.Context) (*Notifier, error) {
+ m.oldValue = func(ctx context.Context) (*TemplateField, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
- value, err = m.Client().Notifier.Get(ctx, id)
+ value, err = m.Client().TemplateField.Get(ctx, id)
}
})
return value, err
@@ -9460,10 +11917,10 @@ func withNotifierID(id uuid.UUID) notifierOption {
}
}
-// withNotifier sets the old Notifier of the mutation.
-func withNotifier(node *Notifier) notifierOption {
- return func(m *NotifierMutation) {
- m.oldValue = func(context.Context) (*Notifier, error) {
+// withTemplateField sets the old TemplateField of the mutation.
+func withTemplateField(node *TemplateField) templatefieldOption {
+ return func(m *TemplateFieldMutation) {
+ m.oldValue = func(context.Context) (*TemplateField, error) {
return node, nil
}
m.id = &node.ID
@@ -9472,7 +11929,7 @@ func withNotifier(node *Notifier) notifierOption {
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
-func (m NotifierMutation) Client() *Client {
+func (m TemplateFieldMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
@@ -9480,7 +11937,7 @@ func (m NotifierMutation) Client() *Client {
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
-func (m NotifierMutation) Tx() (*Tx, error) {
+func (m TemplateFieldMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("ent: mutation is not running in a transaction")
}
@@ -9490,14 +11947,14 @@ func (m NotifierMutation) Tx() (*Tx, error) {
}
// SetID sets the value of the id field. Note that this
-// operation is only accepted on creation of Notifier entities.
-func (m *NotifierMutation) SetID(id uuid.UUID) {
+// operation is only accepted on creation of TemplateField entities.
+func (m *TemplateFieldMutation) SetID(id uuid.UUID) {
m.id = &id
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
-func (m *NotifierMutation) ID() (id uuid.UUID, exists bool) {
+func (m *TemplateFieldMutation) ID() (id uuid.UUID, exists bool) {
if m.id == nil {
return
}
@@ -9508,7 +11965,7 @@ func (m *NotifierMutation) ID() (id uuid.UUID, exists bool) {
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
-func (m *NotifierMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
+func (m *TemplateFieldMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
@@ -9517,19 +11974,19 @@ func (m *NotifierMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Notifier.Query().Where(m.predicates...).IDs(ctx)
+ return m.Client().TemplateField.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetCreatedAt sets the "created_at" field.
-func (m *NotifierMutation) SetCreatedAt(t time.Time) {
+func (m *TemplateFieldMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
-func (m *NotifierMutation) CreatedAt() (r time.Time, exists bool) {
+func (m *TemplateFieldMutation) CreatedAt() (r time.Time, exists bool) {
v := m.created_at
if v == nil {
return
@@ -9537,10 +11994,10 @@ func (m *NotifierMutation) CreatedAt() (r time.Time, exists bool) {
return *v, true
}
-// OldCreatedAt returns the old "created_at" field's value of the Notifier entity.
-// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
+// OldCreatedAt returns the old "created_at" field's value of the TemplateField entity.
+// If the TemplateField object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *NotifierMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
+func (m *TemplateFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
}
@@ -9555,17 +12012,17 @@ func (m *NotifierMutation) OldCreatedAt(ctx context.Context) (v time.Time, err e
}
// ResetCreatedAt resets all changes to the "created_at" field.
-func (m *NotifierMutation) ResetCreatedAt() {
+func (m *TemplateFieldMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
-func (m *NotifierMutation) SetUpdatedAt(t time.Time) {
+func (m *TemplateFieldMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
-func (m *NotifierMutation) UpdatedAt() (r time.Time, exists bool) {
+func (m *TemplateFieldMutation) UpdatedAt() (r time.Time, exists bool) {
v := m.updated_at
if v == nil {
return
@@ -9573,10 +12030,10 @@ func (m *NotifierMutation) UpdatedAt() (r time.Time, exists bool) {
return *v, true
}
-// OldUpdatedAt returns the old "updated_at" field's value of the Notifier entity.
-// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
+// OldUpdatedAt returns the old "updated_at" field's value of the TemplateField entity.
+// If the TemplateField object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *NotifierMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
+func (m *TemplateFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
}
@@ -9591,253 +12048,228 @@ func (m *NotifierMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err e
}
// ResetUpdatedAt resets all changes to the "updated_at" field.
-func (m *NotifierMutation) ResetUpdatedAt() {
+func (m *TemplateFieldMutation) ResetUpdatedAt() {
m.updated_at = nil
}
-// SetGroupID sets the "group_id" field.
-func (m *NotifierMutation) SetGroupID(u uuid.UUID) {
- m.group = &u
+// SetName sets the "name" field.
+func (m *TemplateFieldMutation) SetName(s string) {
+ m.name = &s
}
-// GroupID returns the value of the "group_id" field in the mutation.
-func (m *NotifierMutation) GroupID() (r uuid.UUID, exists bool) {
- v := m.group
+// Name returns the value of the "name" field in the mutation.
+func (m *TemplateFieldMutation) Name() (r string, exists bool) {
+ v := m.name
if v == nil {
return
}
return *v, true
}
-// OldGroupID returns the old "group_id" field's value of the Notifier entity.
-// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
+// OldName returns the old "name" field's value of the TemplateField entity.
+// If the TemplateField object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *NotifierMutation) OldGroupID(ctx context.Context) (v uuid.UUID, err error) {
+func (m *TemplateFieldMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
+ return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupID requires an ID field in the mutation")
+ return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
+ return v, fmt.Errorf("querying old value for OldName: %w", err)
}
- return oldValue.GroupID, nil
+ return oldValue.Name, nil
}
-// ResetGroupID resets all changes to the "group_id" field.
-func (m *NotifierMutation) ResetGroupID() {
- m.group = nil
+// ResetName resets all changes to the "name" field.
+func (m *TemplateFieldMutation) ResetName() {
+ m.name = nil
}
-// SetUserID sets the "user_id" field.
-func (m *NotifierMutation) SetUserID(u uuid.UUID) {
- m.user = &u
+// SetDescription sets the "description" field.
+func (m *TemplateFieldMutation) SetDescription(s string) {
+ m.description = &s
}
-// UserID returns the value of the "user_id" field in the mutation.
-func (m *NotifierMutation) UserID() (r uuid.UUID, exists bool) {
- v := m.user
+// Description returns the value of the "description" field in the mutation.
+func (m *TemplateFieldMutation) Description() (r string, exists bool) {
+ v := m.description
if v == nil {
return
}
return *v, true
}
-// OldUserID returns the old "user_id" field's value of the Notifier entity.
-// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
+// OldDescription returns the old "description" field's value of the TemplateField entity.
+// If the TemplateField object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *NotifierMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
+func (m *TemplateFieldMutation) OldDescription(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
+ return v, errors.New("OldDescription is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
+ return v, errors.New("OldDescription requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
+ return v, fmt.Errorf("querying old value for OldDescription: %w", err)
}
- return oldValue.UserID, nil
-}
-
-// ResetUserID resets all changes to the "user_id" field.
-func (m *NotifierMutation) ResetUserID() {
- m.user = nil
-}
-
-// SetName sets the "name" field.
-func (m *NotifierMutation) SetName(s string) {
- m.name = &s
+ return oldValue.Description, nil
}
-// Name returns the value of the "name" field in the mutation.
-func (m *NotifierMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
+// ClearDescription clears the value of the "description" field.
+func (m *TemplateFieldMutation) ClearDescription() {
+ m.description = nil
+ m.clearedFields[templatefield.FieldDescription] = struct{}{}
}
-// OldName returns the old "name" field's value of the Notifier entity.
-// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
-// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *NotifierMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
+// DescriptionCleared returns if the "description" field was cleared in this mutation.
+func (m *TemplateFieldMutation) DescriptionCleared() bool {
+ _, ok := m.clearedFields[templatefield.FieldDescription]
+ return ok
}
-// ResetName resets all changes to the "name" field.
-func (m *NotifierMutation) ResetName() {
- m.name = nil
+// ResetDescription resets all changes to the "description" field.
+func (m *TemplateFieldMutation) ResetDescription() {
+ m.description = nil
+ delete(m.clearedFields, templatefield.FieldDescription)
}
-// SetURL sets the "url" field.
-func (m *NotifierMutation) SetURL(s string) {
- m.url = &s
+// SetType sets the "type" field.
+func (m *TemplateFieldMutation) SetType(t templatefield.Type) {
+ m._type = &t
}
-
-// URL returns the value of the "url" field in the mutation.
-func (m *NotifierMutation) URL() (r string, exists bool) {
- v := m.url
+
+// GetType returns the value of the "type" field in the mutation.
+func (m *TemplateFieldMutation) GetType() (r templatefield.Type, exists bool) {
+ v := m._type
if v == nil {
return
}
return *v, true
}
-// OldURL returns the old "url" field's value of the Notifier entity.
-// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
+// OldType returns the old "type" field's value of the TemplateField entity.
+// If the TemplateField object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *NotifierMutation) OldURL(ctx context.Context) (v string, err error) {
+func (m *TemplateFieldMutation) OldType(ctx context.Context) (v templatefield.Type, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldURL is only allowed on UpdateOne operations")
+ return v, errors.New("OldType is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldURL requires an ID field in the mutation")
+ return v, errors.New("OldType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldURL: %w", err)
+ return v, fmt.Errorf("querying old value for OldType: %w", err)
}
- return oldValue.URL, nil
+ return oldValue.Type, nil
}
-// ResetURL resets all changes to the "url" field.
-func (m *NotifierMutation) ResetURL() {
- m.url = nil
+// ResetType resets all changes to the "type" field.
+func (m *TemplateFieldMutation) ResetType() {
+ m._type = nil
}
-// SetIsActive sets the "is_active" field.
-func (m *NotifierMutation) SetIsActive(b bool) {
- m.is_active = &b
+// SetTextValue sets the "text_value" field.
+func (m *TemplateFieldMutation) SetTextValue(s string) {
+ m.text_value = &s
}
-// IsActive returns the value of the "is_active" field in the mutation.
-func (m *NotifierMutation) IsActive() (r bool, exists bool) {
- v := m.is_active
+// TextValue returns the value of the "text_value" field in the mutation.
+func (m *TemplateFieldMutation) TextValue() (r string, exists bool) {
+ v := m.text_value
if v == nil {
return
}
return *v, true
}
-// OldIsActive returns the old "is_active" field's value of the Notifier entity.
-// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
+// OldTextValue returns the old "text_value" field's value of the TemplateField entity.
+// If the TemplateField object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *NotifierMutation) OldIsActive(ctx context.Context) (v bool, err error) {
+func (m *TemplateFieldMutation) OldTextValue(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIsActive is only allowed on UpdateOne operations")
+ return v, errors.New("OldTextValue is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIsActive requires an ID field in the mutation")
+ return v, errors.New("OldTextValue requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
- return v, fmt.Errorf("querying old value for OldIsActive: %w", err)
+ return v, fmt.Errorf("querying old value for OldTextValue: %w", err)
}
- return oldValue.IsActive, nil
+ return oldValue.TextValue, nil
}
-// ResetIsActive resets all changes to the "is_active" field.
-func (m *NotifierMutation) ResetIsActive() {
- m.is_active = nil
+// ClearTextValue clears the value of the "text_value" field.
+func (m *TemplateFieldMutation) ClearTextValue() {
+ m.text_value = nil
+ m.clearedFields[templatefield.FieldTextValue] = struct{}{}
}
-// ClearGroup clears the "group" edge to the Group entity.
-func (m *NotifierMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[notifier.FieldGroupID] = struct{}{}
+// TextValueCleared returns if the "text_value" field was cleared in this mutation.
+func (m *TemplateFieldMutation) TextValueCleared() bool {
+ _, ok := m.clearedFields[templatefield.FieldTextValue]
+ return ok
}
-// GroupCleared reports if the "group" edge to the Group entity was cleared.
-func (m *NotifierMutation) GroupCleared() bool {
- return m.clearedgroup
+// ResetTextValue resets all changes to the "text_value" field.
+func (m *TemplateFieldMutation) ResetTextValue() {
+ m.text_value = nil
+ delete(m.clearedFields, templatefield.FieldTextValue)
}
-// GroupIDs returns the "group" edge IDs in the mutation.
-// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
-// GroupID instead. It exists only for internal usage by the builders.
-func (m *NotifierMutation) GroupIDs() (ids []uuid.UUID) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
+// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by id.
+func (m *TemplateFieldMutation) SetItemTemplateID(id uuid.UUID) {
+ m.item_template = &id
}
-// ResetGroup resets all changes to the "group" edge.
-func (m *NotifierMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
+// ClearItemTemplate clears the "item_template" edge to the ItemTemplate entity.
+func (m *TemplateFieldMutation) ClearItemTemplate() {
+ m.cleareditem_template = true
}
-// ClearUser clears the "user" edge to the User entity.
-func (m *NotifierMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[notifier.FieldUserID] = struct{}{}
+// ItemTemplateCleared reports if the "item_template" edge to the ItemTemplate entity was cleared.
+func (m *TemplateFieldMutation) ItemTemplateCleared() bool {
+ return m.cleareditem_template
}
-// UserCleared reports if the "user" edge to the User entity was cleared.
-func (m *NotifierMutation) UserCleared() bool {
- return m.cleareduser
+// ItemTemplateID returns the "item_template" edge ID in the mutation.
+func (m *TemplateFieldMutation) ItemTemplateID() (id uuid.UUID, exists bool) {
+ if m.item_template != nil {
+ return *m.item_template, true
+ }
+ return
}
-// UserIDs returns the "user" edge IDs in the mutation.
+// ItemTemplateIDs returns the "item_template" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
-// UserID instead. It exists only for internal usage by the builders.
-func (m *NotifierMutation) UserIDs() (ids []uuid.UUID) {
- if id := m.user; id != nil {
+// ItemTemplateID instead. It exists only for internal usage by the builders.
+func (m *TemplateFieldMutation) ItemTemplateIDs() (ids []uuid.UUID) {
+ if id := m.item_template; id != nil {
ids = append(ids, *id)
}
return
}
-// ResetUser resets all changes to the "user" edge.
-func (m *NotifierMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
+// ResetItemTemplate resets all changes to the "item_template" edge.
+func (m *TemplateFieldMutation) ResetItemTemplate() {
+ m.item_template = nil
+ m.cleareditem_template = false
}
-// Where appends a list predicates to the NotifierMutation builder.
-func (m *NotifierMutation) Where(ps ...predicate.Notifier) {
+// Where appends a list predicates to the TemplateFieldMutation builder.
+func (m *TemplateFieldMutation) Where(ps ...predicate.TemplateField) {
m.predicates = append(m.predicates, ps...)
}
-// WhereP appends storage-level predicates to the NotifierMutation builder. Using this method,
+// WhereP appends storage-level predicates to the TemplateFieldMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
-func (m *NotifierMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Notifier, len(ps))
+func (m *TemplateFieldMutation) WhereP(ps ...func(*sql.Selector)) {
+ p := make([]predicate.TemplateField, len(ps))
for i := range ps {
p[i] = ps[i]
}
@@ -9845,45 +12277,42 @@ func (m *NotifierMutation) WhereP(ps ...func(*sql.Selector)) {
}
// Op returns the operation name.
-func (m *NotifierMutation) Op() Op {
+func (m *TemplateFieldMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
-func (m *NotifierMutation) SetOp(op Op) {
+func (m *TemplateFieldMutation) SetOp(op Op) {
m.op = op
}
-// Type returns the node type of this mutation (Notifier).
-func (m *NotifierMutation) Type() string {
+// Type returns the node type of this mutation (TemplateField).
+func (m *TemplateFieldMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
-func (m *NotifierMutation) Fields() []string {
- fields := make([]string, 0, 7)
+func (m *TemplateFieldMutation) Fields() []string {
+ fields := make([]string, 0, 6)
if m.created_at != nil {
- fields = append(fields, notifier.FieldCreatedAt)
+ fields = append(fields, templatefield.FieldCreatedAt)
}
if m.updated_at != nil {
- fields = append(fields, notifier.FieldUpdatedAt)
- }
- if m.group != nil {
- fields = append(fields, notifier.FieldGroupID)
- }
- if m.user != nil {
- fields = append(fields, notifier.FieldUserID)
+ fields = append(fields, templatefield.FieldUpdatedAt)
}
if m.name != nil {
- fields = append(fields, notifier.FieldName)
+ fields = append(fields, templatefield.FieldName)
}
- if m.url != nil {
- fields = append(fields, notifier.FieldURL)
+ if m.description != nil {
+ fields = append(fields, templatefield.FieldDescription)
}
- if m.is_active != nil {
- fields = append(fields, notifier.FieldIsActive)
+ if m._type != nil {
+ fields = append(fields, templatefield.FieldType)
+ }
+ if m.text_value != nil {
+ fields = append(fields, templatefield.FieldTextValue)
}
return fields
}
@@ -9891,22 +12320,20 @@ func (m *NotifierMutation) Fields() []string {
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
-func (m *NotifierMutation) Field(name string) (ent.Value, bool) {
+func (m *TemplateFieldMutation) Field(name string) (ent.Value, bool) {
switch name {
- case notifier.FieldCreatedAt:
+ case templatefield.FieldCreatedAt:
return m.CreatedAt()
- case notifier.FieldUpdatedAt:
+ case templatefield.FieldUpdatedAt:
return m.UpdatedAt()
- case notifier.FieldGroupID:
- return m.GroupID()
- case notifier.FieldUserID:
- return m.UserID()
- case notifier.FieldName:
+ case templatefield.FieldName:
return m.Name()
- case notifier.FieldURL:
- return m.URL()
- case notifier.FieldIsActive:
- return m.IsActive()
+ case templatefield.FieldDescription:
+ return m.Description()
+ case templatefield.FieldType:
+ return m.GetType()
+ case templatefield.FieldTextValue:
+ return m.TextValue()
}
return nil, false
}
@@ -9914,176 +12341,172 @@ func (m *NotifierMutation) Field(name string) (ent.Value, bool) {
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
-func (m *NotifierMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
+func (m *TemplateFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
- case notifier.FieldCreatedAt:
+ case templatefield.FieldCreatedAt:
return m.OldCreatedAt(ctx)
- case notifier.FieldUpdatedAt:
+ case templatefield.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
- case notifier.FieldGroupID:
- return m.OldGroupID(ctx)
- case notifier.FieldUserID:
- return m.OldUserID(ctx)
- case notifier.FieldName:
+ case templatefield.FieldName:
return m.OldName(ctx)
- case notifier.FieldURL:
- return m.OldURL(ctx)
- case notifier.FieldIsActive:
- return m.OldIsActive(ctx)
+ case templatefield.FieldDescription:
+ return m.OldDescription(ctx)
+ case templatefield.FieldType:
+ return m.OldType(ctx)
+ case templatefield.FieldTextValue:
+ return m.OldTextValue(ctx)
}
- return nil, fmt.Errorf("unknown Notifier field %s", name)
+ return nil, fmt.Errorf("unknown TemplateField field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
-func (m *NotifierMutation) SetField(name string, value ent.Value) error {
+func (m *TemplateFieldMutation) SetField(name string, value ent.Value) error {
switch name {
- case notifier.FieldCreatedAt:
+ case templatefield.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
- case notifier.FieldUpdatedAt:
+ case templatefield.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
- case notifier.FieldGroupID:
- v, ok := value.(uuid.UUID)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case notifier.FieldUserID:
- v, ok := value.(uuid.UUID)
+ case templatefield.FieldName:
+ v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
- m.SetUserID(v)
+ m.SetName(v)
return nil
- case notifier.FieldName:
+ case templatefield.FieldDescription:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
- m.SetName(v)
+ m.SetDescription(v)
return nil
- case notifier.FieldURL:
- v, ok := value.(string)
+ case templatefield.FieldType:
+ v, ok := value.(templatefield.Type)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
- m.SetURL(v)
+ m.SetType(v)
return nil
- case notifier.FieldIsActive:
- v, ok := value.(bool)
+ case templatefield.FieldTextValue:
+ v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
- m.SetIsActive(v)
+ m.SetTextValue(v)
return nil
}
- return fmt.Errorf("unknown Notifier field %s", name)
+ return fmt.Errorf("unknown TemplateField field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
-func (m *NotifierMutation) AddedFields() []string {
+func (m *TemplateFieldMutation) AddedFields() []string {
return nil
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
-func (m *NotifierMutation) AddedField(name string) (ent.Value, bool) {
+func (m *TemplateFieldMutation) AddedField(name string) (ent.Value, bool) {
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
-func (m *NotifierMutation) AddField(name string, value ent.Value) error {
+func (m *TemplateFieldMutation) AddField(name string, value ent.Value) error {
switch name {
}
- return fmt.Errorf("unknown Notifier numeric field %s", name)
+ return fmt.Errorf("unknown TemplateField numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
-func (m *NotifierMutation) ClearedFields() []string {
- return nil
+func (m *TemplateFieldMutation) ClearedFields() []string {
+ var fields []string
+ if m.FieldCleared(templatefield.FieldDescription) {
+ fields = append(fields, templatefield.FieldDescription)
+ }
+ if m.FieldCleared(templatefield.FieldTextValue) {
+ fields = append(fields, templatefield.FieldTextValue)
+ }
+ return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
-func (m *NotifierMutation) FieldCleared(name string) bool {
+func (m *TemplateFieldMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
-func (m *NotifierMutation) ClearField(name string) error {
- return fmt.Errorf("unknown Notifier nullable field %s", name)
+func (m *TemplateFieldMutation) ClearField(name string) error {
+ switch name {
+ case templatefield.FieldDescription:
+ m.ClearDescription()
+ return nil
+ case templatefield.FieldTextValue:
+ m.ClearTextValue()
+ return nil
+ }
+ return fmt.Errorf("unknown TemplateField nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
-func (m *NotifierMutation) ResetField(name string) error {
+func (m *TemplateFieldMutation) ResetField(name string) error {
switch name {
- case notifier.FieldCreatedAt:
+ case templatefield.FieldCreatedAt:
m.ResetCreatedAt()
return nil
- case notifier.FieldUpdatedAt:
+ case templatefield.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
- case notifier.FieldGroupID:
- m.ResetGroupID()
- return nil
- case notifier.FieldUserID:
- m.ResetUserID()
- return nil
- case notifier.FieldName:
+ case templatefield.FieldName:
m.ResetName()
return nil
- case notifier.FieldURL:
- m.ResetURL()
+ case templatefield.FieldDescription:
+ m.ResetDescription()
return nil
- case notifier.FieldIsActive:
- m.ResetIsActive()
+ case templatefield.FieldType:
+ m.ResetType()
+ return nil
+ case templatefield.FieldTextValue:
+ m.ResetTextValue()
return nil
}
- return fmt.Errorf("unknown Notifier field %s", name)
+ return fmt.Errorf("unknown TemplateField field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
-func (m *NotifierMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.group != nil {
- edges = append(edges, notifier.EdgeGroup)
- }
- if m.user != nil {
- edges = append(edges, notifier.EdgeUser)
+func (m *TemplateFieldMutation) AddedEdges() []string {
+ edges := make([]string, 0, 1)
+ if m.item_template != nil {
+ edges = append(edges, templatefield.EdgeItemTemplate)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
-func (m *NotifierMutation) AddedIDs(name string) []ent.Value {
+func (m *TemplateFieldMutation) AddedIDs(name string) []ent.Value {
switch name {
- case notifier.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- case notifier.EdgeUser:
- if id := m.user; id != nil {
+ case templatefield.EdgeItemTemplate:
+ if id := m.item_template; id != nil {
return []ent.Value{*id}
}
}
@@ -10091,67 +12514,56 @@ func (m *NotifierMutation) AddedIDs(name string) []ent.Value {
}
// RemovedEdges returns all edge names that were removed in this mutation.
-func (m *NotifierMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
+func (m *TemplateFieldMutation) RemovedEdges() []string {
+ edges := make([]string, 0, 1)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
-func (m *NotifierMutation) RemovedIDs(name string) []ent.Value {
+func (m *TemplateFieldMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
-func (m *NotifierMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.clearedgroup {
- edges = append(edges, notifier.EdgeGroup)
- }
- if m.cleareduser {
- edges = append(edges, notifier.EdgeUser)
+func (m *TemplateFieldMutation) ClearedEdges() []string {
+ edges := make([]string, 0, 1)
+ if m.cleareditem_template {
+ edges = append(edges, templatefield.EdgeItemTemplate)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
-func (m *NotifierMutation) EdgeCleared(name string) bool {
+func (m *TemplateFieldMutation) EdgeCleared(name string) bool {
switch name {
- case notifier.EdgeGroup:
- return m.clearedgroup
- case notifier.EdgeUser:
- return m.cleareduser
+ case templatefield.EdgeItemTemplate:
+ return m.cleareditem_template
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
-func (m *NotifierMutation) ClearEdge(name string) error {
+func (m *TemplateFieldMutation) ClearEdge(name string) error {
switch name {
- case notifier.EdgeGroup:
- m.ClearGroup()
- return nil
- case notifier.EdgeUser:
- m.ClearUser()
+ case templatefield.EdgeItemTemplate:
+ m.ClearItemTemplate()
return nil
}
- return fmt.Errorf("unknown Notifier unique edge %s", name)
+ return fmt.Errorf("unknown TemplateField unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
-func (m *NotifierMutation) ResetEdge(name string) error {
+func (m *TemplateFieldMutation) ResetEdge(name string) error {
switch name {
- case notifier.EdgeGroup:
- m.ResetGroup()
- return nil
- case notifier.EdgeUser:
- m.ResetUser()
+ case templatefield.EdgeItemTemplate:
+ m.ResetItemTemplate()
return nil
}
- return fmt.Errorf("unknown Notifier edge %s", name)
+ return fmt.Errorf("unknown TemplateField edge %s", name)
}
// UserMutation represents an operation that mutates the User nodes in the graph.
diff --git a/backend/internal/data/ent/predicate/predicate.go b/backend/internal/data/ent/predicate/predicate.go
index 26e42325..0d9d47f5 100644
--- a/backend/internal/data/ent/predicate/predicate.go
+++ b/backend/internal/data/ent/predicate/predicate.go
@@ -27,6 +27,9 @@ type Item func(*sql.Selector)
// ItemField is the predicate function for itemfield builders.
type ItemField func(*sql.Selector)
+// ItemTemplate is the predicate function for itemtemplate builders.
+type ItemTemplate func(*sql.Selector)
+
// Label is the predicate function for label builders.
type Label func(*sql.Selector)
@@ -39,5 +42,8 @@ type MaintenanceEntry func(*sql.Selector)
// Notifier is the predicate function for notifier builders.
type Notifier func(*sql.Selector)
+// TemplateField is the predicate function for templatefield builders.
+type TemplateField func(*sql.Selector)
+
// User is the predicate function for user builders.
type User func(*sql.Selector)
diff --git a/backend/internal/data/ent/runtime.go b/backend/internal/data/ent/runtime.go
index 2ac6b536..0476c5c6 100644
--- a/backend/internal/data/ent/runtime.go
+++ b/backend/internal/data/ent/runtime.go
@@ -12,11 +12,13 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -310,6 +312,97 @@ func init() {
itemfieldDescID := itemfieldMixinFields0[0].Descriptor()
// itemfield.DefaultID holds the default value on creation for the id field.
itemfield.DefaultID = itemfieldDescID.Default.(func() uuid.UUID)
+ itemtemplateMixin := schema.ItemTemplate{}.Mixin()
+ itemtemplateMixinFields0 := itemtemplateMixin[0].Fields()
+ _ = itemtemplateMixinFields0
+ itemtemplateMixinFields1 := itemtemplateMixin[1].Fields()
+ _ = itemtemplateMixinFields1
+ itemtemplateFields := schema.ItemTemplate{}.Fields()
+ _ = itemtemplateFields
+ // itemtemplateDescCreatedAt is the schema descriptor for created_at field.
+ itemtemplateDescCreatedAt := itemtemplateMixinFields0[1].Descriptor()
+ // itemtemplate.DefaultCreatedAt holds the default value on creation for the created_at field.
+ itemtemplate.DefaultCreatedAt = itemtemplateDescCreatedAt.Default.(func() time.Time)
+ // itemtemplateDescUpdatedAt is the schema descriptor for updated_at field.
+ itemtemplateDescUpdatedAt := itemtemplateMixinFields0[2].Descriptor()
+ // itemtemplate.DefaultUpdatedAt holds the default value on creation for the updated_at field.
+ itemtemplate.DefaultUpdatedAt = itemtemplateDescUpdatedAt.Default.(func() time.Time)
+ // itemtemplate.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
+ itemtemplate.UpdateDefaultUpdatedAt = itemtemplateDescUpdatedAt.UpdateDefault.(func() time.Time)
+ // itemtemplateDescName is the schema descriptor for name field.
+ itemtemplateDescName := itemtemplateMixinFields1[0].Descriptor()
+ // itemtemplate.NameValidator is a validator for the "name" field. It is called by the builders before save.
+ itemtemplate.NameValidator = func() func(string) error {
+ validators := itemtemplateDescName.Validators
+ fns := [...]func(string) error{
+ validators[0].(func(string) error),
+ validators[1].(func(string) error),
+ }
+ return func(name string) error {
+ for _, fn := range fns {
+ if err := fn(name); err != nil {
+ return err
+ }
+ }
+ return nil
+ }
+ }()
+ // itemtemplateDescDescription is the schema descriptor for description field.
+ itemtemplateDescDescription := itemtemplateMixinFields1[1].Descriptor()
+ // itemtemplate.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
+ itemtemplate.DescriptionValidator = itemtemplateDescDescription.Validators[0].(func(string) error)
+ // itemtemplateDescNotes is the schema descriptor for notes field.
+ itemtemplateDescNotes := itemtemplateFields[0].Descriptor()
+ // itemtemplate.NotesValidator is a validator for the "notes" field. It is called by the builders before save.
+ itemtemplate.NotesValidator = itemtemplateDescNotes.Validators[0].(func(string) error)
+ // itemtemplateDescDefaultQuantity is the schema descriptor for default_quantity field.
+ itemtemplateDescDefaultQuantity := itemtemplateFields[1].Descriptor()
+ // itemtemplate.DefaultDefaultQuantity holds the default value on creation for the default_quantity field.
+ itemtemplate.DefaultDefaultQuantity = itemtemplateDescDefaultQuantity.Default.(int)
+ // itemtemplateDescDefaultInsured is the schema descriptor for default_insured field.
+ itemtemplateDescDefaultInsured := itemtemplateFields[2].Descriptor()
+ // itemtemplate.DefaultDefaultInsured holds the default value on creation for the default_insured field.
+ itemtemplate.DefaultDefaultInsured = itemtemplateDescDefaultInsured.Default.(bool)
+ // itemtemplateDescDefaultName is the schema descriptor for default_name field.
+ itemtemplateDescDefaultName := itemtemplateFields[3].Descriptor()
+ // itemtemplate.DefaultNameValidator is a validator for the "default_name" field. It is called by the builders before save.
+ itemtemplate.DefaultNameValidator = itemtemplateDescDefaultName.Validators[0].(func(string) error)
+ // itemtemplateDescDefaultDescription is the schema descriptor for default_description field.
+ itemtemplateDescDefaultDescription := itemtemplateFields[4].Descriptor()
+ // itemtemplate.DefaultDescriptionValidator is a validator for the "default_description" field. It is called by the builders before save.
+ itemtemplate.DefaultDescriptionValidator = itemtemplateDescDefaultDescription.Validators[0].(func(string) error)
+ // itemtemplateDescDefaultManufacturer is the schema descriptor for default_manufacturer field.
+ itemtemplateDescDefaultManufacturer := itemtemplateFields[5].Descriptor()
+ // itemtemplate.DefaultManufacturerValidator is a validator for the "default_manufacturer" field. It is called by the builders before save.
+ itemtemplate.DefaultManufacturerValidator = itemtemplateDescDefaultManufacturer.Validators[0].(func(string) error)
+ // itemtemplateDescDefaultModelNumber is the schema descriptor for default_model_number field.
+ itemtemplateDescDefaultModelNumber := itemtemplateFields[6].Descriptor()
+ // itemtemplate.DefaultModelNumberValidator is a validator for the "default_model_number" field. It is called by the builders before save.
+ itemtemplate.DefaultModelNumberValidator = itemtemplateDescDefaultModelNumber.Validators[0].(func(string) error)
+ // itemtemplateDescDefaultLifetimeWarranty is the schema descriptor for default_lifetime_warranty field.
+ itemtemplateDescDefaultLifetimeWarranty := itemtemplateFields[7].Descriptor()
+ // itemtemplate.DefaultDefaultLifetimeWarranty holds the default value on creation for the default_lifetime_warranty field.
+ itemtemplate.DefaultDefaultLifetimeWarranty = itemtemplateDescDefaultLifetimeWarranty.Default.(bool)
+ // itemtemplateDescDefaultWarrantyDetails is the schema descriptor for default_warranty_details field.
+ itemtemplateDescDefaultWarrantyDetails := itemtemplateFields[8].Descriptor()
+ // itemtemplate.DefaultWarrantyDetailsValidator is a validator for the "default_warranty_details" field. It is called by the builders before save.
+ itemtemplate.DefaultWarrantyDetailsValidator = itemtemplateDescDefaultWarrantyDetails.Validators[0].(func(string) error)
+ // itemtemplateDescIncludeWarrantyFields is the schema descriptor for include_warranty_fields field.
+ itemtemplateDescIncludeWarrantyFields := itemtemplateFields[9].Descriptor()
+ // itemtemplate.DefaultIncludeWarrantyFields holds the default value on creation for the include_warranty_fields field.
+ itemtemplate.DefaultIncludeWarrantyFields = itemtemplateDescIncludeWarrantyFields.Default.(bool)
+ // itemtemplateDescIncludePurchaseFields is the schema descriptor for include_purchase_fields field.
+ itemtemplateDescIncludePurchaseFields := itemtemplateFields[10].Descriptor()
+ // itemtemplate.DefaultIncludePurchaseFields holds the default value on creation for the include_purchase_fields field.
+ itemtemplate.DefaultIncludePurchaseFields = itemtemplateDescIncludePurchaseFields.Default.(bool)
+ // itemtemplateDescIncludeSoldFields is the schema descriptor for include_sold_fields field.
+ itemtemplateDescIncludeSoldFields := itemtemplateFields[11].Descriptor()
+ // itemtemplate.DefaultIncludeSoldFields holds the default value on creation for the include_sold_fields field.
+ itemtemplate.DefaultIncludeSoldFields = itemtemplateDescIncludeSoldFields.Default.(bool)
+ // itemtemplateDescID is the schema descriptor for id field.
+ itemtemplateDescID := itemtemplateMixinFields0[0].Descriptor()
+ // itemtemplate.DefaultID holds the default value on creation for the id field.
+ itemtemplate.DefaultID = itemtemplateDescID.Default.(func() uuid.UUID)
labelMixin := schema.Label{}.Mixin()
labelMixinFields0 := labelMixin[0].Fields()
_ = labelMixinFields0
@@ -504,6 +597,53 @@ func init() {
notifierDescID := notifierMixinFields0[0].Descriptor()
// notifier.DefaultID holds the default value on creation for the id field.
notifier.DefaultID = notifierDescID.Default.(func() uuid.UUID)
+ templatefieldMixin := schema.TemplateField{}.Mixin()
+ templatefieldMixinFields0 := templatefieldMixin[0].Fields()
+ _ = templatefieldMixinFields0
+ templatefieldMixinFields1 := templatefieldMixin[1].Fields()
+ _ = templatefieldMixinFields1
+ templatefieldFields := schema.TemplateField{}.Fields()
+ _ = templatefieldFields
+ // templatefieldDescCreatedAt is the schema descriptor for created_at field.
+ templatefieldDescCreatedAt := templatefieldMixinFields0[1].Descriptor()
+ // templatefield.DefaultCreatedAt holds the default value on creation for the created_at field.
+ templatefield.DefaultCreatedAt = templatefieldDescCreatedAt.Default.(func() time.Time)
+ // templatefieldDescUpdatedAt is the schema descriptor for updated_at field.
+ templatefieldDescUpdatedAt := templatefieldMixinFields0[2].Descriptor()
+ // templatefield.DefaultUpdatedAt holds the default value on creation for the updated_at field.
+ templatefield.DefaultUpdatedAt = templatefieldDescUpdatedAt.Default.(func() time.Time)
+ // templatefield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
+ templatefield.UpdateDefaultUpdatedAt = templatefieldDescUpdatedAt.UpdateDefault.(func() time.Time)
+ // templatefieldDescName is the schema descriptor for name field.
+ templatefieldDescName := templatefieldMixinFields1[0].Descriptor()
+ // templatefield.NameValidator is a validator for the "name" field. It is called by the builders before save.
+ templatefield.NameValidator = func() func(string) error {
+ validators := templatefieldDescName.Validators
+ fns := [...]func(string) error{
+ validators[0].(func(string) error),
+ validators[1].(func(string) error),
+ }
+ return func(name string) error {
+ for _, fn := range fns {
+ if err := fn(name); err != nil {
+ return err
+ }
+ }
+ return nil
+ }
+ }()
+ // templatefieldDescDescription is the schema descriptor for description field.
+ templatefieldDescDescription := templatefieldMixinFields1[1].Descriptor()
+ // templatefield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
+ templatefield.DescriptionValidator = templatefieldDescDescription.Validators[0].(func(string) error)
+ // templatefieldDescTextValue is the schema descriptor for text_value field.
+ templatefieldDescTextValue := templatefieldFields[1].Descriptor()
+ // templatefield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save.
+ templatefield.TextValueValidator = templatefieldDescTextValue.Validators[0].(func(string) error)
+ // templatefieldDescID is the schema descriptor for id field.
+ templatefieldDescID := templatefieldMixinFields0[0].Descriptor()
+ // templatefield.DefaultID holds the default value on creation for the id field.
+ templatefield.DefaultID = templatefieldDescID.Default.(func() uuid.UUID)
userMixin := schema.User{}.Mixin()
userMixinFields0 := userMixin[0].Fields()
_ = userMixinFields0
diff --git a/backend/internal/data/ent/schema/group.go b/backend/internal/data/ent/schema/group.go
index bb93bf15..4deac1ae 100644
--- a/backend/internal/data/ent/schema/group.go
+++ b/backend/internal/data/ent/schema/group.go
@@ -48,6 +48,7 @@ func (Group) Edges() []ent.Edge {
owned("labels", Label.Type),
owned("invitation_tokens", GroupInvitationToken.Type),
owned("notifiers", Notifier.Type),
+ owned("item_templates", ItemTemplate.Type),
// $scaffold_edge
}
}
diff --git a/backend/internal/data/ent/schema/item_template.go b/backend/internal/data/ent/schema/item_template.go
new file mode 100644
index 00000000..bb86170a
--- /dev/null
+++ b/backend/internal/data/ent/schema/item_template.go
@@ -0,0 +1,111 @@
+package schema
+
+import (
+ "entgo.io/ent"
+ "entgo.io/ent/dialect/entsql"
+ "entgo.io/ent/schema/edge"
+ "entgo.io/ent/schema/field"
+ "entgo.io/ent/schema/index"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins"
+)
+
+// ItemTemplate holds the schema definition for the ItemTemplate entity.
+type ItemTemplate struct {
+ ent.Schema
+}
+
+func (ItemTemplate) Mixin() []ent.Mixin {
+ return []ent.Mixin{
+ mixins.BaseMixin{},
+ mixins.DetailsMixin{},
+ GroupMixin{ref: "item_templates"},
+ }
+}
+
+func (ItemTemplate) Indexes() []ent.Index {
+ return []ent.Index{
+ index.Fields("name"),
+ }
+}
+
+// Fields of the ItemTemplate.
+func (ItemTemplate) Fields() []ent.Field {
+ return []ent.Field{
+ // Notes for the template (instructions, hints, etc.)
+ field.String("notes").
+ MaxLen(1000).
+ Optional(),
+
+ // ------------------------------------
+ // Default values for item fields
+ field.Int("default_quantity").
+ Default(1),
+ field.Bool("default_insured").
+ Default(false),
+
+ // ------------------------------------
+ // Default item name/description (templates for item identity)
+ field.String("default_name").
+ MaxLen(255).
+ Optional().
+ Comment("Default name template for items (can use placeholders)"),
+ field.Text("default_description").
+ MaxLen(1000).
+ Optional().
+ Comment("Default description for items created from this template"),
+
+ // ------------------------------------
+ // Default item identification
+ field.String("default_manufacturer").
+ MaxLen(255).
+ Optional(),
+ field.String("default_model_number").
+ MaxLen(255).
+ Optional().
+ Comment("Default model number for items created from this template"),
+
+ // ------------------------------------
+ // Default warranty settings
+ field.Bool("default_lifetime_warranty").
+ Default(false),
+ field.Text("default_warranty_details").
+ MaxLen(1000).
+ Optional(),
+
+ // ------------------------------------
+ // Template metadata
+ field.Bool("include_warranty_fields").
+ Default(false).
+ Comment("Whether to include warranty fields in items created from this template"),
+ field.Bool("include_purchase_fields").
+ Default(false).
+ Comment("Whether to include purchase fields in items created from this template"),
+ field.Bool("include_sold_fields").
+ Default(false).
+ Comment("Whether to include sold fields in items created from this template"),
+
+ // ------------------------------------
+ // Default labels (stored as JSON array of UUIDs to allow reuse across templates)
+ field.JSON("default_label_ids", []uuid.UUID{}).
+ Optional().
+ Comment("Default label IDs for items created from this template"),
+ }
+}
+
+// Edges of the ItemTemplate.
+func (ItemTemplate) Edges() []ent.Edge {
+ owned := func(s string, t any) ent.Edge {
+ return edge.To(s, t).
+ Annotations(entsql.Annotation{
+ OnDelete: entsql.Cascade,
+ })
+ }
+
+ return []ent.Edge{
+ owned("fields", TemplateField.Type),
+ // Default location for items created from this template
+ edge.To("location", Location.Type).
+ Unique(),
+ }
+}
diff --git a/backend/internal/data/ent/schema/template_field.go b/backend/internal/data/ent/schema/template_field.go
new file mode 100644
index 00000000..8c82d43b
--- /dev/null
+++ b/backend/internal/data/ent/schema/template_field.go
@@ -0,0 +1,41 @@
+package schema
+
+import (
+ "entgo.io/ent"
+ "entgo.io/ent/schema/edge"
+ "entgo.io/ent/schema/field"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins"
+)
+
+// TemplateField holds the schema definition for the TemplateField entity.
+// Template fields define custom fields that will be added to items created from a template.
+type TemplateField struct {
+ ent.Schema
+}
+
+func (TemplateField) Mixin() []ent.Mixin {
+ return []ent.Mixin{
+ mixins.BaseMixin{},
+ mixins.DetailsMixin{},
+ }
+}
+
+// Fields of the TemplateField.
+func (TemplateField) Fields() []ent.Field {
+ return []ent.Field{
+ field.Enum("type").
+ Values("text"),
+ field.String("text_value").
+ MaxLen(500).
+ Optional(),
+ }
+}
+
+// Edges of the TemplateField.
+func (TemplateField) Edges() []ent.Edge {
+ return []ent.Edge{
+ edge.From("item_template", ItemTemplate.Type).
+ Ref("fields").
+ Unique(),
+ }
+}
diff --git a/backend/internal/data/ent/templatefield.go b/backend/internal/data/ent/templatefield.go
new file mode 100644
index 00000000..3ba3a489
--- /dev/null
+++ b/backend/internal/data/ent/templatefield.go
@@ -0,0 +1,201 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "fmt"
+ "strings"
+ "time"
+
+ "entgo.io/ent"
+ "entgo.io/ent/dialect/sql"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
+)
+
+// TemplateField is the model entity for the TemplateField schema.
+type TemplateField struct {
+ config `json:"-"`
+ // ID of the ent.
+ ID uuid.UUID `json:"id,omitempty"`
+ // CreatedAt holds the value of the "created_at" field.
+ CreatedAt time.Time `json:"created_at,omitempty"`
+ // UpdatedAt holds the value of the "updated_at" field.
+ UpdatedAt time.Time `json:"updated_at,omitempty"`
+ // Name holds the value of the "name" field.
+ Name string `json:"name,omitempty"`
+ // Description holds the value of the "description" field.
+ Description string `json:"description,omitempty"`
+ // Type holds the value of the "type" field.
+ Type templatefield.Type `json:"type,omitempty"`
+ // TextValue holds the value of the "text_value" field.
+ TextValue string `json:"text_value,omitempty"`
+ // Edges holds the relations/edges for other nodes in the graph.
+ // The values are being populated by the TemplateFieldQuery when eager-loading is set.
+ Edges TemplateFieldEdges `json:"edges"`
+ item_template_fields *uuid.UUID
+ selectValues sql.SelectValues
+}
+
+// TemplateFieldEdges holds the relations/edges for other nodes in the graph.
+type TemplateFieldEdges struct {
+ // ItemTemplate holds the value of the item_template edge.
+ ItemTemplate *ItemTemplate `json:"item_template,omitempty"`
+ // loadedTypes holds the information for reporting if a
+ // type was loaded (or requested) in eager-loading or not.
+ loadedTypes [1]bool
+}
+
+// ItemTemplateOrErr returns the ItemTemplate value or an error if the edge
+// was not loaded in eager-loading, or loaded but was not found.
+func (e TemplateFieldEdges) ItemTemplateOrErr() (*ItemTemplate, error) {
+ if e.ItemTemplate != nil {
+ return e.ItemTemplate, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: itemtemplate.Label}
+ }
+ return nil, &NotLoadedError{edge: "item_template"}
+}
+
+// scanValues returns the types for scanning values from sql.Rows.
+func (*TemplateField) scanValues(columns []string) ([]any, error) {
+ values := make([]any, len(columns))
+ for i := range columns {
+ switch columns[i] {
+ case templatefield.FieldName, templatefield.FieldDescription, templatefield.FieldType, templatefield.FieldTextValue:
+ values[i] = new(sql.NullString)
+ case templatefield.FieldCreatedAt, templatefield.FieldUpdatedAt:
+ values[i] = new(sql.NullTime)
+ case templatefield.FieldID:
+ values[i] = new(uuid.UUID)
+ case templatefield.ForeignKeys[0]: // item_template_fields
+ values[i] = &sql.NullScanner{S: new(uuid.UUID)}
+ default:
+ values[i] = new(sql.UnknownType)
+ }
+ }
+ return values, nil
+}
+
+// assignValues assigns the values that were returned from sql.Rows (after scanning)
+// to the TemplateField fields.
+func (_m *TemplateField) assignValues(columns []string, values []any) error {
+ if m, n := len(values), len(columns); m < n {
+ return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
+ }
+ for i := range columns {
+ switch columns[i] {
+ case templatefield.FieldID:
+ if value, ok := values[i].(*uuid.UUID); !ok {
+ return fmt.Errorf("unexpected type %T for field id", values[i])
+ } else if value != nil {
+ _m.ID = *value
+ }
+ case templatefield.FieldCreatedAt:
+ if value, ok := values[i].(*sql.NullTime); !ok {
+ return fmt.Errorf("unexpected type %T for field created_at", values[i])
+ } else if value.Valid {
+ _m.CreatedAt = value.Time
+ }
+ case templatefield.FieldUpdatedAt:
+ if value, ok := values[i].(*sql.NullTime); !ok {
+ return fmt.Errorf("unexpected type %T for field updated_at", values[i])
+ } else if value.Valid {
+ _m.UpdatedAt = value.Time
+ }
+ case templatefield.FieldName:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field name", values[i])
+ } else if value.Valid {
+ _m.Name = value.String
+ }
+ case templatefield.FieldDescription:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field description", values[i])
+ } else if value.Valid {
+ _m.Description = value.String
+ }
+ case templatefield.FieldType:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field type", values[i])
+ } else if value.Valid {
+ _m.Type = templatefield.Type(value.String)
+ }
+ case templatefield.FieldTextValue:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field text_value", values[i])
+ } else if value.Valid {
+ _m.TextValue = value.String
+ }
+ case templatefield.ForeignKeys[0]:
+ if value, ok := values[i].(*sql.NullScanner); !ok {
+ return fmt.Errorf("unexpected type %T for field item_template_fields", values[i])
+ } else if value.Valid {
+ _m.item_template_fields = new(uuid.UUID)
+ *_m.item_template_fields = *value.S.(*uuid.UUID)
+ }
+ default:
+ _m.selectValues.Set(columns[i], values[i])
+ }
+ }
+ return nil
+}
+
+// Value returns the ent.Value that was dynamically selected and assigned to the TemplateField.
+// This includes values selected through modifiers, order, etc.
+func (_m *TemplateField) Value(name string) (ent.Value, error) {
+ return _m.selectValues.Get(name)
+}
+
+// QueryItemTemplate queries the "item_template" edge of the TemplateField entity.
+func (_m *TemplateField) QueryItemTemplate() *ItemTemplateQuery {
+ return NewTemplateFieldClient(_m.config).QueryItemTemplate(_m)
+}
+
+// Update returns a builder for updating this TemplateField.
+// Note that you need to call TemplateField.Unwrap() before calling this method if this TemplateField
+// was returned from a transaction, and the transaction was committed or rolled back.
+func (_m *TemplateField) Update() *TemplateFieldUpdateOne {
+ return NewTemplateFieldClient(_m.config).UpdateOne(_m)
+}
+
+// Unwrap unwraps the TemplateField entity that was returned from a transaction after it was closed,
+// so that all future queries will be executed through the driver which created the transaction.
+func (_m *TemplateField) Unwrap() *TemplateField {
+ _tx, ok := _m.config.driver.(*txDriver)
+ if !ok {
+ panic("ent: TemplateField is not a transactional entity")
+ }
+ _m.config.driver = _tx.drv
+ return _m
+}
+
+// String implements the fmt.Stringer.
+func (_m *TemplateField) String() string {
+ var builder strings.Builder
+ builder.WriteString("TemplateField(")
+ builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
+ builder.WriteString("created_at=")
+ builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
+ builder.WriteString(", ")
+ builder.WriteString("updated_at=")
+ builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
+ builder.WriteString(", ")
+ builder.WriteString("name=")
+ builder.WriteString(_m.Name)
+ builder.WriteString(", ")
+ builder.WriteString("description=")
+ builder.WriteString(_m.Description)
+ builder.WriteString(", ")
+ builder.WriteString("type=")
+ builder.WriteString(fmt.Sprintf("%v", _m.Type))
+ builder.WriteString(", ")
+ builder.WriteString("text_value=")
+ builder.WriteString(_m.TextValue)
+ builder.WriteByte(')')
+ return builder.String()
+}
+
+// TemplateFields is a parsable slice of TemplateField.
+type TemplateFields []*TemplateField
diff --git a/backend/internal/data/ent/templatefield/templatefield.go b/backend/internal/data/ent/templatefield/templatefield.go
new file mode 100644
index 00000000..6dbde586
--- /dev/null
+++ b/backend/internal/data/ent/templatefield/templatefield.go
@@ -0,0 +1,165 @@
+// Code generated by ent, DO NOT EDIT.
+
+package templatefield
+
+import (
+ "fmt"
+ "time"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/google/uuid"
+)
+
+const (
+ // Label holds the string label denoting the templatefield type in the database.
+ Label = "template_field"
+ // FieldID holds the string denoting the id field in the database.
+ FieldID = "id"
+ // FieldCreatedAt holds the string denoting the created_at field in the database.
+ FieldCreatedAt = "created_at"
+ // FieldUpdatedAt holds the string denoting the updated_at field in the database.
+ FieldUpdatedAt = "updated_at"
+ // FieldName holds the string denoting the name field in the database.
+ FieldName = "name"
+ // FieldDescription holds the string denoting the description field in the database.
+ FieldDescription = "description"
+ // FieldType holds the string denoting the type field in the database.
+ FieldType = "type"
+ // FieldTextValue holds the string denoting the text_value field in the database.
+ FieldTextValue = "text_value"
+ // EdgeItemTemplate holds the string denoting the item_template edge name in mutations.
+ EdgeItemTemplate = "item_template"
+ // Table holds the table name of the templatefield in the database.
+ Table = "template_fields"
+ // ItemTemplateTable is the table that holds the item_template relation/edge.
+ ItemTemplateTable = "template_fields"
+ // ItemTemplateInverseTable is the table name for the ItemTemplate entity.
+ // It exists in this package in order to avoid circular dependency with the "itemtemplate" package.
+ ItemTemplateInverseTable = "item_templates"
+ // ItemTemplateColumn is the table column denoting the item_template relation/edge.
+ ItemTemplateColumn = "item_template_fields"
+)
+
+// Columns holds all SQL columns for templatefield fields.
+var Columns = []string{
+ FieldID,
+ FieldCreatedAt,
+ FieldUpdatedAt,
+ FieldName,
+ FieldDescription,
+ FieldType,
+ FieldTextValue,
+}
+
+// ForeignKeys holds the SQL foreign-keys that are owned by the "template_fields"
+// table and are not defined as standalone fields in the schema.
+var ForeignKeys = []string{
+ "item_template_fields",
+}
+
+// ValidColumn reports if the column name is valid (part of the table columns).
+func ValidColumn(column string) bool {
+ for i := range Columns {
+ if column == Columns[i] {
+ return true
+ }
+ }
+ for i := range ForeignKeys {
+ if column == ForeignKeys[i] {
+ return true
+ }
+ }
+ return false
+}
+
+var (
+ // DefaultCreatedAt holds the default value on creation for the "created_at" field.
+ DefaultCreatedAt func() time.Time
+ // DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
+ DefaultUpdatedAt func() time.Time
+ // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
+ UpdateDefaultUpdatedAt func() time.Time
+ // NameValidator is a validator for the "name" field. It is called by the builders before save.
+ NameValidator func(string) error
+ // DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
+ DescriptionValidator func(string) error
+ // TextValueValidator is a validator for the "text_value" field. It is called by the builders before save.
+ TextValueValidator func(string) error
+ // DefaultID holds the default value on creation for the "id" field.
+ DefaultID func() uuid.UUID
+)
+
+// Type defines the type for the "type" enum field.
+type Type string
+
+// Type values.
+const (
+ TypeText Type = "text"
+)
+
+func (_type Type) String() string {
+ return string(_type)
+}
+
+// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
+func TypeValidator(_type Type) error {
+ switch _type {
+ case TypeText:
+ return nil
+ default:
+ return fmt.Errorf("templatefield: invalid enum value for type field: %q", _type)
+ }
+}
+
+// OrderOption defines the ordering options for the TemplateField queries.
+type OrderOption func(*sql.Selector)
+
+// ByID orders the results by the id field.
+func ByID(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldID, opts...).ToFunc()
+}
+
+// ByCreatedAt orders the results by the created_at field.
+func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
+}
+
+// ByUpdatedAt orders the results by the updated_at field.
+func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
+}
+
+// ByName orders the results by the name field.
+func ByName(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldName, opts...).ToFunc()
+}
+
+// ByDescription orders the results by the description field.
+func ByDescription(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDescription, opts...).ToFunc()
+}
+
+// ByType orders the results by the type field.
+func ByType(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldType, opts...).ToFunc()
+}
+
+// ByTextValue orders the results by the text_value field.
+func ByTextValue(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldTextValue, opts...).ToFunc()
+}
+
+// ByItemTemplateField orders the results by item_template field.
+func ByItemTemplateField(field string, opts ...sql.OrderTermOption) OrderOption {
+ return func(s *sql.Selector) {
+ sqlgraph.OrderByNeighborTerms(s, newItemTemplateStep(), sql.OrderByField(field, opts...))
+ }
+}
+func newItemTemplateStep() *sqlgraph.Step {
+ return sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.To(ItemTemplateInverseTable, FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, true, ItemTemplateTable, ItemTemplateColumn),
+ )
+}
diff --git a/backend/internal/data/ent/templatefield/where.go b/backend/internal/data/ent/templatefield/where.go
new file mode 100644
index 00000000..98021a2a
--- /dev/null
+++ b/backend/internal/data/ent/templatefield/where.go
@@ -0,0 +1,435 @@
+// Code generated by ent, DO NOT EDIT.
+
+package templatefield
+
+import (
+ "time"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
+)
+
+// ID filters vertices based on their ID field.
+func ID(id uuid.UUID) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldID, id))
+}
+
+// IDEQ applies the EQ predicate on the ID field.
+func IDEQ(id uuid.UUID) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldID, id))
+}
+
+// IDNEQ applies the NEQ predicate on the ID field.
+func IDNEQ(id uuid.UUID) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNEQ(FieldID, id))
+}
+
+// IDIn applies the In predicate on the ID field.
+func IDIn(ids ...uuid.UUID) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldIn(FieldID, ids...))
+}
+
+// IDNotIn applies the NotIn predicate on the ID field.
+func IDNotIn(ids ...uuid.UUID) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNotIn(FieldID, ids...))
+}
+
+// IDGT applies the GT predicate on the ID field.
+func IDGT(id uuid.UUID) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGT(FieldID, id))
+}
+
+// IDGTE applies the GTE predicate on the ID field.
+func IDGTE(id uuid.UUID) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGTE(FieldID, id))
+}
+
+// IDLT applies the LT predicate on the ID field.
+func IDLT(id uuid.UUID) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLT(FieldID, id))
+}
+
+// IDLTE applies the LTE predicate on the ID field.
+func IDLTE(id uuid.UUID) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLTE(FieldID, id))
+}
+
+// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
+func CreatedAt(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
+func UpdatedAt(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
+func Name(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldName, v))
+}
+
+// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
+func Description(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldDescription, v))
+}
+
+// TextValue applies equality check predicate on the "text_value" field. It's identical to TextValueEQ.
+func TextValue(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldTextValue, v))
+}
+
+// CreatedAtEQ applies the EQ predicate on the "created_at" field.
+func CreatedAtEQ(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
+func CreatedAtNEQ(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtIn applies the In predicate on the "created_at" field.
+func CreatedAtIn(vs ...time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
+func CreatedAtNotIn(vs ...time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNotIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtGT applies the GT predicate on the "created_at" field.
+func CreatedAtGT(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGT(FieldCreatedAt, v))
+}
+
+// CreatedAtGTE applies the GTE predicate on the "created_at" field.
+func CreatedAtGTE(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGTE(FieldCreatedAt, v))
+}
+
+// CreatedAtLT applies the LT predicate on the "created_at" field.
+func CreatedAtLT(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLT(FieldCreatedAt, v))
+}
+
+// CreatedAtLTE applies the LTE predicate on the "created_at" field.
+func CreatedAtLTE(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLTE(FieldCreatedAt, v))
+}
+
+// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
+func UpdatedAtEQ(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
+func UpdatedAtNEQ(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtIn applies the In predicate on the "updated_at" field.
+func UpdatedAtIn(vs ...time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
+func UpdatedAtNotIn(vs ...time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNotIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtGT applies the GT predicate on the "updated_at" field.
+func UpdatedAtGT(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
+func UpdatedAtGTE(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGTE(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLT applies the LT predicate on the "updated_at" field.
+func UpdatedAtLT(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
+func UpdatedAtLTE(v time.Time) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLTE(FieldUpdatedAt, v))
+}
+
+// NameEQ applies the EQ predicate on the "name" field.
+func NameEQ(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldName, v))
+}
+
+// NameNEQ applies the NEQ predicate on the "name" field.
+func NameNEQ(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNEQ(FieldName, v))
+}
+
+// NameIn applies the In predicate on the "name" field.
+func NameIn(vs ...string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldIn(FieldName, vs...))
+}
+
+// NameNotIn applies the NotIn predicate on the "name" field.
+func NameNotIn(vs ...string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNotIn(FieldName, vs...))
+}
+
+// NameGT applies the GT predicate on the "name" field.
+func NameGT(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGT(FieldName, v))
+}
+
+// NameGTE applies the GTE predicate on the "name" field.
+func NameGTE(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGTE(FieldName, v))
+}
+
+// NameLT applies the LT predicate on the "name" field.
+func NameLT(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLT(FieldName, v))
+}
+
+// NameLTE applies the LTE predicate on the "name" field.
+func NameLTE(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLTE(FieldName, v))
+}
+
+// NameContains applies the Contains predicate on the "name" field.
+func NameContains(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldContains(FieldName, v))
+}
+
+// NameHasPrefix applies the HasPrefix predicate on the "name" field.
+func NameHasPrefix(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldHasPrefix(FieldName, v))
+}
+
+// NameHasSuffix applies the HasSuffix predicate on the "name" field.
+func NameHasSuffix(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldHasSuffix(FieldName, v))
+}
+
+// NameEqualFold applies the EqualFold predicate on the "name" field.
+func NameEqualFold(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEqualFold(FieldName, v))
+}
+
+// NameContainsFold applies the ContainsFold predicate on the "name" field.
+func NameContainsFold(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldContainsFold(FieldName, v))
+}
+
+// DescriptionEQ applies the EQ predicate on the "description" field.
+func DescriptionEQ(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldDescription, v))
+}
+
+// DescriptionNEQ applies the NEQ predicate on the "description" field.
+func DescriptionNEQ(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNEQ(FieldDescription, v))
+}
+
+// DescriptionIn applies the In predicate on the "description" field.
+func DescriptionIn(vs ...string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldIn(FieldDescription, vs...))
+}
+
+// DescriptionNotIn applies the NotIn predicate on the "description" field.
+func DescriptionNotIn(vs ...string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNotIn(FieldDescription, vs...))
+}
+
+// DescriptionGT applies the GT predicate on the "description" field.
+func DescriptionGT(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGT(FieldDescription, v))
+}
+
+// DescriptionGTE applies the GTE predicate on the "description" field.
+func DescriptionGTE(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGTE(FieldDescription, v))
+}
+
+// DescriptionLT applies the LT predicate on the "description" field.
+func DescriptionLT(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLT(FieldDescription, v))
+}
+
+// DescriptionLTE applies the LTE predicate on the "description" field.
+func DescriptionLTE(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLTE(FieldDescription, v))
+}
+
+// DescriptionContains applies the Contains predicate on the "description" field.
+func DescriptionContains(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldContains(FieldDescription, v))
+}
+
+// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
+func DescriptionHasPrefix(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldHasPrefix(FieldDescription, v))
+}
+
+// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
+func DescriptionHasSuffix(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldHasSuffix(FieldDescription, v))
+}
+
+// DescriptionIsNil applies the IsNil predicate on the "description" field.
+func DescriptionIsNil() predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldIsNull(FieldDescription))
+}
+
+// DescriptionNotNil applies the NotNil predicate on the "description" field.
+func DescriptionNotNil() predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNotNull(FieldDescription))
+}
+
+// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
+func DescriptionEqualFold(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEqualFold(FieldDescription, v))
+}
+
+// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
+func DescriptionContainsFold(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldContainsFold(FieldDescription, v))
+}
+
+// TypeEQ applies the EQ predicate on the "type" field.
+func TypeEQ(v Type) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldType, v))
+}
+
+// TypeNEQ applies the NEQ predicate on the "type" field.
+func TypeNEQ(v Type) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNEQ(FieldType, v))
+}
+
+// TypeIn applies the In predicate on the "type" field.
+func TypeIn(vs ...Type) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldIn(FieldType, vs...))
+}
+
+// TypeNotIn applies the NotIn predicate on the "type" field.
+func TypeNotIn(vs ...Type) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNotIn(FieldType, vs...))
+}
+
+// TextValueEQ applies the EQ predicate on the "text_value" field.
+func TextValueEQ(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEQ(FieldTextValue, v))
+}
+
+// TextValueNEQ applies the NEQ predicate on the "text_value" field.
+func TextValueNEQ(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNEQ(FieldTextValue, v))
+}
+
+// TextValueIn applies the In predicate on the "text_value" field.
+func TextValueIn(vs ...string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldIn(FieldTextValue, vs...))
+}
+
+// TextValueNotIn applies the NotIn predicate on the "text_value" field.
+func TextValueNotIn(vs ...string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNotIn(FieldTextValue, vs...))
+}
+
+// TextValueGT applies the GT predicate on the "text_value" field.
+func TextValueGT(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGT(FieldTextValue, v))
+}
+
+// TextValueGTE applies the GTE predicate on the "text_value" field.
+func TextValueGTE(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldGTE(FieldTextValue, v))
+}
+
+// TextValueLT applies the LT predicate on the "text_value" field.
+func TextValueLT(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLT(FieldTextValue, v))
+}
+
+// TextValueLTE applies the LTE predicate on the "text_value" field.
+func TextValueLTE(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldLTE(FieldTextValue, v))
+}
+
+// TextValueContains applies the Contains predicate on the "text_value" field.
+func TextValueContains(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldContains(FieldTextValue, v))
+}
+
+// TextValueHasPrefix applies the HasPrefix predicate on the "text_value" field.
+func TextValueHasPrefix(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldHasPrefix(FieldTextValue, v))
+}
+
+// TextValueHasSuffix applies the HasSuffix predicate on the "text_value" field.
+func TextValueHasSuffix(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldHasSuffix(FieldTextValue, v))
+}
+
+// TextValueIsNil applies the IsNil predicate on the "text_value" field.
+func TextValueIsNil() predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldIsNull(FieldTextValue))
+}
+
+// TextValueNotNil applies the NotNil predicate on the "text_value" field.
+func TextValueNotNil() predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldNotNull(FieldTextValue))
+}
+
+// TextValueEqualFold applies the EqualFold predicate on the "text_value" field.
+func TextValueEqualFold(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldEqualFold(FieldTextValue, v))
+}
+
+// TextValueContainsFold applies the ContainsFold predicate on the "text_value" field.
+func TextValueContainsFold(v string) predicate.TemplateField {
+ return predicate.TemplateField(sql.FieldContainsFold(FieldTextValue, v))
+}
+
+// HasItemTemplate applies the HasEdge predicate on the "item_template" edge.
+func HasItemTemplate() predicate.TemplateField {
+ return predicate.TemplateField(func(s *sql.Selector) {
+ step := sqlgraph.NewStep(
+ sqlgraph.From(Table, FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, true, ItemTemplateTable, ItemTemplateColumn),
+ )
+ sqlgraph.HasNeighbors(s, step)
+ })
+}
+
+// HasItemTemplateWith applies the HasEdge predicate on the "item_template" edge with a given conditions (other predicates).
+func HasItemTemplateWith(preds ...predicate.ItemTemplate) predicate.TemplateField {
+ return predicate.TemplateField(func(s *sql.Selector) {
+ step := newItemTemplateStep()
+ sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
+ for _, p := range preds {
+ p(s)
+ }
+ })
+ })
+}
+
+// And groups predicates with the AND operator between them.
+func And(predicates ...predicate.TemplateField) predicate.TemplateField {
+ return predicate.TemplateField(sql.AndPredicates(predicates...))
+}
+
+// Or groups predicates with the OR operator between them.
+func Or(predicates ...predicate.TemplateField) predicate.TemplateField {
+ return predicate.TemplateField(sql.OrPredicates(predicates...))
+}
+
+// Not applies the not operator on the given predicate.
+func Not(p predicate.TemplateField) predicate.TemplateField {
+ return predicate.TemplateField(sql.NotPredicates(p))
+}
diff --git a/backend/internal/data/ent/templatefield_create.go b/backend/internal/data/ent/templatefield_create.go
new file mode 100644
index 00000000..fa42ba87
--- /dev/null
+++ b/backend/internal/data/ent/templatefield_create.go
@@ -0,0 +1,370 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "time"
+
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
+)
+
+// TemplateFieldCreate is the builder for creating a TemplateField entity.
+type TemplateFieldCreate struct {
+ config
+ mutation *TemplateFieldMutation
+ hooks []Hook
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (_c *TemplateFieldCreate) SetCreatedAt(v time.Time) *TemplateFieldCreate {
+ _c.mutation.SetCreatedAt(v)
+ return _c
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (_c *TemplateFieldCreate) SetNillableCreatedAt(v *time.Time) *TemplateFieldCreate {
+ if v != nil {
+ _c.SetCreatedAt(*v)
+ }
+ return _c
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (_c *TemplateFieldCreate) SetUpdatedAt(v time.Time) *TemplateFieldCreate {
+ _c.mutation.SetUpdatedAt(v)
+ return _c
+}
+
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
+func (_c *TemplateFieldCreate) SetNillableUpdatedAt(v *time.Time) *TemplateFieldCreate {
+ if v != nil {
+ _c.SetUpdatedAt(*v)
+ }
+ return _c
+}
+
+// SetName sets the "name" field.
+func (_c *TemplateFieldCreate) SetName(v string) *TemplateFieldCreate {
+ _c.mutation.SetName(v)
+ return _c
+}
+
+// SetDescription sets the "description" field.
+func (_c *TemplateFieldCreate) SetDescription(v string) *TemplateFieldCreate {
+ _c.mutation.SetDescription(v)
+ return _c
+}
+
+// SetNillableDescription sets the "description" field if the given value is not nil.
+func (_c *TemplateFieldCreate) SetNillableDescription(v *string) *TemplateFieldCreate {
+ if v != nil {
+ _c.SetDescription(*v)
+ }
+ return _c
+}
+
+// SetType sets the "type" field.
+func (_c *TemplateFieldCreate) SetType(v templatefield.Type) *TemplateFieldCreate {
+ _c.mutation.SetType(v)
+ return _c
+}
+
+// SetTextValue sets the "text_value" field.
+func (_c *TemplateFieldCreate) SetTextValue(v string) *TemplateFieldCreate {
+ _c.mutation.SetTextValue(v)
+ return _c
+}
+
+// SetNillableTextValue sets the "text_value" field if the given value is not nil.
+func (_c *TemplateFieldCreate) SetNillableTextValue(v *string) *TemplateFieldCreate {
+ if v != nil {
+ _c.SetTextValue(*v)
+ }
+ return _c
+}
+
+// SetID sets the "id" field.
+func (_c *TemplateFieldCreate) SetID(v uuid.UUID) *TemplateFieldCreate {
+ _c.mutation.SetID(v)
+ return _c
+}
+
+// SetNillableID sets the "id" field if the given value is not nil.
+func (_c *TemplateFieldCreate) SetNillableID(v *uuid.UUID) *TemplateFieldCreate {
+ if v != nil {
+ _c.SetID(*v)
+ }
+ return _c
+}
+
+// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID.
+func (_c *TemplateFieldCreate) SetItemTemplateID(id uuid.UUID) *TemplateFieldCreate {
+ _c.mutation.SetItemTemplateID(id)
+ return _c
+}
+
+// SetNillableItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID if the given value is not nil.
+func (_c *TemplateFieldCreate) SetNillableItemTemplateID(id *uuid.UUID) *TemplateFieldCreate {
+ if id != nil {
+ _c = _c.SetItemTemplateID(*id)
+ }
+ return _c
+}
+
+// SetItemTemplate sets the "item_template" edge to the ItemTemplate entity.
+func (_c *TemplateFieldCreate) SetItemTemplate(v *ItemTemplate) *TemplateFieldCreate {
+ return _c.SetItemTemplateID(v.ID)
+}
+
+// Mutation returns the TemplateFieldMutation object of the builder.
+func (_c *TemplateFieldCreate) Mutation() *TemplateFieldMutation {
+ return _c.mutation
+}
+
+// Save creates the TemplateField in the database.
+func (_c *TemplateFieldCreate) Save(ctx context.Context) (*TemplateField, error) {
+ _c.defaults()
+ return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
+}
+
+// SaveX calls Save and panics if Save returns an error.
+func (_c *TemplateFieldCreate) SaveX(ctx context.Context) *TemplateField {
+ v, err := _c.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
+
+// Exec executes the query.
+func (_c *TemplateFieldCreate) Exec(ctx context.Context) error {
+ _, err := _c.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_c *TemplateFieldCreate) ExecX(ctx context.Context) {
+ if err := _c.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// defaults sets the default values of the builder before save.
+func (_c *TemplateFieldCreate) defaults() {
+ if _, ok := _c.mutation.CreatedAt(); !ok {
+ v := templatefield.DefaultCreatedAt()
+ _c.mutation.SetCreatedAt(v)
+ }
+ if _, ok := _c.mutation.UpdatedAt(); !ok {
+ v := templatefield.DefaultUpdatedAt()
+ _c.mutation.SetUpdatedAt(v)
+ }
+ if _, ok := _c.mutation.ID(); !ok {
+ v := templatefield.DefaultID()
+ _c.mutation.SetID(v)
+ }
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (_c *TemplateFieldCreate) check() error {
+ if _, ok := _c.mutation.CreatedAt(); !ok {
+ return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "TemplateField.created_at"`)}
+ }
+ if _, ok := _c.mutation.UpdatedAt(); !ok {
+ return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "TemplateField.updated_at"`)}
+ }
+ if _, ok := _c.mutation.Name(); !ok {
+ return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "TemplateField.name"`)}
+ }
+ if v, ok := _c.mutation.Name(); ok {
+ if err := templatefield.NameValidator(v); err != nil {
+ return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TemplateField.name": %w`, err)}
+ }
+ }
+ if v, ok := _c.mutation.Description(); ok {
+ if err := templatefield.DescriptionValidator(v); err != nil {
+ return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "TemplateField.description": %w`, err)}
+ }
+ }
+ if _, ok := _c.mutation.GetType(); !ok {
+ return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "TemplateField.type"`)}
+ }
+ if v, ok := _c.mutation.GetType(); ok {
+ if err := templatefield.TypeValidator(v); err != nil {
+ return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "TemplateField.type": %w`, err)}
+ }
+ }
+ if v, ok := _c.mutation.TextValue(); ok {
+ if err := templatefield.TextValueValidator(v); err != nil {
+ return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "TemplateField.text_value": %w`, err)}
+ }
+ }
+ return nil
+}
+
+func (_c *TemplateFieldCreate) sqlSave(ctx context.Context) (*TemplateField, error) {
+ if err := _c.check(); err != nil {
+ return nil, err
+ }
+ _node, _spec := _c.createSpec()
+ if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
+ if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ return nil, err
+ }
+ if _spec.ID.Value != nil {
+ if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
+ _node.ID = *id
+ } else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
+ return nil, err
+ }
+ }
+ _c.mutation.id = &_node.ID
+ _c.mutation.done = true
+ return _node, nil
+}
+
+func (_c *TemplateFieldCreate) createSpec() (*TemplateField, *sqlgraph.CreateSpec) {
+ var (
+ _node = &TemplateField{config: _c.config}
+ _spec = sqlgraph.NewCreateSpec(templatefield.Table, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
+ )
+ if id, ok := _c.mutation.ID(); ok {
+ _node.ID = id
+ _spec.ID.Value = &id
+ }
+ if value, ok := _c.mutation.CreatedAt(); ok {
+ _spec.SetField(templatefield.FieldCreatedAt, field.TypeTime, value)
+ _node.CreatedAt = value
+ }
+ if value, ok := _c.mutation.UpdatedAt(); ok {
+ _spec.SetField(templatefield.FieldUpdatedAt, field.TypeTime, value)
+ _node.UpdatedAt = value
+ }
+ if value, ok := _c.mutation.Name(); ok {
+ _spec.SetField(templatefield.FieldName, field.TypeString, value)
+ _node.Name = value
+ }
+ if value, ok := _c.mutation.Description(); ok {
+ _spec.SetField(templatefield.FieldDescription, field.TypeString, value)
+ _node.Description = value
+ }
+ if value, ok := _c.mutation.GetType(); ok {
+ _spec.SetField(templatefield.FieldType, field.TypeEnum, value)
+ _node.Type = value
+ }
+ if value, ok := _c.mutation.TextValue(); ok {
+ _spec.SetField(templatefield.FieldTextValue, field.TypeString, value)
+ _node.TextValue = value
+ }
+ if nodes := _c.mutation.ItemTemplateIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: templatefield.ItemTemplateTable,
+ Columns: []string{templatefield.ItemTemplateColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _node.item_template_fields = &nodes[0]
+ _spec.Edges = append(_spec.Edges, edge)
+ }
+ return _node, _spec
+}
+
+// TemplateFieldCreateBulk is the builder for creating many TemplateField entities in bulk.
+type TemplateFieldCreateBulk struct {
+ config
+ err error
+ builders []*TemplateFieldCreate
+}
+
+// Save creates the TemplateField entities in the database.
+func (_c *TemplateFieldCreateBulk) Save(ctx context.Context) ([]*TemplateField, error) {
+ if _c.err != nil {
+ return nil, _c.err
+ }
+ specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
+ nodes := make([]*TemplateField, len(_c.builders))
+ mutators := make([]Mutator, len(_c.builders))
+ for i := range _c.builders {
+ func(i int, root context.Context) {
+ builder := _c.builders[i]
+ builder.defaults()
+ var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
+ mutation, ok := m.(*TemplateFieldMutation)
+ if !ok {
+ return nil, fmt.Errorf("unexpected mutation type %T", m)
+ }
+ if err := builder.check(); err != nil {
+ return nil, err
+ }
+ builder.mutation = mutation
+ var err error
+ nodes[i], specs[i] = builder.createSpec()
+ if i < len(mutators)-1 {
+ _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
+ } else {
+ spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
+ // Invoke the actual operation on the latest mutation in the chain.
+ if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
+ if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ }
+ }
+ if err != nil {
+ return nil, err
+ }
+ mutation.id = &nodes[i].ID
+ mutation.done = true
+ return nodes[i], nil
+ })
+ for i := len(builder.hooks) - 1; i >= 0; i-- {
+ mut = builder.hooks[i](mut)
+ }
+ mutators[i] = mut
+ }(i, ctx)
+ }
+ if len(mutators) > 0 {
+ if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
+ return nil, err
+ }
+ }
+ return nodes, nil
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (_c *TemplateFieldCreateBulk) SaveX(ctx context.Context) []*TemplateField {
+ v, err := _c.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
+
+// Exec executes the query.
+func (_c *TemplateFieldCreateBulk) Exec(ctx context.Context) error {
+ _, err := _c.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_c *TemplateFieldCreateBulk) ExecX(ctx context.Context) {
+ if err := _c.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
diff --git a/backend/internal/data/ent/templatefield_delete.go b/backend/internal/data/ent/templatefield_delete.go
new file mode 100644
index 00000000..4e2df011
--- /dev/null
+++ b/backend/internal/data/ent/templatefield_delete.go
@@ -0,0 +1,88 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "context"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
+)
+
+// TemplateFieldDelete is the builder for deleting a TemplateField entity.
+type TemplateFieldDelete struct {
+ config
+ hooks []Hook
+ mutation *TemplateFieldMutation
+}
+
+// Where appends a list predicates to the TemplateFieldDelete builder.
+func (_d *TemplateFieldDelete) Where(ps ...predicate.TemplateField) *TemplateFieldDelete {
+ _d.mutation.Where(ps...)
+ return _d
+}
+
+// Exec executes the deletion query and returns how many vertices were deleted.
+func (_d *TemplateFieldDelete) Exec(ctx context.Context) (int, error) {
+ return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_d *TemplateFieldDelete) ExecX(ctx context.Context) int {
+ n, err := _d.Exec(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return n
+}
+
+func (_d *TemplateFieldDelete) sqlExec(ctx context.Context) (int, error) {
+ _spec := sqlgraph.NewDeleteSpec(templatefield.Table, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
+ if ps := _d.mutation.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
+ if err != nil && sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ _d.mutation.done = true
+ return affected, err
+}
+
+// TemplateFieldDeleteOne is the builder for deleting a single TemplateField entity.
+type TemplateFieldDeleteOne struct {
+ _d *TemplateFieldDelete
+}
+
+// Where appends a list predicates to the TemplateFieldDelete builder.
+func (_d *TemplateFieldDeleteOne) Where(ps ...predicate.TemplateField) *TemplateFieldDeleteOne {
+ _d._d.mutation.Where(ps...)
+ return _d
+}
+
+// Exec executes the deletion query.
+func (_d *TemplateFieldDeleteOne) Exec(ctx context.Context) error {
+ n, err := _d._d.Exec(ctx)
+ switch {
+ case err != nil:
+ return err
+ case n == 0:
+ return &NotFoundError{templatefield.Label}
+ default:
+ return nil
+ }
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_d *TemplateFieldDeleteOne) ExecX(ctx context.Context) {
+ if err := _d.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
diff --git a/backend/internal/data/ent/templatefield_query.go b/backend/internal/data/ent/templatefield_query.go
new file mode 100644
index 00000000..7cf4aa2a
--- /dev/null
+++ b/backend/internal/data/ent/templatefield_query.go
@@ -0,0 +1,615 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "context"
+ "fmt"
+ "math"
+
+ "entgo.io/ent"
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
+)
+
+// TemplateFieldQuery is the builder for querying TemplateField entities.
+type TemplateFieldQuery struct {
+ config
+ ctx *QueryContext
+ order []templatefield.OrderOption
+ inters []Interceptor
+ predicates []predicate.TemplateField
+ withItemTemplate *ItemTemplateQuery
+ withFKs bool
+ // intermediate query (i.e. traversal path).
+ sql *sql.Selector
+ path func(context.Context) (*sql.Selector, error)
+}
+
+// Where adds a new predicate for the TemplateFieldQuery builder.
+func (_q *TemplateFieldQuery) Where(ps ...predicate.TemplateField) *TemplateFieldQuery {
+ _q.predicates = append(_q.predicates, ps...)
+ return _q
+}
+
+// Limit the number of records to be returned by this query.
+func (_q *TemplateFieldQuery) Limit(limit int) *TemplateFieldQuery {
+ _q.ctx.Limit = &limit
+ return _q
+}
+
+// Offset to start from.
+func (_q *TemplateFieldQuery) Offset(offset int) *TemplateFieldQuery {
+ _q.ctx.Offset = &offset
+ return _q
+}
+
+// Unique configures the query builder to filter duplicate records on query.
+// By default, unique is set to true, and can be disabled using this method.
+func (_q *TemplateFieldQuery) Unique(unique bool) *TemplateFieldQuery {
+ _q.ctx.Unique = &unique
+ return _q
+}
+
+// Order specifies how the records should be ordered.
+func (_q *TemplateFieldQuery) Order(o ...templatefield.OrderOption) *TemplateFieldQuery {
+ _q.order = append(_q.order, o...)
+ return _q
+}
+
+// QueryItemTemplate chains the current query on the "item_template" edge.
+func (_q *TemplateFieldQuery) QueryItemTemplate() *ItemTemplateQuery {
+ query := (&ItemTemplateClient{config: _q.config}).Query()
+ query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
+ if err := _q.prepareQuery(ctx); err != nil {
+ return nil, err
+ }
+ selector := _q.sqlQuery(ctx)
+ if err := selector.Err(); err != nil {
+ return nil, err
+ }
+ step := sqlgraph.NewStep(
+ sqlgraph.From(templatefield.Table, templatefield.FieldID, selector),
+ sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
+ sqlgraph.Edge(sqlgraph.M2O, true, templatefield.ItemTemplateTable, templatefield.ItemTemplateColumn),
+ )
+ fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
+ return fromU, nil
+ }
+ return query
+}
+
+// First returns the first TemplateField entity from the query.
+// Returns a *NotFoundError when no TemplateField was found.
+func (_q *TemplateFieldQuery) First(ctx context.Context) (*TemplateField, error) {
+ nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
+ if err != nil {
+ return nil, err
+ }
+ if len(nodes) == 0 {
+ return nil, &NotFoundError{templatefield.Label}
+ }
+ return nodes[0], nil
+}
+
+// FirstX is like First, but panics if an error occurs.
+func (_q *TemplateFieldQuery) FirstX(ctx context.Context) *TemplateField {
+ node, err := _q.First(ctx)
+ if err != nil && !IsNotFound(err) {
+ panic(err)
+ }
+ return node
+}
+
+// FirstID returns the first TemplateField ID from the query.
+// Returns a *NotFoundError when no TemplateField ID was found.
+func (_q *TemplateFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
+ var ids []uuid.UUID
+ if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
+ return
+ }
+ if len(ids) == 0 {
+ err = &NotFoundError{templatefield.Label}
+ return
+ }
+ return ids[0], nil
+}
+
+// FirstIDX is like FirstID, but panics if an error occurs.
+func (_q *TemplateFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
+ id, err := _q.FirstID(ctx)
+ if err != nil && !IsNotFound(err) {
+ panic(err)
+ }
+ return id
+}
+
+// Only returns a single TemplateField entity found by the query, ensuring it only returns one.
+// Returns a *NotSingularError when more than one TemplateField entity is found.
+// Returns a *NotFoundError when no TemplateField entities are found.
+func (_q *TemplateFieldQuery) Only(ctx context.Context) (*TemplateField, error) {
+ nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
+ if err != nil {
+ return nil, err
+ }
+ switch len(nodes) {
+ case 1:
+ return nodes[0], nil
+ case 0:
+ return nil, &NotFoundError{templatefield.Label}
+ default:
+ return nil, &NotSingularError{templatefield.Label}
+ }
+}
+
+// OnlyX is like Only, but panics if an error occurs.
+func (_q *TemplateFieldQuery) OnlyX(ctx context.Context) *TemplateField {
+ node, err := _q.Only(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return node
+}
+
+// OnlyID is like Only, but returns the only TemplateField ID in the query.
+// Returns a *NotSingularError when more than one TemplateField ID is found.
+// Returns a *NotFoundError when no entities are found.
+func (_q *TemplateFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
+ var ids []uuid.UUID
+ if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
+ return
+ }
+ switch len(ids) {
+ case 1:
+ id = ids[0]
+ case 0:
+ err = &NotFoundError{templatefield.Label}
+ default:
+ err = &NotSingularError{templatefield.Label}
+ }
+ return
+}
+
+// OnlyIDX is like OnlyID, but panics if an error occurs.
+func (_q *TemplateFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
+ id, err := _q.OnlyID(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return id
+}
+
+// All executes the query and returns a list of TemplateFields.
+func (_q *TemplateFieldQuery) All(ctx context.Context) ([]*TemplateField, error) {
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
+ if err := _q.prepareQuery(ctx); err != nil {
+ return nil, err
+ }
+ qr := querierAll[[]*TemplateField, *TemplateFieldQuery]()
+ return withInterceptors[[]*TemplateField](ctx, _q, qr, _q.inters)
+}
+
+// AllX is like All, but panics if an error occurs.
+func (_q *TemplateFieldQuery) AllX(ctx context.Context) []*TemplateField {
+ nodes, err := _q.All(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return nodes
+}
+
+// IDs executes the query and returns a list of TemplateField IDs.
+func (_q *TemplateFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
+ if _q.ctx.Unique == nil && _q.path != nil {
+ _q.Unique(true)
+ }
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
+ if err = _q.Select(templatefield.FieldID).Scan(ctx, &ids); err != nil {
+ return nil, err
+ }
+ return ids, nil
+}
+
+// IDsX is like IDs, but panics if an error occurs.
+func (_q *TemplateFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
+ ids, err := _q.IDs(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return ids
+}
+
+// Count returns the count of the given query.
+func (_q *TemplateFieldQuery) Count(ctx context.Context) (int, error) {
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
+ if err := _q.prepareQuery(ctx); err != nil {
+ return 0, err
+ }
+ return withInterceptors[int](ctx, _q, querierCount[*TemplateFieldQuery](), _q.inters)
+}
+
+// CountX is like Count, but panics if an error occurs.
+func (_q *TemplateFieldQuery) CountX(ctx context.Context) int {
+ count, err := _q.Count(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return count
+}
+
+// Exist returns true if the query has elements in the graph.
+func (_q *TemplateFieldQuery) Exist(ctx context.Context) (bool, error) {
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
+ switch _, err := _q.FirstID(ctx); {
+ case IsNotFound(err):
+ return false, nil
+ case err != nil:
+ return false, fmt.Errorf("ent: check existence: %w", err)
+ default:
+ return true, nil
+ }
+}
+
+// ExistX is like Exist, but panics if an error occurs.
+func (_q *TemplateFieldQuery) ExistX(ctx context.Context) bool {
+ exist, err := _q.Exist(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return exist
+}
+
+// Clone returns a duplicate of the TemplateFieldQuery builder, including all associated steps. It can be
+// used to prepare common query builders and use them differently after the clone is made.
+func (_q *TemplateFieldQuery) Clone() *TemplateFieldQuery {
+ if _q == nil {
+ return nil
+ }
+ return &TemplateFieldQuery{
+ config: _q.config,
+ ctx: _q.ctx.Clone(),
+ order: append([]templatefield.OrderOption{}, _q.order...),
+ inters: append([]Interceptor{}, _q.inters...),
+ predicates: append([]predicate.TemplateField{}, _q.predicates...),
+ withItemTemplate: _q.withItemTemplate.Clone(),
+ // clone intermediate query.
+ sql: _q.sql.Clone(),
+ path: _q.path,
+ }
+}
+
+// WithItemTemplate tells the query-builder to eager-load the nodes that are connected to
+// the "item_template" edge. The optional arguments are used to configure the query builder of the edge.
+func (_q *TemplateFieldQuery) WithItemTemplate(opts ...func(*ItemTemplateQuery)) *TemplateFieldQuery {
+ query := (&ItemTemplateClient{config: _q.config}).Query()
+ for _, opt := range opts {
+ opt(query)
+ }
+ _q.withItemTemplate = query
+ return _q
+}
+
+// GroupBy is used to group vertices by one or more fields/columns.
+// It is often used with aggregate functions, like: count, max, mean, min, sum.
+//
+// Example:
+//
+// var v []struct {
+// CreatedAt time.Time `json:"created_at,omitempty"`
+// Count int `json:"count,omitempty"`
+// }
+//
+// client.TemplateField.Query().
+// GroupBy(templatefield.FieldCreatedAt).
+// Aggregate(ent.Count()).
+// Scan(ctx, &v)
+func (_q *TemplateFieldQuery) GroupBy(field string, fields ...string) *TemplateFieldGroupBy {
+ _q.ctx.Fields = append([]string{field}, fields...)
+ grbuild := &TemplateFieldGroupBy{build: _q}
+ grbuild.flds = &_q.ctx.Fields
+ grbuild.label = templatefield.Label
+ grbuild.scan = grbuild.Scan
+ return grbuild
+}
+
+// Select allows the selection one or more fields/columns for the given query,
+// instead of selecting all fields in the entity.
+//
+// Example:
+//
+// var v []struct {
+// CreatedAt time.Time `json:"created_at,omitempty"`
+// }
+//
+// client.TemplateField.Query().
+// Select(templatefield.FieldCreatedAt).
+// Scan(ctx, &v)
+func (_q *TemplateFieldQuery) Select(fields ...string) *TemplateFieldSelect {
+ _q.ctx.Fields = append(_q.ctx.Fields, fields...)
+ sbuild := &TemplateFieldSelect{TemplateFieldQuery: _q}
+ sbuild.label = templatefield.Label
+ sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
+ return sbuild
+}
+
+// Aggregate returns a TemplateFieldSelect configured with the given aggregations.
+func (_q *TemplateFieldQuery) Aggregate(fns ...AggregateFunc) *TemplateFieldSelect {
+ return _q.Select().Aggregate(fns...)
+}
+
+func (_q *TemplateFieldQuery) prepareQuery(ctx context.Context) error {
+ for _, inter := range _q.inters {
+ if inter == nil {
+ return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
+ }
+ if trv, ok := inter.(Traverser); ok {
+ if err := trv.Traverse(ctx, _q); err != nil {
+ return err
+ }
+ }
+ }
+ for _, f := range _q.ctx.Fields {
+ if !templatefield.ValidColumn(f) {
+ return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+ }
+ }
+ if _q.path != nil {
+ prev, err := _q.path(ctx)
+ if err != nil {
+ return err
+ }
+ _q.sql = prev
+ }
+ return nil
+}
+
+func (_q *TemplateFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*TemplateField, error) {
+ var (
+ nodes = []*TemplateField{}
+ withFKs = _q.withFKs
+ _spec = _q.querySpec()
+ loadedTypes = [1]bool{
+ _q.withItemTemplate != nil,
+ }
+ )
+ if _q.withItemTemplate != nil {
+ withFKs = true
+ }
+ if withFKs {
+ _spec.Node.Columns = append(_spec.Node.Columns, templatefield.ForeignKeys...)
+ }
+ _spec.ScanValues = func(columns []string) ([]any, error) {
+ return (*TemplateField).scanValues(nil, columns)
+ }
+ _spec.Assign = func(columns []string, values []any) error {
+ node := &TemplateField{config: _q.config}
+ nodes = append(nodes, node)
+ node.Edges.loadedTypes = loadedTypes
+ return node.assignValues(columns, values)
+ }
+ for i := range hooks {
+ hooks[i](ctx, _spec)
+ }
+ if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
+ return nil, err
+ }
+ if len(nodes) == 0 {
+ return nodes, nil
+ }
+ if query := _q.withItemTemplate; query != nil {
+ if err := _q.loadItemTemplate(ctx, query, nodes, nil,
+ func(n *TemplateField, e *ItemTemplate) { n.Edges.ItemTemplate = e }); err != nil {
+ return nil, err
+ }
+ }
+ return nodes, nil
+}
+
+func (_q *TemplateFieldQuery) loadItemTemplate(ctx context.Context, query *ItemTemplateQuery, nodes []*TemplateField, init func(*TemplateField), assign func(*TemplateField, *ItemTemplate)) error {
+ ids := make([]uuid.UUID, 0, len(nodes))
+ nodeids := make(map[uuid.UUID][]*TemplateField)
+ for i := range nodes {
+ if nodes[i].item_template_fields == nil {
+ continue
+ }
+ fk := *nodes[i].item_template_fields
+ if _, ok := nodeids[fk]; !ok {
+ ids = append(ids, fk)
+ }
+ nodeids[fk] = append(nodeids[fk], nodes[i])
+ }
+ if len(ids) == 0 {
+ return nil
+ }
+ query.Where(itemtemplate.IDIn(ids...))
+ neighbors, err := query.All(ctx)
+ if err != nil {
+ return err
+ }
+ for _, n := range neighbors {
+ nodes, ok := nodeids[n.ID]
+ if !ok {
+ return fmt.Errorf(`unexpected foreign-key "item_template_fields" returned %v`, n.ID)
+ }
+ for i := range nodes {
+ assign(nodes[i], n)
+ }
+ }
+ return nil
+}
+
+func (_q *TemplateFieldQuery) sqlCount(ctx context.Context) (int, error) {
+ _spec := _q.querySpec()
+ _spec.Node.Columns = _q.ctx.Fields
+ if len(_q.ctx.Fields) > 0 {
+ _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
+ }
+ return sqlgraph.CountNodes(ctx, _q.driver, _spec)
+}
+
+func (_q *TemplateFieldQuery) querySpec() *sqlgraph.QuerySpec {
+ _spec := sqlgraph.NewQuerySpec(templatefield.Table, templatefield.Columns, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
+ _spec.From = _q.sql
+ if unique := _q.ctx.Unique; unique != nil {
+ _spec.Unique = *unique
+ } else if _q.path != nil {
+ _spec.Unique = true
+ }
+ if fields := _q.ctx.Fields; len(fields) > 0 {
+ _spec.Node.Columns = make([]string, 0, len(fields))
+ _spec.Node.Columns = append(_spec.Node.Columns, templatefield.FieldID)
+ for i := range fields {
+ if fields[i] != templatefield.FieldID {
+ _spec.Node.Columns = append(_spec.Node.Columns, fields[i])
+ }
+ }
+ }
+ if ps := _q.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ if limit := _q.ctx.Limit; limit != nil {
+ _spec.Limit = *limit
+ }
+ if offset := _q.ctx.Offset; offset != nil {
+ _spec.Offset = *offset
+ }
+ if ps := _q.order; len(ps) > 0 {
+ _spec.Order = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ return _spec
+}
+
+func (_q *TemplateFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
+ builder := sql.Dialect(_q.driver.Dialect())
+ t1 := builder.Table(templatefield.Table)
+ columns := _q.ctx.Fields
+ if len(columns) == 0 {
+ columns = templatefield.Columns
+ }
+ selector := builder.Select(t1.Columns(columns...)...).From(t1)
+ if _q.sql != nil {
+ selector = _q.sql
+ selector.Select(selector.Columns(columns...)...)
+ }
+ if _q.ctx.Unique != nil && *_q.ctx.Unique {
+ selector.Distinct()
+ }
+ for _, p := range _q.predicates {
+ p(selector)
+ }
+ for _, p := range _q.order {
+ p(selector)
+ }
+ if offset := _q.ctx.Offset; offset != nil {
+ // limit is mandatory for offset clause. We start
+ // with default value, and override it below if needed.
+ selector.Offset(*offset).Limit(math.MaxInt32)
+ }
+ if limit := _q.ctx.Limit; limit != nil {
+ selector.Limit(*limit)
+ }
+ return selector
+}
+
+// TemplateFieldGroupBy is the group-by builder for TemplateField entities.
+type TemplateFieldGroupBy struct {
+ selector
+ build *TemplateFieldQuery
+}
+
+// Aggregate adds the given aggregation functions to the group-by query.
+func (_g *TemplateFieldGroupBy) Aggregate(fns ...AggregateFunc) *TemplateFieldGroupBy {
+ _g.fns = append(_g.fns, fns...)
+ return _g
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (_g *TemplateFieldGroupBy) Scan(ctx context.Context, v any) error {
+ ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
+ if err := _g.build.prepareQuery(ctx); err != nil {
+ return err
+ }
+ return scanWithInterceptors[*TemplateFieldQuery, *TemplateFieldGroupBy](ctx, _g.build, _g, _g.build.inters, v)
+}
+
+func (_g *TemplateFieldGroupBy) sqlScan(ctx context.Context, root *TemplateFieldQuery, v any) error {
+ selector := root.sqlQuery(ctx).Select()
+ aggregation := make([]string, 0, len(_g.fns))
+ for _, fn := range _g.fns {
+ aggregation = append(aggregation, fn(selector))
+ }
+ if len(selector.SelectedColumns()) == 0 {
+ columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
+ for _, f := range *_g.flds {
+ columns = append(columns, selector.C(f))
+ }
+ columns = append(columns, aggregation...)
+ selector.Select(columns...)
+ }
+ selector.GroupBy(selector.Columns(*_g.flds...)...)
+ if err := selector.Err(); err != nil {
+ return err
+ }
+ rows := &sql.Rows{}
+ query, args := selector.Query()
+ if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
+ return err
+ }
+ defer rows.Close()
+ return sql.ScanSlice(rows, v)
+}
+
+// TemplateFieldSelect is the builder for selecting fields of TemplateField entities.
+type TemplateFieldSelect struct {
+ *TemplateFieldQuery
+ selector
+}
+
+// Aggregate adds the given aggregation functions to the selector query.
+func (_s *TemplateFieldSelect) Aggregate(fns ...AggregateFunc) *TemplateFieldSelect {
+ _s.fns = append(_s.fns, fns...)
+ return _s
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (_s *TemplateFieldSelect) Scan(ctx context.Context, v any) error {
+ ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
+ if err := _s.prepareQuery(ctx); err != nil {
+ return err
+ }
+ return scanWithInterceptors[*TemplateFieldQuery, *TemplateFieldSelect](ctx, _s.TemplateFieldQuery, _s, _s.inters, v)
+}
+
+func (_s *TemplateFieldSelect) sqlScan(ctx context.Context, root *TemplateFieldQuery, v any) error {
+ selector := root.sqlQuery(ctx)
+ aggregation := make([]string, 0, len(_s.fns))
+ for _, fn := range _s.fns {
+ aggregation = append(aggregation, fn(selector))
+ }
+ switch n := len(*_s.selector.flds); {
+ case n == 0 && len(aggregation) > 0:
+ selector.Select(aggregation...)
+ case n != 0 && len(aggregation) > 0:
+ selector.AppendSelect(aggregation...)
+ }
+ rows := &sql.Rows{}
+ query, args := selector.Query()
+ if err := _s.driver.Query(ctx, query, args, rows); err != nil {
+ return err
+ }
+ defer rows.Close()
+ return sql.ScanSlice(rows, v)
+}
diff --git a/backend/internal/data/ent/templatefield_update.go b/backend/internal/data/ent/templatefield_update.go
new file mode 100644
index 00000000..521659c0
--- /dev/null
+++ b/backend/internal/data/ent/templatefield_update.go
@@ -0,0 +1,550 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "time"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+ "github.com/google/uuid"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
+)
+
+// TemplateFieldUpdate is the builder for updating TemplateField entities.
+type TemplateFieldUpdate struct {
+ config
+ hooks []Hook
+ mutation *TemplateFieldMutation
+}
+
+// Where appends a list predicates to the TemplateFieldUpdate builder.
+func (_u *TemplateFieldUpdate) Where(ps ...predicate.TemplateField) *TemplateFieldUpdate {
+ _u.mutation.Where(ps...)
+ return _u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (_u *TemplateFieldUpdate) SetUpdatedAt(v time.Time) *TemplateFieldUpdate {
+ _u.mutation.SetUpdatedAt(v)
+ return _u
+}
+
+// SetName sets the "name" field.
+func (_u *TemplateFieldUpdate) SetName(v string) *TemplateFieldUpdate {
+ _u.mutation.SetName(v)
+ return _u
+}
+
+// SetNillableName sets the "name" field if the given value is not nil.
+func (_u *TemplateFieldUpdate) SetNillableName(v *string) *TemplateFieldUpdate {
+ if v != nil {
+ _u.SetName(*v)
+ }
+ return _u
+}
+
+// SetDescription sets the "description" field.
+func (_u *TemplateFieldUpdate) SetDescription(v string) *TemplateFieldUpdate {
+ _u.mutation.SetDescription(v)
+ return _u
+}
+
+// SetNillableDescription sets the "description" field if the given value is not nil.
+func (_u *TemplateFieldUpdate) SetNillableDescription(v *string) *TemplateFieldUpdate {
+ if v != nil {
+ _u.SetDescription(*v)
+ }
+ return _u
+}
+
+// ClearDescription clears the value of the "description" field.
+func (_u *TemplateFieldUpdate) ClearDescription() *TemplateFieldUpdate {
+ _u.mutation.ClearDescription()
+ return _u
+}
+
+// SetType sets the "type" field.
+func (_u *TemplateFieldUpdate) SetType(v templatefield.Type) *TemplateFieldUpdate {
+ _u.mutation.SetType(v)
+ return _u
+}
+
+// SetNillableType sets the "type" field if the given value is not nil.
+func (_u *TemplateFieldUpdate) SetNillableType(v *templatefield.Type) *TemplateFieldUpdate {
+ if v != nil {
+ _u.SetType(*v)
+ }
+ return _u
+}
+
+// SetTextValue sets the "text_value" field.
+func (_u *TemplateFieldUpdate) SetTextValue(v string) *TemplateFieldUpdate {
+ _u.mutation.SetTextValue(v)
+ return _u
+}
+
+// SetNillableTextValue sets the "text_value" field if the given value is not nil.
+func (_u *TemplateFieldUpdate) SetNillableTextValue(v *string) *TemplateFieldUpdate {
+ if v != nil {
+ _u.SetTextValue(*v)
+ }
+ return _u
+}
+
+// ClearTextValue clears the value of the "text_value" field.
+func (_u *TemplateFieldUpdate) ClearTextValue() *TemplateFieldUpdate {
+ _u.mutation.ClearTextValue()
+ return _u
+}
+
+// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID.
+func (_u *TemplateFieldUpdate) SetItemTemplateID(id uuid.UUID) *TemplateFieldUpdate {
+ _u.mutation.SetItemTemplateID(id)
+ return _u
+}
+
+// SetNillableItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID if the given value is not nil.
+func (_u *TemplateFieldUpdate) SetNillableItemTemplateID(id *uuid.UUID) *TemplateFieldUpdate {
+ if id != nil {
+ _u = _u.SetItemTemplateID(*id)
+ }
+ return _u
+}
+
+// SetItemTemplate sets the "item_template" edge to the ItemTemplate entity.
+func (_u *TemplateFieldUpdate) SetItemTemplate(v *ItemTemplate) *TemplateFieldUpdate {
+ return _u.SetItemTemplateID(v.ID)
+}
+
+// Mutation returns the TemplateFieldMutation object of the builder.
+func (_u *TemplateFieldUpdate) Mutation() *TemplateFieldMutation {
+ return _u.mutation
+}
+
+// ClearItemTemplate clears the "item_template" edge to the ItemTemplate entity.
+func (_u *TemplateFieldUpdate) ClearItemTemplate() *TemplateFieldUpdate {
+ _u.mutation.ClearItemTemplate()
+ return _u
+}
+
+// Save executes the query and returns the number of nodes affected by the update operation.
+func (_u *TemplateFieldUpdate) Save(ctx context.Context) (int, error) {
+ _u.defaults()
+ return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (_u *TemplateFieldUpdate) SaveX(ctx context.Context) int {
+ affected, err := _u.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return affected
+}
+
+// Exec executes the query.
+func (_u *TemplateFieldUpdate) Exec(ctx context.Context) error {
+ _, err := _u.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_u *TemplateFieldUpdate) ExecX(ctx context.Context) {
+ if err := _u.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// defaults sets the default values of the builder before save.
+func (_u *TemplateFieldUpdate) defaults() {
+ if _, ok := _u.mutation.UpdatedAt(); !ok {
+ v := templatefield.UpdateDefaultUpdatedAt()
+ _u.mutation.SetUpdatedAt(v)
+ }
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (_u *TemplateFieldUpdate) check() error {
+ if v, ok := _u.mutation.Name(); ok {
+ if err := templatefield.NameValidator(v); err != nil {
+ return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TemplateField.name": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.Description(); ok {
+ if err := templatefield.DescriptionValidator(v); err != nil {
+ return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "TemplateField.description": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.GetType(); ok {
+ if err := templatefield.TypeValidator(v); err != nil {
+ return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "TemplateField.type": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.TextValue(); ok {
+ if err := templatefield.TextValueValidator(v); err != nil {
+ return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "TemplateField.text_value": %w`, err)}
+ }
+ }
+ return nil
+}
+
+func (_u *TemplateFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
+ if err := _u.check(); err != nil {
+ return _node, err
+ }
+ _spec := sqlgraph.NewUpdateSpec(templatefield.Table, templatefield.Columns, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
+ if ps := _u.mutation.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ if value, ok := _u.mutation.UpdatedAt(); ok {
+ _spec.SetField(templatefield.FieldUpdatedAt, field.TypeTime, value)
+ }
+ if value, ok := _u.mutation.Name(); ok {
+ _spec.SetField(templatefield.FieldName, field.TypeString, value)
+ }
+ if value, ok := _u.mutation.Description(); ok {
+ _spec.SetField(templatefield.FieldDescription, field.TypeString, value)
+ }
+ if _u.mutation.DescriptionCleared() {
+ _spec.ClearField(templatefield.FieldDescription, field.TypeString)
+ }
+ if value, ok := _u.mutation.GetType(); ok {
+ _spec.SetField(templatefield.FieldType, field.TypeEnum, value)
+ }
+ if value, ok := _u.mutation.TextValue(); ok {
+ _spec.SetField(templatefield.FieldTextValue, field.TypeString, value)
+ }
+ if _u.mutation.TextValueCleared() {
+ _spec.ClearField(templatefield.FieldTextValue, field.TypeString)
+ }
+ if _u.mutation.ItemTemplateCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: templatefield.ItemTemplateTable,
+ Columns: []string{templatefield.ItemTemplateColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.ItemTemplateIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: templatefield.ItemTemplateTable,
+ Columns: []string{templatefield.ItemTemplateColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
+ if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
+ if _, ok := err.(*sqlgraph.NotFoundError); ok {
+ err = &NotFoundError{templatefield.Label}
+ } else if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ return 0, err
+ }
+ _u.mutation.done = true
+ return _node, nil
+}
+
+// TemplateFieldUpdateOne is the builder for updating a single TemplateField entity.
+type TemplateFieldUpdateOne struct {
+ config
+ fields []string
+ hooks []Hook
+ mutation *TemplateFieldMutation
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (_u *TemplateFieldUpdateOne) SetUpdatedAt(v time.Time) *TemplateFieldUpdateOne {
+ _u.mutation.SetUpdatedAt(v)
+ return _u
+}
+
+// SetName sets the "name" field.
+func (_u *TemplateFieldUpdateOne) SetName(v string) *TemplateFieldUpdateOne {
+ _u.mutation.SetName(v)
+ return _u
+}
+
+// SetNillableName sets the "name" field if the given value is not nil.
+func (_u *TemplateFieldUpdateOne) SetNillableName(v *string) *TemplateFieldUpdateOne {
+ if v != nil {
+ _u.SetName(*v)
+ }
+ return _u
+}
+
+// SetDescription sets the "description" field.
+func (_u *TemplateFieldUpdateOne) SetDescription(v string) *TemplateFieldUpdateOne {
+ _u.mutation.SetDescription(v)
+ return _u
+}
+
+// SetNillableDescription sets the "description" field if the given value is not nil.
+func (_u *TemplateFieldUpdateOne) SetNillableDescription(v *string) *TemplateFieldUpdateOne {
+ if v != nil {
+ _u.SetDescription(*v)
+ }
+ return _u
+}
+
+// ClearDescription clears the value of the "description" field.
+func (_u *TemplateFieldUpdateOne) ClearDescription() *TemplateFieldUpdateOne {
+ _u.mutation.ClearDescription()
+ return _u
+}
+
+// SetType sets the "type" field.
+func (_u *TemplateFieldUpdateOne) SetType(v templatefield.Type) *TemplateFieldUpdateOne {
+ _u.mutation.SetType(v)
+ return _u
+}
+
+// SetNillableType sets the "type" field if the given value is not nil.
+func (_u *TemplateFieldUpdateOne) SetNillableType(v *templatefield.Type) *TemplateFieldUpdateOne {
+ if v != nil {
+ _u.SetType(*v)
+ }
+ return _u
+}
+
+// SetTextValue sets the "text_value" field.
+func (_u *TemplateFieldUpdateOne) SetTextValue(v string) *TemplateFieldUpdateOne {
+ _u.mutation.SetTextValue(v)
+ return _u
+}
+
+// SetNillableTextValue sets the "text_value" field if the given value is not nil.
+func (_u *TemplateFieldUpdateOne) SetNillableTextValue(v *string) *TemplateFieldUpdateOne {
+ if v != nil {
+ _u.SetTextValue(*v)
+ }
+ return _u
+}
+
+// ClearTextValue clears the value of the "text_value" field.
+func (_u *TemplateFieldUpdateOne) ClearTextValue() *TemplateFieldUpdateOne {
+ _u.mutation.ClearTextValue()
+ return _u
+}
+
+// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID.
+func (_u *TemplateFieldUpdateOne) SetItemTemplateID(id uuid.UUID) *TemplateFieldUpdateOne {
+ _u.mutation.SetItemTemplateID(id)
+ return _u
+}
+
+// SetNillableItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID if the given value is not nil.
+func (_u *TemplateFieldUpdateOne) SetNillableItemTemplateID(id *uuid.UUID) *TemplateFieldUpdateOne {
+ if id != nil {
+ _u = _u.SetItemTemplateID(*id)
+ }
+ return _u
+}
+
+// SetItemTemplate sets the "item_template" edge to the ItemTemplate entity.
+func (_u *TemplateFieldUpdateOne) SetItemTemplate(v *ItemTemplate) *TemplateFieldUpdateOne {
+ return _u.SetItemTemplateID(v.ID)
+}
+
+// Mutation returns the TemplateFieldMutation object of the builder.
+func (_u *TemplateFieldUpdateOne) Mutation() *TemplateFieldMutation {
+ return _u.mutation
+}
+
+// ClearItemTemplate clears the "item_template" edge to the ItemTemplate entity.
+func (_u *TemplateFieldUpdateOne) ClearItemTemplate() *TemplateFieldUpdateOne {
+ _u.mutation.ClearItemTemplate()
+ return _u
+}
+
+// Where appends a list predicates to the TemplateFieldUpdate builder.
+func (_u *TemplateFieldUpdateOne) Where(ps ...predicate.TemplateField) *TemplateFieldUpdateOne {
+ _u.mutation.Where(ps...)
+ return _u
+}
+
+// Select allows selecting one or more fields (columns) of the returned entity.
+// The default is selecting all fields defined in the entity schema.
+func (_u *TemplateFieldUpdateOne) Select(field string, fields ...string) *TemplateFieldUpdateOne {
+ _u.fields = append([]string{field}, fields...)
+ return _u
+}
+
+// Save executes the query and returns the updated TemplateField entity.
+func (_u *TemplateFieldUpdateOne) Save(ctx context.Context) (*TemplateField, error) {
+ _u.defaults()
+ return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (_u *TemplateFieldUpdateOne) SaveX(ctx context.Context) *TemplateField {
+ node, err := _u.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return node
+}
+
+// Exec executes the query on the entity.
+func (_u *TemplateFieldUpdateOne) Exec(ctx context.Context) error {
+ _, err := _u.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_u *TemplateFieldUpdateOne) ExecX(ctx context.Context) {
+ if err := _u.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// defaults sets the default values of the builder before save.
+func (_u *TemplateFieldUpdateOne) defaults() {
+ if _, ok := _u.mutation.UpdatedAt(); !ok {
+ v := templatefield.UpdateDefaultUpdatedAt()
+ _u.mutation.SetUpdatedAt(v)
+ }
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (_u *TemplateFieldUpdateOne) check() error {
+ if v, ok := _u.mutation.Name(); ok {
+ if err := templatefield.NameValidator(v); err != nil {
+ return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TemplateField.name": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.Description(); ok {
+ if err := templatefield.DescriptionValidator(v); err != nil {
+ return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "TemplateField.description": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.GetType(); ok {
+ if err := templatefield.TypeValidator(v); err != nil {
+ return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "TemplateField.type": %w`, err)}
+ }
+ }
+ if v, ok := _u.mutation.TextValue(); ok {
+ if err := templatefield.TextValueValidator(v); err != nil {
+ return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "TemplateField.text_value": %w`, err)}
+ }
+ }
+ return nil
+}
+
+func (_u *TemplateFieldUpdateOne) sqlSave(ctx context.Context) (_node *TemplateField, err error) {
+ if err := _u.check(); err != nil {
+ return _node, err
+ }
+ _spec := sqlgraph.NewUpdateSpec(templatefield.Table, templatefield.Columns, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
+ id, ok := _u.mutation.ID()
+ if !ok {
+ return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "TemplateField.id" for update`)}
+ }
+ _spec.Node.ID.Value = id
+ if fields := _u.fields; len(fields) > 0 {
+ _spec.Node.Columns = make([]string, 0, len(fields))
+ _spec.Node.Columns = append(_spec.Node.Columns, templatefield.FieldID)
+ for _, f := range fields {
+ if !templatefield.ValidColumn(f) {
+ return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+ }
+ if f != templatefield.FieldID {
+ _spec.Node.Columns = append(_spec.Node.Columns, f)
+ }
+ }
+ }
+ if ps := _u.mutation.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ if value, ok := _u.mutation.UpdatedAt(); ok {
+ _spec.SetField(templatefield.FieldUpdatedAt, field.TypeTime, value)
+ }
+ if value, ok := _u.mutation.Name(); ok {
+ _spec.SetField(templatefield.FieldName, field.TypeString, value)
+ }
+ if value, ok := _u.mutation.Description(); ok {
+ _spec.SetField(templatefield.FieldDescription, field.TypeString, value)
+ }
+ if _u.mutation.DescriptionCleared() {
+ _spec.ClearField(templatefield.FieldDescription, field.TypeString)
+ }
+ if value, ok := _u.mutation.GetType(); ok {
+ _spec.SetField(templatefield.FieldType, field.TypeEnum, value)
+ }
+ if value, ok := _u.mutation.TextValue(); ok {
+ _spec.SetField(templatefield.FieldTextValue, field.TypeString, value)
+ }
+ if _u.mutation.TextValueCleared() {
+ _spec.ClearField(templatefield.FieldTextValue, field.TypeString)
+ }
+ if _u.mutation.ItemTemplateCleared() {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: templatefield.ItemTemplateTable,
+ Columns: []string{templatefield.ItemTemplateColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+ }
+ if nodes := _u.mutation.ItemTemplateIDs(); len(nodes) > 0 {
+ edge := &sqlgraph.EdgeSpec{
+ Rel: sqlgraph.M2O,
+ Inverse: true,
+ Table: templatefield.ItemTemplateTable,
+ Columns: []string{templatefield.ItemTemplateColumn},
+ Bidi: false,
+ Target: &sqlgraph.EdgeTarget{
+ IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
+ },
+ }
+ for _, k := range nodes {
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
+ }
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
+ }
+ _node = &TemplateField{config: _u.config}
+ _spec.Assign = _node.assignValues
+ _spec.ScanValues = _node.scanValues
+ if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
+ if _, ok := err.(*sqlgraph.NotFoundError); ok {
+ err = &NotFoundError{templatefield.Label}
+ } else if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ return nil, err
+ }
+ _u.mutation.done = true
+ return _node, nil
+}
diff --git a/backend/internal/data/ent/tx.go b/backend/internal/data/ent/tx.go
index 0642f2b8..f8561a0b 100644
--- a/backend/internal/data/ent/tx.go
+++ b/backend/internal/data/ent/tx.go
@@ -26,6 +26,8 @@ type Tx struct {
Item *ItemClient
// ItemField is the client for interacting with the ItemField builders.
ItemField *ItemFieldClient
+ // ItemTemplate is the client for interacting with the ItemTemplate builders.
+ ItemTemplate *ItemTemplateClient
// Label is the client for interacting with the Label builders.
Label *LabelClient
// Location is the client for interacting with the Location builders.
@@ -34,6 +36,8 @@ type Tx struct {
MaintenanceEntry *MaintenanceEntryClient
// Notifier is the client for interacting with the Notifier builders.
Notifier *NotifierClient
+ // TemplateField is the client for interacting with the TemplateField builders.
+ TemplateField *TemplateFieldClient
// User is the client for interacting with the User builders.
User *UserClient
@@ -174,10 +178,12 @@ func (tx *Tx) init() {
tx.GroupInvitationToken = NewGroupInvitationTokenClient(tx.config)
tx.Item = NewItemClient(tx.config)
tx.ItemField = NewItemFieldClient(tx.config)
+ tx.ItemTemplate = NewItemTemplateClient(tx.config)
tx.Label = NewLabelClient(tx.config)
tx.Location = NewLocationClient(tx.config)
tx.MaintenanceEntry = NewMaintenanceEntryClient(tx.config)
tx.Notifier = NewNotifierClient(tx.config)
+ tx.TemplateField = NewTemplateFieldClient(tx.config)
tx.User = NewUserClient(tx.config)
}
diff --git a/backend/internal/data/migrations/postgres/20251128120201_recreate_item_templates.sql b/backend/internal/data/migrations/postgres/20251128120201_recreate_item_templates.sql
new file mode 100644
index 00000000..6dd35a5f
--- /dev/null
+++ b/backend/internal/data/migrations/postgres/20251128120201_recreate_item_templates.sql
@@ -0,0 +1,29 @@
+-- +goose Up
+-- Create "item_templates" table
+CREATE TABLE IF NOT EXISTS "item_templates" (
+ "id" uuid NOT NULL,
+ "created_at" timestamptz NOT NULL,
+ "updated_at" timestamptz NOT NULL,
+ "name" character varying NOT NULL,
+ "description" character varying NULL,
+ "notes" character varying NULL,
+ "default_quantity" bigint NOT NULL DEFAULT 1,
+ "default_insured" boolean NOT NULL DEFAULT false,
+ "default_name" character varying NULL,
+ "default_description" character varying NULL,
+ "default_manufacturer" character varying NULL,
+ "default_model_number" character varying NULL,
+ "default_lifetime_warranty" boolean NOT NULL DEFAULT false,
+ "default_warranty_details" character varying NULL,
+ "include_warranty_fields" boolean NOT NULL DEFAULT false,
+ "include_purchase_fields" boolean NOT NULL DEFAULT false,
+ "include_sold_fields" boolean NOT NULL DEFAULT false,
+ "default_label_ids" jsonb NULL,
+ "item_template_location" uuid NULL,
+ "group_item_templates" uuid NOT NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "item_templates_groups_item_templates" FOREIGN KEY ("group_item_templates") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE,
+ CONSTRAINT "item_templates_locations_location" FOREIGN KEY ("item_template_location") REFERENCES "locations" ("id") ON UPDATE NO ACTION ON DELETE SET NULL
+);
+-- Create "template_fields" table
+CREATE TABLE IF NOT EXISTS "template_fields" ("id" uuid NOT NULL, "created_at" timestamptz NOT NULL, "updated_at" timestamptz NOT NULL, "name" character varying NOT NULL, "description" character varying NULL, "type" character varying NOT NULL, "text_value" character varying NULL, "item_template_fields" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "template_fields_item_templates_fields" FOREIGN KEY ("item_template_fields") REFERENCES "item_templates" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
diff --git a/backend/internal/data/migrations/sqlite3/20251128120200_recreate_item_templates.sql b/backend/internal/data/migrations/sqlite3/20251128120200_recreate_item_templates.sql
new file mode 100644
index 00000000..6a7adf3c
--- /dev/null
+++ b/backend/internal/data/migrations/sqlite3/20251128120200_recreate_item_templates.sql
@@ -0,0 +1,46 @@
+-- +goose Up
+create table if not exists item_templates
+(
+ id uuid not null
+ primary key,
+ created_at datetime not null,
+ updated_at datetime not null,
+ name text not null,
+ description text,
+ notes text,
+ default_quantity integer default 1 not null,
+ default_insured bool default false not null,
+ default_name text,
+ default_description text,
+ default_manufacturer text,
+ default_model_number text,
+ default_lifetime_warranty bool default false not null,
+ default_warranty_details text,
+ include_warranty_fields bool default false not null,
+ include_purchase_fields bool default false not null,
+ include_sold_fields bool default false not null,
+ default_label_ids json,
+ item_template_location uuid
+ references locations(id)
+ on delete set null,
+ group_item_templates uuid not null
+ constraint item_templates_groups_item_templates
+ references groups
+ on delete cascade
+);
+
+create table if not exists template_fields
+(
+ id uuid not null
+ primary key,
+ created_at datetime not null,
+ updated_at datetime not null,
+ name text not null,
+ description text,
+ type text not null,
+ text_value text,
+ item_template_fields uuid
+ constraint template_fields_item_templates_fields
+ references item_templates
+ on delete cascade
+);
diff --git a/backend/internal/data/repo/repo_item_templates.go b/backend/internal/data/repo/repo_item_templates.go
new file mode 100644
index 00000000..532c6fe5
--- /dev/null
+++ b/backend/internal/data/repo/repo_item_templates.go
@@ -0,0 +1,451 @@
+package repo
+
+import (
+ "context"
+ "time"
+
+ "github.com/google/uuid"
+ "github.com/rs/zerolog/log"
+ "github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
+ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
+)
+
+type ItemTemplatesRepository struct {
+ db *ent.Client
+ bus *eventbus.EventBus
+}
+
+type (
+ TemplateField struct {
+ ID *uuid.UUID `json:"id,omitempty"`
+ Type string `json:"type"`
+ Name string `json:"name"`
+ TextValue string `json:"textValue"`
+ }
+
+ TemplateLabelSummary struct {
+ ID uuid.UUID `json:"id"`
+ Name string `json:"name"`
+ }
+
+ TemplateLocationSummary struct {
+ ID uuid.UUID `json:"id"`
+ Name string `json:"name"`
+ }
+
+ ItemTemplateCreate struct {
+ Name string `json:"name" validate:"required,min=1,max=255"`
+ Description string `json:"description" validate:"max=1000"`
+ Notes string `json:"notes" validate:"max=1000"`
+
+ // Default values for items
+ DefaultQuantity *int `json:"defaultQuantity,omitempty" extensions:"x-nullable"`
+ DefaultInsured bool `json:"defaultInsured"`
+ DefaultName *string `json:"defaultName,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
+ DefaultDescription *string `json:"defaultDescription,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
+ DefaultManufacturer *string `json:"defaultManufacturer,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
+ DefaultModelNumber *string `json:"defaultModelNumber,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
+ DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"`
+ DefaultWarrantyDetails *string `json:"defaultWarrantyDetails,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
+
+ // Default location and labels
+ DefaultLocationID *uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"`
+ DefaultLabelIDs *[]uuid.UUID `json:"defaultLabelIds,omitempty" extensions:"x-nullable"`
+
+ // Metadata flags
+ IncludeWarrantyFields bool `json:"includeWarrantyFields"`
+ IncludePurchaseFields bool `json:"includePurchaseFields"`
+ IncludeSoldFields bool `json:"includeSoldFields"`
+
+ // Custom fields
+ Fields []TemplateField `json:"fields"`
+ }
+
+ ItemTemplateUpdate struct {
+ ID uuid.UUID `json:"id"`
+ Name string `json:"name" validate:"required,min=1,max=255"`
+ Description string `json:"description" validate:"max=1000"`
+ Notes string `json:"notes" validate:"max=1000"`
+
+ // Default values for items
+ DefaultQuantity *int `json:"defaultQuantity,omitempty" extensions:"x-nullable"`
+ DefaultInsured bool `json:"defaultInsured"`
+ DefaultName *string `json:"defaultName,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
+ DefaultDescription *string `json:"defaultDescription,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
+ DefaultManufacturer *string `json:"defaultManufacturer,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
+ DefaultModelNumber *string `json:"defaultModelNumber,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
+ DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"`
+ DefaultWarrantyDetails *string `json:"defaultWarrantyDetails,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
+
+ // Default location and labels
+ DefaultLocationID *uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"`
+ DefaultLabelIDs *[]uuid.UUID `json:"defaultLabelIds,omitempty" extensions:"x-nullable"`
+
+ // Metadata flags
+ IncludeWarrantyFields bool `json:"includeWarrantyFields"`
+ IncludePurchaseFields bool `json:"includePurchaseFields"`
+ IncludeSoldFields bool `json:"includeSoldFields"`
+
+ // Custom fields
+ Fields []TemplateField `json:"fields"`
+ }
+
+ ItemTemplateSummary struct {
+ ID uuid.UUID `json:"id"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ CreatedAt time.Time `json:"createdAt"`
+ UpdatedAt time.Time `json:"updatedAt"`
+ }
+
+ ItemTemplateOut struct {
+ ID uuid.UUID `json:"id"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Notes string `json:"notes"`
+ CreatedAt time.Time `json:"createdAt"`
+ UpdatedAt time.Time `json:"updatedAt"`
+
+ // Default values for items
+ DefaultQuantity int `json:"defaultQuantity"`
+ DefaultInsured bool `json:"defaultInsured"`
+ DefaultName string `json:"defaultName"`
+ DefaultDescription string `json:"defaultDescription"`
+ DefaultManufacturer string `json:"defaultManufacturer"`
+ DefaultModelNumber string `json:"defaultModelNumber"`
+ DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"`
+ DefaultWarrantyDetails string `json:"defaultWarrantyDetails"`
+
+ // Default location and labels
+ DefaultLocation *TemplateLocationSummary `json:"defaultLocation"`
+ DefaultLabels []TemplateLabelSummary `json:"defaultLabels"`
+
+ // Metadata flags
+ IncludeWarrantyFields bool `json:"includeWarrantyFields"`
+ IncludePurchaseFields bool `json:"includePurchaseFields"`
+ IncludeSoldFields bool `json:"includeSoldFields"`
+
+ // Custom fields
+ Fields []TemplateField `json:"fields"`
+ }
+)
+
+func mapTemplateField(field *ent.TemplateField) TemplateField {
+ id := field.ID
+ return TemplateField{
+ ID: &id,
+ Type: string(field.Type),
+ Name: field.Name,
+ TextValue: field.TextValue,
+ }
+}
+
+func mapTemplateFieldSlice(fields []*ent.TemplateField) []TemplateField {
+ result := make([]TemplateField, len(fields))
+ for i, field := range fields {
+ result[i] = mapTemplateField(field)
+ }
+ return result
+}
+
+func mapTemplateSummary(template *ent.ItemTemplate) ItemTemplateSummary {
+ return ItemTemplateSummary{
+ ID: template.ID,
+ Name: template.Name,
+ Description: template.Description,
+ CreatedAt: template.CreatedAt,
+ UpdatedAt: template.UpdatedAt,
+ }
+}
+
+func (r *ItemTemplatesRepository) mapTemplateOut(ctx context.Context, template *ent.ItemTemplate) ItemTemplateOut {
+ fields := make([]TemplateField, 0)
+ if template.Edges.Fields != nil {
+ fields = mapTemplateFieldSlice(template.Edges.Fields)
+ }
+
+ // Map location if present
+ var location *TemplateLocationSummary
+ if template.Edges.Location != nil {
+ location = &TemplateLocationSummary{
+ ID: template.Edges.Location.ID,
+ Name: template.Edges.Location.Name,
+ }
+ }
+
+ // Fetch labels from database using stored IDs
+ labels := make([]TemplateLabelSummary, 0)
+ if len(template.DefaultLabelIds) > 0 {
+ labelEntities, err := r.db.Label.Query().
+ Where(label.IDIn(template.DefaultLabelIds...)).
+ All(ctx)
+ if err == nil {
+ for _, l := range labelEntities {
+ labels = append(labels, TemplateLabelSummary{
+ ID: l.ID,
+ Name: l.Name,
+ })
+ }
+ }
+ }
+
+ return ItemTemplateOut{
+ ID: template.ID,
+ Name: template.Name,
+ Description: template.Description,
+ Notes: template.Notes,
+ CreatedAt: template.CreatedAt,
+ UpdatedAt: template.UpdatedAt,
+ DefaultQuantity: template.DefaultQuantity,
+ DefaultInsured: template.DefaultInsured,
+ DefaultName: template.DefaultName,
+ DefaultDescription: template.DefaultDescription,
+ DefaultManufacturer: template.DefaultManufacturer,
+ DefaultModelNumber: template.DefaultModelNumber,
+ DefaultLifetimeWarranty: template.DefaultLifetimeWarranty,
+ DefaultWarrantyDetails: template.DefaultWarrantyDetails,
+ DefaultLocation: location,
+ DefaultLabels: labels,
+ IncludeWarrantyFields: template.IncludeWarrantyFields,
+ IncludePurchaseFields: template.IncludePurchaseFields,
+ IncludeSoldFields: template.IncludeSoldFields,
+ Fields: fields,
+ }
+}
+
+func (r *ItemTemplatesRepository) publishMutationEvent(gid uuid.UUID) {
+ if r.bus != nil {
+ r.bus.Publish(eventbus.EventItemMutation, eventbus.GroupMutationEvent{GID: gid})
+ }
+}
+
+// GetAll returns all templates for a group
+func (r *ItemTemplatesRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]ItemTemplateSummary, error) {
+ templates, err := r.db.ItemTemplate.Query().
+ Where(itemtemplate.HasGroupWith(group.ID(gid))).
+ Order(ent.Asc(itemtemplate.FieldName)).
+ All(ctx)
+
+ if err != nil {
+ return nil, err
+ }
+
+ result := make([]ItemTemplateSummary, len(templates))
+ for i, template := range templates {
+ result[i] = mapTemplateSummary(template)
+ }
+
+ return result, nil
+}
+
+// GetOne returns a single template by ID, verified to belong to the specified group
+func (r *ItemTemplatesRepository) GetOne(ctx context.Context, gid uuid.UUID, id uuid.UUID) (ItemTemplateOut, error) {
+ template, err := r.db.ItemTemplate.Query().
+ Where(
+ itemtemplate.ID(id),
+ itemtemplate.HasGroupWith(group.ID(gid)),
+ ).
+ WithFields().
+ WithLocation().
+ Only(ctx)
+
+ if err != nil {
+ return ItemTemplateOut{}, err
+ }
+
+ return r.mapTemplateOut(ctx, template), nil
+}
+
+// Create creates a new template
+func (r *ItemTemplatesRepository) Create(ctx context.Context, gid uuid.UUID, data ItemTemplateCreate) (ItemTemplateOut, error) {
+ q := r.db.ItemTemplate.Create().
+ SetName(data.Name).
+ SetDescription(data.Description).
+ SetNotes(data.Notes).
+ SetNillableDefaultQuantity(data.DefaultQuantity).
+ SetDefaultInsured(data.DefaultInsured).
+ SetNillableDefaultName(data.DefaultName).
+ SetNillableDefaultDescription(data.DefaultDescription).
+ SetNillableDefaultManufacturer(data.DefaultManufacturer).
+ SetNillableDefaultModelNumber(data.DefaultModelNumber).
+ SetDefaultLifetimeWarranty(data.DefaultLifetimeWarranty).
+ SetNillableDefaultWarrantyDetails(data.DefaultWarrantyDetails).
+ SetIncludeWarrantyFields(data.IncludeWarrantyFields).
+ SetIncludePurchaseFields(data.IncludePurchaseFields).
+ SetIncludeSoldFields(data.IncludeSoldFields).
+ SetGroupID(gid).
+ SetNillableLocationID(data.DefaultLocationID)
+
+ // Set default label IDs (stored as JSON)
+ if data.DefaultLabelIDs != nil && len(*data.DefaultLabelIDs) > 0 {
+ q.SetDefaultLabelIds(*data.DefaultLabelIDs)
+ }
+
+ template, err := q.Save(ctx)
+ if err != nil {
+ return ItemTemplateOut{}, err
+ }
+
+ // Create template fields
+ for _, field := range data.Fields {
+ _, err = r.db.TemplateField.Create().
+ SetItemTemplateID(template.ID).
+ SetType(templatefield.Type(field.Type)).
+ SetName(field.Name).
+ SetTextValue(field.TextValue).
+ Save(ctx)
+
+ if err != nil {
+ log.Err(err).Msg("failed to create template field")
+ return ItemTemplateOut{}, err
+ }
+ }
+
+ r.publishMutationEvent(gid)
+ return r.GetOne(ctx, gid, template.ID)
+}
+
+// Update updates an existing template
+func (r *ItemTemplatesRepository) Update(ctx context.Context, gid uuid.UUID, data ItemTemplateUpdate) (ItemTemplateOut, error) {
+ // Verify template belongs to group
+ template, err := r.db.ItemTemplate.Query().
+ Where(
+ itemtemplate.ID(data.ID),
+ itemtemplate.HasGroupWith(group.ID(gid)),
+ ).
+ Only(ctx)
+
+ if err != nil {
+ return ItemTemplateOut{}, err
+ }
+
+ // Update template
+ updateQ := template.Update().
+ SetName(data.Name).
+ SetDescription(data.Description).
+ SetNotes(data.Notes).
+ SetNillableDefaultQuantity(data.DefaultQuantity).
+ SetDefaultInsured(data.DefaultInsured).
+ SetNillableDefaultName(data.DefaultName).
+ SetNillableDefaultDescription(data.DefaultDescription).
+ SetNillableDefaultManufacturer(data.DefaultManufacturer).
+ SetNillableDefaultModelNumber(data.DefaultModelNumber).
+ SetDefaultLifetimeWarranty(data.DefaultLifetimeWarranty).
+ SetNillableDefaultWarrantyDetails(data.DefaultWarrantyDetails).
+ SetIncludeWarrantyFields(data.IncludeWarrantyFields).
+ SetIncludePurchaseFields(data.IncludePurchaseFields).
+ SetIncludeSoldFields(data.IncludeSoldFields)
+
+ // Update location
+ if data.DefaultLocationID != nil {
+ updateQ.SetLocationID(*data.DefaultLocationID)
+ } else {
+ updateQ.ClearLocation()
+ }
+
+ // Update default label IDs (stored as JSON)
+ if data.DefaultLabelIDs != nil && len(*data.DefaultLabelIDs) > 0 {
+ updateQ.SetDefaultLabelIds(*data.DefaultLabelIDs)
+ } else {
+ updateQ.ClearDefaultLabelIds()
+ }
+
+ _, err = updateQ.Save(ctx)
+ if err != nil {
+ return ItemTemplateOut{}, err
+ }
+
+ // Get existing fields
+ existingFields, err := r.db.TemplateField.Query().
+ Where(templatefield.HasItemTemplateWith(itemtemplate.ID(data.ID))).
+ All(ctx)
+
+ if err != nil {
+ return ItemTemplateOut{}, err
+ }
+
+ // Create a map of existing field IDs for quick lookup
+ existingFieldMap := make(map[uuid.UUID]bool)
+ for _, field := range existingFields {
+ existingFieldMap[field.ID] = true
+ }
+
+ // Track which fields are being updated
+ updatedFieldIDs := make(map[uuid.UUID]bool)
+
+ // Create or update fields
+ for _, field := range data.Fields {
+ if field.ID == nil || *field.ID == uuid.Nil {
+ // Create new field
+ _, err = r.db.TemplateField.Create().
+ SetItemTemplateID(data.ID).
+ SetType(templatefield.Type(field.Type)).
+ SetName(field.Name).
+ SetTextValue(field.TextValue).
+ Save(ctx)
+
+ if err != nil {
+ log.Err(err).Msg("failed to create template field")
+ return ItemTemplateOut{}, err
+ }
+ } else {
+ // Update existing field
+ updatedFieldIDs[*field.ID] = true
+ _, err = r.db.TemplateField.Update().
+ Where(
+ templatefield.ID(*field.ID),
+ templatefield.HasItemTemplateWith(itemtemplate.ID(data.ID)),
+ ).
+ SetType(templatefield.Type(field.Type)).
+ SetName(field.Name).
+ SetTextValue(field.TextValue).
+ Save(ctx)
+
+ if err != nil {
+ log.Err(err).Msg("failed to update template field")
+ return ItemTemplateOut{}, err
+ }
+ }
+ }
+
+ // Delete fields that are no longer present
+ for _, field := range existingFields {
+ if !updatedFieldIDs[field.ID] {
+ err = r.db.TemplateField.DeleteOne(field).Exec(ctx)
+ if err != nil {
+ log.Err(err).Msg("failed to delete template field")
+ }
+ }
+ }
+
+ r.publishMutationEvent(gid)
+ return r.GetOne(ctx, gid, template.ID)
+}
+
+// Delete deletes a template
+func (r *ItemTemplatesRepository) Delete(ctx context.Context, gid uuid.UUID, id uuid.UUID) error {
+ // Verify template belongs to group
+ _, err := r.db.ItemTemplate.Query().
+ Where(
+ itemtemplate.ID(id),
+ itemtemplate.HasGroupWith(group.ID(gid)),
+ ).
+ Only(ctx)
+
+ if err != nil {
+ return err
+ }
+
+ // Delete template (fields will be cascade deleted)
+ err = r.db.ItemTemplate.DeleteOneID(id).Exec(ctx)
+ if err != nil {
+ return err
+ }
+
+ r.publishMutationEvent(gid)
+ return nil
+}
diff --git a/backend/internal/data/repo/repo_item_templates_test.go b/backend/internal/data/repo/repo_item_templates_test.go
new file mode 100644
index 00000000..dab5627d
--- /dev/null
+++ b/backend/internal/data/repo/repo_item_templates_test.go
@@ -0,0 +1,337 @@
+package repo
+
+import (
+ "context"
+ "testing"
+
+ "github.com/google/uuid"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func templateFactory() ItemTemplateCreate {
+ qty := 1
+ name := fk.Str(20)
+ desc := fk.Str(50)
+ mfr := fk.Str(15)
+ model := fk.Str(10)
+ warranty := ""
+
+ return ItemTemplateCreate{
+ Name: fk.Str(10),
+ Description: fk.Str(100),
+ Notes: fk.Str(50),
+ DefaultQuantity: &qty,
+ DefaultInsured: false,
+ DefaultName: &name,
+ DefaultDescription: &desc,
+ DefaultManufacturer: &mfr,
+ DefaultModelNumber: &model,
+ DefaultLifetimeWarranty: false,
+ DefaultWarrantyDetails: &warranty,
+ IncludeWarrantyFields: false,
+ IncludePurchaseFields: false,
+ IncludeSoldFields: false,
+ Fields: []TemplateField{},
+ }
+}
+
+func useTemplates(t *testing.T, count int) []ItemTemplateOut {
+ t.Helper()
+
+ templates := make([]ItemTemplateOut, count)
+ for i := 0; i < count; i++ {
+ data := templateFactory()
+
+ template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
+ require.NoError(t, err)
+ templates[i] = template
+ }
+
+ t.Cleanup(func() {
+ for _, template := range templates {
+ _ = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
+ }
+ })
+
+ return templates
+}
+
+func TestItemTemplatesRepository_GetAll(t *testing.T) {
+ useTemplates(t, 5)
+
+ all, err := tRepos.ItemTemplates.GetAll(context.Background(), tGroup.ID)
+ require.NoError(t, err)
+ assert.GreaterOrEqual(t, len(all), 5)
+}
+
+func TestItemTemplatesRepository_GetOne(t *testing.T) {
+ templates := useTemplates(t, 1)
+ template := templates[0]
+
+ found, err := tRepos.ItemTemplates.GetOne(context.Background(), tGroup.ID, template.ID)
+ require.NoError(t, err)
+ assert.Equal(t, template.ID, found.ID)
+ assert.Equal(t, template.Name, found.Name)
+ assert.Equal(t, template.Description, found.Description)
+}
+
+func TestItemTemplatesRepository_Create(t *testing.T) {
+ data := templateFactory()
+
+ template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
+ require.NoError(t, err)
+
+ assert.NotEqual(t, uuid.Nil, template.ID)
+ assert.Equal(t, data.Name, template.Name)
+ assert.Equal(t, data.Description, template.Description)
+ assert.Equal(t, *data.DefaultQuantity, template.DefaultQuantity)
+ assert.Equal(t, data.DefaultInsured, template.DefaultInsured)
+ assert.Equal(t, *data.DefaultName, template.DefaultName)
+ assert.Equal(t, *data.DefaultDescription, template.DefaultDescription)
+ assert.Equal(t, *data.DefaultManufacturer, template.DefaultManufacturer)
+ assert.Equal(t, *data.DefaultModelNumber, template.DefaultModelNumber)
+
+ // Cleanup
+ err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
+ require.NoError(t, err)
+}
+
+func TestItemTemplatesRepository_CreateWithFields(t *testing.T) {
+ data := templateFactory()
+ data.Fields = []TemplateField{
+ {Name: "Field 1", Type: "text", TextValue: "Value 1"},
+ {Name: "Field 2", Type: "text", TextValue: "Value 2"},
+ }
+
+ template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
+ require.NoError(t, err)
+
+ assert.Len(t, template.Fields, 2)
+ assert.Equal(t, "Field 1", template.Fields[0].Name)
+ assert.Equal(t, "Value 1", template.Fields[0].TextValue)
+ assert.Equal(t, "Field 2", template.Fields[1].Name)
+ assert.Equal(t, "Value 2", template.Fields[1].TextValue)
+
+ // Cleanup
+ err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
+ require.NoError(t, err)
+}
+
+func TestItemTemplatesRepository_Update(t *testing.T) {
+ templates := useTemplates(t, 1)
+ template := templates[0]
+
+ qty := 5
+ defaultName := "Default Item Name"
+ defaultDesc := "Default Item Description"
+ defaultMfr := "Updated Manufacturer"
+ defaultModel := "MODEL-123"
+ defaultWarranty := "Lifetime coverage"
+
+ updateData := ItemTemplateUpdate{
+ ID: template.ID,
+ Name: "Updated Name",
+ Description: "Updated Description",
+ Notes: "Updated Notes",
+ DefaultQuantity: &qty,
+ DefaultInsured: true,
+ DefaultName: &defaultName,
+ DefaultDescription: &defaultDesc,
+ DefaultManufacturer: &defaultMfr,
+ DefaultModelNumber: &defaultModel,
+ DefaultLifetimeWarranty: true,
+ DefaultWarrantyDetails: &defaultWarranty,
+ IncludeWarrantyFields: true,
+ IncludePurchaseFields: true,
+ IncludeSoldFields: false,
+ Fields: []TemplateField{},
+ }
+
+ updated, err := tRepos.ItemTemplates.Update(context.Background(), tGroup.ID, updateData)
+ require.NoError(t, err)
+
+ assert.Equal(t, template.ID, updated.ID)
+ assert.Equal(t, "Updated Name", updated.Name)
+ assert.Equal(t, "Updated Description", updated.Description)
+ assert.Equal(t, "Updated Notes", updated.Notes)
+ assert.Equal(t, 5, updated.DefaultQuantity)
+ assert.True(t, updated.DefaultInsured)
+ assert.Equal(t, "Default Item Name", updated.DefaultName)
+ assert.Equal(t, "Default Item Description", updated.DefaultDescription)
+ assert.Equal(t, "Updated Manufacturer", updated.DefaultManufacturer)
+ assert.Equal(t, "MODEL-123", updated.DefaultModelNumber)
+ assert.True(t, updated.DefaultLifetimeWarranty)
+ assert.Equal(t, "Lifetime coverage", updated.DefaultWarrantyDetails)
+ assert.True(t, updated.IncludeWarrantyFields)
+ assert.True(t, updated.IncludePurchaseFields)
+ assert.False(t, updated.IncludeSoldFields)
+}
+
+func TestItemTemplatesRepository_UpdateWithFields(t *testing.T) {
+ data := templateFactory()
+ data.Fields = []TemplateField{
+ {Name: "Original Field", Type: "text", TextValue: "Original Value"},
+ }
+
+ template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
+ require.NoError(t, err)
+ require.Len(t, template.Fields, 1)
+
+ // Update with new fields
+ qty := template.DefaultQuantity
+ updateData := ItemTemplateUpdate{
+ ID: template.ID,
+ Name: template.Name,
+ Description: template.Description,
+ DefaultQuantity: &qty,
+ Fields: []TemplateField{
+ {ID: template.Fields[0].ID, Name: "Updated Field", Type: "text", TextValue: "Updated Value"},
+ {Name: "New Field", Type: "text", TextValue: "New Value"},
+ },
+ }
+
+ updated, err := tRepos.ItemTemplates.Update(context.Background(), tGroup.ID, updateData)
+ require.NoError(t, err)
+
+ assert.Len(t, updated.Fields, 2)
+
+ // Cleanup
+ err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
+ require.NoError(t, err)
+}
+
+func TestItemTemplatesRepository_Delete(t *testing.T) {
+ data := templateFactory()
+
+ template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
+ require.NoError(t, err)
+
+ err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
+ require.NoError(t, err)
+
+ // Verify it's deleted
+ _, err = tRepos.ItemTemplates.GetOne(context.Background(), tGroup.ID, template.ID)
+ require.Error(t, err)
+}
+
+func TestItemTemplatesRepository_DeleteCascadesFields(t *testing.T) {
+ data := templateFactory()
+ data.Fields = []TemplateField{
+ {Name: "Field 1", Type: "text", TextValue: "Value 1"},
+ {Name: "Field 2", Type: "text", TextValue: "Value 2"},
+ }
+
+ template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
+ require.NoError(t, err)
+ require.Len(t, template.Fields, 2)
+
+ // Delete template - fields should be cascade deleted
+ err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
+ require.NoError(t, err)
+
+ // Verify template is deleted
+ _, err = tRepos.ItemTemplates.GetOne(context.Background(), tGroup.ID, template.ID)
+ require.Error(t, err)
+}
+
+func TestItemTemplatesRepository_CreateWithLocation(t *testing.T) {
+ // First create a location
+ loc, err := tRepos.Locations.Create(context.Background(), tGroup.ID, LocationCreate{
+ Name: fk.Str(10),
+ Description: fk.Str(50),
+ })
+ require.NoError(t, err)
+
+ t.Cleanup(func() {
+ _ = tRepos.Locations.delete(context.Background(), loc.ID)
+ })
+
+ // Create template with location
+ data := templateFactory()
+ data.DefaultLocationID = &loc.ID
+
+ template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
+ require.NoError(t, err)
+
+ assert.NotNil(t, template.DefaultLocation)
+ assert.Equal(t, loc.ID, template.DefaultLocation.ID)
+ assert.Equal(t, loc.Name, template.DefaultLocation.Name)
+
+ // Cleanup
+ err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
+ require.NoError(t, err)
+}
+
+func TestItemTemplatesRepository_CreateWithLabels(t *testing.T) {
+ // Create some labels
+ label1, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
+ Name: fk.Str(10),
+ Description: fk.Str(50),
+ })
+ require.NoError(t, err)
+
+ label2, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
+ Name: fk.Str(10),
+ Description: fk.Str(50),
+ })
+ require.NoError(t, err)
+
+ t.Cleanup(func() {
+ _ = tRepos.Labels.delete(context.Background(), label1.ID)
+ _ = tRepos.Labels.delete(context.Background(), label2.ID)
+ })
+
+ // Create template with labels
+ data := templateFactory()
+ labelIDs := []uuid.UUID{label1.ID, label2.ID}
+ data.DefaultLabelIDs = &labelIDs
+
+ template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
+ require.NoError(t, err)
+
+ assert.Len(t, template.DefaultLabels, 2)
+
+ // Cleanup
+ err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
+ require.NoError(t, err)
+}
+
+func TestItemTemplatesRepository_UpdateRemoveLocation(t *testing.T) {
+ // First create a location
+ loc, err := tRepos.Locations.Create(context.Background(), tGroup.ID, LocationCreate{
+ Name: fk.Str(10),
+ Description: fk.Str(50),
+ })
+ require.NoError(t, err)
+
+ t.Cleanup(func() {
+ _ = tRepos.Locations.delete(context.Background(), loc.ID)
+ })
+
+ // Create template with location
+ data := templateFactory()
+ data.DefaultLocationID = &loc.ID
+
+ template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
+ require.NoError(t, err)
+ require.NotNil(t, template.DefaultLocation)
+
+ // Update to remove location
+ qty := template.DefaultQuantity
+ updateData := ItemTemplateUpdate{
+ ID: template.ID,
+ Name: template.Name,
+ DefaultQuantity: &qty,
+ DefaultLocationID: nil, // Remove location
+ }
+
+ updated, err := tRepos.ItemTemplates.Update(context.Background(), tGroup.ID, updateData)
+ require.NoError(t, err)
+
+ assert.Nil(t, updated.DefaultLocation)
+
+ // Cleanup
+ err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
+ require.NoError(t, err)
+}
diff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.go
index 9a014b83..c2749b0a 100644
--- a/backend/internal/data/repo/repo_items.go
+++ b/backend/internal/data/repo/repo_items.go
@@ -654,6 +654,90 @@ func (e *ItemsRepository) Create(ctx context.Context, gid uuid.UUID, data ItemCr
return e.GetOne(ctx, result.ID)
}
+// ItemCreateFromTemplate contains all data needed to create an item from a template.
+type ItemCreateFromTemplate struct {
+ Name string
+ Description string
+ Quantity int
+ LocationID uuid.UUID
+ LabelIDs []uuid.UUID
+ Insured bool
+ Manufacturer string
+ ModelNumber string
+ LifetimeWarranty bool
+ WarrantyDetails string
+ Fields []ItemField
+}
+
+// CreateFromTemplate creates an item with all template data in a single transaction.
+func (e *ItemsRepository) CreateFromTemplate(ctx context.Context, gid uuid.UUID, data ItemCreateFromTemplate) (ItemOut, error) {
+ tx, err := e.db.Tx(ctx)
+ if err != nil {
+ return ItemOut{}, err
+ }
+ committed := false
+ defer func() {
+ if !committed {
+ if err := tx.Rollback(); err != nil {
+ log.Warn().Err(err).Msg("failed to rollback transaction during template item creation")
+ }
+ }
+ }()
+
+ // Get next asset ID within transaction
+ nextAssetID, err := e.GetHighestAssetIDTx(ctx, tx, gid)
+ if err != nil {
+ return ItemOut{}, err
+ }
+ nextAssetID++
+
+ // Create item with all template data
+ newItemID := uuid.New()
+ itemBuilder := tx.Item.Create().
+ SetID(newItemID).
+ SetName(data.Name).
+ SetDescription(data.Description).
+ SetQuantity(data.Quantity).
+ SetLocationID(data.LocationID).
+ SetGroupID(gid).
+ SetAssetID(int(nextAssetID)).
+ SetInsured(data.Insured).
+ SetManufacturer(data.Manufacturer).
+ SetModelNumber(data.ModelNumber).
+ SetLifetimeWarranty(data.LifetimeWarranty).
+ SetWarrantyDetails(data.WarrantyDetails)
+
+ if len(data.LabelIDs) > 0 {
+ itemBuilder.AddLabelIDs(data.LabelIDs...)
+ }
+
+ _, err = itemBuilder.Save(ctx)
+ if err != nil {
+ return ItemOut{}, err
+ }
+
+ // Create custom fields
+ for _, field := range data.Fields {
+ _, err = tx.ItemField.Create().
+ SetItemID(newItemID).
+ SetType(itemfield.Type(field.Type)).
+ SetName(field.Name).
+ SetTextValue(field.TextValue).
+ Save(ctx)
+ if err != nil {
+ return ItemOut{}, fmt.Errorf("failed to create field %s: %w", field.Name, err)
+ }
+ }
+
+ if err = tx.Commit(); err != nil {
+ return ItemOut{}, err
+ }
+ committed = true
+
+ e.publishMutationEvent(gid)
+ return e.GetOne(ctx, newItemID)
+}
+
func (e *ItemsRepository) Delete(ctx context.Context, id uuid.UUID) error {
// Get the item with its group and attachments before deletion
itm, err := e.db.Item.Query().
diff --git a/backend/internal/data/repo/repos_all.go b/backend/internal/data/repo/repos_all.go
index a9670aaa..6109d743 100644
--- a/backend/internal/data/repo/repos_all.go
+++ b/backend/internal/data/repo/repos_all.go
@@ -9,28 +9,30 @@ import (
// AllRepos is a container for all the repository interfaces
type AllRepos struct {
- Users *UserRepository
- AuthTokens *TokenRepository
- Groups *GroupRepository
- Locations *LocationRepository
- Labels *LabelRepository
- Items *ItemsRepository
- Attachments *AttachmentRepo
- MaintEntry *MaintenanceEntryRepository
- Notifiers *NotifierRepository
+ Users *UserRepository
+ AuthTokens *TokenRepository
+ Groups *GroupRepository
+ Locations *LocationRepository
+ Labels *LabelRepository
+ Items *ItemsRepository
+ ItemTemplates *ItemTemplatesRepository
+ Attachments *AttachmentRepo
+ MaintEntry *MaintenanceEntryRepository
+ Notifiers *NotifierRepository
}
func New(db *ent.Client, bus *eventbus.EventBus, storage config.Storage, pubSubConn string, thumbnail config.Thumbnail) *AllRepos {
attachments := &AttachmentRepo{db, storage, pubSubConn, thumbnail}
return &AllRepos{
- Users: &UserRepository{db},
- AuthTokens: &TokenRepository{db},
- Groups: NewGroupRepository(db),
- Locations: &LocationRepository{db, bus},
- Labels: &LabelRepository{db, bus},
- Items: &ItemsRepository{db, bus, attachments},
- Attachments: attachments,
- MaintEntry: &MaintenanceEntryRepository{db},
- Notifiers: NewNotifierRepository(db),
+ Users: &UserRepository{db},
+ AuthTokens: &TokenRepository{db},
+ Groups: NewGroupRepository(db),
+ Locations: &LocationRepository{db, bus},
+ Labels: &LabelRepository{db, bus},
+ Items: &ItemsRepository{db, bus, attachments},
+ ItemTemplates: &ItemTemplatesRepository{db, bus},
+ Attachments: attachments,
+ MaintEntry: &MaintenanceEntryRepository{db},
+ Notifiers: NewNotifierRepository(db),
}
}
diff --git a/docs/en/api/openapi-2.0.json b/docs/en/api/openapi-2.0.json
new file mode 100644
index 00000000..cd4721fa
--- /dev/null
+++ b/docs/en/api/openapi-2.0.json
@@ -0,0 +1,5195 @@
+{
+ "schemes": [
+ "https",
+ "http"
+ ],
+ "swagger": "2.0",
+ "info": {
+ "description": "Track, Manage, and Organize your Things.",
+ "title": "Homebox API",
+ "contact": {
+ "name": "Homebox Team",
+ "url": "https://discord.homebox.software"
+ },
+ "version": "1.0"
+ },
+ "host": "demo.homebox.software",
+ "basePath": "/api",
+ "paths": {
+ "/v1/actions/create-missing-thumbnails": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "description": "Creates thumbnails for items that are missing them",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Actions"
+ ],
+ "summary": "Create Missing Thumbnails",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/v1.ActionAmountResult"
+ }
+ }
+ }
+ }
+ },
+ "/v1/actions/ensure-asset-ids": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "description": "Ensures all items in the database have an asset ID",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Actions"
+ ],
+ "summary": "Ensure Asset IDs",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/v1.ActionAmountResult"
+ }
+ }
+ }
+ }
+ },
+ "/v1/actions/ensure-import-refs": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "description": "Ensures all items in the database have an import ref",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Actions"
+ ],
+ "summary": "Ensures Import Refs",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/v1.ActionAmountResult"
+ }
+ }
+ }
+ }
+ },
+ "/v1/actions/set-primary-photos": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "description": "Sets the first photo of each item as the primary photo",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Actions"
+ ],
+ "summary": "Set Primary Photos",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/v1.ActionAmountResult"
+ }
+ }
+ }
+ }
+ },
+ "/v1/actions/zero-item-time-fields": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "description": "Resets all item date fields to the beginning of the day",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Actions"
+ ],
+ "summary": "Zero Out Time Fields",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/v1.ActionAmountResult"
+ }
+ }
+ }
+ }
+ },
+ "/v1/assets/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Get Item by Asset ID",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Asset ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary"
+ }
+ }
+ }
+ }
+ },
+ "/v1/currency": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Base"
+ ],
+ "summary": "Currency",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/currencies.Currency"
+ }
+ }
+ }
+ }
+ },
+ "/v1/groups": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Group"
+ ],
+ "summary": "Get Group",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.Group"
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Group"
+ ],
+ "summary": "Update Group",
+ "parameters": [
+ {
+ "description": "User Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.GroupUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.Group"
+ }
+ }
+ }
+ }
+ },
+ "/v1/groups/invitations": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Group"
+ ],
+ "summary": "Create Group Invitation",
+ "parameters": [
+ {
+ "description": "User Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v1.GroupInvitationCreate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/v1.GroupInvitation"
+ }
+ }
+ }
+ }
+ },
+ "/v1/groups/statistics": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Statistics"
+ ],
+ "summary": "Get Group Statistics",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.GroupStatistics"
+ }
+ }
+ }
+ }
+ },
+ "/v1/groups/statistics/labels": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Statistics"
+ ],
+ "summary": "Get Label Statistics",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TotalsByOrganizer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/groups/statistics/locations": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Statistics"
+ ],
+ "summary": "Get Location Statistics",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TotalsByOrganizer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/groups/statistics/purchase-price": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Statistics"
+ ],
+ "summary": "Get Purchase Price Statistics",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "start date",
+ "name": "start",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "description": "end date",
+ "name": "end",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ValueOverTime"
+ }
+ }
+ }
+ }
+ },
+ "/v1/items": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Query All Items",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "search string",
+ "name": "q",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "page number",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "items per page",
+ "name": "pageSize",
+ "in": "query"
+ },
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "collectionFormat": "multi",
+ "description": "label Ids",
+ "name": "labels",
+ "in": "query"
+ },
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "collectionFormat": "multi",
+ "description": "location Ids",
+ "name": "locations",
+ "in": "query"
+ },
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "collectionFormat": "multi",
+ "description": "parent Ids",
+ "name": "parentIds",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary"
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Create Item",
+ "parameters": [
+ {
+ "description": "Item Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemCreate"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemSummary"
+ }
+ }
+ }
+ }
+ },
+ "/v1/items/export": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Export Items",
+ "responses": {
+ "200": {
+ "description": "text/csv",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/v1/items/fields": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Get All Custom Field Names",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/items/fields/values": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Get All Custom Field Values",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/items/import": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "consumes": [
+ "multipart/form-data"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Import Items",
+ "parameters": [
+ {
+ "type": "file",
+ "description": "Image to upload",
+ "name": "csv",
+ "in": "formData",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/items/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Get Item",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Item ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Update Item",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Item ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Item Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Delete Item",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Item ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ },
+ "patch": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Update Item",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Item ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Item Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemPatch"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ }
+ }
+ }
+ },
+ "/v1/items/{id}/attachments": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "consumes": [
+ "multipart/form-data"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items Attachments"
+ ],
+ "summary": "Create Item Attachment",
+ "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"
+ },
+ {
+ "type": "boolean",
+ "description": "Is this the primary attachment",
+ "name": "primary",
+ "in": "formData"
+ },
+ {
+ "type": "string",
+ "description": "name of the file including extension",
+ "name": "name",
+ "in": "formData",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ },
+ "422": {
+ "description": "Unprocessable Entity",
+ "schema": {
+ "$ref": "#/definitions/validate.ErrorResponse"
+ }
+ }
+ }
+ }
+ },
+ "/v1/items/{id}/attachments/{attachment_id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/octet-stream"
+ ],
+ "tags": [
+ "Items Attachments"
+ ],
+ "summary": "Get Item Attachment",
+ "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/v1.ItemAttachmentToken"
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Items Attachments"
+ ],
+ "summary": "Update Item Attachment",
+ "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/repo.ItemAttachmentUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Items Attachments"
+ ],
+ "summary": "Delete Item Attachment",
+ "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": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/items/{id}/duplicate": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Duplicate Item",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Item ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Duplicate Options",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.DuplicateOptions"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ }
+ }
+ }
+ },
+ "/v1/items/{id}/maintenance": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Maintenance"
+ ],
+ "summary": "Get Maintenance Log",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Item ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "enum": [
+ "scheduled",
+ "completed",
+ "both"
+ ],
+ "type": "string",
+ "x-enum-varnames": [
+ "MaintenanceFilterStatusScheduled",
+ "MaintenanceFilterStatusCompleted",
+ "MaintenanceFilterStatusBoth"
+ ],
+ "name": "status",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.MaintenanceEntryWithDetails"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Maintenance"
+ ],
+ "summary": "Create Maintenance Entry",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Item ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Entry Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.MaintenanceEntryCreate"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.MaintenanceEntry"
+ }
+ }
+ }
+ }
+ },
+ "/v1/items/{id}/path": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Get the full path of an item",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Item ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ItemPath"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/labelmaker/assets/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Get Asset label",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Asset ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "boolean",
+ "description": "Print this label, defaults to false",
+ "name": "print",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "image/png",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/v1/labelmaker/item/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Get Item label",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Item ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "boolean",
+ "description": "Print this label, defaults to false",
+ "name": "print",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "image/png",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/v1/labelmaker/location/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Locations"
+ ],
+ "summary": "Get Location label",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Location ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "boolean",
+ "description": "Print this label, defaults to false",
+ "name": "print",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "image/png",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/v1/labels": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Labels"
+ ],
+ "summary": "Get All Labels",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.LabelOut"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Labels"
+ ],
+ "summary": "Create Label",
+ "parameters": [
+ {
+ "description": "Label Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.LabelCreate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.LabelSummary"
+ }
+ }
+ }
+ }
+ },
+ "/v1/labels/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Labels"
+ ],
+ "summary": "Get Label",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Label ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.LabelOut"
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Labels"
+ ],
+ "summary": "Update Label",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Label ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.LabelOut"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Labels"
+ ],
+ "summary": "Delete Label",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Label ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/locations": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Locations"
+ ],
+ "summary": "Get All Locations",
+ "parameters": [
+ {
+ "type": "boolean",
+ "description": "Filter locations with parents",
+ "name": "filterChildren",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.LocationOutCount"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Locations"
+ ],
+ "summary": "Create Location",
+ "parameters": [
+ {
+ "description": "Location Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.LocationCreate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.LocationSummary"
+ }
+ }
+ }
+ }
+ },
+ "/v1/locations/tree": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Locations"
+ ],
+ "summary": "Get Locations Tree",
+ "parameters": [
+ {
+ "type": "boolean",
+ "description": "include items in response tree",
+ "name": "withItems",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TreeItem"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/locations/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Locations"
+ ],
+ "summary": "Get Location",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Location ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.LocationOut"
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Locations"
+ ],
+ "summary": "Update Location",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Location ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Location Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.LocationUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.LocationOut"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Locations"
+ ],
+ "summary": "Delete Location",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Location ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/maintenance": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Maintenance"
+ ],
+ "summary": "Query All Maintenance",
+ "parameters": [
+ {
+ "enum": [
+ "scheduled",
+ "completed",
+ "both"
+ ],
+ "type": "string",
+ "x-enum-varnames": [
+ "MaintenanceFilterStatusScheduled",
+ "MaintenanceFilterStatusCompleted",
+ "MaintenanceFilterStatusBoth"
+ ],
+ "name": "status",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.MaintenanceEntryWithDetails"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/maintenance/{id}": {
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Maintenance"
+ ],
+ "summary": "Update Maintenance Entry",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Maintenance ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Entry Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.MaintenanceEntryUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.MaintenanceEntry"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Maintenance"
+ ],
+ "summary": "Delete Maintenance Entry",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Maintenance ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/notifiers": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Notifiers"
+ ],
+ "summary": "Get Notifiers",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.NotifierOut"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Notifiers"
+ ],
+ "summary": "Create Notifier",
+ "parameters": [
+ {
+ "description": "Notifier Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.NotifierCreate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.NotifierOut"
+ }
+ }
+ }
+ }
+ },
+ "/v1/notifiers/test": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Notifiers"
+ ],
+ "summary": "Test Notifier",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "URL",
+ "name": "url",
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/notifiers/{id}": {
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Notifiers"
+ ],
+ "summary": "Update Notifier",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Notifier ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Notifier Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.NotifierUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.NotifierOut"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Notifiers"
+ ],
+ "summary": "Delete a Notifier",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Notifier ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/products/search-from-barcode": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Search EAN from Barcode",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "barcode to be searched",
+ "name": "data",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.BarcodeProduct"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/qrcode": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Create QR Code",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "data to be encoded into qrcode",
+ "name": "data",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "image/jpeg",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/v1/reporting/bill-of-materials": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Reporting"
+ ],
+ "summary": "Export Bill of Materials",
+ "responses": {
+ "200": {
+ "description": "text/csv",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/v1/status": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Base"
+ ],
+ "summary": "Application Info",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/v1.APISummary"
+ }
+ }
+ }
+ }
+ },
+ "/v1/templates": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get All Item Templates",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ItemTemplateSummary"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item Template",
+ "parameters": [
+ {
+ "description": "Template Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateCreate"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Update Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Template Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Delete Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}/create-item": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item from Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Item Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v1.ItemTemplateCreateItemRequest"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ }
+ }
+ }
+ },
+ "/v1/users/change-password": {
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "User"
+ ],
+ "summary": "Change Password",
+ "parameters": [
+ {
+ "description": "Password Payload",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v1.ChangePassword"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/users/login": {
+ "post": {
+ "consumes": [
+ "application/x-www-form-urlencoded",
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "User Login",
+ "parameters": [
+ {
+ "description": "Login Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v1.LoginForm"
+ }
+ },
+ {
+ "type": "string",
+ "description": "auth provider",
+ "name": "provider",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/v1.TokenResponse"
+ }
+ }
+ }
+ }
+ },
+ "/v1/users/login/oidc": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Login Initiation",
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
+ "/v1/users/login/oidc/callback": {
+ "get": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Callback Handler",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Authorization code",
+ "name": "code",
+ "in": "query",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "State parameter",
+ "name": "state",
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
+ "/v1/users/logout": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "User Logout",
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/users/refresh": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "description": "handleAuthRefresh returns a handler that will issue a new token from an existing token.\nThis does not validate that the user still exists within the database.",
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "User Token Refresh",
+ "responses": {
+ "200": {
+ "description": "OK"
+ }
+ }
+ }
+ },
+ "/v1/users/register": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "User"
+ ],
+ "summary": "Register New User",
+ "parameters": [
+ {
+ "description": "User Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/services.UserRegistration"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ },
+ "403": {
+ "description": "Local login is not enabled",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/v1/users/self": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "User"
+ ],
+ "summary": "Get User Self",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/v1.Wrapped"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "item": {
+ "$ref": "#/definitions/repo.UserOut"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "User"
+ ],
+ "summary": "Update Account",
+ "parameters": [
+ {
+ "description": "User Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.UserUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/v1.Wrapped"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "item": {
+ "$ref": "#/definitions/repo.UserUpdate"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "User"
+ ],
+ "summary": "Delete Account",
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ }
+ },
+ "definitions": {
+ "attachment.Type": {
+ "type": "string",
+ "enum": [
+ "attachment",
+ "photo",
+ "manual",
+ "warranty",
+ "attachment",
+ "receipt",
+ "thumbnail"
+ ],
+ "x-enum-varnames": [
+ "DefaultType",
+ "TypePhoto",
+ "TypeManual",
+ "TypeWarranty",
+ "TypeAttachment",
+ "TypeReceipt",
+ "TypeThumbnail"
+ ]
+ },
+ "authroles.Role": {
+ "type": "string",
+ "enum": [
+ "user",
+ "admin",
+ "user",
+ "attachments"
+ ],
+ "x-enum-varnames": [
+ "DefaultRole",
+ "RoleAdmin",
+ "RoleUser",
+ "RoleAttachments"
+ ]
+ },
+ "currencies.Currency": {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "string"
+ },
+ "decimals": {
+ "type": "integer"
+ },
+ "local": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "symbol": {
+ "type": "string"
+ }
+ }
+ },
+ "ent.Attachment": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AttachmentQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.AttachmentEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "mime_type": {
+ "description": "MimeType holds the value of the \"mime_type\" field.",
+ "type": "string"
+ },
+ "path": {
+ "description": "Path holds the value of the \"path\" field.",
+ "type": "string"
+ },
+ "primary": {
+ "description": "Primary holds the value of the \"primary\" field.",
+ "type": "boolean"
+ },
+ "title": {
+ "description": "Title holds the value of the \"title\" field.",
+ "type": "string"
+ },
+ "type": {
+ "description": "Type holds the value of the \"type\" field.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/attachment.Type"
+ }
+ ]
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.AttachmentEdges": {
+ "type": "object",
+ "properties": {
+ "item": {
+ "description": "Item holds the value of the item edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Item"
+ }
+ ]
+ },
+ "thumbnail": {
+ "description": "Thumbnail holds the value of the thumbnail edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Attachment"
+ }
+ ]
+ }
+ }
+ },
+ "ent.AuthRoles": {
+ "type": "object",
+ "properties": {
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthRolesQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.AuthRolesEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "integer"
+ },
+ "role": {
+ "description": "Role holds the value of the \"role\" field.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/authroles.Role"
+ }
+ ]
+ }
+ }
+ },
+ "ent.AuthRolesEdges": {
+ "type": "object",
+ "properties": {
+ "token": {
+ "description": "Token holds the value of the token edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.AuthTokens"
+ }
+ ]
+ }
+ }
+ },
+ "ent.AuthTokens": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthTokensQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.AuthTokensEdges"
+ }
+ ]
+ },
+ "expires_at": {
+ "description": "ExpiresAt holds the value of the \"expires_at\" field.",
+ "type": "string"
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "token": {
+ "description": "Token holds the value of the \"token\" field.",
+ "type": "array",
+ "items": {
+ "type": "integer"
+ }
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.AuthTokensEdges": {
+ "type": "object",
+ "properties": {
+ "roles": {
+ "description": "Roles holds the value of the roles edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.AuthRoles"
+ }
+ ]
+ },
+ "user": {
+ "description": "User holds the value of the user edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.User"
+ }
+ ]
+ }
+ }
+ },
+ "ent.Group": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "currency": {
+ "description": "Currency holds the value of the \"currency\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.GroupEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.GroupEdges": {
+ "type": "object",
+ "properties": {
+ "invitation_tokens": {
+ "description": "InvitationTokens holds the value of the invitation_tokens edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.GroupInvitationToken"
+ }
+ },
+ "item_templates": {
+ "description": "ItemTemplates holds the value of the item_templates edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.ItemTemplate"
+ }
+ },
+ "items": {
+ "description": "Items holds the value of the items edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Item"
+ }
+ },
+ "labels": {
+ "description": "Labels holds the value of the labels edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Label"
+ }
+ },
+ "locations": {
+ "description": "Locations holds the value of the locations edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Location"
+ }
+ },
+ "notifiers": {
+ "description": "Notifiers holds the value of the notifiers edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Notifier"
+ }
+ },
+ "users": {
+ "description": "Users holds the value of the users edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.User"
+ }
+ }
+ }
+ },
+ "ent.GroupInvitationToken": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupInvitationTokenQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.GroupInvitationTokenEdges"
+ }
+ ]
+ },
+ "expires_at": {
+ "description": "ExpiresAt holds the value of the \"expires_at\" field.",
+ "type": "string"
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "token": {
+ "description": "Token holds the value of the \"token\" field.",
+ "type": "array",
+ "items": {
+ "type": "integer"
+ }
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ },
+ "uses": {
+ "description": "Uses holds the value of the \"uses\" field.",
+ "type": "integer"
+ }
+ }
+ },
+ "ent.GroupInvitationTokenEdges": {
+ "type": "object",
+ "properties": {
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ }
+ }
+ },
+ "ent.Item": {
+ "type": "object",
+ "properties": {
+ "archived": {
+ "description": "Archived holds the value of the \"archived\" field.",
+ "type": "boolean"
+ },
+ "asset_id": {
+ "description": "AssetID holds the value of the \"asset_id\" field.",
+ "type": "integer"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.ItemEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "import_ref": {
+ "description": "ImportRef holds the value of the \"import_ref\" field.",
+ "type": "string"
+ },
+ "insured": {
+ "description": "Insured holds the value of the \"insured\" field.",
+ "type": "boolean"
+ },
+ "lifetime_warranty": {
+ "description": "LifetimeWarranty holds the value of the \"lifetime_warranty\" field.",
+ "type": "boolean"
+ },
+ "manufacturer": {
+ "description": "Manufacturer holds the value of the \"manufacturer\" field.",
+ "type": "string"
+ },
+ "model_number": {
+ "description": "ModelNumber holds the value of the \"model_number\" field.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "notes": {
+ "description": "Notes holds the value of the \"notes\" field.",
+ "type": "string"
+ },
+ "purchase_from": {
+ "description": "PurchaseFrom holds the value of the \"purchase_from\" field.",
+ "type": "string"
+ },
+ "purchase_price": {
+ "description": "PurchasePrice holds the value of the \"purchase_price\" field.",
+ "type": "number"
+ },
+ "purchase_time": {
+ "description": "PurchaseTime holds the value of the \"purchase_time\" field.",
+ "type": "string"
+ },
+ "quantity": {
+ "description": "Quantity holds the value of the \"quantity\" field.",
+ "type": "integer"
+ },
+ "serial_number": {
+ "description": "SerialNumber holds the value of the \"serial_number\" field.",
+ "type": "string"
+ },
+ "sold_notes": {
+ "description": "SoldNotes holds the value of the \"sold_notes\" field.",
+ "type": "string"
+ },
+ "sold_price": {
+ "description": "SoldPrice holds the value of the \"sold_price\" field.",
+ "type": "number"
+ },
+ "sold_time": {
+ "description": "SoldTime holds the value of the \"sold_time\" field.",
+ "type": "string"
+ },
+ "sold_to": {
+ "description": "SoldTo holds the value of the \"sold_to\" field.",
+ "type": "string"
+ },
+ "sync_child_items_locations": {
+ "description": "SyncChildItemsLocations holds the value of the \"sync_child_items_locations\" field.",
+ "type": "boolean"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ },
+ "warranty_details": {
+ "description": "WarrantyDetails holds the value of the \"warranty_details\" field.",
+ "type": "string"
+ },
+ "warranty_expires": {
+ "description": "WarrantyExpires holds the value of the \"warranty_expires\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.ItemEdges": {
+ "type": "object",
+ "properties": {
+ "attachments": {
+ "description": "Attachments holds the value of the attachments edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Attachment"
+ }
+ },
+ "children": {
+ "description": "Children holds the value of the children edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Item"
+ }
+ },
+ "fields": {
+ "description": "Fields holds the value of the fields edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.ItemField"
+ }
+ },
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ },
+ "label": {
+ "description": "Label holds the value of the label edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Label"
+ }
+ },
+ "location": {
+ "description": "Location holds the value of the location edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Location"
+ }
+ ]
+ },
+ "maintenance_entries": {
+ "description": "MaintenanceEntries holds the value of the maintenance_entries edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.MaintenanceEntry"
+ }
+ },
+ "parent": {
+ "description": "Parent holds the value of the parent edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Item"
+ }
+ ]
+ }
+ }
+ },
+ "ent.ItemField": {
+ "type": "object",
+ "properties": {
+ "boolean_value": {
+ "description": "BooleanValue holds the value of the \"boolean_value\" field.",
+ "type": "boolean"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemFieldQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.ItemFieldEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "number_value": {
+ "description": "NumberValue holds the value of the \"number_value\" field.",
+ "type": "integer"
+ },
+ "text_value": {
+ "description": "TextValue holds the value of the \"text_value\" field.",
+ "type": "string"
+ },
+ "time_value": {
+ "description": "TimeValue holds the value of the \"time_value\" field.",
+ "type": "string"
+ },
+ "type": {
+ "description": "Type holds the value of the \"type\" field.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/itemfield.Type"
+ }
+ ]
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.ItemFieldEdges": {
+ "type": "object",
+ "properties": {
+ "item": {
+ "description": "Item holds the value of the item edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Item"
+ }
+ ]
+ }
+ }
+ },
+ "ent.ItemTemplate": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "default_description": {
+ "description": "Default description for items created from this template",
+ "type": "string"
+ },
+ "default_insured": {
+ "description": "DefaultInsured holds the value of the \"default_insured\" field.",
+ "type": "boolean"
+ },
+ "default_label_ids": {
+ "description": "Default label IDs for items created from this template",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "default_lifetime_warranty": {
+ "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.",
+ "type": "boolean"
+ },
+ "default_manufacturer": {
+ "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.",
+ "type": "string"
+ },
+ "default_model_number": {
+ "description": "Default model number for items created from this template",
+ "type": "string"
+ },
+ "default_name": {
+ "description": "Default name template for items (can use placeholders)",
+ "type": "string"
+ },
+ "default_quantity": {
+ "description": "DefaultQuantity holds the value of the \"default_quantity\" field.",
+ "type": "integer"
+ },
+ "default_warranty_details": {
+ "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.ItemTemplateEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "include_purchase_fields": {
+ "description": "Whether to include purchase fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_sold_fields": {
+ "description": "Whether to include sold fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_warranty_fields": {
+ "description": "Whether to include warranty fields in items created from this template",
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "notes": {
+ "description": "Notes holds the value of the \"notes\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.ItemTemplateEdges": {
+ "type": "object",
+ "properties": {
+ "fields": {
+ "description": "Fields holds the value of the fields edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.TemplateField"
+ }
+ },
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ },
+ "location": {
+ "description": "Location holds the value of the location edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Location"
+ }
+ ]
+ }
+ }
+ },
+ "ent.Label": {
+ "type": "object",
+ "properties": {
+ "color": {
+ "description": "Color holds the value of the \"color\" field.",
+ "type": "string"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.LabelEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.LabelEdges": {
+ "type": "object",
+ "properties": {
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ },
+ "items": {
+ "description": "Items holds the value of the items edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Item"
+ }
+ }
+ }
+ },
+ "ent.Location": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LocationQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.LocationEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.LocationEdges": {
+ "type": "object",
+ "properties": {
+ "children": {
+ "description": "Children holds the value of the children edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Location"
+ }
+ },
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ },
+ "items": {
+ "description": "Items holds the value of the items edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Item"
+ }
+ },
+ "parent": {
+ "description": "Parent holds the value of the parent edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Location"
+ }
+ ]
+ }
+ }
+ },
+ "ent.MaintenanceEntry": {
+ "type": "object",
+ "properties": {
+ "cost": {
+ "description": "Cost holds the value of the \"cost\" field.",
+ "type": "number"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "date": {
+ "description": "Date holds the value of the \"date\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the MaintenanceEntryQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.MaintenanceEntryEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "item_id": {
+ "description": "ItemID holds the value of the \"item_id\" field.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "scheduled_date": {
+ "description": "ScheduledDate holds the value of the \"scheduled_date\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.MaintenanceEntryEdges": {
+ "type": "object",
+ "properties": {
+ "item": {
+ "description": "Item holds the value of the item edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Item"
+ }
+ ]
+ }
+ }
+ },
+ "ent.Notifier": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the NotifierQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.NotifierEdges"
+ }
+ ]
+ },
+ "group_id": {
+ "description": "GroupID holds the value of the \"group_id\" field.",
+ "type": "string"
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "is_active": {
+ "description": "IsActive holds the value of the \"is_active\" field.",
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ },
+ "user_id": {
+ "description": "UserID holds the value of the \"user_id\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.NotifierEdges": {
+ "type": "object",
+ "properties": {
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ },
+ "user": {
+ "description": "User holds the value of the user edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.User"
+ }
+ ]
+ }
+ }
+ },
+ "ent.TemplateField": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.TemplateFieldEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "text_value": {
+ "description": "TextValue holds the value of the \"text_value\" field.",
+ "type": "string"
+ },
+ "type": {
+ "description": "Type holds the value of the \"type\" field.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/templatefield.Type"
+ }
+ ]
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.TemplateFieldEdges": {
+ "type": "object",
+ "properties": {
+ "item_template": {
+ "description": "ItemTemplate holds the value of the item_template edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.ItemTemplate"
+ }
+ ]
+ }
+ }
+ },
+ "ent.User": {
+ "type": "object",
+ "properties": {
+ "activated_on": {
+ "description": "ActivatedOn holds the value of the \"activated_on\" field.",
+ "type": "string"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the UserQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.UserEdges"
+ }
+ ]
+ },
+ "email": {
+ "description": "Email holds the value of the \"email\" field.",
+ "type": "string"
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "is_superuser": {
+ "description": "IsSuperuser holds the value of the \"is_superuser\" field.",
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "oidc_issuer": {
+ "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.",
+ "type": "string"
+ },
+ "oidc_subject": {
+ "description": "OidcSubject holds the value of the \"oidc_subject\" field.",
+ "type": "string"
+ },
+ "role": {
+ "description": "Role holds the value of the \"role\" field.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/user.Role"
+ }
+ ]
+ },
+ "superuser": {
+ "description": "Superuser holds the value of the \"superuser\" field.",
+ "type": "boolean"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.UserEdges": {
+ "type": "object",
+ "properties": {
+ "auth_tokens": {
+ "description": "AuthTokens holds the value of the auth_tokens edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.AuthTokens"
+ }
+ },
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ },
+ "notifiers": {
+ "description": "Notifiers holds the value of the notifiers edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.Notifier"
+ }
+ }
+ }
+ },
+ "itemfield.Type": {
+ "type": "string",
+ "enum": [
+ "text",
+ "number",
+ "boolean",
+ "time"
+ ],
+ "x-enum-varnames": [
+ "TypeText",
+ "TypeNumber",
+ "TypeBoolean",
+ "TypeTime"
+ ]
+ },
+ "repo.BarcodeProduct": {
+ "type": "object",
+ "properties": {
+ "barcode": {
+ "type": "string"
+ },
+ "imageBase64": {
+ "type": "string"
+ },
+ "imageURL": {
+ "type": "string"
+ },
+ "item": {
+ "$ref": "#/definitions/repo.ItemCreate"
+ },
+ "manufacturer": {
+ "type": "string"
+ },
+ "modelNumber": {
+ "description": "Identifications",
+ "type": "string"
+ },
+ "notes": {
+ "description": "Extras",
+ "type": "string"
+ },
+ "search_engine_name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.DuplicateOptions": {
+ "type": "object",
+ "properties": {
+ "copyAttachments": {
+ "type": "boolean"
+ },
+ "copyCustomFields": {
+ "type": "boolean"
+ },
+ "copyMaintenance": {
+ "type": "boolean"
+ },
+ "copyPrefix": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.Group": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "currency": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.GroupStatistics": {
+ "type": "object",
+ "properties": {
+ "totalItemPrice": {
+ "type": "number"
+ },
+ "totalItems": {
+ "type": "integer"
+ },
+ "totalLabels": {
+ "type": "integer"
+ },
+ "totalLocations": {
+ "type": "integer"
+ },
+ "totalUsers": {
+ "type": "integer"
+ },
+ "totalWithWarranty": {
+ "type": "integer"
+ }
+ }
+ },
+ "repo.GroupUpdate": {
+ "type": "object",
+ "properties": {
+ "currency": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemAttachment": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "mimeType": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "primary": {
+ "type": "boolean"
+ },
+ "thumbnail": {
+ "$ref": "#/definitions/ent.Attachment"
+ },
+ "title": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemAttachmentUpdate": {
+ "type": "object",
+ "properties": {
+ "primary": {
+ "type": "boolean"
+ },
+ "title": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemCreate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "labelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "locationId": {
+ "description": "Edges",
+ "type": "string"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "parentId": {
+ "type": "string",
+ "x-nullable": true
+ },
+ "quantity": {
+ "type": "integer"
+ }
+ }
+ },
+ "repo.ItemField": {
+ "type": "object",
+ "properties": {
+ "booleanValue": {
+ "type": "boolean"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "numberValue": {
+ "type": "integer"
+ },
+ "textValue": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemOut": {
+ "type": "object",
+ "properties": {
+ "archived": {
+ "type": "boolean"
+ },
+ "assetId": {
+ "type": "string",
+ "example": "0"
+ },
+ "attachments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ItemAttachment"
+ }
+ },
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "fields": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ItemField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "imageId": {
+ "type": "string",
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "insured": {
+ "type": "boolean"
+ },
+ "labels": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.LabelSummary"
+ }
+ },
+ "lifetimeWarranty": {
+ "description": "Warranty",
+ "type": "boolean"
+ },
+ "location": {
+ "description": "Edges",
+ "allOf": [
+ {
+ "$ref": "#/definitions/repo.LocationSummary"
+ }
+ ],
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "manufacturer": {
+ "type": "string"
+ },
+ "modelNumber": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "notes": {
+ "description": "Extras",
+ "type": "string"
+ },
+ "parent": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/repo.ItemSummary"
+ }
+ ],
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "purchaseFrom": {
+ "type": "string"
+ },
+ "purchasePrice": {
+ "type": "number"
+ },
+ "purchaseTime": {
+ "description": "Purchase",
+ "type": "string"
+ },
+ "quantity": {
+ "type": "integer"
+ },
+ "serialNumber": {
+ "type": "string"
+ },
+ "soldNotes": {
+ "type": "string"
+ },
+ "soldPrice": {
+ "type": "number"
+ },
+ "soldTime": {
+ "description": "Sold",
+ "type": "string"
+ },
+ "soldTo": {
+ "type": "string"
+ },
+ "syncChildItemsLocations": {
+ "type": "boolean"
+ },
+ "thumbnailId": {
+ "type": "string",
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "updatedAt": {
+ "type": "string"
+ },
+ "warrantyDetails": {
+ "type": "string"
+ },
+ "warrantyExpires": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemPatch": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "labelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "locationId": {
+ "type": "string",
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "quantity": {
+ "type": "integer",
+ "x-nullable": true,
+ "x-omitempty": true
+ }
+ }
+ },
+ "repo.ItemPath": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "type": {
+ "$ref": "#/definitions/repo.ItemType"
+ }
+ }
+ },
+ "repo.ItemSummary": {
+ "type": "object",
+ "properties": {
+ "archived": {
+ "type": "boolean"
+ },
+ "assetId": {
+ "type": "string",
+ "example": "0"
+ },
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "imageId": {
+ "type": "string",
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "insured": {
+ "type": "boolean"
+ },
+ "labels": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.LabelSummary"
+ }
+ },
+ "location": {
+ "description": "Edges",
+ "allOf": [
+ {
+ "$ref": "#/definitions/repo.LocationSummary"
+ }
+ ],
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "name": {
+ "type": "string"
+ },
+ "purchasePrice": {
+ "type": "number"
+ },
+ "quantity": {
+ "type": "integer"
+ },
+ "soldTime": {
+ "description": "Sale details",
+ "type": "string"
+ },
+ "thumbnailId": {
+ "type": "string",
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateCreate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string"
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer"
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
+ "repo.ItemTemplateOut": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "defaultDescription": {
+ "type": "string"
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabels": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateLabelSummary"
+ }
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocation": {
+ "description": "Default location and labels",
+ "allOf": [
+ {
+ "$ref": "#/definitions/repo.TemplateLocationSummary"
+ }
+ ]
+ },
+ "defaultManufacturer": {
+ "type": "string"
+ },
+ "defaultModelNumber": {
+ "type": "string"
+ },
+ "defaultName": {
+ "type": "string"
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer"
+ },
+ "defaultWarrantyDetails": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "notes": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateSummary": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateUpdate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string"
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer"
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
+ "repo.ItemType": {
+ "type": "string",
+ "enum": [
+ "location",
+ "item"
+ ],
+ "x-enum-varnames": [
+ "ItemTypeLocation",
+ "ItemTypeItem"
+ ]
+ },
+ "repo.ItemUpdate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "archived": {
+ "type": "boolean"
+ },
+ "assetId": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ItemField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "insured": {
+ "type": "boolean"
+ },
+ "labelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "lifetimeWarranty": {
+ "description": "Warranty",
+ "type": "boolean"
+ },
+ "locationId": {
+ "description": "Edges",
+ "type": "string"
+ },
+ "manufacturer": {
+ "type": "string"
+ },
+ "modelNumber": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "description": "Extras",
+ "type": "string"
+ },
+ "parentId": {
+ "type": "string",
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "purchaseFrom": {
+ "type": "string",
+ "maxLength": 255
+ },
+ "purchasePrice": {
+ "type": "number",
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "purchaseTime": {
+ "description": "Purchase",
+ "type": "string"
+ },
+ "quantity": {
+ "type": "integer"
+ },
+ "serialNumber": {
+ "description": "Identifications",
+ "type": "string"
+ },
+ "soldNotes": {
+ "type": "string"
+ },
+ "soldPrice": {
+ "type": "number",
+ "x-nullable": true,
+ "x-omitempty": true
+ },
+ "soldTime": {
+ "description": "Sold",
+ "type": "string"
+ },
+ "soldTo": {
+ "type": "string",
+ "maxLength": 255
+ },
+ "syncChildItemsLocations": {
+ "type": "boolean"
+ },
+ "warrantyDetails": {
+ "type": "string"
+ },
+ "warrantyExpires": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.LabelCreate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "color": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ }
+ }
+ },
+ "repo.LabelOut": {
+ "type": "object",
+ "properties": {
+ "color": {
+ "type": "string"
+ },
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.LabelSummary": {
+ "type": "object",
+ "properties": {
+ "color": {
+ "type": "string"
+ },
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.LocationCreate": {
+ "type": "object",
+ "properties": {
+ "description": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "parentId": {
+ "type": "string",
+ "x-nullable": true
+ }
+ }
+ },
+ "repo.LocationOut": {
+ "type": "object",
+ "properties": {
+ "children": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.LocationSummary"
+ }
+ },
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "parent": {
+ "$ref": "#/definitions/repo.LocationSummary"
+ },
+ "totalPrice": {
+ "type": "number"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.LocationOutCount": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "itemCount": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.LocationSummary": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.LocationUpdate": {
+ "type": "object",
+ "properties": {
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "parentId": {
+ "type": "string",
+ "x-nullable": true
+ }
+ }
+ },
+ "repo.MaintenanceEntry": {
+ "type": "object",
+ "properties": {
+ "completedDate": {
+ "type": "string"
+ },
+ "cost": {
+ "type": "string",
+ "example": "0"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "scheduledDate": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.MaintenanceEntryCreate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "completedDate": {
+ "type": "string"
+ },
+ "cost": {
+ "type": "string",
+ "example": "0"
+ },
+ "description": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "scheduledDate": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.MaintenanceEntryUpdate": {
+ "type": "object",
+ "properties": {
+ "completedDate": {
+ "type": "string"
+ },
+ "cost": {
+ "type": "string",
+ "example": "0"
+ },
+ "description": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "scheduledDate": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.MaintenanceEntryWithDetails": {
+ "type": "object",
+ "properties": {
+ "completedDate": {
+ "type": "string"
+ },
+ "cost": {
+ "type": "string",
+ "example": "0"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "itemID": {
+ "type": "string"
+ },
+ "itemName": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "scheduledDate": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.MaintenanceFilterStatus": {
+ "type": "string",
+ "enum": [
+ "scheduled",
+ "completed",
+ "both"
+ ],
+ "x-enum-varnames": [
+ "MaintenanceFilterStatusScheduled",
+ "MaintenanceFilterStatusCompleted",
+ "MaintenanceFilterStatusBoth"
+ ]
+ },
+ "repo.NotifierCreate": {
+ "type": "object",
+ "required": [
+ "name",
+ "url"
+ ],
+ "properties": {
+ "isActive": {
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "url": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.NotifierOut": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "groupId": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "isActive": {
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string"
+ },
+ "userId": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.NotifierUpdate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "isActive": {
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "url": {
+ "type": "string",
+ "x-nullable": true
+ }
+ }
+ },
+ "repo.PaginationResult-repo_ItemSummary": {
+ "type": "object",
+ "properties": {
+ "items": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ItemSummary"
+ }
+ },
+ "page": {
+ "type": "integer"
+ },
+ "pageSize": {
+ "type": "integer"
+ },
+ "total": {
+ "type": "integer"
+ }
+ }
+ },
+ "repo.TemplateField": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "textValue": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLabelSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLocationSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TotalsByOrganizer": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "total": {
+ "type": "number"
+ }
+ }
+ },
+ "repo.TreeItem": {
+ "type": "object",
+ "properties": {
+ "children": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TreeItem"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.UserOut": {
+ "type": "object",
+ "properties": {
+ "email": {
+ "type": "string"
+ },
+ "groupId": {
+ "type": "string"
+ },
+ "groupName": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "isOwner": {
+ "type": "boolean"
+ },
+ "isSuperuser": {
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "oidcIssuer": {
+ "type": "string"
+ },
+ "oidcSubject": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.UserUpdate": {
+ "type": "object",
+ "properties": {
+ "email": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ValueOverTime": {
+ "type": "object",
+ "properties": {
+ "end": {
+ "type": "string"
+ },
+ "entries": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ValueOverTimeEntry"
+ }
+ },
+ "start": {
+ "type": "string"
+ },
+ "valueAtEnd": {
+ "type": "number"
+ },
+ "valueAtStart": {
+ "type": "number"
+ }
+ }
+ },
+ "repo.ValueOverTimeEntry": {
+ "type": "object",
+ "properties": {
+ "date": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "value": {
+ "type": "number"
+ }
+ }
+ },
+ "services.Latest": {
+ "type": "object",
+ "properties": {
+ "date": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ }
+ }
+ },
+ "services.UserRegistration": {
+ "type": "object",
+ "properties": {
+ "email": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ },
+ "token": {
+ "type": "string"
+ }
+ }
+ },
+ "templatefield.Type": {
+ "type": "string",
+ "enum": [
+ "text"
+ ],
+ "x-enum-varnames": [
+ "TypeText"
+ ]
+ },
+ "user.Role": {
+ "type": "string",
+ "enum": [
+ "user",
+ "user",
+ "owner"
+ ],
+ "x-enum-varnames": [
+ "DefaultRole",
+ "RoleUser",
+ "RoleOwner"
+ ]
+ },
+ "v1.APISummary": {
+ "type": "object",
+ "properties": {
+ "allowRegistration": {
+ "type": "boolean"
+ },
+ "build": {
+ "$ref": "#/definitions/v1.Build"
+ },
+ "demo": {
+ "type": "boolean"
+ },
+ "health": {
+ "type": "boolean"
+ },
+ "labelPrinting": {
+ "type": "boolean"
+ },
+ "latest": {
+ "$ref": "#/definitions/services.Latest"
+ },
+ "message": {
+ "type": "string"
+ },
+ "oidc": {
+ "$ref": "#/definitions/v1.OIDCStatus"
+ },
+ "title": {
+ "type": "string"
+ },
+ "versions": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "v1.ActionAmountResult": {
+ "type": "object",
+ "properties": {
+ "completed": {
+ "type": "integer"
+ }
+ }
+ },
+ "v1.Build": {
+ "type": "object",
+ "properties": {
+ "buildTime": {
+ "type": "string"
+ },
+ "commit": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ }
+ }
+ },
+ "v1.ChangePassword": {
+ "type": "object",
+ "properties": {
+ "current": {
+ "type": "string"
+ },
+ "new": {
+ "type": "string"
+ }
+ }
+ },
+ "v1.GroupInvitation": {
+ "type": "object",
+ "properties": {
+ "expiresAt": {
+ "type": "string"
+ },
+ "token": {
+ "type": "string"
+ },
+ "uses": {
+ "type": "integer"
+ }
+ }
+ },
+ "v1.GroupInvitationCreate": {
+ "type": "object",
+ "required": [
+ "uses"
+ ],
+ "properties": {
+ "expiresAt": {
+ "type": "string"
+ },
+ "uses": {
+ "type": "integer",
+ "maximum": 100,
+ "minimum": 1
+ }
+ }
+ },
+ "v1.ItemAttachmentToken": {
+ "type": "object",
+ "properties": {
+ "token": {
+ "type": "string"
+ }
+ }
+ },
+ "v1.ItemTemplateCreateItemRequest": {
+ "type": "object",
+ "required": [
+ "locationId",
+ "name"
+ ],
+ "properties": {
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "labelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "locationId": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "quantity": {
+ "type": "integer"
+ }
+ }
+ },
+ "v1.LoginForm": {
+ "type": "object",
+ "properties": {
+ "password": {
+ "type": "string",
+ "example": "admin"
+ },
+ "stayLoggedIn": {
+ "type": "boolean"
+ },
+ "username": {
+ "type": "string",
+ "example": "[email protected]"
+ }
+ }
+ },
+ "v1.OIDCStatus": {
+ "type": "object",
+ "properties": {
+ "allowLocal": {
+ "type": "boolean"
+ },
+ "autoRedirect": {
+ "type": "boolean"
+ },
+ "buttonText": {
+ "type": "string"
+ },
+ "enabled": {
+ "type": "boolean"
+ }
+ }
+ },
+ "v1.TokenResponse": {
+ "type": "object",
+ "properties": {
+ "attachmentToken": {
+ "type": "string"
+ },
+ "expiresAt": {
+ "type": "string"
+ },
+ "token": {
+ "type": "string"
+ }
+ }
+ },
+ "v1.Wrapped": {
+ "type": "object",
+ "properties": {
+ "item": {}
+ }
+ },
+ "validate.ErrorResponse": {
+ "type": "object",
+ "properties": {
+ "error": {
+ "type": "string"
+ },
+ "fields": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "securityDefinitions": {
+ "Bearer": {
+ "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"",
+ "type": "apiKey",
+ "name": "Authorization",
+ "in": "header"
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/en/api/openapi-2.0.yaml b/docs/en/api/openapi-2.0.yaml
new file mode 100644
index 00000000..8926c617
--- /dev/null
+++ b/docs/en/api/openapi-2.0.yaml
@@ -0,0 +1,3369 @@
+basePath: /api
+definitions:
+ attachment.Type:
+ enum:
+ - attachment
+ - photo
+ - manual
+ - warranty
+ - attachment
+ - receipt
+ - thumbnail
+ type: string
+ x-enum-varnames:
+ - DefaultType
+ - TypePhoto
+ - TypeManual
+ - TypeWarranty
+ - TypeAttachment
+ - TypeReceipt
+ - TypeThumbnail
+ authroles.Role:
+ enum:
+ - user
+ - admin
+ - user
+ - attachments
+ type: string
+ x-enum-varnames:
+ - DefaultRole
+ - RoleAdmin
+ - RoleUser
+ - RoleAttachments
+ currencies.Currency:
+ properties:
+ code:
+ type: string
+ decimals:
+ type: integer
+ local:
+ type: string
+ name:
+ type: string
+ symbol:
+ type: string
+ type: object
+ ent.Attachment:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.AttachmentEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the AttachmentQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ mime_type:
+ description: MimeType holds the value of the "mime_type" field.
+ type: string
+ path:
+ description: Path holds the value of the "path" field.
+ type: string
+ primary:
+ description: Primary holds the value of the "primary" field.
+ type: boolean
+ title:
+ description: Title holds the value of the "title" field.
+ type: string
+ type:
+ allOf:
+ - $ref: '#/definitions/attachment.Type'
+ description: Type holds the value of the "type" field.
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.AttachmentEdges:
+ properties:
+ item:
+ allOf:
+ - $ref: '#/definitions/ent.Item'
+ description: Item holds the value of the item edge.
+ thumbnail:
+ allOf:
+ - $ref: '#/definitions/ent.Attachment'
+ description: Thumbnail holds the value of the thumbnail edge.
+ type: object
+ ent.AuthRoles:
+ properties:
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.AuthRolesEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the AuthRolesQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: integer
+ role:
+ allOf:
+ - $ref: '#/definitions/authroles.Role'
+ description: Role holds the value of the "role" field.
+ type: object
+ ent.AuthRolesEdges:
+ properties:
+ token:
+ allOf:
+ - $ref: '#/definitions/ent.AuthTokens'
+ description: Token holds the value of the token edge.
+ type: object
+ ent.AuthTokens:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.AuthTokensEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the AuthTokensQuery when eager-loading is set.
+ expires_at:
+ description: ExpiresAt holds the value of the "expires_at" field.
+ type: string
+ id:
+ description: ID of the ent.
+ type: string
+ token:
+ description: Token holds the value of the "token" field.
+ items:
+ type: integer
+ type: array
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.AuthTokensEdges:
+ properties:
+ roles:
+ allOf:
+ - $ref: '#/definitions/ent.AuthRoles'
+ description: Roles holds the value of the roles edge.
+ user:
+ allOf:
+ - $ref: '#/definitions/ent.User'
+ description: User holds the value of the user edge.
+ type: object
+ ent.Group:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ currency:
+ description: Currency holds the value of the "currency" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.GroupEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the GroupQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.GroupEdges:
+ properties:
+ invitation_tokens:
+ description: InvitationTokens holds the value of the invitation_tokens edge.
+ items:
+ $ref: '#/definitions/ent.GroupInvitationToken'
+ type: array
+ item_templates:
+ description: ItemTemplates holds the value of the item_templates edge.
+ items:
+ $ref: '#/definitions/ent.ItemTemplate'
+ type: array
+ items:
+ description: Items holds the value of the items edge.
+ items:
+ $ref: '#/definitions/ent.Item'
+ type: array
+ labels:
+ description: Labels holds the value of the labels edge.
+ items:
+ $ref: '#/definitions/ent.Label'
+ type: array
+ locations:
+ description: Locations holds the value of the locations edge.
+ items:
+ $ref: '#/definitions/ent.Location'
+ type: array
+ notifiers:
+ description: Notifiers holds the value of the notifiers edge.
+ items:
+ $ref: '#/definitions/ent.Notifier'
+ type: array
+ users:
+ description: Users holds the value of the users edge.
+ items:
+ $ref: '#/definitions/ent.User'
+ type: array
+ type: object
+ ent.GroupInvitationToken:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.GroupInvitationTokenEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the GroupInvitationTokenQuery when eager-loading is set.
+ expires_at:
+ description: ExpiresAt holds the value of the "expires_at" field.
+ type: string
+ id:
+ description: ID of the ent.
+ type: string
+ token:
+ description: Token holds the value of the "token" field.
+ items:
+ type: integer
+ type: array
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ uses:
+ description: Uses holds the value of the "uses" field.
+ type: integer
+ type: object
+ ent.GroupInvitationTokenEdges:
+ properties:
+ group:
+ allOf:
+ - $ref: '#/definitions/ent.Group'
+ description: Group holds the value of the group edge.
+ type: object
+ ent.Item:
+ properties:
+ archived:
+ description: Archived holds the value of the "archived" field.
+ type: boolean
+ asset_id:
+ description: AssetID holds the value of the "asset_id" field.
+ type: integer
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.ItemEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the ItemQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ import_ref:
+ description: ImportRef holds the value of the "import_ref" field.
+ type: string
+ insured:
+ description: Insured holds the value of the "insured" field.
+ type: boolean
+ lifetime_warranty:
+ description: LifetimeWarranty holds the value of the "lifetime_warranty" field.
+ type: boolean
+ manufacturer:
+ description: Manufacturer holds the value of the "manufacturer" field.
+ type: string
+ model_number:
+ description: ModelNumber holds the value of the "model_number" field.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ notes:
+ description: Notes holds the value of the "notes" field.
+ type: string
+ purchase_from:
+ description: PurchaseFrom holds the value of the "purchase_from" field.
+ type: string
+ purchase_price:
+ description: PurchasePrice holds the value of the "purchase_price" field.
+ type: number
+ purchase_time:
+ description: PurchaseTime holds the value of the "purchase_time" field.
+ type: string
+ quantity:
+ description: Quantity holds the value of the "quantity" field.
+ type: integer
+ serial_number:
+ description: SerialNumber holds the value of the "serial_number" field.
+ type: string
+ sold_notes:
+ description: SoldNotes holds the value of the "sold_notes" field.
+ type: string
+ sold_price:
+ description: SoldPrice holds the value of the "sold_price" field.
+ type: number
+ sold_time:
+ description: SoldTime holds the value of the "sold_time" field.
+ type: string
+ sold_to:
+ description: SoldTo holds the value of the "sold_to" field.
+ type: string
+ sync_child_items_locations:
+ description: SyncChildItemsLocations holds the value of the "sync_child_items_locations"
+ field.
+ type: boolean
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ warranty_details:
+ description: WarrantyDetails holds the value of the "warranty_details" field.
+ type: string
+ warranty_expires:
+ description: WarrantyExpires holds the value of the "warranty_expires" field.
+ type: string
+ type: object
+ ent.ItemEdges:
+ properties:
+ attachments:
+ description: Attachments holds the value of the attachments edge.
+ items:
+ $ref: '#/definitions/ent.Attachment'
+ type: array
+ children:
+ description: Children holds the value of the children edge.
+ items:
+ $ref: '#/definitions/ent.Item'
+ type: array
+ fields:
+ description: Fields holds the value of the fields edge.
+ items:
+ $ref: '#/definitions/ent.ItemField'
+ type: array
+ group:
+ allOf:
+ - $ref: '#/definitions/ent.Group'
+ description: Group holds the value of the group edge.
+ label:
+ description: Label holds the value of the label edge.
+ items:
+ $ref: '#/definitions/ent.Label'
+ type: array
+ location:
+ allOf:
+ - $ref: '#/definitions/ent.Location'
+ description: Location holds the value of the location edge.
+ maintenance_entries:
+ description: MaintenanceEntries holds the value of the maintenance_entries
+ edge.
+ items:
+ $ref: '#/definitions/ent.MaintenanceEntry'
+ type: array
+ parent:
+ allOf:
+ - $ref: '#/definitions/ent.Item'
+ description: Parent holds the value of the parent edge.
+ type: object
+ ent.ItemField:
+ properties:
+ boolean_value:
+ description: BooleanValue holds the value of the "boolean_value" field.
+ type: boolean
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.ItemFieldEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the ItemFieldQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ number_value:
+ description: NumberValue holds the value of the "number_value" field.
+ type: integer
+ text_value:
+ description: TextValue holds the value of the "text_value" field.
+ type: string
+ time_value:
+ description: TimeValue holds the value of the "time_value" field.
+ type: string
+ type:
+ allOf:
+ - $ref: '#/definitions/itemfield.Type'
+ description: Type holds the value of the "type" field.
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.ItemFieldEdges:
+ properties:
+ item:
+ allOf:
+ - $ref: '#/definitions/ent.Item'
+ description: Item holds the value of the item edge.
+ type: object
+ ent.ItemTemplate:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ default_description:
+ description: Default description for items created from this template
+ type: string
+ default_insured:
+ description: DefaultInsured holds the value of the "default_insured" field.
+ type: boolean
+ default_label_ids:
+ description: Default label IDs for items created from this template
+ items:
+ type: string
+ type: array
+ default_lifetime_warranty:
+ description: DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty"
+ field.
+ type: boolean
+ default_manufacturer:
+ description: DefaultManufacturer holds the value of the "default_manufacturer"
+ field.
+ type: string
+ default_model_number:
+ description: Default model number for items created from this template
+ type: string
+ default_name:
+ description: Default name template for items (can use placeholders)
+ type: string
+ default_quantity:
+ description: DefaultQuantity holds the value of the "default_quantity" field.
+ type: integer
+ default_warranty_details:
+ description: DefaultWarrantyDetails holds the value of the "default_warranty_details"
+ field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.ItemTemplateEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the ItemTemplateQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ include_purchase_fields:
+ description: Whether to include purchase fields in items created from this
+ template
+ type: boolean
+ include_sold_fields:
+ description: Whether to include sold fields in items created from this template
+ type: boolean
+ include_warranty_fields:
+ description: Whether to include warranty fields in items created from this
+ template
+ type: boolean
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ notes:
+ description: Notes holds the value of the "notes" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.ItemTemplateEdges:
+ properties:
+ fields:
+ description: Fields holds the value of the fields edge.
+ items:
+ $ref: '#/definitions/ent.TemplateField'
+ type: array
+ group:
+ allOf:
+ - $ref: '#/definitions/ent.Group'
+ description: Group holds the value of the group edge.
+ location:
+ allOf:
+ - $ref: '#/definitions/ent.Location'
+ description: Location holds the value of the location edge.
+ type: object
+ ent.Label:
+ properties:
+ color:
+ description: Color holds the value of the "color" field.
+ type: string
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.LabelEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the LabelQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.LabelEdges:
+ properties:
+ group:
+ allOf:
+ - $ref: '#/definitions/ent.Group'
+ description: Group holds the value of the group edge.
+ items:
+ description: Items holds the value of the items edge.
+ items:
+ $ref: '#/definitions/ent.Item'
+ type: array
+ type: object
+ ent.Location:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.LocationEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the LocationQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.LocationEdges:
+ properties:
+ children:
+ description: Children holds the value of the children edge.
+ items:
+ $ref: '#/definitions/ent.Location'
+ type: array
+ group:
+ allOf:
+ - $ref: '#/definitions/ent.Group'
+ description: Group holds the value of the group edge.
+ items:
+ description: Items holds the value of the items edge.
+ items:
+ $ref: '#/definitions/ent.Item'
+ type: array
+ parent:
+ allOf:
+ - $ref: '#/definitions/ent.Location'
+ description: Parent holds the value of the parent edge.
+ type: object
+ ent.MaintenanceEntry:
+ properties:
+ cost:
+ description: Cost holds the value of the "cost" field.
+ type: number
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ date:
+ description: Date holds the value of the "date" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.MaintenanceEntryEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the MaintenanceEntryQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ item_id:
+ description: ItemID holds the value of the "item_id" field.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ scheduled_date:
+ description: ScheduledDate holds the value of the "scheduled_date" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.MaintenanceEntryEdges:
+ properties:
+ item:
+ allOf:
+ - $ref: '#/definitions/ent.Item'
+ description: Item holds the value of the item edge.
+ type: object
+ ent.Notifier:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.NotifierEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the NotifierQuery when eager-loading is set.
+ group_id:
+ description: GroupID holds the value of the "group_id" field.
+ type: string
+ id:
+ description: ID of the ent.
+ type: string
+ is_active:
+ description: IsActive holds the value of the "is_active" field.
+ type: boolean
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ user_id:
+ description: UserID holds the value of the "user_id" field.
+ type: string
+ type: object
+ ent.NotifierEdges:
+ properties:
+ group:
+ allOf:
+ - $ref: '#/definitions/ent.Group'
+ description: Group holds the value of the group edge.
+ user:
+ allOf:
+ - $ref: '#/definitions/ent.User'
+ description: User holds the value of the user edge.
+ type: object
+ ent.TemplateField:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.TemplateFieldEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the TemplateFieldQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ text_value:
+ description: TextValue holds the value of the "text_value" field.
+ type: string
+ type:
+ allOf:
+ - $ref: '#/definitions/templatefield.Type'
+ description: Type holds the value of the "type" field.
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.TemplateFieldEdges:
+ properties:
+ item_template:
+ allOf:
+ - $ref: '#/definitions/ent.ItemTemplate'
+ description: ItemTemplate holds the value of the item_template edge.
+ type: object
+ ent.User:
+ properties:
+ activated_on:
+ description: ActivatedOn holds the value of the "activated_on" field.
+ type: string
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.UserEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the UserQuery when eager-loading is set.
+ email:
+ description: Email holds the value of the "email" field.
+ type: string
+ id:
+ description: ID of the ent.
+ type: string
+ is_superuser:
+ description: IsSuperuser holds the value of the "is_superuser" field.
+ type: boolean
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ oidc_issuer:
+ description: OidcIssuer holds the value of the "oidc_issuer" field.
+ type: string
+ oidc_subject:
+ description: OidcSubject holds the value of the "oidc_subject" field.
+ type: string
+ role:
+ allOf:
+ - $ref: '#/definitions/user.Role'
+ description: Role holds the value of the "role" field.
+ superuser:
+ description: Superuser holds the value of the "superuser" field.
+ type: boolean
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.UserEdges:
+ properties:
+ auth_tokens:
+ description: AuthTokens holds the value of the auth_tokens edge.
+ items:
+ $ref: '#/definitions/ent.AuthTokens'
+ type: array
+ group:
+ allOf:
+ - $ref: '#/definitions/ent.Group'
+ description: Group holds the value of the group edge.
+ notifiers:
+ description: Notifiers holds the value of the notifiers edge.
+ items:
+ $ref: '#/definitions/ent.Notifier'
+ type: array
+ type: object
+ itemfield.Type:
+ enum:
+ - text
+ - number
+ - boolean
+ - time
+ type: string
+ x-enum-varnames:
+ - TypeText
+ - TypeNumber
+ - TypeBoolean
+ - TypeTime
+ repo.BarcodeProduct:
+ properties:
+ barcode:
+ type: string
+ imageBase64:
+ type: string
+ imageURL:
+ type: string
+ item:
+ $ref: '#/definitions/repo.ItemCreate'
+ manufacturer:
+ type: string
+ modelNumber:
+ description: Identifications
+ type: string
+ notes:
+ description: Extras
+ type: string
+ search_engine_name:
+ type: string
+ type: object
+ repo.DuplicateOptions:
+ properties:
+ copyAttachments:
+ type: boolean
+ copyCustomFields:
+ type: boolean
+ copyMaintenance:
+ type: boolean
+ copyPrefix:
+ type: string
+ type: object
+ repo.Group:
+ properties:
+ createdAt:
+ type: string
+ currency:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.GroupStatistics:
+ properties:
+ totalItemPrice:
+ type: number
+ totalItems:
+ type: integer
+ totalLabels:
+ type: integer
+ totalLocations:
+ type: integer
+ totalUsers:
+ type: integer
+ totalWithWarranty:
+ type: integer
+ type: object
+ repo.GroupUpdate:
+ properties:
+ currency:
+ type: string
+ name:
+ type: string
+ type: object
+ repo.ItemAttachment:
+ properties:
+ createdAt:
+ type: string
+ id:
+ type: string
+ mimeType:
+ type: string
+ path:
+ type: string
+ primary:
+ type: boolean
+ thumbnail:
+ $ref: '#/definitions/ent.Attachment'
+ title:
+ type: string
+ type:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.ItemAttachmentUpdate:
+ properties:
+ primary:
+ type: boolean
+ title:
+ type: string
+ type:
+ type: string
+ type: object
+ repo.ItemCreate:
+ properties:
+ description:
+ maxLength: 1000
+ type: string
+ labelIds:
+ items:
+ type: string
+ type: array
+ locationId:
+ description: Edges
+ type: string
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ parentId:
+ type: string
+ x-nullable: true
+ quantity:
+ type: integer
+ required:
+ - name
+ type: object
+ repo.ItemField:
+ properties:
+ booleanValue:
+ type: boolean
+ id:
+ type: string
+ name:
+ type: string
+ numberValue:
+ type: integer
+ textValue:
+ type: string
+ type:
+ type: string
+ type: object
+ repo.ItemOut:
+ properties:
+ archived:
+ type: boolean
+ assetId:
+ example: "0"
+ type: string
+ attachments:
+ items:
+ $ref: '#/definitions/repo.ItemAttachment'
+ type: array
+ createdAt:
+ type: string
+ description:
+ type: string
+ fields:
+ items:
+ $ref: '#/definitions/repo.ItemField'
+ type: array
+ id:
+ type: string
+ imageId:
+ type: string
+ x-nullable: true
+ x-omitempty: true
+ insured:
+ type: boolean
+ labels:
+ items:
+ $ref: '#/definitions/repo.LabelSummary'
+ type: array
+ lifetimeWarranty:
+ description: Warranty
+ type: boolean
+ location:
+ allOf:
+ - $ref: '#/definitions/repo.LocationSummary'
+ description: Edges
+ x-nullable: true
+ x-omitempty: true
+ manufacturer:
+ type: string
+ modelNumber:
+ type: string
+ name:
+ type: string
+ notes:
+ description: Extras
+ type: string
+ parent:
+ allOf:
+ - $ref: '#/definitions/repo.ItemSummary'
+ x-nullable: true
+ x-omitempty: true
+ purchaseFrom:
+ type: string
+ purchasePrice:
+ type: number
+ purchaseTime:
+ description: Purchase
+ type: string
+ quantity:
+ type: integer
+ serialNumber:
+ type: string
+ soldNotes:
+ type: string
+ soldPrice:
+ type: number
+ soldTime:
+ description: Sold
+ type: string
+ soldTo:
+ type: string
+ syncChildItemsLocations:
+ type: boolean
+ thumbnailId:
+ type: string
+ x-nullable: true
+ x-omitempty: true
+ updatedAt:
+ type: string
+ warrantyDetails:
+ type: string
+ warrantyExpires:
+ type: string
+ type: object
+ repo.ItemPatch:
+ properties:
+ id:
+ type: string
+ labelIds:
+ items:
+ type: string
+ type: array
+ x-nullable: true
+ x-omitempty: true
+ locationId:
+ type: string
+ x-nullable: true
+ x-omitempty: true
+ quantity:
+ type: integer
+ x-nullable: true
+ x-omitempty: true
+ type: object
+ repo.ItemPath:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ type:
+ $ref: '#/definitions/repo.ItemType'
+ type: object
+ repo.ItemSummary:
+ properties:
+ archived:
+ type: boolean
+ assetId:
+ example: "0"
+ type: string
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ imageId:
+ type: string
+ x-nullable: true
+ x-omitempty: true
+ insured:
+ type: boolean
+ labels:
+ items:
+ $ref: '#/definitions/repo.LabelSummary'
+ type: array
+ location:
+ allOf:
+ - $ref: '#/definitions/repo.LocationSummary'
+ description: Edges
+ x-nullable: true
+ x-omitempty: true
+ name:
+ type: string
+ purchasePrice:
+ type: number
+ quantity:
+ type: integer
+ soldTime:
+ description: Sale details
+ type: string
+ thumbnailId:
+ type: string
+ x-nullable: true
+ x-omitempty: true
+ updatedAt:
+ type: string
+ type: object
+ repo.ItemTemplateCreate:
+ properties:
+ defaultDescription:
+ maxLength: 1000
+ type: string
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ items:
+ type: string
+ type: array
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ defaultManufacturer:
+ maxLength: 255
+ type: string
+ defaultModelNumber:
+ maxLength: 255
+ type: string
+ defaultName:
+ maxLength: 255
+ type: string
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ defaultWarrantyDetails:
+ maxLength: 1000
+ type: string
+ description:
+ maxLength: 1000
+ type: string
+ fields:
+ description: Custom fields
+ items:
+ $ref: '#/definitions/repo.TemplateField'
+ type: array
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ notes:
+ maxLength: 1000
+ type: string
+ required:
+ - name
+ type: object
+ repo.ItemTemplateOut:
+ properties:
+ createdAt:
+ type: string
+ defaultDescription:
+ type: string
+ defaultInsured:
+ type: boolean
+ defaultLabels:
+ items:
+ $ref: '#/definitions/repo.TemplateLabelSummary'
+ type: array
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocation:
+ allOf:
+ - $ref: '#/definitions/repo.TemplateLocationSummary'
+ description: Default location and labels
+ defaultManufacturer:
+ type: string
+ defaultModelNumber:
+ type: string
+ defaultName:
+ type: string
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ defaultWarrantyDetails:
+ type: string
+ description:
+ type: string
+ fields:
+ description: Custom fields
+ items:
+ $ref: '#/definitions/repo.TemplateField'
+ type: array
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ type: string
+ notes:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.ItemTemplateSummary:
+ properties:
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.ItemTemplateUpdate:
+ properties:
+ defaultDescription:
+ maxLength: 1000
+ type: string
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ items:
+ type: string
+ type: array
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ defaultManufacturer:
+ maxLength: 255
+ type: string
+ defaultModelNumber:
+ maxLength: 255
+ type: string
+ defaultName:
+ maxLength: 255
+ type: string
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ defaultWarrantyDetails:
+ maxLength: 1000
+ type: string
+ description:
+ maxLength: 1000
+ type: string
+ fields:
+ description: Custom fields
+ items:
+ $ref: '#/definitions/repo.TemplateField'
+ type: array
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ notes:
+ maxLength: 1000
+ type: string
+ required:
+ - name
+ type: object
+ repo.ItemType:
+ enum:
+ - location
+ - item
+ type: string
+ x-enum-varnames:
+ - ItemTypeLocation
+ - ItemTypeItem
+ repo.ItemUpdate:
+ properties:
+ archived:
+ type: boolean
+ assetId:
+ type: string
+ description:
+ maxLength: 1000
+ type: string
+ fields:
+ items:
+ $ref: '#/definitions/repo.ItemField'
+ type: array
+ id:
+ type: string
+ insured:
+ type: boolean
+ labelIds:
+ items:
+ type: string
+ type: array
+ lifetimeWarranty:
+ description: Warranty
+ type: boolean
+ locationId:
+ description: Edges
+ type: string
+ manufacturer:
+ type: string
+ modelNumber:
+ type: string
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ notes:
+ description: Extras
+ type: string
+ parentId:
+ type: string
+ x-nullable: true
+ x-omitempty: true
+ purchaseFrom:
+ maxLength: 255
+ type: string
+ purchasePrice:
+ type: number
+ x-nullable: true
+ x-omitempty: true
+ purchaseTime:
+ description: Purchase
+ type: string
+ quantity:
+ type: integer
+ serialNumber:
+ description: Identifications
+ type: string
+ soldNotes:
+ type: string
+ soldPrice:
+ type: number
+ x-nullable: true
+ x-omitempty: true
+ soldTime:
+ description: Sold
+ type: string
+ soldTo:
+ maxLength: 255
+ type: string
+ syncChildItemsLocations:
+ type: boolean
+ warrantyDetails:
+ type: string
+ warrantyExpires:
+ type: string
+ required:
+ - name
+ type: object
+ repo.LabelCreate:
+ properties:
+ color:
+ type: string
+ description:
+ maxLength: 1000
+ type: string
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ required:
+ - name
+ type: object
+ repo.LabelOut:
+ properties:
+ color:
+ type: string
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.LabelSummary:
+ properties:
+ color:
+ type: string
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.LocationCreate:
+ properties:
+ description:
+ type: string
+ name:
+ type: string
+ parentId:
+ type: string
+ x-nullable: true
+ type: object
+ repo.LocationOut:
+ properties:
+ children:
+ items:
+ $ref: '#/definitions/repo.LocationSummary'
+ type: array
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ parent:
+ $ref: '#/definitions/repo.LocationSummary'
+ totalPrice:
+ type: number
+ updatedAt:
+ type: string
+ type: object
+ repo.LocationOutCount:
+ properties:
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ itemCount:
+ type: integer
+ name:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.LocationSummary:
+ properties:
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.LocationUpdate:
+ properties:
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ parentId:
+ type: string
+ x-nullable: true
+ type: object
+ repo.MaintenanceEntry:
+ properties:
+ completedDate:
+ type: string
+ cost:
+ example: "0"
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ scheduledDate:
+ type: string
+ type: object
+ repo.MaintenanceEntryCreate:
+ properties:
+ completedDate:
+ type: string
+ cost:
+ example: "0"
+ type: string
+ description:
+ type: string
+ name:
+ type: string
+ scheduledDate:
+ type: string
+ required:
+ - name
+ type: object
+ repo.MaintenanceEntryUpdate:
+ properties:
+ completedDate:
+ type: string
+ cost:
+ example: "0"
+ type: string
+ description:
+ type: string
+ name:
+ type: string
+ scheduledDate:
+ type: string
+ type: object
+ repo.MaintenanceEntryWithDetails:
+ properties:
+ completedDate:
+ type: string
+ cost:
+ example: "0"
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ itemID:
+ type: string
+ itemName:
+ type: string
+ name:
+ type: string
+ scheduledDate:
+ type: string
+ type: object
+ repo.MaintenanceFilterStatus:
+ enum:
+ - scheduled
+ - completed
+ - both
+ type: string
+ x-enum-varnames:
+ - MaintenanceFilterStatusScheduled
+ - MaintenanceFilterStatusCompleted
+ - MaintenanceFilterStatusBoth
+ repo.NotifierCreate:
+ properties:
+ isActive:
+ type: boolean
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ url:
+ type: string
+ required:
+ - name
+ - url
+ type: object
+ repo.NotifierOut:
+ properties:
+ createdAt:
+ type: string
+ groupId:
+ type: string
+ id:
+ type: string
+ isActive:
+ type: boolean
+ name:
+ type: string
+ updatedAt:
+ type: string
+ url:
+ type: string
+ userId:
+ type: string
+ type: object
+ repo.NotifierUpdate:
+ properties:
+ isActive:
+ type: boolean
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ url:
+ type: string
+ x-nullable: true
+ required:
+ - name
+ type: object
+ repo.PaginationResult-repo_ItemSummary:
+ properties:
+ items:
+ items:
+ $ref: '#/definitions/repo.ItemSummary'
+ type: array
+ page:
+ type: integer
+ pageSize:
+ type: integer
+ total:
+ type: integer
+ type: object
+ repo.TemplateField:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ textValue:
+ type: string
+ type:
+ type: string
+ type: object
+ repo.TemplateLabelSummary:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ type: object
+ repo.TemplateLocationSummary:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ type: object
+ repo.TotalsByOrganizer:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ total:
+ type: number
+ type: object
+ repo.TreeItem:
+ properties:
+ children:
+ items:
+ $ref: '#/definitions/repo.TreeItem'
+ type: array
+ id:
+ type: string
+ name:
+ type: string
+ type:
+ type: string
+ type: object
+ repo.UserOut:
+ properties:
+ email:
+ type: string
+ groupId:
+ type: string
+ groupName:
+ type: string
+ id:
+ type: string
+ isOwner:
+ type: boolean
+ isSuperuser:
+ type: boolean
+ name:
+ type: string
+ oidcIssuer:
+ type: string
+ oidcSubject:
+ type: string
+ type: object
+ repo.UserUpdate:
+ properties:
+ email:
+ type: string
+ name:
+ type: string
+ type: object
+ repo.ValueOverTime:
+ properties:
+ end:
+ type: string
+ entries:
+ items:
+ $ref: '#/definitions/repo.ValueOverTimeEntry'
+ type: array
+ start:
+ type: string
+ valueAtEnd:
+ type: number
+ valueAtStart:
+ type: number
+ type: object
+ repo.ValueOverTimeEntry:
+ properties:
+ date:
+ type: string
+ name:
+ type: string
+ value:
+ type: number
+ type: object
+ services.Latest:
+ properties:
+ date:
+ type: string
+ version:
+ type: string
+ type: object
+ services.UserRegistration:
+ properties:
+ email:
+ type: string
+ name:
+ type: string
+ password:
+ type: string
+ token:
+ type: string
+ type: object
+ templatefield.Type:
+ enum:
+ - text
+ type: string
+ x-enum-varnames:
+ - TypeText
+ user.Role:
+ enum:
+ - user
+ - user
+ - owner
+ type: string
+ x-enum-varnames:
+ - DefaultRole
+ - RoleUser
+ - RoleOwner
+ v1.APISummary:
+ properties:
+ allowRegistration:
+ type: boolean
+ build:
+ $ref: '#/definitions/v1.Build'
+ demo:
+ type: boolean
+ health:
+ type: boolean
+ labelPrinting:
+ type: boolean
+ latest:
+ $ref: '#/definitions/services.Latest'
+ message:
+ type: string
+ oidc:
+ $ref: '#/definitions/v1.OIDCStatus'
+ title:
+ type: string
+ versions:
+ items:
+ type: string
+ type: array
+ type: object
+ v1.ActionAmountResult:
+ properties:
+ completed:
+ type: integer
+ type: object
+ v1.Build:
+ properties:
+ buildTime:
+ type: string
+ commit:
+ type: string
+ version:
+ type: string
+ type: object
+ v1.ChangePassword:
+ properties:
+ current:
+ type: string
+ new:
+ type: string
+ type: object
+ v1.GroupInvitation:
+ properties:
+ expiresAt:
+ type: string
+ token:
+ type: string
+ uses:
+ type: integer
+ type: object
+ v1.GroupInvitationCreate:
+ properties:
+ expiresAt:
+ type: string
+ uses:
+ maximum: 100
+ minimum: 1
+ type: integer
+ required:
+ - uses
+ type: object
+ v1.ItemAttachmentToken:
+ properties:
+ token:
+ type: string
+ type: object
+ v1.ItemTemplateCreateItemRequest:
+ properties:
+ description:
+ maxLength: 1000
+ type: string
+ labelIds:
+ items:
+ type: string
+ type: array
+ locationId:
+ type: string
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ quantity:
+ type: integer
+ required:
+ - locationId
+ - name
+ type: object
+ v1.LoginForm:
+ properties:
+ password:
+ example: admin
+ type: string
+ stayLoggedIn:
+ type: boolean
+ username:
+ type: string
+ type: object
+ v1.OIDCStatus:
+ properties:
+ allowLocal:
+ type: boolean
+ autoRedirect:
+ type: boolean
+ buttonText:
+ type: string
+ enabled:
+ type: boolean
+ type: object
+ v1.TokenResponse:
+ properties:
+ attachmentToken:
+ type: string
+ expiresAt:
+ type: string
+ token:
+ type: string
+ type: object
+ v1.Wrapped:
+ properties:
+ item: {}
+ type: object
+ validate.ErrorResponse:
+ properties:
+ error:
+ type: string
+ fields:
+ type: string
+ type: object
+host: demo.homebox.software
+info:
+ contact:
+ name: Homebox Team
+ url: https://discord.homebox.software
+ description: Track, Manage, and Organize your Things.
+ title: Homebox API
+ version: "1.0"
+paths:
+ /v1/actions/create-missing-thumbnails:
+ post:
+ description: Creates thumbnails for items that are missing them
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/v1.ActionAmountResult'
+ security:
+ - Bearer: []
+ summary: Create Missing Thumbnails
+ tags:
+ - Actions
+ /v1/actions/ensure-asset-ids:
+ post:
+ description: Ensures all items in the database have an asset ID
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/v1.ActionAmountResult'
+ security:
+ - Bearer: []
+ summary: Ensure Asset IDs
+ tags:
+ - Actions
+ /v1/actions/ensure-import-refs:
+ post:
+ description: Ensures all items in the database have an import ref
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/v1.ActionAmountResult'
+ security:
+ - Bearer: []
+ summary: Ensures Import Refs
+ tags:
+ - Actions
+ /v1/actions/set-primary-photos:
+ post:
+ description: Sets the first photo of each item as the primary photo
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/v1.ActionAmountResult'
+ security:
+ - Bearer: []
+ summary: Set Primary Photos
+ tags:
+ - Actions
+ /v1/actions/zero-item-time-fields:
+ post:
+ description: Resets all item date fields to the beginning of the day
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/v1.ActionAmountResult'
+ security:
+ - Bearer: []
+ summary: Zero Out Time Fields
+ tags:
+ - Actions
+ /v1/assets/{id}:
+ get:
+ parameters:
+ - description: Asset ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.PaginationResult-repo_ItemSummary'
+ security:
+ - Bearer: []
+ summary: Get Item by Asset ID
+ tags:
+ - Items
+ /v1/currency:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/currencies.Currency'
+ summary: Currency
+ tags:
+ - Base
+ /v1/groups:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.Group'
+ security:
+ - Bearer: []
+ summary: Get Group
+ tags:
+ - Group
+ put:
+ parameters:
+ - description: User Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.GroupUpdate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.Group'
+ security:
+ - Bearer: []
+ summary: Update Group
+ tags:
+ - Group
+ /v1/groups/invitations:
+ post:
+ parameters:
+ - description: User Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/v1.GroupInvitationCreate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/v1.GroupInvitation'
+ security:
+ - Bearer: []
+ summary: Create Group Invitation
+ tags:
+ - Group
+ /v1/groups/statistics:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.GroupStatistics'
+ security:
+ - Bearer: []
+ summary: Get Group Statistics
+ tags:
+ - Statistics
+ /v1/groups/statistics/labels:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.TotalsByOrganizer'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get Label Statistics
+ tags:
+ - Statistics
+ /v1/groups/statistics/locations:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.TotalsByOrganizer'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get Location Statistics
+ tags:
+ - Statistics
+ /v1/groups/statistics/purchase-price:
+ get:
+ parameters:
+ - description: start date
+ in: query
+ name: start
+ type: string
+ - description: end date
+ in: query
+ name: end
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ValueOverTime'
+ security:
+ - Bearer: []
+ summary: Get Purchase Price Statistics
+ tags:
+ - Statistics
+ /v1/items:
+ get:
+ parameters:
+ - description: search string
+ in: query
+ name: q
+ type: string
+ - description: page number
+ in: query
+ name: page
+ type: integer
+ - description: items per page
+ in: query
+ name: pageSize
+ type: integer
+ - collectionFormat: multi
+ description: label Ids
+ in: query
+ items:
+ type: string
+ name: labels
+ type: array
+ - collectionFormat: multi
+ description: location Ids
+ in: query
+ items:
+ type: string
+ name: locations
+ type: array
+ - collectionFormat: multi
+ description: parent Ids
+ in: query
+ items:
+ type: string
+ name: parentIds
+ type: array
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.PaginationResult-repo_ItemSummary'
+ security:
+ - Bearer: []
+ summary: Query All Items
+ tags:
+ - Items
+ post:
+ parameters:
+ - description: Item Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.ItemCreate'
+ produces:
+ - application/json
+ responses:
+ "201":
+ description: Created
+ schema:
+ $ref: '#/definitions/repo.ItemSummary'
+ security:
+ - Bearer: []
+ summary: Create Item
+ tags:
+ - Items
+ /v1/items/{id}:
+ delete:
+ parameters:
+ - description: Item ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Delete Item
+ tags:
+ - Items
+ get:
+ parameters:
+ - description: Item ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemOut'
+ security:
+ - Bearer: []
+ summary: Get Item
+ tags:
+ - Items
+ patch:
+ parameters:
+ - description: Item ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Item Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.ItemPatch'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemOut'
+ security:
+ - Bearer: []
+ summary: Update Item
+ tags:
+ - Items
+ put:
+ parameters:
+ - description: Item ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Item Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.ItemUpdate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemOut'
+ security:
+ - Bearer: []
+ summary: Update Item
+ tags:
+ - Items
+ /v1/items/{id}/attachments:
+ post:
+ consumes:
+ - multipart/form-data
+ 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
+ type: string
+ - description: Is this the primary attachment
+ in: formData
+ name: primary
+ type: boolean
+ - 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/repo.ItemOut'
+ "422":
+ description: Unprocessable Entity
+ schema:
+ $ref: '#/definitions/validate.ErrorResponse'
+ security:
+ - Bearer: []
+ summary: Create Item Attachment
+ tags:
+ - Items Attachments
+ /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: No Content
+ security:
+ - Bearer: []
+ summary: Delete Item Attachment
+ tags:
+ - Items Attachments
+ 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/v1.ItemAttachmentToken'
+ security:
+ - Bearer: []
+ summary: Get Item Attachment
+ tags:
+ - Items Attachments
+ 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/repo.ItemAttachmentUpdate'
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemOut'
+ security:
+ - Bearer: []
+ summary: Update Item Attachment
+ tags:
+ - Items Attachments
+ /v1/items/{id}/duplicate:
+ post:
+ parameters:
+ - description: Item ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Duplicate Options
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.DuplicateOptions'
+ produces:
+ - application/json
+ responses:
+ "201":
+ description: Created
+ schema:
+ $ref: '#/definitions/repo.ItemOut'
+ security:
+ - Bearer: []
+ summary: Duplicate Item
+ tags:
+ - Items
+ /v1/items/{id}/maintenance:
+ get:
+ parameters:
+ - description: Item ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - enum:
+ - scheduled
+ - completed
+ - both
+ in: query
+ name: status
+ type: string
+ x-enum-varnames:
+ - MaintenanceFilterStatusScheduled
+ - MaintenanceFilterStatusCompleted
+ - MaintenanceFilterStatusBoth
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.MaintenanceEntryWithDetails'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get Maintenance Log
+ tags:
+ - Item Maintenance
+ post:
+ parameters:
+ - description: Item ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Entry Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.MaintenanceEntryCreate'
+ produces:
+ - application/json
+ responses:
+ "201":
+ description: Created
+ schema:
+ $ref: '#/definitions/repo.MaintenanceEntry'
+ security:
+ - Bearer: []
+ summary: Create Maintenance Entry
+ tags:
+ - Item Maintenance
+ /v1/items/{id}/path:
+ get:
+ parameters:
+ - description: Item ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.ItemPath'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get the full path of an item
+ tags:
+ - Items
+ /v1/items/export:
+ get:
+ responses:
+ "200":
+ description: text/csv
+ schema:
+ type: string
+ security:
+ - Bearer: []
+ summary: Export Items
+ tags:
+ - Items
+ /v1/items/fields:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ type: string
+ type: array
+ security:
+ - Bearer: []
+ summary: Get All Custom Field Names
+ tags:
+ - Items
+ /v1/items/fields/values:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ type: string
+ type: array
+ security:
+ - Bearer: []
+ summary: Get All Custom Field Values
+ tags:
+ - Items
+ /v1/items/import:
+ post:
+ consumes:
+ - multipart/form-data
+ parameters:
+ - description: Image to upload
+ in: formData
+ name: csv
+ required: true
+ type: file
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Import Items
+ tags:
+ - Items
+ /v1/labelmaker/assets/{id}:
+ get:
+ parameters:
+ - description: Asset ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Print this label, defaults to false
+ in: query
+ name: print
+ type: boolean
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: image/png
+ schema:
+ type: string
+ security:
+ - Bearer: []
+ summary: Get Asset label
+ tags:
+ - Items
+ /v1/labelmaker/item/{id}:
+ get:
+ parameters:
+ - description: Item ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Print this label, defaults to false
+ in: query
+ name: print
+ type: boolean
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: image/png
+ schema:
+ type: string
+ security:
+ - Bearer: []
+ summary: Get Item label
+ tags:
+ - Items
+ /v1/labelmaker/location/{id}:
+ get:
+ parameters:
+ - description: Location ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Print this label, defaults to false
+ in: query
+ name: print
+ type: boolean
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: image/png
+ schema:
+ type: string
+ security:
+ - Bearer: []
+ summary: Get Location label
+ tags:
+ - Locations
+ /v1/labels:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.LabelOut'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get All Labels
+ tags:
+ - Labels
+ post:
+ parameters:
+ - description: Label Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.LabelCreate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.LabelSummary'
+ security:
+ - Bearer: []
+ summary: Create Label
+ tags:
+ - Labels
+ /v1/labels/{id}:
+ delete:
+ parameters:
+ - description: Label ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Delete Label
+ tags:
+ - Labels
+ get:
+ parameters:
+ - description: Label ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.LabelOut'
+ security:
+ - Bearer: []
+ summary: Get Label
+ tags:
+ - Labels
+ put:
+ parameters:
+ - description: Label ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.LabelOut'
+ security:
+ - Bearer: []
+ summary: Update Label
+ tags:
+ - Labels
+ /v1/locations:
+ get:
+ parameters:
+ - description: Filter locations with parents
+ in: query
+ name: filterChildren
+ type: boolean
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.LocationOutCount'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get All Locations
+ tags:
+ - Locations
+ post:
+ parameters:
+ - description: Location Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.LocationCreate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.LocationSummary'
+ security:
+ - Bearer: []
+ summary: Create Location
+ tags:
+ - Locations
+ /v1/locations/{id}:
+ delete:
+ parameters:
+ - description: Location ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Delete Location
+ tags:
+ - Locations
+ get:
+ parameters:
+ - description: Location ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.LocationOut'
+ security:
+ - Bearer: []
+ summary: Get Location
+ tags:
+ - Locations
+ put:
+ parameters:
+ - description: Location ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Location Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.LocationUpdate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.LocationOut'
+ security:
+ - Bearer: []
+ summary: Update Location
+ tags:
+ - Locations
+ /v1/locations/tree:
+ get:
+ parameters:
+ - description: include items in response tree
+ in: query
+ name: withItems
+ type: boolean
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.TreeItem'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get Locations Tree
+ tags:
+ - Locations
+ /v1/maintenance:
+ get:
+ parameters:
+ - enum:
+ - scheduled
+ - completed
+ - both
+ in: query
+ name: status
+ type: string
+ x-enum-varnames:
+ - MaintenanceFilterStatusScheduled
+ - MaintenanceFilterStatusCompleted
+ - MaintenanceFilterStatusBoth
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.MaintenanceEntryWithDetails'
+ type: array
+ security:
+ - Bearer: []
+ summary: Query All Maintenance
+ tags:
+ - Maintenance
+ /v1/maintenance/{id}:
+ delete:
+ parameters:
+ - description: Maintenance ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Delete Maintenance Entry
+ tags:
+ - Maintenance
+ put:
+ parameters:
+ - description: Maintenance ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Entry Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.MaintenanceEntryUpdate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.MaintenanceEntry'
+ security:
+ - Bearer: []
+ summary: Update Maintenance Entry
+ tags:
+ - Maintenance
+ /v1/notifiers:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.NotifierOut'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get Notifiers
+ tags:
+ - Notifiers
+ post:
+ parameters:
+ - description: Notifier Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.NotifierCreate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.NotifierOut'
+ security:
+ - Bearer: []
+ summary: Create Notifier
+ tags:
+ - Notifiers
+ /v1/notifiers/{id}:
+ delete:
+ parameters:
+ - description: Notifier ID
+ in: path
+ name: id
+ required: true
+ type: string
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Delete a Notifier
+ tags:
+ - Notifiers
+ put:
+ parameters:
+ - description: Notifier ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Notifier Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.NotifierUpdate'
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.NotifierOut'
+ security:
+ - Bearer: []
+ summary: Update Notifier
+ tags:
+ - Notifiers
+ /v1/notifiers/test:
+ post:
+ parameters:
+ - description: URL
+ in: query
+ name: url
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Test Notifier
+ tags:
+ - Notifiers
+ /v1/products/search-from-barcode:
+ get:
+ parameters:
+ - description: barcode to be searched
+ in: query
+ name: data
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.BarcodeProduct'
+ type: array
+ security:
+ - Bearer: []
+ summary: Search EAN from Barcode
+ tags:
+ - Items
+ /v1/qrcode:
+ get:
+ parameters:
+ - description: data to be encoded into qrcode
+ in: query
+ name: data
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: image/jpeg
+ schema:
+ type: string
+ security:
+ - Bearer: []
+ summary: Create QR Code
+ tags:
+ - Items
+ /v1/reporting/bill-of-materials:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: text/csv
+ schema:
+ type: string
+ security:
+ - Bearer: []
+ summary: Export Bill of Materials
+ tags:
+ - Reporting
+ /v1/status:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/v1.APISummary'
+ summary: Application Info
+ tags:
+ - Base
+ /v1/templates:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.ItemTemplateSummary'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get All Item Templates
+ tags:
+ - Item Templates
+ post:
+ parameters:
+ - description: Template Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateCreate'
+ produces:
+ - application/json
+ responses:
+ "201":
+ description: Created
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateOut'
+ security:
+ - Bearer: []
+ summary: Create Item Template
+ tags:
+ - Item Templates
+ /v1/templates/{id}:
+ delete:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Delete Item Template
+ tags:
+ - Item Templates
+ get:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateOut'
+ security:
+ - Bearer: []
+ summary: Get Item Template
+ tags:
+ - Item Templates
+ put:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Template Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateUpdate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateOut'
+ security:
+ - Bearer: []
+ summary: Update Item Template
+ tags:
+ - Item Templates
+ /v1/templates/{id}/create-item:
+ post:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Item Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/v1.ItemTemplateCreateItemRequest'
+ produces:
+ - application/json
+ responses:
+ "201":
+ description: Created
+ schema:
+ $ref: '#/definitions/repo.ItemOut'
+ security:
+ - Bearer: []
+ summary: Create Item from Template
+ tags:
+ - Item Templates
+ /v1/users/change-password:
+ put:
+ parameters:
+ - description: Password Payload
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/v1.ChangePassword'
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Change Password
+ tags:
+ - User
+ /v1/users/login:
+ post:
+ consumes:
+ - application/x-www-form-urlencoded
+ - application/json
+ parameters:
+ - description: Login Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/v1.LoginForm'
+ - description: auth provider
+ in: query
+ name: provider
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/v1.TokenResponse'
+ summary: User Login
+ tags:
+ - Authentication
+ /v1/users/login/oidc:
+ get:
+ produces:
+ - application/json
+ responses:
+ "302":
+ description: Found
+ summary: OIDC Login Initiation
+ tags:
+ - Authentication
+ /v1/users/login/oidc/callback:
+ get:
+ parameters:
+ - description: Authorization code
+ in: query
+ name: code
+ required: true
+ type: string
+ - description: State parameter
+ in: query
+ name: state
+ required: true
+ type: string
+ responses:
+ "302":
+ description: Found
+ summary: OIDC Callback Handler
+ tags:
+ - Authentication
+ /v1/users/logout:
+ post:
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: User Logout
+ tags:
+ - Authentication
+ /v1/users/refresh:
+ get:
+ description: |-
+ handleAuthRefresh returns a handler that will issue a new token from an existing token.
+ This does not validate that the user still exists within the database.
+ responses:
+ "200":
+ description: OK
+ security:
+ - Bearer: []
+ summary: User Token Refresh
+ tags:
+ - Authentication
+ /v1/users/register:
+ post:
+ parameters:
+ - description: User Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/services.UserRegistration'
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ "403":
+ description: Local login is not enabled
+ schema:
+ type: string
+ summary: Register New User
+ tags:
+ - User
+ /v1/users/self:
+ delete:
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Delete Account
+ tags:
+ - User
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ allOf:
+ - $ref: '#/definitions/v1.Wrapped'
+ - properties:
+ item:
+ $ref: '#/definitions/repo.UserOut'
+ type: object
+ security:
+ - Bearer: []
+ summary: Get User Self
+ tags:
+ - User
+ put:
+ parameters:
+ - description: User Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.UserUpdate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ allOf:
+ - $ref: '#/definitions/v1.Wrapped'
+ - properties:
+ item:
+ $ref: '#/definitions/repo.UserUpdate'
+ type: object
+ security:
+ - Bearer: []
+ summary: Update Account
+ tags:
+ - User
+schemes:
+- https
+- http
+securityDefinitions:
+ Bearer:
+ description: '"Type ''Bearer TOKEN'' to correctly set the API Key"'
+ in: header
+ name: Authorization
+ type: apiKey
+swagger: "2.0"
diff --git a/docs/en/api/openapi-3.0.json b/docs/en/api/openapi-3.0.json
index 2ae3681d..a80a6124 100644
--- a/docs/en/api/openapi-3.0.json
+++ b/docs/en/api/openapi-3.0.json
@@ -2122,6 +2122,223 @@
}
}
},
+ "/v1/templates": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get All Item Templates",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.ItemTemplateSummary"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item Template",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateCreate"
+ }
+ }
+ },
+ "description": "Template Data",
+ "required": true
+ },
+ "responses": {
+ "201": {
+ "description": "Created",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get Item Template",
+ "parameters": [
+ {
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Update Item Template",
+ "parameters": [
+ {
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateUpdate"
+ }
+ }
+ },
+ "description": "Template Data",
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Delete Item Template",
+ "parameters": [
+ {
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}/create-item": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item from Template",
+ "parameters": [
+ {
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/v1.ItemTemplateCreateItemRequest"
+ }
+ }
+ },
+ "description": "Item Data",
+ "required": true
+ },
+ "responses": {
+ "201": {
+ "description": "Created",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/repo.ItemOut"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"/v1/users/change-password": {
"put": {
"security": [
@@ -2197,6 +2414,52 @@
}
}
},
+ "/v1/users/login/oidc": {
+ "get": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Login Initiation",
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
+ "/v1/users/login/oidc/callback": {
+ "get": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Callback Handler",
+ "parameters": [
+ {
+ "description": "Authorization code",
+ "name": "code",
+ "in": "query",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "description": "State parameter",
+ "name": "state",
+ "in": "query",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
"/v1/users/logout": {
"post": {
"security": [
@@ -2254,6 +2517,16 @@
"responses": {
"204": {
"description": "No Content"
+ },
+ "403": {
+ "description": "Local login is not enabled",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
}
}
}
@@ -2640,6 +2913,13 @@
"$ref": "#/components/schemas/ent.GroupInvitationToken"
}
},
+ "item_templates": {
+ "description": "ItemTemplates holds the value of the item_templates edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ent.ItemTemplate"
+ }
+ },
"items": {
"description": "Items holds the value of the items edge.",
"type": "array",
@@ -2977,35 +3257,151 @@
}
}
},
- "ent.Label": {
+ "ent.ItemTemplate": {
"type": "object",
"properties": {
- "color": {
- "description": "Color holds the value of the \"color\" field.",
- "type": "string"
- },
"created_at": {
"description": "CreatedAt holds the value of the \"created_at\" field.",
"type": "string"
},
- "description": {
- "description": "Description holds the value of the \"description\" field.",
+ "default_description": {
+ "description": "Default description for items created from this template",
"type": "string"
},
- "edges": {
- "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
- "allOf": [
- {
- "$ref": "#/components/schemas/ent.LabelEdges"
- }
- ]
- },
- "id": {
- "description": "ID of the ent.",
- "type": "string"
+ "default_insured": {
+ "description": "DefaultInsured holds the value of the \"default_insured\" field.",
+ "type": "boolean"
},
- "name": {
- "description": "Name holds the value of the \"name\" field.",
+ "default_label_ids": {
+ "description": "Default label IDs for items created from this template",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "default_lifetime_warranty": {
+ "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.",
+ "type": "boolean"
+ },
+ "default_manufacturer": {
+ "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.",
+ "type": "string"
+ },
+ "default_model_number": {
+ "description": "Default model number for items created from this template",
+ "type": "string"
+ },
+ "default_name": {
+ "description": "Default name template for items (can use placeholders)",
+ "type": "string"
+ },
+ "default_quantity": {
+ "description": "DefaultQuantity holds the value of the \"default_quantity\" field.",
+ "type": "integer"
+ },
+ "default_warranty_details": {
+ "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.ItemTemplateEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "include_purchase_fields": {
+ "description": "Whether to include purchase fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_sold_fields": {
+ "description": "Whether to include sold fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_warranty_fields": {
+ "description": "Whether to include warranty fields in items created from this template",
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "notes": {
+ "description": "Notes holds the value of the \"notes\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.ItemTemplateEdges": {
+ "type": "object",
+ "properties": {
+ "fields": {
+ "description": "Fields holds the value of the fields edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ent.TemplateField"
+ }
+ },
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.Group"
+ }
+ ]
+ },
+ "location": {
+ "description": "Location holds the value of the location edge.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.Location"
+ }
+ ]
+ }
+ }
+ },
+ "ent.Label": {
+ "type": "object",
+ "properties": {
+ "color": {
+ "description": "Color holds the value of the \"color\" field.",
+ "type": "string"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.LabelEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
"type": "string"
},
"updated_at": {
@@ -3226,6 +3622,64 @@
}
}
},
+ "ent.TemplateField": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.TemplateFieldEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "text_value": {
+ "description": "TextValue holds the value of the \"text_value\" field.",
+ "type": "string"
+ },
+ "type": {
+ "description": "Type holds the value of the \"type\" field.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/templatefield.Type"
+ }
+ ]
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.TemplateFieldEdges": {
+ "type": "object",
+ "properties": {
+ "item_template": {
+ "description": "ItemTemplate holds the value of the item_template edge.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ent.ItemTemplate"
+ }
+ ]
+ }
+ }
+ },
"ent.User": {
"type": "object",
"properties": {
@@ -3261,6 +3715,14 @@
"description": "Name holds the value of the \"name\" field.",
"type": "string"
},
+ "oidc_issuer": {
+ "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.",
+ "type": "string"
+ },
+ "oidc_subject": {
+ "description": "OidcSubject holds the value of the \"oidc_subject\" field.",
+ "type": "string"
+ },
"role": {
"description": "Role holds the value of the \"role\" field.",
"allOf": [
@@ -3761,6 +4223,280 @@
}
}
},
+ "repo.ItemTemplateCreate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.TemplateField"
+ }
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
+ "repo.ItemTemplateOut": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "defaultDescription": {
+ "type": "string"
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabels": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.TemplateLabelSummary"
+ }
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocation": {
+ "description": "Default location and labels",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/repo.TemplateLocationSummary"
+ }
+ ]
+ },
+ "defaultManufacturer": {
+ "type": "string"
+ },
+ "defaultModelNumber": {
+ "type": "string"
+ },
+ "defaultName": {
+ "type": "string"
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer"
+ },
+ "defaultWarrantyDetails": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "notes": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateSummary": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateUpdate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
"repo.ItemType": {
"type": "string",
"enum": [
@@ -4256,6 +4992,45 @@
}
}
},
+ "repo.TemplateField": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "textValue": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLabelSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLocationSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
"repo.TotalsByOrganizer": {
"type": "object",
"properties": {
@@ -4313,6 +5088,12 @@
},
"name": {
"type": "string"
+ },
+ "oidcIssuer": {
+ "type": "string"
+ },
+ "oidcSubject": {
+ "type": "string"
}
}
},
@@ -4392,6 +5173,15 @@
}
}
},
+ "templatefield.Type": {
+ "type": "string",
+ "enum": [
+ "text"
+ ],
+ "x-enum-varnames": [
+ "TypeText"
+ ]
+ },
"user.Role": {
"type": "string",
"enum": [
@@ -4429,6 +5219,9 @@
"message": {
"type": "string"
},
+ "oidc": {
+ "$ref": "#/components/schemas/v1.OIDCStatus"
+ },
"title": {
"type": "string"
},
@@ -4511,6 +5304,36 @@
}
}
},
+ "v1.ItemTemplateCreateItemRequest": {
+ "type": "object",
+ "required": [
+ "locationId",
+ "name"
+ ],
+ "properties": {
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "labelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "locationId": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "quantity": {
+ "type": "integer"
+ }
+ }
+ },
"v1.LoginForm": {
"type": "object",
"properties": {
@@ -4527,6 +5350,23 @@
}
}
},
+ "v1.OIDCStatus": {
+ "type": "object",
+ "properties": {
+ "allowLocal": {
+ "type": "boolean"
+ },
+ "autoRedirect": {
+ "type": "boolean"
+ },
+ "buttonText": {
+ "type": "string"
+ },
+ "enabled": {
+ "type": "boolean"
+ }
+ }
+ },
"v1.TokenResponse": {
"type": "object",
"properties": {
diff --git a/docs/en/api/openapi-3.0.yaml b/docs/en/api/openapi-3.0.yaml
index bc56d4a2..0a6d2042 100644
--- a/docs/en/api/openapi-3.0.yaml
+++ b/docs/en/api/openapi-3.0.yaml
@@ -1257,6 +1257,134 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/v1.APISummary"
+ /v1/templates:
+ get:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Get All Item Templates
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.ItemTemplateSummary"
+ post:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Create Item Template
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateCreate"
+ description: Template Data
+ required: true
+ responses:
+ "201":
+ description: Created
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateOut"
+ "/v1/templates/{id}":
+ get:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Get Item Template
+ parameters:
+ - description: Template ID
+ name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateOut"
+ put:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Update Item Template
+ parameters:
+ - description: Template ID
+ name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateUpdate"
+ description: Template Data
+ required: true
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemTemplateOut"
+ delete:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Delete Item Template
+ parameters:
+ - description: Template ID
+ name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "204":
+ description: No Content
+ "/v1/templates/{id}/create-item":
+ post:
+ security:
+ - Bearer: []
+ tags:
+ - Item Templates
+ summary: Create Item from Template
+ parameters:
+ - description: Template ID
+ name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/v1.ItemTemplateCreateItemRequest"
+ description: Item Data
+ required: true
+ responses:
+ "201":
+ description: Created
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/repo.ItemOut"
/v1/users/change-password:
put:
security:
@@ -1302,6 +1430,35 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/v1.TokenResponse"
+ /v1/users/login/oidc:
+ get:
+ tags:
+ - Authentication
+ summary: OIDC Login Initiation
+ responses:
+ "302":
+ description: Found
+ /v1/users/login/oidc/callback:
+ get:
+ tags:
+ - Authentication
+ summary: OIDC Callback Handler
+ parameters:
+ - description: Authorization code
+ name: code
+ in: query
+ required: true
+ schema:
+ type: string
+ - description: State parameter
+ name: state
+ in: query
+ required: true
+ schema:
+ type: string
+ responses:
+ "302":
+ description: Found
/v1/users/logout:
post:
security:
@@ -1342,6 +1499,12 @@ paths:
responses:
"204":
description: No Content
+ "403":
+ description: Local login is not enabled
+ content:
+ application/json:
+ schema:
+ type: string
/v1/users/self:
get:
security:
@@ -1590,6 +1753,11 @@ components:
type: array
items:
$ref: "#/components/schemas/ent.GroupInvitationToken"
+ item_templates:
+ description: ItemTemplates holds the value of the item_templates edge.
+ type: array
+ items:
+ $ref: "#/components/schemas/ent.ItemTemplate"
items:
description: Items holds the value of the items edge.
type: array
@@ -1826,6 +1994,93 @@ components:
description: Item holds the value of the item edge.
allOf:
- $ref: "#/components/schemas/ent.Item"
+ ent.ItemTemplate:
+ type: object
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ default_description:
+ description: Default description for items created from this template
+ type: string
+ default_insured:
+ description: DefaultInsured holds the value of the "default_insured" field.
+ type: boolean
+ default_label_ids:
+ description: Default label IDs for items created from this template
+ type: array
+ items:
+ type: string
+ default_lifetime_warranty:
+ description: DefaultLifetimeWarranty holds the value of the
+ "default_lifetime_warranty" field.
+ type: boolean
+ default_manufacturer:
+ description: DefaultManufacturer holds the value of the "default_manufacturer"
+ field.
+ type: string
+ default_model_number:
+ description: Default model number for items created from this template
+ type: string
+ default_name:
+ description: Default name template for items (can use placeholders)
+ type: string
+ default_quantity:
+ description: DefaultQuantity holds the value of the "default_quantity" field.
+ type: integer
+ default_warranty_details:
+ description: DefaultWarrantyDetails holds the value of the
+ "default_warranty_details" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ description: >-
+ Edges holds the relations/edges for other nodes in the graph.
+
+ The values are being populated by the ItemTemplateQuery when eager-loading is set.
+ allOf:
+ - $ref: "#/components/schemas/ent.ItemTemplateEdges"
+ id:
+ description: ID of the ent.
+ type: string
+ include_purchase_fields:
+ description: Whether to include purchase fields in items created from this
+ template
+ type: boolean
+ include_sold_fields:
+ description: Whether to include sold fields in items created from this template
+ type: boolean
+ include_warranty_fields:
+ description: Whether to include warranty fields in items created from this
+ template
+ type: boolean
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ notes:
+ description: Notes holds the value of the "notes" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ ent.ItemTemplateEdges:
+ type: object
+ properties:
+ fields:
+ description: Fields holds the value of the fields edge.
+ type: array
+ items:
+ $ref: "#/components/schemas/ent.TemplateField"
+ group:
+ description: Group holds the value of the group edge.
+ allOf:
+ - $ref: "#/components/schemas/ent.Group"
+ location:
+ description: Location holds the value of the location edge.
+ allOf:
+ - $ref: "#/components/schemas/ent.Location"
ent.Label:
type: object
properties:
@@ -1998,6 +2253,45 @@ components:
description: User holds the value of the user edge.
allOf:
- $ref: "#/components/schemas/ent.User"
+ ent.TemplateField:
+ type: object
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ description: >-
+ Edges holds the relations/edges for other nodes in the graph.
+
+ The values are being populated by the TemplateFieldQuery when eager-loading is set.
+ allOf:
+ - $ref: "#/components/schemas/ent.TemplateFieldEdges"
+ id:
+ description: ID of the ent.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ text_value:
+ description: TextValue holds the value of the "text_value" field.
+ type: string
+ type:
+ description: Type holds the value of the "type" field.
+ allOf:
+ - $ref: "#/components/schemas/templatefield.Type"
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ ent.TemplateFieldEdges:
+ type: object
+ properties:
+ item_template:
+ description: ItemTemplate holds the value of the item_template edge.
+ allOf:
+ - $ref: "#/components/schemas/ent.ItemTemplate"
ent.User:
type: object
properties:
@@ -2026,6 +2320,12 @@ components:
name:
description: Name holds the value of the "name" field.
type: string
+ oidc_issuer:
+ description: OidcIssuer holds the value of the "oidc_issuer" field.
+ type: string
+ oidc_subject:
+ description: OidcSubject holds the value of the "oidc_subject" field.
+ type: string
role:
description: Role holds the value of the "role" field.
allOf:
@@ -2361,6 +2661,201 @@ components:
nullable: true
updatedAt:
type: string
+ repo.ItemTemplateCreate:
+ type: object
+ required:
+ - name
+ properties:
+ defaultDescription:
+ type: string
+ maxLength: 1000
+ nullable: true
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ type: array
+ items:
+ type: string
+ nullable: true
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ nullable: true
+ defaultManufacturer:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultModelNumber:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultName:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ nullable: true
+ defaultWarrantyDetails:
+ type: string
+ maxLength: 1000
+ nullable: true
+ description:
+ type: string
+ maxLength: 1000
+ fields:
+ description: Custom fields
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.TemplateField"
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ type: string
+ maxLength: 255
+ minLength: 1
+ notes:
+ type: string
+ maxLength: 1000
+ repo.ItemTemplateOut:
+ type: object
+ properties:
+ createdAt:
+ type: string
+ defaultDescription:
+ type: string
+ defaultInsured:
+ type: boolean
+ defaultLabels:
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.TemplateLabelSummary"
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocation:
+ description: Default location and labels
+ allOf:
+ - $ref: "#/components/schemas/repo.TemplateLocationSummary"
+ defaultManufacturer:
+ type: string
+ defaultModelNumber:
+ type: string
+ defaultName:
+ type: string
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ defaultWarrantyDetails:
+ type: string
+ description:
+ type: string
+ fields:
+ description: Custom fields
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.TemplateField"
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ type: string
+ notes:
+ type: string
+ updatedAt:
+ type: string
+ repo.ItemTemplateSummary:
+ type: object
+ properties:
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ updatedAt:
+ type: string
+ repo.ItemTemplateUpdate:
+ type: object
+ required:
+ - name
+ properties:
+ defaultDescription:
+ type: string
+ maxLength: 1000
+ nullable: true
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ type: array
+ items:
+ type: string
+ nullable: true
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ nullable: true
+ defaultManufacturer:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultModelNumber:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultName:
+ type: string
+ maxLength: 255
+ nullable: true
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ nullable: true
+ defaultWarrantyDetails:
+ type: string
+ maxLength: 1000
+ nullable: true
+ description:
+ type: string
+ maxLength: 1000
+ fields:
+ description: Custom fields
+ type: array
+ items:
+ $ref: "#/components/schemas/repo.TemplateField"
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ type: string
+ maxLength: 255
+ minLength: 1
+ notes:
+ type: string
+ maxLength: 1000
repo.ItemType:
type: string
enum:
@@ -2698,6 +3193,31 @@ components:
type: integer
total:
type: integer
+ repo.TemplateField:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ textValue:
+ type: string
+ type:
+ type: string
+ repo.TemplateLabelSummary:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ repo.TemplateLocationSummary:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
repo.TotalsByOrganizer:
type: object
properties:
@@ -2737,6 +3257,10 @@ components:
type: boolean
name:
type: string
+ oidcIssuer:
+ type: string
+ oidcSubject:
+ type: string
repo.UserUpdate:
type: object
properties:
@@ -2786,6 +3310,12 @@ components:
type: string
token:
type: string
+ templatefield.Type:
+ type: string
+ enum:
+ - text
+ x-enum-varnames:
+ - TypeText
user.Role:
type: string
enum:
@@ -2813,6 +3343,8 @@ components:
$ref: "#/components/schemas/services.Latest"
message:
type: string
+ oidc:
+ $ref: "#/components/schemas/v1.OIDCStatus"
title:
type: string
versions:
@@ -2865,6 +3397,27 @@ components:
properties:
token:
type: string
+ v1.ItemTemplateCreateItemRequest:
+ type: object
+ required:
+ - locationId
+ - name
+ properties:
+ description:
+ type: string
+ maxLength: 1000
+ labelIds:
+ type: array
+ items:
+ type: string
+ locationId:
+ type: string
+ name:
+ type: string
+ maxLength: 255
+ minLength: 1
+ quantity:
+ type: integer
v1.LoginForm:
type: object
properties:
@@ -2876,6 +3429,17 @@ components:
username:
type: string
+ v1.OIDCStatus:
+ type: object
+ properties:
+ allowLocal:
+ type: boolean
+ autoRedirect:
+ type: boolean
+ buttonText:
+ type: string
+ enabled:
+ type: boolean
v1.TokenResponse:
type: object
properties:
diff --git a/docs/en/api/swagger-2.0.json b/docs/en/api/swagger-2.0.json
index 3fd96322..61b8612a 100644
--- a/docs/en/api/swagger-2.0.json
+++ b/docs/en/api/swagger-2.0.json
@@ -1961,6 +1961,209 @@
}
}
},
+ "/v1/templates": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get All Item Templates",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.ItemTemplateSummary"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item Template",
+ "parameters": [
+ {
+ "description": "Template Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateCreate"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Get Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Update Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Template Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemTemplateOut"
+ }
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Delete Item Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/v1/templates/{id}/create-item": {
+ "post": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Item Templates"
+ ],
+ "summary": "Create Item from Template",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Template ID",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Item Data",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v1.ItemTemplateCreateItemRequest"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/repo.ItemOut"
+ }
+ }
+ }
+ }
+ },
"/v1/users/change-password": {
"put": {
"security": [
@@ -2030,6 +2233,51 @@
}
}
},
+ "/v1/users/login/oidc": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Login Initiation",
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
+ "/v1/users/login/oidc/callback": {
+ "get": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "OIDC Callback Handler",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "Authorization code",
+ "name": "code",
+ "in": "query",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "State parameter",
+ "name": "state",
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "302": {
+ "description": "Found"
+ }
+ }
+ }
+ },
"/v1/users/logout": {
"post": {
"security": [
@@ -2090,6 +2338,12 @@
"responses": {
"204": {
"description": "No Content"
+ },
+ "403": {
+ "description": "Local login is not enabled",
+ "schema": {
+ "type": "string"
+ }
}
}
}
@@ -2460,6 +2714,13 @@
"$ref": "#/definitions/ent.GroupInvitationToken"
}
},
+ "item_templates": {
+ "description": "ItemTemplates holds the value of the item_templates edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.ItemTemplate"
+ }
+ },
"items": {
"description": "Items holds the value of the items edge.",
"type": "array",
@@ -2797,26 +3058,61 @@
}
}
},
- "ent.Label": {
+ "ent.ItemTemplate": {
"type": "object",
"properties": {
- "color": {
- "description": "Color holds the value of the \"color\" field.",
- "type": "string"
- },
"created_at": {
"description": "CreatedAt holds the value of the \"created_at\" field.",
"type": "string"
},
+ "default_description": {
+ "description": "Default description for items created from this template",
+ "type": "string"
+ },
+ "default_insured": {
+ "description": "DefaultInsured holds the value of the \"default_insured\" field.",
+ "type": "boolean"
+ },
+ "default_label_ids": {
+ "description": "Default label IDs for items created from this template",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "default_lifetime_warranty": {
+ "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.",
+ "type": "boolean"
+ },
+ "default_manufacturer": {
+ "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.",
+ "type": "string"
+ },
+ "default_model_number": {
+ "description": "Default model number for items created from this template",
+ "type": "string"
+ },
+ "default_name": {
+ "description": "Default name template for items (can use placeholders)",
+ "type": "string"
+ },
+ "default_quantity": {
+ "description": "DefaultQuantity holds the value of the \"default_quantity\" field.",
+ "type": "integer"
+ },
+ "default_warranty_details": {
+ "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.",
+ "type": "string"
+ },
"description": {
"description": "Description holds the value of the \"description\" field.",
"type": "string"
},
"edges": {
- "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.",
"allOf": [
{
- "$ref": "#/definitions/ent.LabelEdges"
+ "$ref": "#/definitions/ent.ItemTemplateEdges"
}
]
},
@@ -2824,20 +3120,101 @@
"description": "ID of the ent.",
"type": "string"
},
+ "include_purchase_fields": {
+ "description": "Whether to include purchase fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_sold_fields": {
+ "description": "Whether to include sold fields in items created from this template",
+ "type": "boolean"
+ },
+ "include_warranty_fields": {
+ "description": "Whether to include warranty fields in items created from this template",
+ "type": "boolean"
+ },
"name": {
"description": "Name holds the value of the \"name\" field.",
"type": "string"
},
+ "notes": {
+ "description": "Notes holds the value of the \"notes\" field.",
+ "type": "string"
+ },
"updated_at": {
"description": "UpdatedAt holds the value of the \"updated_at\" field.",
"type": "string"
}
}
},
- "ent.LabelEdges": {
+ "ent.ItemTemplateEdges": {
"type": "object",
"properties": {
- "group": {
+ "fields": {
+ "description": "Fields holds the value of the fields edge.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ent.TemplateField"
+ }
+ },
+ "group": {
+ "description": "Group holds the value of the group edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Group"
+ }
+ ]
+ },
+ "location": {
+ "description": "Location holds the value of the location edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.Location"
+ }
+ ]
+ }
+ }
+ },
+ "ent.Label": {
+ "type": "object",
+ "properties": {
+ "color": {
+ "description": "Color holds the value of the \"color\" field.",
+ "type": "string"
+ },
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.LabelEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.LabelEdges": {
+ "type": "object",
+ "properties": {
+ "group": {
"description": "Group holds the value of the group edge.",
"allOf": [
{
@@ -3046,6 +3423,64 @@
}
}
},
+ "ent.TemplateField": {
+ "type": "object",
+ "properties": {
+ "created_at": {
+ "description": "CreatedAt holds the value of the \"created_at\" field.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Description holds the value of the \"description\" field.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.TemplateFieldEdges"
+ }
+ ]
+ },
+ "id": {
+ "description": "ID of the ent.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Name holds the value of the \"name\" field.",
+ "type": "string"
+ },
+ "text_value": {
+ "description": "TextValue holds the value of the \"text_value\" field.",
+ "type": "string"
+ },
+ "type": {
+ "description": "Type holds the value of the \"type\" field.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/templatefield.Type"
+ }
+ ]
+ },
+ "updated_at": {
+ "description": "UpdatedAt holds the value of the \"updated_at\" field.",
+ "type": "string"
+ }
+ }
+ },
+ "ent.TemplateFieldEdges": {
+ "type": "object",
+ "properties": {
+ "item_template": {
+ "description": "ItemTemplate holds the value of the item_template edge.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/ent.ItemTemplate"
+ }
+ ]
+ }
+ }
+ },
"ent.User": {
"type": "object",
"properties": {
@@ -3081,6 +3516,14 @@
"description": "Name holds the value of the \"name\" field.",
"type": "string"
},
+ "oidc_issuer": {
+ "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.",
+ "type": "string"
+ },
+ "oidc_subject": {
+ "description": "OidcSubject holds the value of the \"oidc_subject\" field.",
+ "type": "string"
+ },
"role": {
"description": "Role holds the value of the \"role\" field.",
"allOf": [
@@ -3581,6 +4024,280 @@
}
}
},
+ "repo.ItemTemplateCreate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "x-nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "x-nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
+ "repo.ItemTemplateOut": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "defaultDescription": {
+ "type": "string"
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabels": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateLabelSummary"
+ }
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocation": {
+ "description": "Default location and labels",
+ "allOf": [
+ {
+ "$ref": "#/definitions/repo.TemplateLocationSummary"
+ }
+ ]
+ },
+ "defaultManufacturer": {
+ "type": "string"
+ },
+ "defaultModelNumber": {
+ "type": "string"
+ },
+ "defaultName": {
+ "type": "string"
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer"
+ },
+ "defaultWarrantyDetails": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "notes": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateSummary": {
+ "type": "object",
+ "properties": {
+ "createdAt": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.ItemTemplateUpdate": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "defaultDescription": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "defaultInsured": {
+ "type": "boolean"
+ },
+ "defaultLabelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-nullable": true
+ },
+ "defaultLifetimeWarranty": {
+ "type": "boolean"
+ },
+ "defaultLocationId": {
+ "description": "Default location and labels",
+ "type": "string",
+ "x-nullable": true
+ },
+ "defaultManufacturer": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultModelNumber": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultName": {
+ "type": "string",
+ "maxLength": 255,
+ "x-nullable": true
+ },
+ "defaultQuantity": {
+ "description": "Default values for items",
+ "type": "integer",
+ "x-nullable": true
+ },
+ "defaultWarrantyDetails": {
+ "type": "string",
+ "maxLength": 1000,
+ "x-nullable": true
+ },
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "fields": {
+ "description": "Custom fields",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.TemplateField"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "includePurchaseFields": {
+ "type": "boolean"
+ },
+ "includeSoldFields": {
+ "type": "boolean"
+ },
+ "includeWarrantyFields": {
+ "description": "Metadata flags",
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 1000
+ }
+ }
+ },
"repo.ItemType": {
"type": "string",
"enum": [
@@ -4076,6 +4793,45 @@
}
}
},
+ "repo.TemplateField": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "textValue": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLabelSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "repo.TemplateLocationSummary": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
"repo.TotalsByOrganizer": {
"type": "object",
"properties": {
@@ -4133,6 +4889,12 @@
},
"name": {
"type": "string"
+ },
+ "oidcIssuer": {
+ "type": "string"
+ },
+ "oidcSubject": {
+ "type": "string"
}
}
},
@@ -4212,6 +4974,15 @@
}
}
},
+ "templatefield.Type": {
+ "type": "string",
+ "enum": [
+ "text"
+ ],
+ "x-enum-varnames": [
+ "TypeText"
+ ]
+ },
"user.Role": {
"type": "string",
"enum": [
@@ -4249,6 +5020,9 @@
"message": {
"type": "string"
},
+ "oidc": {
+ "$ref": "#/definitions/v1.OIDCStatus"
+ },
"title": {
"type": "string"
},
@@ -4331,6 +5105,36 @@
}
}
},
+ "v1.ItemTemplateCreateItemRequest": {
+ "type": "object",
+ "required": [
+ "locationId",
+ "name"
+ ],
+ "properties": {
+ "description": {
+ "type": "string",
+ "maxLength": 1000
+ },
+ "labelIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "locationId": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ "quantity": {
+ "type": "integer"
+ }
+ }
+ },
"v1.LoginForm": {
"type": "object",
"properties": {
@@ -4347,6 +5151,23 @@
}
}
},
+ "v1.OIDCStatus": {
+ "type": "object",
+ "properties": {
+ "allowLocal": {
+ "type": "boolean"
+ },
+ "autoRedirect": {
+ "type": "boolean"
+ },
+ "buttonText": {
+ "type": "string"
+ },
+ "enabled": {
+ "type": "boolean"
+ }
+ }
+ },
"v1.TokenResponse": {
"type": "object",
"properties": {
diff --git a/docs/en/api/swagger-2.0.yaml b/docs/en/api/swagger-2.0.yaml
index 1fc5f05e..d18a8f45 100644
--- a/docs/en/api/swagger-2.0.yaml
+++ b/docs/en/api/swagger-2.0.yaml
@@ -179,6 +179,11 @@ definitions:
items:
$ref: '#/definitions/ent.GroupInvitationToken'
type: array
+ item_templates:
+ description: ItemTemplates holds the value of the item_templates edge.
+ items:
+ $ref: '#/definitions/ent.ItemTemplate'
+ type: array
items:
description: Items holds the value of the items edge.
items:
@@ -414,6 +419,92 @@ definitions:
- $ref: '#/definitions/ent.Item'
description: Item holds the value of the item edge.
type: object
+ ent.ItemTemplate:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ default_description:
+ description: Default description for items created from this template
+ type: string
+ default_insured:
+ description: DefaultInsured holds the value of the "default_insured" field.
+ type: boolean
+ default_label_ids:
+ description: Default label IDs for items created from this template
+ items:
+ type: string
+ type: array
+ default_lifetime_warranty:
+ description: DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty"
+ field.
+ type: boolean
+ default_manufacturer:
+ description: DefaultManufacturer holds the value of the "default_manufacturer"
+ field.
+ type: string
+ default_model_number:
+ description: Default model number for items created from this template
+ type: string
+ default_name:
+ description: Default name template for items (can use placeholders)
+ type: string
+ default_quantity:
+ description: DefaultQuantity holds the value of the "default_quantity" field.
+ type: integer
+ default_warranty_details:
+ description: DefaultWarrantyDetails holds the value of the "default_warranty_details"
+ field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.ItemTemplateEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the ItemTemplateQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ include_purchase_fields:
+ description: Whether to include purchase fields in items created from this
+ template
+ type: boolean
+ include_sold_fields:
+ description: Whether to include sold fields in items created from this template
+ type: boolean
+ include_warranty_fields:
+ description: Whether to include warranty fields in items created from this
+ template
+ type: boolean
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ notes:
+ description: Notes holds the value of the "notes" field.
+ type: string
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.ItemTemplateEdges:
+ properties:
+ fields:
+ description: Fields holds the value of the fields edge.
+ items:
+ $ref: '#/definitions/ent.TemplateField'
+ type: array
+ group:
+ allOf:
+ - $ref: '#/definitions/ent.Group'
+ description: Group holds the value of the group edge.
+ location:
+ allOf:
+ - $ref: '#/definitions/ent.Location'
+ description: Location holds the value of the location edge.
+ type: object
ent.Label:
properties:
color:
@@ -582,6 +673,44 @@ definitions:
- $ref: '#/definitions/ent.User'
description: User holds the value of the user edge.
type: object
+ ent.TemplateField:
+ properties:
+ created_at:
+ description: CreatedAt holds the value of the "created_at" field.
+ type: string
+ description:
+ description: Description holds the value of the "description" field.
+ type: string
+ edges:
+ allOf:
+ - $ref: '#/definitions/ent.TemplateFieldEdges'
+ description: |-
+ Edges holds the relations/edges for other nodes in the graph.
+ The values are being populated by the TemplateFieldQuery when eager-loading is set.
+ id:
+ description: ID of the ent.
+ type: string
+ name:
+ description: Name holds the value of the "name" field.
+ type: string
+ text_value:
+ description: TextValue holds the value of the "text_value" field.
+ type: string
+ type:
+ allOf:
+ - $ref: '#/definitions/templatefield.Type'
+ description: Type holds the value of the "type" field.
+ updated_at:
+ description: UpdatedAt holds the value of the "updated_at" field.
+ type: string
+ type: object
+ ent.TemplateFieldEdges:
+ properties:
+ item_template:
+ allOf:
+ - $ref: '#/definitions/ent.ItemTemplate'
+ description: ItemTemplate holds the value of the item_template edge.
+ type: object
ent.User:
properties:
activated_on:
@@ -608,6 +737,12 @@ definitions:
name:
description: Name holds the value of the "name" field.
type: string
+ oidc_issuer:
+ description: OidcIssuer holds the value of the "oidc_issuer" field.
+ type: string
+ oidc_subject:
+ description: OidcSubject holds the value of the "oidc_subject" field.
+ type: string
role:
allOf:
- $ref: '#/definitions/user.Role'
@@ -944,6 +1079,201 @@ definitions:
updatedAt:
type: string
type: object
+ repo.ItemTemplateCreate:
+ properties:
+ defaultDescription:
+ maxLength: 1000
+ type: string
+ x-nullable: true
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ items:
+ type: string
+ type: array
+ x-nullable: true
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ x-nullable: true
+ defaultManufacturer:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultModelNumber:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultName:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ x-nullable: true
+ defaultWarrantyDetails:
+ maxLength: 1000
+ type: string
+ x-nullable: true
+ description:
+ maxLength: 1000
+ type: string
+ fields:
+ description: Custom fields
+ items:
+ $ref: '#/definitions/repo.TemplateField'
+ type: array
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ notes:
+ maxLength: 1000
+ type: string
+ required:
+ - name
+ type: object
+ repo.ItemTemplateOut:
+ properties:
+ createdAt:
+ type: string
+ defaultDescription:
+ type: string
+ defaultInsured:
+ type: boolean
+ defaultLabels:
+ items:
+ $ref: '#/definitions/repo.TemplateLabelSummary'
+ type: array
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocation:
+ allOf:
+ - $ref: '#/definitions/repo.TemplateLocationSummary'
+ description: Default location and labels
+ defaultManufacturer:
+ type: string
+ defaultModelNumber:
+ type: string
+ defaultName:
+ type: string
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ defaultWarrantyDetails:
+ type: string
+ description:
+ type: string
+ fields:
+ description: Custom fields
+ items:
+ $ref: '#/definitions/repo.TemplateField'
+ type: array
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ type: string
+ notes:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.ItemTemplateSummary:
+ properties:
+ createdAt:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ name:
+ type: string
+ updatedAt:
+ type: string
+ type: object
+ repo.ItemTemplateUpdate:
+ properties:
+ defaultDescription:
+ maxLength: 1000
+ type: string
+ x-nullable: true
+ defaultInsured:
+ type: boolean
+ defaultLabelIds:
+ items:
+ type: string
+ type: array
+ x-nullable: true
+ defaultLifetimeWarranty:
+ type: boolean
+ defaultLocationId:
+ description: Default location and labels
+ type: string
+ x-nullable: true
+ defaultManufacturer:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultModelNumber:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultName:
+ maxLength: 255
+ type: string
+ x-nullable: true
+ defaultQuantity:
+ description: Default values for items
+ type: integer
+ x-nullable: true
+ defaultWarrantyDetails:
+ maxLength: 1000
+ type: string
+ x-nullable: true
+ description:
+ maxLength: 1000
+ type: string
+ fields:
+ description: Custom fields
+ items:
+ $ref: '#/definitions/repo.TemplateField'
+ type: array
+ id:
+ type: string
+ includePurchaseFields:
+ type: boolean
+ includeSoldFields:
+ type: boolean
+ includeWarrantyFields:
+ description: Metadata flags
+ type: boolean
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ notes:
+ maxLength: 1000
+ type: string
+ required:
+ - name
+ type: object
repo.ItemType:
enum:
- location
@@ -1281,6 +1611,31 @@ definitions:
total:
type: integer
type: object
+ repo.TemplateField:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ textValue:
+ type: string
+ type:
+ type: string
+ type: object
+ repo.TemplateLabelSummary:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ type: object
+ repo.TemplateLocationSummary:
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ type: object
repo.TotalsByOrganizer:
properties:
id:
@@ -1319,6 +1674,10 @@ definitions:
type: boolean
name:
type: string
+ oidcIssuer:
+ type: string
+ oidcSubject:
+ type: string
type: object
repo.UserUpdate:
properties:
@@ -1369,6 +1728,12 @@ definitions:
token:
type: string
type: object
+ templatefield.Type:
+ enum:
+ - text
+ type: string
+ x-enum-varnames:
+ - TypeText
user.Role:
enum:
- user
@@ -1395,6 +1760,8 @@ definitions:
$ref: '#/definitions/services.Latest'
message:
type: string
+ oidc:
+ $ref: '#/definitions/v1.OIDCStatus'
title:
type: string
versions:
@@ -1448,6 +1815,27 @@ definitions:
token:
type: string
type: object
+ v1.ItemTemplateCreateItemRequest:
+ properties:
+ description:
+ maxLength: 1000
+ type: string
+ labelIds:
+ items:
+ type: string
+ type: array
+ locationId:
+ type: string
+ name:
+ maxLength: 255
+ minLength: 1
+ type: string
+ quantity:
+ type: integer
+ required:
+ - locationId
+ - name
+ type: object
v1.LoginForm:
properties:
password:
@@ -1459,6 +1847,17 @@ definitions:
type: string
type: object
+ v1.OIDCStatus:
+ properties:
+ allowLocal:
+ type: boolean
+ autoRedirect:
+ type: boolean
+ buttonText:
+ type: string
+ enabled:
+ type: boolean
+ type: object
v1.TokenResponse:
properties:
attachmentToken:
@@ -2679,6 +3078,130 @@ paths:
summary: Application Info
tags:
- Base
+ /v1/templates:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.ItemTemplateSummary'
+ type: array
+ security:
+ - Bearer: []
+ summary: Get All Item Templates
+ tags:
+ - Item Templates
+ post:
+ parameters:
+ - description: Template Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateCreate'
+ produces:
+ - application/json
+ responses:
+ "201":
+ description: Created
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateOut'
+ security:
+ - Bearer: []
+ summary: Create Item Template
+ tags:
+ - Item Templates
+ /v1/templates/{id}:
+ delete:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "204":
+ description: No Content
+ security:
+ - Bearer: []
+ summary: Delete Item Template
+ tags:
+ - Item Templates
+ get:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateOut'
+ security:
+ - Bearer: []
+ summary: Get Item Template
+ tags:
+ - Item Templates
+ put:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Template Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateUpdate'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/repo.ItemTemplateOut'
+ security:
+ - Bearer: []
+ summary: Update Item Template
+ tags:
+ - Item Templates
+ /v1/templates/{id}/create-item:
+ post:
+ parameters:
+ - description: Template ID
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Item Data
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: '#/definitions/v1.ItemTemplateCreateItemRequest'
+ produces:
+ - application/json
+ responses:
+ "201":
+ description: Created
+ schema:
+ $ref: '#/definitions/repo.ItemOut'
+ security:
+ - Bearer: []
+ summary: Create Item from Template
+ tags:
+ - Item Templates
/v1/users/change-password:
put:
parameters:
@@ -2722,6 +3245,35 @@ paths:
summary: User Login
tags:
- Authentication
+ /v1/users/login/oidc:
+ get:
+ produces:
+ - application/json
+ responses:
+ "302":
+ description: Found
+ summary: OIDC Login Initiation
+ tags:
+ - Authentication
+ /v1/users/login/oidc/callback:
+ get:
+ parameters:
+ - description: Authorization code
+ in: query
+ name: code
+ required: true
+ type: string
+ - description: State parameter
+ in: query
+ name: state
+ required: true
+ type: string
+ responses:
+ "302":
+ description: Found
+ summary: OIDC Callback Handler
+ tags:
+ - Authentication
/v1/users/logout:
post:
responses:
@@ -2759,6 +3311,10 @@ paths:
responses:
"204":
description: No Content
+ "403":
+ description: Local login is not enabled
+ schema:
+ type: string
summary: Register New User
tags:
- User
diff --git a/frontend/components/Item/CreateModal.vue b/frontend/components/Item/CreateModal.vue
index 5910e8c0..6f578b16 100644
--- a/frontend/components/Item/CreateModal.vue
+++ b/frontend/components/Item/CreateModal.vue
@@ -1,8 +1,18 @@
<template>
<BaseModal :dialog-id="DialogID.CreateItem" :title="$t('components.item.create_modal.title')">
<template #header-actions>
- <div class="flex">
+ <div class="flex gap-2">
<TooltipProvider :delay-duration="0">
+ <!-- Template selector button -->
+ <Tooltip>
+ <TooltipTrigger>
+ <TemplateSelector v-model="selectedTemplate" compact @template-selected="handleTemplateSelected" />
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>{{ $t("components.template.apply_template") }}</p>
+ </TooltipContent>
+ </Tooltip>
+
<ButtonGroup>
<Tooltip>
<TooltipTrigger>
@@ -31,6 +41,92 @@
<form class="flex flex-col gap-2" @submit.prevent="create()">
<LocationSelector v-model="form.location" />
+
+ <!-- Template Info Display - Collapsible banner with distinct styling -->
+ <div v-if="templateData" class="rounded-lg border-l-4 border-l-primary bg-primary/5 p-3">
+ <div class="flex items-start justify-between gap-2">
+ <div class="flex flex-1 items-start gap-2">
+ <MdiFileDocumentOutline class="mt-0.5 size-4 shrink-0 text-primary" />
+ <div class="flex-1">
+ <h4 class="text-sm font-medium text-foreground">
+ {{ $t("components.template.using_template", { name: templateData.name }) }}
+ </h4>
+ <button
+ type="button"
+ class="mt-1 flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"
+ @click="showTemplateDetails = !showTemplateDetails"
+ >
+ <span v-if="!showTemplateDetails">{{ $t("components.template.show_defaults") }}</span>
+ <span v-else>{{ $t("components.template.hide_defaults") }}</span>
+ <MdiChevronDown class="size-4 transition-transform" :class="{ 'rotate-180': showTemplateDetails }" />
+ </button>
+ </div>
+ </div>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ class="size-7 shrink-0"
+ :aria-label="$t('components.item.create_modal.clear_template')"
+ @click="clearTemplate"
+ >
+ <MdiClose class="size-4" />
+ </Button>
+ </div>
+
+ <!-- Collapsible details section -->
+ <div v-if="showTemplateDetails" class="mt-3 border-t border-primary/20 pt-3">
+ <div class="flex flex-col gap-2 text-xs text-muted-foreground">
+ <p v-if="templateData.description" class="text-foreground/80">{{ templateData.description }}</p>
+ <div class="grid grid-cols-2 gap-x-4 gap-y-1">
+ <div v-if="templateData.defaultName">
+ <span class="font-medium">{{ $t("global.name") }}:</span> {{ templateData.defaultName }}
+ </div>
+ <div>
+ <span class="font-medium">{{ $t("global.quantity") }}:</span> {{ templateData.defaultQuantity }}
+ </div>
+ <div>
+ <span class="font-medium">{{ $t("global.insured") }}:</span>
+ {{ templateData.defaultInsured ? $t("global.yes") : $t("global.no") }}
+ </div>
+ <div v-if="templateData.defaultManufacturer">
+ <span class="font-medium">{{ $t("components.template.form.manufacturer") }}:</span>
+ {{ templateData.defaultManufacturer }}
+ </div>
+ <div v-if="templateData.defaultModelNumber">
+ <span class="font-medium">{{ $t("components.template.form.model_number") }}:</span>
+ {{ templateData.defaultModelNumber }}
+ </div>
+ <div v-if="templateData.defaultLifetimeWarranty">
+ <span class="font-medium">{{ $t("components.template.form.lifetime_warranty") }}:</span>
+ {{ $t("global.yes") }}
+ </div>
+ <div v-if="templateData.defaultLocation">
+ <span class="font-medium">{{ $t("components.template.form.location") }}:</span>
+ {{ templateData.defaultLocation.name }}
+ </div>
+ </div>
+ <div v-if="templateData.defaultLabels && templateData.defaultLabels.length > 0" class="mt-1">
+ <span class="font-medium">{{ $t("global.labels") }}:</span>
+ {{ templateData.defaultLabels.map((l: any) => l.name).join(", ") }}
+ </div>
+ <div v-if="templateData.defaultDescription" class="mt-1">
+ <p class="font-medium">{{ $t("components.template.form.item_description") }}:</p>
+ <p class="ml-2">{{ templateData.defaultDescription }}</p>
+ </div>
+ <div v-if="templateData.fields && templateData.fields.length > 0" class="mt-1">
+ <p class="font-medium">{{ $t("components.template.form.custom_fields") }}:</p>
+ <ul class="ml-4 flex list-none flex-col gap-1">
+ <li v-for="field in templateData.fields" :key="field.id">
+ <span class="font-medium">{{ field.name }}:</span>
+ <span> {{ field.textValue || $t("components.template.empty_value") }}</span>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
<ItemSelector
v-if="subItemCreate"
v-model="parent"
@@ -177,7 +273,7 @@
import BaseModal from "@/components/App/CreateModal.vue";
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
- import type { ItemCreate, LocationOut } from "~~/lib/api/types/data-contracts";
+ import type { ItemCreate, ItemTemplateOut, ItemTemplateSummary, LocationOut } from "~~/lib/api/types/data-contracts";
import { useLabelStore } from "~~/stores/labels";
import { useLocationStore } from "~~/stores/locations";
import MdiBarcode from "~icons/mdi/barcode";
@@ -188,10 +284,14 @@
import MdiRotateClockwise from "~icons/mdi/rotate-clockwise";
import MdiStarOutline from "~icons/mdi/star-outline";
import MdiStar from "~icons/mdi/star";
+ import MdiFileDocumentOutline from "~icons/mdi/file-document-outline";
+ import MdiChevronDown from "~icons/mdi/chevron-down";
+ import MdiClose from "~icons/mdi/close";
import { AttachmentTypes } from "~~/lib/api/types/non-generated";
import { useDialog, useDialogHotkey } from "~/components/ui/dialog-provider";
import LabelSelector from "~/components/Label/Selector.vue";
import ItemSelector from "~/components/Item/Selector.vue";
+ import TemplateSelector from "~/components/Template/Selector.vue";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "~/components/ui/tooltip";
import LocationSelector from "~/components/Location/Selector.vue";
import FormTextField from "~/components/Form/TextField.vue";
@@ -248,8 +348,13 @@
const nameInput = ref<HTMLInputElement | null>(null);
+ const LAST_TEMPLATE_KEY = "homebox:lastUsedTemplate";
+
const loading = ref(false);
const focused = ref(false);
+ const selectedTemplate = ref<ItemTemplateSummary | null>(null);
+ const templateData = ref<ItemTemplateOut | null>(null);
+ const showTemplateDetails = ref(false);
const form = reactive({
location: locations.value && locations.value.length > 0 ? locations.value[0] : ({} as LocationOut),
parentId: null,
@@ -261,6 +366,94 @@
photos: [] as PhotoPreview[],
});
+ async function handleTemplateSelected(template: ItemTemplateSummary | null) {
+ if (!template) {
+ // Template was deselected, clear template data and remove from storage
+ templateData.value = null;
+ form.quantity = 1;
+ localStorage.removeItem(LAST_TEMPLATE_KEY);
+ return;
+ }
+
+ // Load full template details
+ const { data, error } = await api.templates.get(template.id);
+ if (error || !data) {
+ toast.error(t("components.template.toast.load_failed"));
+ return;
+ }
+
+ // Store template data for display and item creation
+ templateData.value = data;
+
+ // Pre-fill form with template defaults
+ form.quantity = data.defaultQuantity;
+ if (data.defaultName) {
+ form.name = data.defaultName;
+ }
+ if (data.defaultDescription) {
+ form.description = data.defaultDescription;
+ }
+ // Pre-fill location if template has one and current form doesn't
+ if (data.defaultLocation && !form.location?.id) {
+ const found = locations.value.find(l => l.id === data.defaultLocation!.id);
+ if (found) {
+ form.location = found;
+ }
+ }
+ // Pre-fill labels from template
+ if (data.defaultLabels && data.defaultLabels.length > 0) {
+ form.labels = data.defaultLabels.map(l => l.id);
+ }
+
+ // Save template ID to localStorage for persistence
+ localStorage.setItem(LAST_TEMPLATE_KEY, template.id);
+
+ toast.success(t("components.template.toast.applied", { name: data.name }));
+ }
+
+ async function restoreLastTemplate() {
+ const lastTemplateId = localStorage.getItem(LAST_TEMPLATE_KEY);
+ if (!lastTemplateId) return;
+
+ // Load the template details
+ const { data, error } = await api.templates.get(lastTemplateId);
+ if (error || !data) {
+ // Template might have been deleted, clear the stored ID
+ localStorage.removeItem(LAST_TEMPLATE_KEY);
+ return;
+ }
+
+ // Set the template
+ selectedTemplate.value = { id: data.id, name: data.name, description: data.description } as ItemTemplateSummary;
+ templateData.value = data;
+ form.quantity = data.defaultQuantity;
+ if (data.defaultName) {
+ form.name = data.defaultName;
+ }
+ if (data.defaultDescription) {
+ form.description = data.defaultDescription;
+ }
+ // Pre-fill location if template has one
+ if (data.defaultLocation) {
+ const found = locations.value.find(l => l.id === data.defaultLocation!.id);
+ if (found) {
+ form.location = found;
+ }
+ }
+ // Pre-fill labels from template
+ if (data.defaultLabels && data.defaultLabels.length > 0) {
+ form.labels = data.defaultLabels.map(l => l.id);
+ }
+ }
+
+ function clearTemplate() {
+ selectedTemplate.value = null;
+ templateData.value = null;
+ showTemplateDetails.value = false;
+ form.quantity = 1;
+ localStorage.removeItem(LAST_TEMPLATE_KEY);
+ }
+
watch(
parent,
newParent => {
@@ -364,6 +557,9 @@
if (labelId.value) {
form.labels = labels.value.filter(l => l.id === labelId.value).map(l => l.id);
}
+
+ // Restore last used template if available
+ await restoreLastTemplate();
});
onUnmounted(cleanup);
@@ -384,16 +580,36 @@
if (shift?.value) close = false;
- const out: ItemCreate = {
- parentId: form.parentId,
- name: form.name,
- quantity: form.quantity,
- description: form.description,
- locationId: form.location.id as string,
- labelIds: form.labels,
- };
-
- const { error, data } = await api.items.create(out);
+ let error, data;
+
+ // If a template is selected, use the template creation endpoint
+ if (templateData.value) {
+ const templateRequest = {
+ name: form.name,
+ description: form.description,
+ locationId: form.location.id as string,
+ labelIds: form.labels,
+ quantity: form.quantity,
+ };
+
+ const result = await api.templates.createItem(templateData.value.id, templateRequest);
+ error = result.error;
+ data = result.data;
+ } else {
+ // Normal item creation without template
+ const out: ItemCreate = {
+ parentId: form.parentId,
+ name: form.name,
+ quantity: form.quantity,
+ description: form.description,
+ locationId: form.location.id as string,
+ labelIds: form.labels,
+ };
+
+ const result = await api.items.create(out);
+ error = result.error;
+ data = result.data;
+ }
if (error) {
loading.value = false;
@@ -434,6 +650,9 @@
form.color = "";
form.photos = [];
form.labels = [];
+ selectedTemplate.value = null;
+ templateData.value = null;
+ showTemplateDetails.value = false;
focused.value = false;
loading.value = false;
diff --git a/frontend/components/Template/Card.vue b/frontend/components/Template/Card.vue
new file mode 100644
index 00000000..080e0f77
--- /dev/null
+++ b/frontend/components/Template/Card.vue
@@ -0,0 +1,119 @@
+<script setup lang="ts">
+ import { useI18n } from "vue-i18n";
+ import { toast } from "@/components/ui/sonner";
+ import MdiPencil from "~icons/mdi/pencil";
+ import MdiDelete from "~icons/mdi/delete";
+ import MdiContentCopy from "~icons/mdi/content-copy";
+ import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
+ import { Button } from "@/components/ui/button";
+ import type { ItemTemplateSummary, ItemTemplateCreate } from "~/lib/api/types/data-contracts";
+
+ const props = defineProps<{
+ template: ItemTemplateSummary;
+ }>();
+
+ const emit = defineEmits<{
+ deleted: [];
+ duplicated: [id: string];
+ }>();
+
+ const api = useUserApi();
+ const confirm = useConfirm();
+ const { t } = useI18n();
+
+ async function handleDelete() {
+ const { isCanceled } = await confirm.open(t("components.template.confirm_delete"));
+ if (isCanceled) return;
+
+ const { error } = await api.templates.delete(props.template.id);
+ if (error) {
+ toast.error(t("components.template.toast.delete_failed"));
+ return;
+ }
+
+ toast.success(t("components.template.toast.deleted"));
+ emit("deleted");
+ }
+
+ async function handleDuplicate() {
+ // First, get the full template details
+ const { data: fullTemplate, error: getError } = await api.templates.get(props.template.id);
+ if (getError || !fullTemplate) {
+ toast.error(t("components.template.toast.load_failed"));
+ return;
+ }
+
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
+
+ // Create a duplicate with "(Copy)" suffix
+ const duplicateData: ItemTemplateCreate = {
+ name: `${fullTemplate.name} (Copy)`,
+ description: fullTemplate.description,
+ notes: fullTemplate.notes,
+ defaultName: fullTemplate.defaultName,
+ defaultDescription: fullTemplate.defaultDescription,
+ defaultQuantity: fullTemplate.defaultQuantity,
+ defaultInsured: fullTemplate.defaultInsured,
+ defaultManufacturer: fullTemplate.defaultManufacturer,
+ defaultModelNumber: fullTemplate.defaultModelNumber,
+ defaultLifetimeWarranty: fullTemplate.defaultLifetimeWarranty,
+ defaultWarrantyDetails: fullTemplate.defaultWarrantyDetails,
+ defaultLocationId: fullTemplate.defaultLocation?.id ?? "",
+ defaultLabelIds: fullTemplate.defaultLabels?.map(l => l.id) || [],
+ includeWarrantyFields: fullTemplate.includeWarrantyFields,
+ includePurchaseFields: fullTemplate.includePurchaseFields,
+ includeSoldFields: fullTemplate.includeSoldFields,
+ fields: fullTemplate.fields.map(field => ({
+ id: NIL_UUID,
+ name: field.name,
+ type: field.type,
+ textValue: field.textValue,
+ })),
+ };
+
+ const { data, error } = await api.templates.create(duplicateData);
+ if (error) {
+ toast.error(t("components.template.toast.duplicate_failed"));
+ return;
+ }
+
+ toast.success(t("components.template.toast.duplicated", { name: duplicateData.name }));
+ emit("duplicated", data.id);
+ }
+</script>
+
+<template>
+ <Card>
+ <CardHeader>
+ <CardTitle class="truncate">{{ template.name }}</CardTitle>
+ <CardDescription v-if="template.description" class="line-clamp-2">
+ {{ template.description }}
+ </CardDescription>
+ </CardHeader>
+ <CardFooter class="flex justify-end gap-1">
+ <Button size="icon" variant="outline" class="size-8" as-child :title="$t('components.template.card.edit')">
+ <NuxtLink :to="`/template/${template.id}`">
+ <MdiPencil class="size-4" />
+ </NuxtLink>
+ </Button>
+ <Button
+ size="icon"
+ variant="outline"
+ class="size-8"
+ :title="$t('components.template.card.duplicate')"
+ @click="handleDuplicate"
+ >
+ <MdiContentCopy class="size-4" />
+ </Button>
+ <Button
+ size="icon"
+ variant="destructive"
+ class="size-8"
+ :title="$t('components.template.card.delete')"
+ @click="handleDelete"
+ >
+ <MdiDelete class="size-4" />
+ </Button>
+ </CardFooter>
+ </Card>
+</template>
diff --git a/frontend/components/Template/CreateModal.vue b/frontend/components/Template/CreateModal.vue
new file mode 100644
index 00000000..8ccbe736
--- /dev/null
+++ b/frontend/components/Template/CreateModal.vue
@@ -0,0 +1,211 @@
+<template>
+ <BaseModal :dialog-id="DialogID.CreateTemplate" :title="$t('components.template.create_modal.title')">
+ <form class="flex flex-col gap-2" @submit.prevent="create()">
+ <FormTextField
+ v-model="form.name"
+ :autofocus="true"
+ :label="$t('components.template.form.template_name')"
+ :max-length="255"
+ :min-length="1"
+ />
+ <FormTextArea
+ v-model="form.description"
+ :label="$t('components.template.form.template_description')"
+ :max-length="1000"
+ />
+
+ <Separator class="my-2" />
+ <h3 class="text-sm font-medium">{{ $t("components.template.form.default_item_values") }}</h3>
+ <div class="grid gap-2">
+ <FormTextField v-model="form.defaultName" :label="$t('components.template.form.item_name')" :max-length="255" />
+ <FormTextArea
+ v-model="form.defaultDescription"
+ :label="$t('components.template.form.item_description')"
+ :max-length="1000"
+ />
+ <div class="grid grid-cols-2 gap-2">
+ <FormTextField v-model.number="form.defaultQuantity" :label="$t('global.quantity')" type="number" :min="1" />
+ <FormTextField
+ v-model="form.defaultModelNumber"
+ :label="$t('components.template.form.model_number')"
+ :max-length="255"
+ />
+ </div>
+ <FormTextField
+ v-model="form.defaultManufacturer"
+ :label="$t('components.template.form.manufacturer')"
+ :max-length="255"
+ />
+ <LocationSelector
+ v-model="form.defaultLocationObject"
+ :label="$t('components.template.form.default_location')"
+ />
+ <LabelSelector v-model="form.defaultLabelIds" :labels="labels ?? []" />
+ <div class="flex items-center gap-4">
+ <div class="flex items-center gap-2">
+ <Switch id="defaultInsured" v-model:checked="form.defaultInsured" />
+ <Label for="defaultInsured" class="text-sm">{{ $t("global.insured") }}</Label>
+ </div>
+ <div class="flex items-center gap-2">
+ <Switch id="defaultLifetimeWarranty" v-model:checked="form.defaultLifetimeWarranty" />
+ <Label for="defaultLifetimeWarranty" class="text-sm">{{
+ $t("components.template.form.lifetime_warranty")
+ }}</Label>
+ </div>
+ </div>
+ </div>
+
+ <Separator class="my-2" />
+ <div class="flex items-center justify-between">
+ <h3 class="text-sm font-medium">{{ $t("components.template.form.custom_fields") }}</h3>
+ <Button type="button" size="sm" variant="outline" @click="addField">
+ <MdiPlus class="mr-1 size-4" />
+ {{ $t("global.add") }}
+ </Button>
+ </div>
+ <div v-if="form.fields.length > 0" class="flex flex-col gap-2">
+ <div v-for="(field, idx) in form.fields" :key="idx" class="flex items-end gap-2">
+ <FormTextField
+ v-model="field.name"
+ :label="$t('components.template.form.field_name')"
+ :max-length="255"
+ class="flex-1"
+ />
+ <FormTextField
+ v-model="field.textValue"
+ :label="$t('components.template.form.default_value')"
+ class="flex-1"
+ />
+ <Button type="button" size="icon" variant="ghost" @click="form.fields.splice(idx, 1)">
+ <MdiDelete class="size-4" />
+ </Button>
+ </div>
+ </div>
+ <p v-else class="text-sm text-muted-foreground">{{ $t("components.template.form.no_custom_fields") }}</p>
+
+ <div class="mt-4 flex justify-end">
+ <Button type="submit" :loading="loading">{{ $t("global.create") }}</Button>
+ </div>
+ </form>
+ </BaseModal>
+</template>
+
+<script setup lang="ts">
+ import { useI18n } from "vue-i18n";
+ import { toast } from "@/components/ui/sonner";
+ import MdiPlus from "~icons/mdi/plus";
+ import MdiDelete from "~icons/mdi/delete";
+ import { DialogID } from "@/components/ui/dialog-provider/utils";
+ import BaseModal from "@/components/App/CreateModal.vue";
+ import { useDialog } from "~/components/ui/dialog-provider";
+ import FormTextField from "~/components/Form/TextField.vue";
+ import FormTextArea from "~/components/Form/TextArea.vue";
+ import { Button } from "~/components/ui/button";
+ import { Separator } from "@/components/ui/separator";
+ import { Switch } from "@/components/ui/switch";
+ import { Label } from "@/components/ui/label";
+ import LocationSelector from "~/components/Location/Selector.vue";
+ import LabelSelector from "~/components/Label/Selector.vue";
+ import { useLabelStore } from "~~/stores/labels";
+ import type { LocationSummary } from "~~/lib/api/types/data-contracts";
+
+ const emit = defineEmits<{ created: [] }>();
+ const { closeDialog } = useDialog();
+
+ const labelStore = useLabelStore();
+ const labels = computed(() => labelStore.labels);
+
+ const loading = ref(false);
+ const form = reactive({
+ name: "",
+ description: "",
+ notes: "",
+ defaultName: "",
+ defaultDescription: "",
+ defaultQuantity: 1,
+ defaultInsured: false,
+ defaultManufacturer: "",
+ defaultModelNumber: "",
+ defaultLifetimeWarranty: false,
+ defaultWarrantyDetails: "",
+ defaultLocationId: null as string | null,
+ defaultLocationObject: null as LocationSummary | null,
+ defaultLabelIds: [] as string[],
+ includeWarrantyFields: false,
+ includePurchaseFields: false,
+ includeSoldFields: false,
+ fields: [] as Array<{ id: string; name: string; type: "text"; textValue: string }>,
+ });
+
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
+
+ function addField() {
+ form.fields.push({ id: NIL_UUID, name: "", type: "text", textValue: "" });
+ }
+
+ function reset() {
+ Object.assign(form, {
+ name: "",
+ description: "",
+ notes: "",
+ defaultName: "",
+ defaultDescription: "",
+ defaultQuantity: 1,
+ defaultInsured: false,
+ defaultManufacturer: "",
+ defaultModelNumber: "",
+ defaultLifetimeWarranty: false,
+ defaultWarrantyDetails: "",
+ defaultLocationId: null,
+ defaultLocationObject: null,
+ defaultLabelIds: [],
+ includeWarrantyFields: false,
+ includePurchaseFields: false,
+ includeSoldFields: false,
+ fields: [],
+ });
+ loading.value = false;
+ }
+
+ const api = useUserApi();
+
+ const { t } = useI18n();
+
+ async function create() {
+ if (loading.value) return;
+ loading.value = true;
+
+ // Prepare the data with proper format for API
+ const createData = {
+ name: form.name,
+ description: form.description,
+ notes: form.notes,
+ defaultName: form.defaultName || null,
+ defaultDescription: form.defaultDescription || null,
+ defaultQuantity: form.defaultQuantity,
+ defaultInsured: form.defaultInsured,
+ defaultManufacturer: form.defaultManufacturer || null,
+ defaultModelNumber: form.defaultModelNumber || null,
+ defaultLifetimeWarranty: form.defaultLifetimeWarranty,
+ defaultWarrantyDetails: form.defaultWarrantyDetails || null,
+ defaultLocationId: form.defaultLocationObject?.id ?? null,
+ defaultLabelIds: form.defaultLabelIds,
+ includeWarrantyFields: form.includeWarrantyFields,
+ includePurchaseFields: form.includePurchaseFields,
+ includeSoldFields: form.includeSoldFields,
+ fields: form.fields,
+ };
+
+ const { error } = await api.templates.create(createData);
+ if (error) {
+ toast.error(t("components.template.toast.create_failed"));
+ loading.value = false;
+ return;
+ }
+
+ toast.success(t("components.template.toast.created"));
+ reset();
+ closeDialog(DialogID.CreateTemplate);
+ emit("created");
+ }
+</script>
diff --git a/frontend/components/Template/Selector.vue b/frontend/components/Template/Selector.vue
new file mode 100644
index 00000000..51570f9a
--- /dev/null
+++ b/frontend/components/Template/Selector.vue
@@ -0,0 +1,149 @@
+<template>
+ <!-- Compact mode: icon button only -->
+ <Popover v-if="compact" v-model:open="open">
+ <PopoverTrigger as-child>
+ <Button
+ :id="id"
+ variant="outline"
+ size="icon"
+ role="combobox"
+ :aria-expanded="open"
+ :class="value ? 'border-primary text-primary' : ''"
+ >
+ <MdiFileDocumentOutline class="size-5" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent class="w-72 p-0" align="end">
+ <Command :ignore-filter="true">
+ <CommandInput
+ v-model="search"
+ :placeholder="$t('components.template.selector.search')"
+ :display-value="_ => ''"
+ />
+ <CommandEmpty>{{ $t("components.template.selector.not_found") }}</CommandEmpty>
+ <CommandList>
+ <CommandGroup>
+ <CommandItem
+ v-for="template in filteredTemplates"
+ :key="template.id"
+ :value="template.id"
+ @select="selectTemplate(template)"
+ >
+ <Check :class="cn('mr-2 h-4 w-4', value?.id === template.id ? 'opacity-100' : 'opacity-0')" />
+ <div class="flex w-full flex-col">
+ <div>{{ template.name }}</div>
+ <div v-if="template.description" class="mt-1 line-clamp-1 text-xs text-muted-foreground">
+ {{ template.description }}
+ </div>
+ </div>
+ </CommandItem>
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+
+ <!-- Full mode: label + full-width button -->
+ <div v-else class="flex flex-col gap-1">
+ <Label :for="id" class="px-1">{{ $t("components.template.selector.label") }}</Label>
+
+ <Popover v-model:open="open">
+ <PopoverTrigger as-child>
+ <Button :id="id" variant="outline" role="combobox" :aria-expanded="open" class="w-full justify-between">
+ {{ value && value.name ? value.name : $t("components.template.selector.select") }}
+ <ChevronsUpDown class="ml-2 size-4 shrink-0 opacity-50" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent class="w-[--reka-popper-anchor-width] p-0">
+ <Command :ignore-filter="true">
+ <CommandInput
+ v-model="search"
+ :placeholder="$t('components.template.selector.search')"
+ :display-value="_ => ''"
+ />
+ <CommandEmpty>{{ $t("components.template.selector.not_found") }}</CommandEmpty>
+ <CommandList>
+ <CommandGroup>
+ <CommandItem
+ v-for="template in filteredTemplates"
+ :key="template.id"
+ :value="template.id"
+ @select="selectTemplate(template)"
+ >
+ <Check :class="cn('mr-2 h-4 w-4', value?.id === template.id ? 'opacity-100' : 'opacity-0')" />
+ <div class="flex w-full flex-col">
+ <div>{{ template.name }}</div>
+ <div v-if="template.description" class="mt-1 line-clamp-1 text-xs text-muted-foreground">
+ {{ template.description }}
+ </div>
+ </div>
+ </CommandItem>
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ </div>
+</template>
+
+<script setup lang="ts">
+ import { Check, ChevronsUpDown } from "lucide-vue-next";
+ import fuzzysort from "fuzzysort";
+ import { Button } from "~/components/ui/button";
+ import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "~/components/ui/command";
+ import { Label } from "~/components/ui/label";
+ import { Popover, PopoverContent, PopoverTrigger } from "~/components/ui/popover";
+ import { cn } from "~/lib/utils";
+ import type { ItemTemplateSummary } from "~~/lib/api/types/data-contracts";
+ import MdiFileDocumentOutline from "~icons/mdi/file-document-outline";
+
+ type Props = {
+ modelValue?: ItemTemplateSummary | null;
+ compact?: boolean;
+ };
+
+ const props = defineProps<Props>();
+ const emit = defineEmits(["update:modelValue", "template-selected"]);
+
+ const { compact } = toRefs(props);
+ const open = ref(false);
+ const search = ref("");
+ const id = useId();
+ const value = useVModel(props, "modelValue", emit);
+
+ const api = useUserApi();
+
+ const { data: templates } = useAsyncData("templates-selector", async () => {
+ const { data, error } = await api.templates.getAll();
+ if (error) {
+ return [];
+ }
+ return data;
+ });
+
+ function selectTemplate(template: ItemTemplateSummary) {
+ if (value.value?.id !== template.id) {
+ value.value = template;
+ emit("template-selected", template);
+ } else {
+ value.value = null;
+ emit("template-selected", null);
+ }
+ open.value = false;
+ }
+
+ const filteredTemplates = computed(() => {
+ if (!templates.value) return [];
+ const filtered = fuzzysort.go(search.value, templates.value, { key: "name", all: true }).map(i => i.obj);
+ return filtered;
+ });
+
+ watch(
+ () => value.value,
+ () => {
+ if (!value.value) {
+ search.value = "";
+ }
+ }
+ );
+</script>
diff --git a/frontend/components/ui/dialog-provider/utils.ts b/frontend/components/ui/dialog-provider/utils.ts
index e49e1831..8cc992cc 100644
--- a/frontend/components/ui/dialog-provider/utils.ts
+++ b/frontend/components/ui/dialog-provider/utils.ts
@@ -10,6 +10,7 @@ export enum DialogID {
CreateLocation = "create-location",
CreateLabel = "create-label",
CreateNotifier = "create-notifier",
+ CreateTemplate = "create-template",
DuplicateSettings = "duplicate-settings",
DuplicateTemporarySettings = "duplicate-temporary-settings",
EditMaintenance = "edit-maintenance",
@@ -23,6 +24,7 @@ export enum DialogID {
PageQRCode = "page-qr-code",
UpdateLabel = "update-label",
UpdateLocation = "update-location",
+ UpdateTemplate = "update-template",
ItemChangeDetails = "item-table-updater",
}
diff --git a/frontend/layouts/default.vue b/frontend/layouts/default.vue
index 7877da5b..df2fa6f2 100644
--- a/frontend/layouts/default.vue
+++ b/frontend/layouts/default.vue
@@ -183,6 +183,7 @@
import MdiWrench from "~icons/mdi/wrench";
import MdiPlus from "~icons/mdi/plus";
import MdiLogout from "~icons/mdi/logout";
+ import MdiFileDocumentMultiple from "~icons/mdi/file-document-multiple";
import {
Sidebar,
@@ -330,6 +331,13 @@
name: computed(() => t("menu.search")),
to: "/items",
},
+ {
+ icon: MdiFileDocumentMultiple,
+ id: 3,
+ active: computed(() => route.path === "/templates"),
+ name: computed(() => t("menu.templates")),
+ to: "/templates",
+ },
{
icon: MdiWrench,
id: 4,
diff --git a/frontend/lib/api/__test__/factories/index.ts b/frontend/lib/api/__test__/factories/index.ts
index 0611a7b9..47e8e20a 100644
--- a/frontend/lib/api/__test__/factories/index.ts
+++ b/frontend/lib/api/__test__/factories/index.ts
@@ -2,7 +2,13 @@ import { faker } from "@faker-js/faker";
import { expect } from "vitest";
import { overrideParts } from "../../base/urls";
import { PublicApi } from "../../public";
-import type { ItemField, LabelCreate, LocationCreate, UserRegistration } from "../../types/data-contracts";
+import type {
+ ItemField,
+ ItemTemplateCreate,
+ LabelCreate,
+ LocationCreate,
+ UserRegistration,
+} from "../../types/data-contracts";
import * as config from "../../../../test/config";
import { UserClient } from "../../user";
import { Requests } from "../../../requests";
@@ -49,6 +55,28 @@ function label(): LabelCreate {
};
}
+function template(): ItemTemplateCreate {
+ return {
+ name: faker.lorem.words(2),
+ description: faker.lorem.sentence(),
+ notes: "",
+ defaultQuantity: 1,
+ defaultInsured: false,
+ defaultName: faker.lorem.word(),
+ defaultDescription: faker.lorem.sentence(),
+ defaultManufacturer: faker.company.name(),
+ defaultModelNumber: faker.string.alphanumeric(10),
+ defaultLifetimeWarranty: false,
+ defaultWarrantyDetails: "",
+ defaultLocationId: null,
+ defaultLabelIds: null,
+ includeWarrantyFields: false,
+ includePurchaseFields: false,
+ includeSoldFields: false,
+ fields: [],
+ };
+}
+
function publicClient(): PublicApi {
overrideParts(config.BASE_URL, "/api/v1");
const requests = new Requests("");
@@ -86,6 +114,7 @@ export const factories = {
user,
location,
label,
+ template,
itemField,
client: {
public: publicClient,
diff --git a/frontend/lib/api/__test__/test-utils.ts b/frontend/lib/api/__test__/test-utils.ts
index 673773de..3ccf33fd 100644
--- a/frontend/lib/api/__test__/test-utils.ts
+++ b/frontend/lib/api/__test__/test-utils.ts
@@ -37,7 +37,7 @@ export async function sharedUserClient(): Promise<UserClient> {
expect(loginResp.status).toBe(200);
cache.token = loginData.token;
- return factories.client.user(data.token);
+ return factories.client.user(loginData.token);
}
beforeAll(async () => {
diff --git a/frontend/lib/api/__test__/user/templates.test.ts b/frontend/lib/api/__test__/user/templates.test.ts
new file mode 100644
index 00000000..a183e624
--- /dev/null
+++ b/frontend/lib/api/__test__/user/templates.test.ts
@@ -0,0 +1,297 @@
+import { describe, expect, test } from "vitest";
+import type { ItemTemplateOut } from "../../types/data-contracts";
+import type { UserClient } from "../../user";
+import { factories } from "../factories";
+import { sharedUserClient } from "../test-utils";
+
+describe("templates lifecycle (create, update, delete)", () => {
+ /**
+ * useTemplate sets up a template resource for testing, and returns a function
+ * that can be used to delete the template from the backend server.
+ */
+ async function useTemplate(api: UserClient): Promise<[ItemTemplateOut, () => Promise<void>]> {
+ const { response, data } = await api.templates.create(factories.template());
+ expect(response.status).toBe(201);
+
+ const cleanup = async () => {
+ const { response } = await api.templates.delete(data.id);
+ expect(response.status).toBe(204);
+ };
+
+ return [data, cleanup];
+ }
+
+ test("user should be able to create a template", async () => {
+ const api = await sharedUserClient();
+
+ const templateData = factories.template();
+
+ const { response, data } = await api.templates.create(templateData);
+
+ expect(response.status).toBe(201);
+ expect(data.id).toBeTruthy();
+
+ // Ensure we can get the template
+ const { response: getResponse, data: getData } = await api.templates.get(data.id);
+
+ expect(getResponse.status).toBe(200);
+ expect(getData.id).toBe(data.id);
+ expect(getData.name).toBe(templateData.name);
+ expect(getData.description).toBe(templateData.description);
+ expect(getData.defaultQuantity).toBe(templateData.defaultQuantity);
+ expect(getData.defaultInsured).toBe(templateData.defaultInsured);
+ expect(getData.defaultName).toBe(templateData.defaultName);
+ expect(getData.defaultDescription).toBe(templateData.defaultDescription);
+ expect(getData.defaultManufacturer).toBe(templateData.defaultManufacturer);
+ expect(getData.defaultModelNumber).toBe(templateData.defaultModelNumber);
+
+ // Cleanup
+ const { response: deleteResponse } = await api.templates.delete(data.id);
+ expect(deleteResponse.status).toBe(204);
+ });
+
+ test("user should be able to get all templates", async () => {
+ const api = await sharedUserClient();
+ const [_, cleanup] = await useTemplate(api);
+
+ const { response, data } = await api.templates.getAll();
+
+ expect(response.status).toBe(200);
+ expect(Array.isArray(data)).toBe(true);
+ expect(data.length).toBeGreaterThanOrEqual(1);
+
+ await cleanup();
+ });
+
+ test("user should be able to update a template", async () => {
+ const api = await sharedUserClient();
+ const [template, cleanup] = await useTemplate(api);
+
+ const updateData = {
+ id: template.id,
+ name: "updated-template-name",
+ description: "updated-description",
+ notes: "updated-notes",
+ defaultQuantity: 5,
+ defaultInsured: true,
+ defaultName: "Updated Default Name",
+ defaultDescription: "Updated Default Description",
+ defaultManufacturer: "Updated Manufacturer",
+ defaultModelNumber: "MODEL-999",
+ defaultLifetimeWarranty: true,
+ defaultWarrantyDetails: "Lifetime coverage",
+ defaultLocationId: null,
+ defaultLabelIds: null,
+ includeWarrantyFields: true,
+ includePurchaseFields: true,
+ includeSoldFields: false,
+ fields: [],
+ };
+
+ const { response, data } = await api.templates.update(template.id, updateData);
+ expect(response.status).toBe(200);
+ expect(data.id).toBe(template.id);
+
+ // Ensure the template was updated
+ const { response: getResponse, data: getData } = await api.templates.get(template.id);
+ expect(getResponse.status).toBe(200);
+ expect(getData.name).toBe(updateData.name);
+ expect(getData.description).toBe(updateData.description);
+ expect(getData.notes).toBe(updateData.notes);
+ expect(getData.defaultQuantity).toBe(updateData.defaultQuantity);
+ expect(getData.defaultInsured).toBe(updateData.defaultInsured);
+ expect(getData.defaultName).toBe(updateData.defaultName);
+ expect(getData.defaultDescription).toBe(updateData.defaultDescription);
+ expect(getData.defaultManufacturer).toBe(updateData.defaultManufacturer);
+ expect(getData.defaultModelNumber).toBe(updateData.defaultModelNumber);
+ expect(getData.defaultLifetimeWarranty).toBe(updateData.defaultLifetimeWarranty);
+ expect(getData.includeWarrantyFields).toBe(updateData.includeWarrantyFields);
+ expect(getData.includePurchaseFields).toBe(updateData.includePurchaseFields);
+
+ await cleanup();
+ });
+
+ test("user should be able to delete a template", async () => {
+ const api = await sharedUserClient();
+ const [template, _] = await useTemplate(api);
+
+ const { response } = await api.templates.delete(template.id);
+ expect(response.status).toBe(204);
+
+ // Ensure we can't get the template
+ const { response: getResponse } = await api.templates.get(template.id);
+ expect(getResponse.status).toBe(404);
+ });
+
+ test("user should be able to create a template with custom fields", async () => {
+ const api = await sharedUserClient();
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
+
+ const templateData = factories.template();
+ templateData.fields = [
+ { id: NIL_UUID, name: "Custom Field 1", type: "text", textValue: "Value 1" },
+ { id: NIL_UUID, name: "Custom Field 2", type: "text", textValue: "Value 2" },
+ ];
+
+ const { response, data } = await api.templates.create(templateData);
+
+ expect(response.status).toBe(201);
+ expect(data.fields).toHaveLength(2);
+ expect(data.fields![0]!.name).toBe("Custom Field 1");
+ expect(data.fields![0]!.textValue).toBe("Value 1");
+ expect(data.fields![1]!.name).toBe("Custom Field 2");
+ expect(data.fields![1]!.textValue).toBe("Value 2");
+
+ // Cleanup
+ const { response: deleteResponse } = await api.templates.delete(data.id);
+ expect(deleteResponse.status).toBe(204);
+ });
+
+ test("user should be able to update template custom fields", async () => {
+ const api = await sharedUserClient();
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
+
+ // Create template with a field
+ const templateData = factories.template();
+ templateData.fields = [{ id: NIL_UUID, name: "Original Field", type: "text", textValue: "Original Value" }];
+
+ const { response: createResponse, data: createdTemplate } = await api.templates.create(templateData);
+ expect(createResponse.status).toBe(201);
+ expect(createdTemplate.fields).toHaveLength(1);
+
+ // Update with modified and new fields
+ const updateData = {
+ id: createdTemplate.id,
+ name: createdTemplate.name,
+ description: createdTemplate.description,
+ notes: createdTemplate.notes,
+ defaultQuantity: createdTemplate.defaultQuantity,
+ defaultInsured: createdTemplate.defaultInsured,
+ defaultName: createdTemplate.defaultName,
+ defaultDescription: createdTemplate.defaultDescription,
+ defaultManufacturer: createdTemplate.defaultManufacturer,
+ defaultModelNumber: createdTemplate.defaultModelNumber,
+ defaultLifetimeWarranty: createdTemplate.defaultLifetimeWarranty,
+ defaultWarrantyDetails: createdTemplate.defaultWarrantyDetails,
+ defaultLocationId: null,
+ defaultLabelIds: null,
+ includeWarrantyFields: createdTemplate.includeWarrantyFields,
+ includePurchaseFields: createdTemplate.includePurchaseFields,
+ includeSoldFields: createdTemplate.includeSoldFields,
+ fields: [
+ { id: createdTemplate.fields![0]!.id, name: "Updated Field", type: "text", textValue: "Updated Value" },
+ { id: NIL_UUID, name: "New Field", type: "text", textValue: "New Value" },
+ ],
+ };
+
+ const { response: updateResponse, data: updatedTemplate } = await api.templates.update(
+ createdTemplate.id,
+ updateData
+ );
+ expect(updateResponse.status).toBe(200);
+ expect(updatedTemplate.fields).toHaveLength(2);
+
+ // Cleanup
+ const { response: deleteResponse } = await api.templates.delete(createdTemplate.id);
+ expect(deleteResponse.status).toBe(204);
+ });
+});
+
+describe("templates with location and labels", () => {
+ test("user should be able to create a template with a default location", async () => {
+ const api = await sharedUserClient();
+
+ // First create a location
+ const locationData = factories.location();
+ const { response: locResponse, data: location } = await api.locations.create(locationData);
+ expect(locResponse.status).toBe(201);
+
+ // Create template with the location
+ const templateData = factories.template();
+ templateData.defaultLocationId = location.id;
+
+ const { response, data } = await api.templates.create(templateData);
+
+ expect(response.status).toBe(201);
+ expect(data.defaultLocation).toBeTruthy();
+ expect(data.defaultLocation?.id).toBe(location.id);
+ expect(data.defaultLocation?.name).toBe(location.name);
+
+ // Cleanup
+ await api.templates.delete(data.id);
+ await api.locations.delete(location.id);
+ });
+
+ test("user should be able to create a template with default labels", async () => {
+ const api = await sharedUserClient();
+
+ // First create some labels
+ const { response: label1Response, data: label1 } = await api.labels.create(factories.label());
+ expect(label1Response.status).toBe(201);
+
+ const { response: label2Response, data: label2 } = await api.labels.create(factories.label());
+ expect(label2Response.status).toBe(201);
+
+ // Create template with labels
+ const templateData = factories.template();
+ templateData.defaultLabelIds = [label1.id, label2.id];
+
+ const { response, data } = await api.templates.create(templateData);
+
+ expect(response.status).toBe(201);
+ expect(data.defaultLabels).toHaveLength(2);
+ expect(data.defaultLabels.map(l => l.id)).toContain(label1.id);
+ expect(data.defaultLabels.map(l => l.id)).toContain(label2.id);
+
+ // Cleanup
+ await api.templates.delete(data.id);
+ await api.labels.delete(label1.id);
+ await api.labels.delete(label2.id);
+ });
+
+ test("user should be able to update template to remove location", async () => {
+ const api = await sharedUserClient();
+
+ // Create a location
+ const { response: locResponse, data: location } = await api.locations.create(factories.location());
+ expect(locResponse.status).toBe(201);
+
+ // Create template with location
+ const templateData = factories.template();
+ templateData.defaultLocationId = location.id;
+
+ const { response: createResponse, data: template } = await api.templates.create(templateData);
+ expect(createResponse.status).toBe(201);
+ expect(template.defaultLocation).toBeTruthy();
+
+ // Update to remove location
+ const updateData = {
+ id: template.id,
+ name: template.name,
+ description: template.description,
+ notes: template.notes,
+ defaultQuantity: template.defaultQuantity,
+ defaultInsured: template.defaultInsured,
+ defaultName: template.defaultName,
+ defaultDescription: template.defaultDescription,
+ defaultManufacturer: template.defaultManufacturer,
+ defaultModelNumber: template.defaultModelNumber,
+ defaultLifetimeWarranty: template.defaultLifetimeWarranty,
+ defaultWarrantyDetails: template.defaultWarrantyDetails,
+ defaultLocationId: null,
+ defaultLabelIds: null,
+ includeWarrantyFields: template.includeWarrantyFields,
+ includePurchaseFields: template.includePurchaseFields,
+ includeSoldFields: template.includeSoldFields,
+ fields: [],
+ };
+
+ const { response: updateResponse, data: updated } = await api.templates.update(template.id, updateData);
+ expect(updateResponse.status).toBe(200);
+ expect(updated.defaultLocation).toBeNull();
+
+ // Cleanup
+ await api.templates.delete(template.id);
+ await api.locations.delete(location.id);
+ });
+});
diff --git a/frontend/lib/api/classes/templates.ts b/frontend/lib/api/classes/templates.ts
new file mode 100644
index 00000000..f9e2e6da
--- /dev/null
+++ b/frontend/lib/api/classes/templates.ts
@@ -0,0 +1,38 @@
+import { BaseAPI, route } from "../base";
+import type {
+ ItemTemplateCreate,
+ ItemTemplateOut,
+ ItemTemplateSummary,
+ ItemTemplateUpdate,
+ ItemTemplateCreateItemRequest,
+ ItemOut,
+} from "../types/data-contracts";
+
+export class TemplatesApi extends BaseAPI {
+ getAll() {
+ return this.http.get<ItemTemplateSummary[]>({ url: route("/templates") });
+ }
+
+ create(body: ItemTemplateCreate) {
+ return this.http.post<ItemTemplateCreate, ItemTemplateOut>({ url: route("/templates"), body });
+ }
+
+ get(id: string) {
+ return this.http.get<ItemTemplateOut>({ url: route(`/templates/${id}`) });
+ }
+
+ delete(id: string) {
+ return this.http.delete<void>({ url: route(`/templates/${id}`) });
+ }
+
+ update(id: string, body: ItemTemplateUpdate) {
+ return this.http.put<ItemTemplateUpdate, ItemTemplateOut>({ url: route(`/templates/${id}`), body });
+ }
+
+ createItem(templateId: string, body: ItemTemplateCreateItemRequest) {
+ return this.http.post<ItemTemplateCreateItemRequest, ItemOut>({
+ url: route(`/templates/${templateId}/create-item`),
+ body,
+ });
+ }
+}
diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.ts
index 19c853ba..10414206 100644
--- a/frontend/lib/api/types/data-contracts.ts
+++ b/frontend/lib/api/types/data-contracts.ts
@@ -17,6 +17,10 @@ export enum UserRole {
RoleOwner = "owner",
}
+export enum TemplatefieldType {
+ TypeText = "text",
+}
+
export enum MaintenanceFilterStatus {
MaintenanceFilterStatusScheduled = "scheduled",
MaintenanceFilterStatusCompleted = "completed",
@@ -154,6 +158,8 @@ export interface EntGroup {
export interface EntGroupEdges {
/** InvitationTokens holds the value of the invitation_tokens edge. */
invitation_tokens: EntGroupInvitationToken[];
+ /** ItemTemplates holds the value of the item_templates edge. */
+ item_templates: EntItemTemplate[];
/** Items holds the value of the items edge. */
items: EntItem[];
/** Labels holds the value of the labels edge. */
@@ -301,6 +307,59 @@ export interface EntItemFieldEdges {
item: EntItem;
}
+export interface EntItemTemplate {
+ /** CreatedAt holds the value of the "created_at" field. */
+ created_at: string;
+ /** Default description for items created from this template */
+ default_description: string;
+ /** DefaultInsured holds the value of the "default_insured" field. */
+ default_insured: boolean;
+ /** Default label IDs for items created from this template */
+ default_label_ids: string[];
+ /** DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty" field. */
+ default_lifetime_warranty: boolean;
+ /** DefaultManufacturer holds the value of the "default_manufacturer" field. */
+ default_manufacturer: string;
+ /** Default model number for items created from this template */
+ default_model_number: string;
+ /** Default name template for items (can use placeholders) */
+ default_name: string;
+ /** DefaultQuantity holds the value of the "default_quantity" field. */
+ default_quantity: number;
+ /** DefaultWarrantyDetails holds the value of the "default_warranty_details" field. */
+ default_warranty_details: string;
+ /** Description holds the value of the "description" field. */
+ description: string;
+ /**
+ * Edges holds the relations/edges for other nodes in the graph.
+ * The values are being populated by the ItemTemplateQuery when eager-loading is set.
+ */
+ edges: EntItemTemplateEdges;
+ /** ID of the ent. */
+ id: string;
+ /** Whether to include purchase fields in items created from this template */
+ include_purchase_fields: boolean;
+ /** Whether to include sold fields in items created from this template */
+ include_sold_fields: boolean;
+ /** Whether to include warranty fields in items created from this template */
+ include_warranty_fields: boolean;
+ /** Name holds the value of the "name" field. */
+ name: string;
+ /** Notes holds the value of the "notes" field. */
+ notes: string;
+ /** UpdatedAt holds the value of the "updated_at" field. */
+ updated_at: string;
+}
+
+export interface EntItemTemplateEdges {
+ /** Fields holds the value of the fields edge. */
+ fields: EntTemplateField[];
+ /** Group holds the value of the group edge. */
+ group: EntGroup;
+ /** Location holds the value of the location edge. */
+ location: EntLocation;
+}
+
export interface EntLabel {
/** Color holds the value of the "color" field. */
color: string;
@@ -417,6 +476,33 @@ export interface EntNotifierEdges {
user: EntUser;
}
+export interface EntTemplateField {
+ /** CreatedAt holds the value of the "created_at" field. */
+ created_at: string;
+ /** Description holds the value of the "description" field. */
+ description: string;
+ /**
+ * Edges holds the relations/edges for other nodes in the graph.
+ * The values are being populated by the TemplateFieldQuery when eager-loading is set.
+ */
+ edges: EntTemplateFieldEdges;
+ /** ID of the ent. */
+ id: string;
+ /** Name holds the value of the "name" field. */
+ name: string;
+ /** TextValue holds the value of the "text_value" field. */
+ text_value: string;
+ /** Type holds the value of the "type" field. */
+ type: TemplatefieldType;
+ /** UpdatedAt holds the value of the "updated_at" field. */
+ updated_at: string;
+}
+
+export interface EntTemplateFieldEdges {
+ /** ItemTemplate holds the value of the item_template edge. */
+ item_template: EntItemTemplate;
+}
+
export interface EntUser {
/** ActivatedOn holds the value of the "activated_on" field. */
activated_on: string;
@@ -435,6 +521,10 @@ export interface EntUser {
is_superuser: boolean;
/** Name holds the value of the "name" field. */
name: string;
+ /** OidcIssuer holds the value of the "oidc_issuer" field. */
+ oidc_issuer: string;
+ /** OidcSubject holds the value of the "oidc_subject" field. */
+ oidc_subject: string;
/** Role holds the value of the "role" field. */
role: UserRole;
/** Superuser holds the value of the "superuser" field. */
@@ -610,6 +700,112 @@ export interface ItemSummary {
updatedAt: Date | string;
}
+export interface ItemTemplateCreate {
+ /** @maxLength 1000 */
+ defaultDescription?: string | null;
+ defaultInsured: boolean;
+ defaultLabelIds?: string[] | null;
+ defaultLifetimeWarranty: boolean;
+ /** Default location and labels */
+ defaultLocationId?: string | null;
+ /** @maxLength 255 */
+ defaultManufacturer?: string | null;
+ /** @maxLength 255 */
+ defaultModelNumber?: string | null;
+ /** @maxLength 255 */
+ defaultName?: string | null;
+ /** Default values for items */
+ defaultQuantity?: number | null;
+ /** @maxLength 1000 */
+ defaultWarrantyDetails?: string | null;
+ /** @maxLength 1000 */
+ description: string;
+ /** Custom fields */
+ fields: TemplateField[];
+ includePurchaseFields: boolean;
+ includeSoldFields: boolean;
+ /** Metadata flags */
+ includeWarrantyFields: boolean;
+ /**
+ * @minLength 1
+ * @maxLength 255
+ */
+ name: string;
+ /** @maxLength 1000 */
+ notes: string;
+}
+
+export interface ItemTemplateOut {
+ createdAt: Date | string;
+ defaultDescription: string;
+ defaultInsured: boolean;
+ defaultLabels: TemplateLabelSummary[];
+ defaultLifetimeWarranty: boolean;
+ /** Default location and labels */
+ defaultLocation: TemplateLocationSummary;
+ defaultManufacturer: string;
+ defaultModelNumber: string;
+ defaultName: string;
+ /** Default values for items */
+ defaultQuantity: number;
+ defaultWarrantyDetails: string;
+ description: string;
+ /** Custom fields */
+ fields: TemplateField[];
+ id: string;
+ includePurchaseFields: boolean;
+ includeSoldFields: boolean;
+ /** Metadata flags */
+ includeWarrantyFields: boolean;
+ name: string;
+ notes: string;
+ updatedAt: Date | string;
+}
+
+export interface ItemTemplateSummary {
+ createdAt: Date | string;
+ description: string;
+ id: string;
+ name: string;
+ updatedAt: Date | string;
+}
+
+export interface ItemTemplateUpdate {
+ /** @maxLength 1000 */
+ defaultDescription?: string | null;
+ defaultInsured: boolean;
+ defaultLabelIds?: string[] | null;
+ defaultLifetimeWarranty: boolean;
+ /** Default location and labels */
+ defaultLocationId?: string | null;
+ /** @maxLength 255 */
+ defaultManufacturer?: string | null;
+ /** @maxLength 255 */
+ defaultModelNumber?: string | null;
+ /** @maxLength 255 */
+ defaultName?: string | null;
+ /** Default values for items */
+ defaultQuantity?: number | null;
+ /** @maxLength 1000 */
+ defaultWarrantyDetails?: string | null;
+ /** @maxLength 1000 */
+ description: string;
+ /** Custom fields */
+ fields: TemplateField[];
+ id: string;
+ includePurchaseFields: boolean;
+ includeSoldFields: boolean;
+ /** Metadata flags */
+ includeWarrantyFields: boolean;
+ /**
+ * @minLength 1
+ * @maxLength 255
+ */
+ name: string;
+ /** @maxLength 1000 */
+ notes: string;
+}
+
export interface ItemUpdate {
archived: boolean;
assetId: string;
@@ -800,6 +996,23 @@ export interface PaginationResultItemSummary {
total: number;
}
+export interface TemplateField {
+ id: string;
+ name: string;
+ textValue: string;
+ type: string;
+}
+
+export interface TemplateLabelSummary {
+ id: string;
+ name: string;
+}
+
+export interface TemplateLocationSummary {
+ id: string;
+ name: string;
+}
+
export interface TotalsByOrganizer {
id: string;
name: string;
@@ -821,6 +1034,8 @@ export interface UserOut {
isOwner: boolean;
isSuperuser: boolean;
name: string;
+ oidcIssuer: string;
+ oidcSubject: string;
}
export interface UserUpdate {
@@ -862,12 +1077,7 @@ export interface APISummary {
labelPrinting: boolean;
latest: Latest;
message: string;
- oidc?: {
- enabled: boolean;
- autoRedirect?: boolean;
- allowLocal?: boolean;
- buttonText?: string;
- };
+ oidc: OIDCStatus;
title: string;
versions: string[];
}
@@ -906,6 +1116,19 @@ export interface ItemAttachmentToken {
token: string;
}
+export interface ItemTemplateCreateItemRequest {
+ /** @maxLength 1000 */
+ description: string;
+ labelIds: string[];
+ locationId: string;
+ /**
+ * @minLength 1
+ * @maxLength 255
+ */
+ name: string;
+ quantity: number;
+}
+
export interface LoginForm {
/** @example "admin" */
password: string;
@@ -914,6 +1137,13 @@ export interface LoginForm {
username: string;
}
+export interface OIDCStatus {
+ allowLocal: boolean;
+ autoRedirect: boolean;
+ buttonText: string;
+ enabled: boolean;
+}
+
export interface TokenResponse {
attachmentToken: string;
expiresAt: Date | string;
diff --git a/frontend/lib/api/user.ts b/frontend/lib/api/user.ts
index ffaede3d..ed1d78c2 100644
--- a/frontend/lib/api/user.ts
+++ b/frontend/lib/api/user.ts
@@ -11,12 +11,14 @@ import { ReportsAPI } from "./classes/reports";
import { NotifiersAPI } from "./classes/notifiers";
import { MaintenanceAPI } from "./classes/maintenance";
import { ProductAPI } from "./classes/product";
+import { TemplatesApi } from "./classes/templates";
import type { Requests } from "~~/lib/requests";
export class UserClient extends BaseAPI {
locations: LocationsApi;
labels: LabelsApi;
items: ItemsApi;
+ templates: TemplatesApi;
maintenance: MaintenanceAPI;
group: GroupApi;
user: UserApi;
@@ -33,6 +35,7 @@ export class UserClient extends BaseAPI {
this.locations = new LocationsApi(requests);
this.labels = new LabelsApi(requests);
this.items = new ItemsApi(requests, attachmentToken);
+ this.templates = new TemplatesApi(requests);
this.maintenance = new MaintenanceAPI(requests);
this.group = new GroupApi(requests);
this.user = new UserApi(requests);
diff --git a/frontend/locales/en.json b/frontend/locales/en.json
index f669bebe..394b251c 100644
--- a/frontend/locales/en.json
+++ b/frontend/locales/en.json
@@ -105,6 +105,7 @@
"rotate_photo": "Rotate photo",
"set_as_primary_photo": "Set as { isPrimary, select, true {non-} false {} other {}}primary photo",
"title": "Create Item",
+ "clear_template": "Clear Template",
"toast": {
"already_creating": "Already creating an item",
"create_failed": "Couldn't create item",
@@ -229,6 +230,65 @@
"quick_menu": {
"no_results": "No results found.",
"shortcut_hint": "Use the number keys to quickly select an action."
+ },
+ "template": {
+ "card": {
+ "delete": "Delete template",
+ "duplicate": "Duplicate template",
+ "edit": "Edit template"
+ },
+ "confirm_delete": "Delete this template?",
+ "create_modal": {
+ "title": "Create Template"
+ },
+ "detail": {
+ "default_values": "Default Values",
+ "updated": "Updated"
+ },
+ "edit_modal": {
+ "title": "Edit Template"
+ },
+ "form": {
+ "custom_fields": "Custom Fields",
+ "default_item_values": "Default Item Values",
+ "default_location": "Default Location",
+ "default_value": "Default Value",
+ "field_name": "Field Name",
+ "item_description": "Item Description",
+ "item_name": "Item Name",
+ "lifetime_warranty": "Lifetime Warranty",
+ "location": "Location",
+ "manufacturer": "Manufacturer",
+ "model_number": "Model Number",
+ "no_custom_fields": "No custom fields.",
+ "template_description": "Template Description",
+ "template_name": "Template Name"
+ },
+ "selector": {
+ "label": "Template (Optional)",
+ "not_found": "No template found",
+ "search": "Search templates...",
+ "select": "Select template..."
+ },
+ "toast": {
+ "applied": "Template \"{name}\" applied",
+ "create_failed": "Failed to create template",
+ "created": "Template created",
+ "delete_failed": "Failed to delete template",
+ "deleted": "Template deleted",
+ "duplicate_failed": "Failed to duplicate template",
+ "duplicated": "Template duplicated as \"{name}\"",
+ "load_failed": "Failed to load template details",
+ "saved_as_template": "Item saved as template \"{name}\"",
+ "update_failed": "Failed to update template",
+ "updated": "Template updated"
+ },
+ "apply_template": "Apply a template",
+ "using_template": "Using template: {name}",
+ "show_defaults": "Show defaults",
+ "hide_defaults": "Hide defaults",
+ "empty_value": "(empty)",
+ "save_as_template": "Save as Template"
}
},
"errors": {
@@ -280,7 +340,9 @@
"value": "Value",
"version": "Version: { version }",
"welcome": "Welcome, { username }",
- "preview": "Preview"
+ "preview": "Preview",
+ "yes": "Yes",
+ "no": "No"
},
"home": {
"labels": "Labels",
@@ -553,8 +615,15 @@
"profile": "Profile",
"scanner": "Scanner",
"search": "Search",
+ "templates": "Templates",
"tools": "Tools"
},
+ "pages": {
+ "templates": {
+ "title": "Templates",
+ "no_templates": "No templates yet."
+ }
+ },
"profile": {
"active": "Active",
"change_password": "Change Password",
diff --git a/frontend/package.json b/frontend/package.json
index 35bf75ee..5e4166e8 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,5 +1,6 @@
{
"private": true,
+ "type": "module",
"scripts": {
"build": "nuxt generate",
"dev": "nuxt dev",
diff --git a/frontend/pages/item/[id]/index.vue b/frontend/pages/item/[id]/index.vue
index 29afd22c..21211533 100644
--- a/frontend/pages/item/[id]/index.vue
+++ b/frontend/pages/item/[id]/index.vue
@@ -9,7 +9,16 @@
import MdiMinus from "~icons/mdi/minus";
import MdiDelete from "~icons/mdi/delete";
import MdiPlusBoxMultipleOutline from "~icons/mdi/plus-box-multiple-outline";
+ import MdiContentSaveEdit from "~icons/mdi/content-save-edit";
+ import MdiDotsVertical from "~icons/mdi/dots-vertical";
import { Separator } from "@/components/ui/separator";
+ import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+ } from "@/components/ui/dropdown-menu";
import {
Breadcrumb,
BreadcrumbItem,
@@ -556,6 +565,53 @@
navigateTo("/home");
}
+ async function saveAsTemplate() {
+ if (!item.value) {
+ return;
+ }
+
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
+
+ // Create template from item data
+ const templateData = {
+ name: `Template: ${item.value.name}`,
+ description: "",
+ notes: "",
+ defaultName: item.value.name,
+ defaultDescription: item.value.description || "",
+ defaultQuantity: item.value.quantity,
+ defaultInsured: item.value.insured,
+ defaultManufacturer: item.value.manufacturer || "",
+ defaultModelNumber: item.value.modelNumber || "",
+ defaultLifetimeWarranty: item.value.lifetimeWarranty,
+ defaultWarrantyDetails: item.value.warrantyDetails || "",
+ defaultLocationId: item.value.location?.id || "",
+ defaultLabelIds: item.value.labels?.map(l => l.id) || [],
+ includeWarrantyFields: !!(
+ item.value.warrantyDetails ||
+ item.value.lifetimeWarranty ||
+ item.value.warrantyExpires
+ ),
+ includePurchaseFields: !!(item.value.purchaseFrom || item.value.purchasePrice || item.value.purchaseTime),
+ includeSoldFields: !!(item.value.soldTo || item.value.soldPrice || item.value.soldTime),
+ fields: item.value.fields.map(field => ({
+ id: NIL_UUID,
+ name: field.name,
+ type: "text",
+ textValue: field.textValue || "",
+ })),
+ };
+
+ const { data, error } = await api.templates.create(templateData);
+ if (error) {
+ toast.error(t("components.template.toast.create_failed"));
+ return;
+ }
+
+ toast.success(t("components.template.toast.saved_as_template", { name: templateData.name }));
+ navigateTo(`/template/${data.id}`);
+ }
+
async function createSubitem() {
// setting URL Parameter that is read and immidiately removed in the Item-CreateModal
await router.push({
@@ -640,7 +696,7 @@
</div>
</div>
</div>
- <div class="ml-auto mt-2 flex flex-wrap items-center justify-between gap-3">
+ <div class="ml-auto mt-2 flex flex-wrap items-center justify-between gap-2">
<LabelMaker
v-if="typeof item.assetId === 'string' && item.assetId != ''"
:id="item.assetId"
@@ -651,14 +707,30 @@
<MdiPlus />
<span class="hidden md:inline">{{ $t("global.create_subitem") }}</span>
</Button>
- <Button class="w-9 md:w-auto" :aria-label="$t('global.duplicate')" @click="handleDuplicateClick">
- <MdiPlusBoxMultipleOutline />
- <span class="hidden md:inline">{{ $t("global.duplicate") }}</span>
- </Button>
- <Button variant="destructive" class="w-9 md:w-auto" :aria-label="$t('global.delete')" @click="deleteItem">
- <MdiDelete />
- <span class="hidden md:inline">{{ $t("global.delete") }}</span>
- </Button>
+
+ <!-- More actions dropdown -->
+ <DropdownMenu>
+ <DropdownMenuTrigger as-child>
+ <Button variant="outline" size="icon" :aria-label="$t('global.more_actions')">
+ <MdiDotsVertical class="size-5" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" class="w-48">
+ <DropdownMenuItem @click="handleDuplicateClick">
+ <MdiPlusBoxMultipleOutline class="mr-2 size-4" />
+ {{ $t("global.duplicate") }}
+ </DropdownMenuItem>
+ <DropdownMenuItem @click="saveAsTemplate">
+ <MdiContentSaveEdit class="mr-2 size-4" />
+ {{ $t("components.template.save_as_template") }}
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem class="text-destructive focus:text-destructive" @click="deleteItem">
+ <MdiDelete class="mr-2 size-4" />
+ {{ $t("global.delete") }}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
</div>
</div>
</header>
diff --git a/frontend/pages/template/[id].vue b/frontend/pages/template/[id].vue
new file mode 100644
index 00000000..78abc1e9
--- /dev/null
+++ b/frontend/pages/template/[id].vue
@@ -0,0 +1,333 @@
+<script setup lang="ts">
+ import { useI18n } from "vue-i18n";
+ import { toast } from "@/components/ui/sonner";
+ import MdiPencil from "~icons/mdi/pencil";
+ import MdiDelete from "~icons/mdi/delete";
+ import MdiPlus from "~icons/mdi/plus";
+ import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
+ import { useDialog } from "@/components/ui/dialog-provider";
+ import { Card } from "@/components/ui/card";
+ import { Button } from "@/components/ui/button";
+ import { Separator } from "@/components/ui/separator";
+ import { Switch } from "@/components/ui/switch";
+ import { Label } from "@/components/ui/label";
+ import { DialogID } from "~/components/ui/dialog-provider/utils";
+ import FormTextField from "~/components/Form/TextField.vue";
+ import FormTextArea from "~/components/Form/TextArea.vue";
+ import BaseContainer from "@/components/Base/Container.vue";
+ import DateTime from "~/components/global/DateTime.vue";
+ import Markdown from "~/components/global/Markdown.vue";
+ import LocationSelector from "~/components/Location/Selector.vue";
+ import LabelSelector from "~/components/Label/Selector.vue";
+ import { useLabelStore } from "~~/stores/labels";
+ import type { LocationOut } from "~~/lib/api/types/data-contracts";
+
+ definePageMeta({
+ middleware: ["auth"],
+ });
+
+ const { openDialog, closeDialog } = useDialog();
+ const route = useRoute();
+ const api = useUserApi();
+ const confirm = useConfirm();
+
+ const labelStore = useLabelStore();
+ const labels = computed(() => labelStore.labels);
+
+ const templateId = computed<string>(() => route.params.id as string);
+
+ const { t } = useI18n();
+
+ const { data: template, refresh } = useAsyncData(templateId.value, async () => {
+ const { data, error } = await api.templates.get(templateId.value);
+ if (error) {
+ toast.error(t("components.template.toast.load_failed"));
+ navigateTo("/templates");
+ return;
+ }
+ return data;
+ });
+
+ async function confirmDelete() {
+ const { isCanceled } = await confirm.open(t("components.template.confirm_delete"));
+ if (isCanceled) return;
+
+ const { error } = await api.templates.delete(templateId.value);
+ if (error) {
+ toast.error(t("components.template.toast.delete_failed"));
+ return;
+ }
+ toast.success(t("components.template.toast.deleted"));
+ navigateTo("/templates");
+ }
+
+ const updating = ref(false);
+ const updateData = reactive({
+ id: "",
+ name: "",
+ description: "",
+ notes: "",
+ defaultName: "",
+ defaultDescription: "",
+ defaultQuantity: 1,
+ defaultInsured: false,
+ defaultManufacturer: "",
+ defaultModelNumber: "",
+ defaultLifetimeWarranty: false,
+ defaultWarrantyDetails: "",
+ defaultLocation: null as LocationOut | null,
+ defaultLabelIds: [] as string[],
+ includeWarrantyFields: false,
+ includePurchaseFields: false,
+ includeSoldFields: false,
+ fields: [] as Array<{ id: string; name: string; type: "text"; textValue: string }>,
+ });
+
+ function openUpdate() {
+ if (!template.value) return;
+ Object.assign(updateData, {
+ id: template.value.id,
+ name: template.value.name,
+ description: template.value.description,
+ notes: template.value.notes,
+ defaultName: template.value.defaultName ?? "",
+ defaultDescription: template.value.defaultDescription ?? "",
+ defaultQuantity: template.value.defaultQuantity,
+ defaultInsured: template.value.defaultInsured,
+ defaultManufacturer: template.value.defaultManufacturer,
+ defaultModelNumber: template.value.defaultModelNumber ?? "",
+ defaultLifetimeWarranty: template.value.defaultLifetimeWarranty,
+ defaultWarrantyDetails: template.value.defaultWarrantyDetails,
+ defaultLocation: template.value.defaultLocation ?? null,
+ defaultLabelIds: template.value.defaultLabels?.map(l => l.id) ?? [],
+ includeWarrantyFields: template.value.includeWarrantyFields,
+ includePurchaseFields: template.value.includePurchaseFields,
+ includeSoldFields: template.value.includeSoldFields,
+ fields: template.value.fields.map(f => ({
+ id: f.id,
+ name: f.name,
+ type: "text" as const,
+ textValue: f.textValue,
+ })),
+ });
+ openDialog(DialogID.UpdateTemplate);
+ }
+
+ async function update() {
+ updating.value = true;
+
+ // Prepare the data with proper format for API
+ const payload = {
+ ...updateData,
+ defaultLocationId: updateData.defaultLocation?.id ?? "",
+ };
+
+ const { error, data } = await api.templates.update(templateId.value, payload);
+ if (error) {
+ updating.value = false;
+ toast.error(t("components.template.toast.update_failed"));
+ return;
+ }
+ toast.success(t("components.template.toast.updated"));
+ template.value = data;
+ closeDialog(DialogID.UpdateTemplate);
+ updating.value = false;
+ refresh();
+ }
+
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
+</script>
+
+<template>
+ <Dialog :dialog-id="DialogID.UpdateTemplate">
+ <DialogContent class="max-h-[90vh] overflow-y-auto">
+ <DialogHeader>
+ <DialogTitle>{{ $t("components.template.edit_modal.title") }}</DialogTitle>
+ </DialogHeader>
+
+ <form v-if="template" class="flex flex-col gap-2" @submit.prevent="update">
+ <FormTextField
+ v-model="updateData.name"
+ :autofocus="true"
+ :label="$t('components.template.form.template_name')"
+ :max-length="255"
+ />
+ <FormTextArea
+ v-model="updateData.description"
+ :label="$t('components.template.form.template_description')"
+ :max-length="1000"
+ />
+
+ <Separator class="my-2" />
+ <h3 class="text-sm font-medium">{{ $t("components.template.form.default_item_values") }}</h3>
+ <div class="grid gap-2">
+ <FormTextField
+ v-model="updateData.defaultName"
+ :label="$t('components.template.form.item_name')"
+ :max-length="255"
+ />
+ <FormTextArea
+ v-model="updateData.defaultDescription"
+ :label="$t('components.template.form.item_description')"
+ :max-length="1000"
+ />
+ <div class="grid grid-cols-2 gap-2">
+ <FormTextField
+ v-model.number="updateData.defaultQuantity"
+ :label="$t('global.quantity')"
+ type="number"
+ :min="1"
+ />
+ <FormTextField
+ v-model="updateData.defaultModelNumber"
+ :label="$t('components.template.form.model_number')"
+ :max-length="255"
+ />
+ </div>
+ <FormTextField
+ v-model="updateData.defaultManufacturer"
+ :label="$t('components.template.form.manufacturer')"
+ :max-length="255"
+ />
+ <LocationSelector
+ v-model="updateData.defaultLocation"
+ :label="$t('components.template.form.default_location')"
+ />
+ <LabelSelector v-model="updateData.defaultLabelIds" :labels="labels ?? []" />
+ <div class="flex items-center gap-4">
+ <div class="flex items-center gap-2">
+ <Switch id="editInsured" v-model:checked="updateData.defaultInsured" />
+ <Label for="editInsured" class="text-sm">{{ $t("global.insured") }}</Label>
+ </div>
+ <div class="flex items-center gap-2">
+ <Switch id="editWarranty" v-model:checked="updateData.defaultLifetimeWarranty" />
+ <Label for="editWarranty" class="text-sm">{{ $t("components.template.form.lifetime_warranty") }}</Label>
+ </div>
+ </div>
+ </div>
+
+ <Separator class="my-2" />
+ <div class="flex items-center justify-between">
+ <h3 class="text-sm font-medium">{{ $t("components.template.form.custom_fields") }}</h3>
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ @click="updateData.fields.push({ id: NIL_UUID, name: '', type: 'text', textValue: '' })"
+ >
+ <MdiPlus class="mr-1 size-4" />
+ {{ $t("global.add") }}
+ </Button>
+ </div>
+ <div v-if="updateData.fields.length > 0" class="flex flex-col gap-2">
+ <div v-for="(field, idx) in updateData.fields" :key="idx" class="flex items-end gap-2">
+ <FormTextField
+ v-model="field.name"
+ :label="$t('components.template.form.field_name')"
+ :max-length="255"
+ class="flex-1"
+ />
+ <FormTextField
+ v-model="field.textValue"
+ :label="$t('components.template.form.default_value')"
+ class="flex-1"
+ />
+ <Button type="button" size="icon" variant="ghost" @click="updateData.fields.splice(idx, 1)">
+ <MdiDelete class="size-4" />
+ </Button>
+ </div>
+ </div>
+
+ <DialogFooter>
+ <Button type="submit" :loading="updating">{{ $t("global.update") }}</Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+
+ <BaseContainer v-if="template">
+ <Title>{{ template.name }}</Title>
+
+ <Card class="p-3">
+ <header :class="{ 'mb-2': template.description }">
+ <div class="flex flex-wrap items-end gap-2">
+ <div>
+ <h1 class="pb-1 text-2xl">{{ template.name }}</h1>
+ <div class="flex flex-wrap gap-1 text-xs text-muted-foreground">
+ <span>{{ $t("global.created") }} <DateTime :date="template.createdAt" /></span>
+ <span>•</span>
+ <span>{{ $t("components.template.detail.updated") }} <DateTime :date="template.updatedAt" /></span>
+ </div>
+ </div>
+ <div class="ml-auto flex gap-2">
+ <Button @click="openUpdate">
+ <MdiPencil class="mr-1" />
+ {{ $t("global.edit") }}
+ </Button>
+ <Button variant="destructive" @click="confirmDelete">
+ <MdiDelete class="mr-1" />
+ {{ $t("global.delete") }}
+ </Button>
+ </div>
+ </div>
+ </header>
+
+ <Separator v-if="template.description" class="my-3" />
+ <Markdown v-if="template.description" :source="template.description" />
+
+ <Separator class="my-3" />
+ <div class="grid gap-4 text-sm md:grid-cols-2">
+ <div>
+ <h3 class="mb-2 font-medium">{{ $t("components.template.detail.default_values") }}</h3>
+ <dl class="flex flex-col gap-1">
+ <div v-if="template.defaultName" class="flex justify-between">
+ <dt class="text-muted-foreground">{{ $t("components.template.form.item_name") }}</dt>
+ <dd>{{ template.defaultName }}</dd>
+ </div>
+ <div v-if="template.defaultDescription" class="flex justify-between">
+ <dt class="text-muted-foreground">{{ $t("components.template.form.item_description") }}</dt>
+ <dd class="max-w-[200px] truncate">{{ template.defaultDescription }}</dd>
+ </div>
+ <div class="flex justify-between">
+ <dt class="text-muted-foreground">{{ $t("global.quantity") }}</dt>
+ <dd>{{ template.defaultQuantity }}</dd>
+ </div>
+ <div v-if="template.defaultModelNumber" class="flex justify-between">
+ <dt class="text-muted-foreground">{{ $t("components.template.form.model_number") }}</dt>
+ <dd>{{ template.defaultModelNumber }}</dd>
+ </div>
+ <div v-if="template.defaultManufacturer" class="flex justify-between">
+ <dt class="text-muted-foreground">{{ $t("components.template.form.manufacturer") }}</dt>
+ <dd>{{ template.defaultManufacturer }}</dd>
+ </div>
+ <div v-if="template.defaultLocation" class="flex justify-between">
+ <dt class="text-muted-foreground">{{ $t("components.template.form.location") }}</dt>
+ <dd>{{ template.defaultLocation.name }}</dd>
+ </div>
+ <div v-if="template.defaultLabels && template.defaultLabels.length > 0" class="flex justify-between">
+ <dt class="text-muted-foreground">{{ $t("global.labels") }}</dt>
+ <dd>{{ template.defaultLabels.map(l => l.name).join(", ") }}</dd>
+ </div>
+ <div class="flex justify-between">
+ <dt class="text-muted-foreground">{{ $t("global.insured") }}</dt>
+ <dd>{{ template.defaultInsured ? $t("global.yes") : $t("global.no") }}</dd>
+ </div>
+ <div class="flex justify-between">
+ <dt class="text-muted-foreground">{{ $t("components.template.form.lifetime_warranty") }}</dt>
+ <dd>{{ template.defaultLifetimeWarranty ? $t("global.yes") : $t("global.no") }}</dd>
+ </div>
+ </dl>
+ </div>
+ <div v-if="template.fields.length > 0">
+ <h3 class="mb-2 font-medium">{{ $t("components.template.form.custom_fields") }}</h3>
+ <dl class="flex flex-col gap-1">
+ <div v-for="field in template.fields" :key="field.id" class="flex justify-between">
+ <dt class="text-muted-foreground">{{ field.name }}</dt>
+ <dd>{{ field.textValue || "—" }}</dd>
+ </div>
+ </dl>
+ </div>
+ </div>
+ </Card>
+ </BaseContainer>
+</template>
diff --git a/frontend/pages/templates.vue b/frontend/pages/templates.vue
new file mode 100644
index 00000000..aa5d54b1
--- /dev/null
+++ b/frontend/pages/templates.vue
@@ -0,0 +1,70 @@
+<script setup lang="ts">
+ import { useI18n } from "vue-i18n";
+ import { toast } from "@/components/ui/sonner";
+ import MdiPlus from "~icons/mdi/plus";
+ import { Button } from "@/components/ui/button";
+ import { useDialog } from "@/components/ui/dialog-provider";
+ import { DialogID } from "~/components/ui/dialog-provider/utils";
+ import BaseContainer from "@/components/Base/Container.vue";
+ import BaseSectionHeader from "@/components/Base/SectionHeader.vue";
+ import TemplateCard from "~/components/Template/Card.vue";
+ import TemplateCreateModal from "~/components/Template/CreateModal.vue";
+
+ definePageMeta({
+ middleware: ["auth"],
+ });
+
+ const { t } = useI18n();
+
+ useHead({
+ title: computed(() => `HomeBox | ${t("pages.templates.title")}`),
+ });
+
+ const api = useUserApi();
+ const { openDialog } = useDialog();
+
+ const { data: templates, refresh } = useAsyncData("templates", async () => {
+ const { data, error } = await api.templates.getAll();
+ if (error) {
+ toast.error(t("components.template.toast.load_failed"));
+ return [];
+ }
+ return data;
+ });
+
+ // Wrapper functions to match event signatures
+ const handleRefresh = () => refresh();
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ const handleDuplicated = (_id: string) => refresh();
+</script>
+<template>
+ <BaseContainer>
+ <div class="mb-4 flex justify-between">
+ <BaseSectionHeader>{{ $t("pages.templates.title") }}</BaseSectionHeader>
+ <Button @click="openDialog(DialogID.CreateTemplate)">
+ <MdiPlus class="mr-2" />
+ {{ $t("global.create") }}
+ </Button>
+ </div>
+
+ <TemplateCreateModal @created="handleRefresh" />
+
+ <div v-if="templates && templates.length > 0" class="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
+ <TemplateCard
+ v-for="tpl in templates"
+ :key="tpl.id"
+ :template="tpl"
+ @deleted="handleRefresh"
+ @duplicated="handleDuplicated"
+ />
+ </div>
+
+ <div v-else class="flex flex-col items-center justify-center py-12 text-center">
+ <p class="mb-4 text-muted-foreground">{{ $t("pages.templates.no_templates") }}</p>
+ <Button @click="openDialog(DialogID.CreateTemplate)">
+ <MdiPlus class="mr-2" />
+ {{ $t("components.template.create_modal.title") }}
+ </Button>
+ </div>
+ </BaseContainer>
+</template>
diff --git a/frontend/test/playwright.config.ts b/frontend/test/playwright.config.ts
index 458efa38..b68213e5 100644
--- a/frontend/test/playwright.config.ts
+++ b/frontend/test/playwright.config.ts
@@ -1,4 +1,5 @@
import { defineConfig, devices } from "@playwright/test";
+import { fileURLToPath } from "node:url";
export default defineConfig({
testDir: "./e2e",
@@ -25,5 +26,5 @@ export default defineConfig({
use: { ...devices["Desktop Safari"] },
},
],
- globalTeardown: require.resolve("./playwright.teardown"),
+ globalTeardown: fileURLToPath(new URL("./playwright.teardown.ts", import.meta.url)),
});