diff --git a/.vscode/launch.json b/.vscode/launch.json index 32daf54d..1b97b1b2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,47 +1,44 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "compounds": [ - { - "name": "Full Stack", - "configurations": ["Launch Backend", "Launch Frontend"], - "stopAll": true - } - ], - "configurations": [ - { - "name": "Launch Backend", - "type": "go", - "request": "launch", - "mode": "debug", - "program": "${workspaceFolder}/backend/app/api/", - "args": [], - "env": { - "HBOX_DEMO": "true", - "HBOX_LOG_LEVEL": "debug", - "HBOX_DEBUG_ENABLED": "true" - }, - "console": "integratedTerminal", - }, - { - "name": "Launch Frontend", - "type": "node", - "request": "launch", - "runtimeExecutable": "pnpm", - "runtimeArgs": [ - "run", - "dev" - ], - "cwd": "${workspaceFolder}/frontend", - "serverReadyAction": { - "action": "debugWithChrome", - "pattern": "Local: +http://localhost:([0-9]+)", - "uriFormat": "http://localhost:%s", - "webRoot": "${workspaceFolder}/frontend" - }, - "console": "integratedTerminal", - } - ] + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "compounds": [ + { + "name": "Full Stack", + "configurations": ["Launch Backend", "Launch Frontend"], + "stopAll": true + } + ], + "configurations": [ + { + "name": "Launch Backend", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "${workspaceFolder}/backend/app/api/", + "args": [], + "env": { + "HBOX_DEMO": "true", + "HBOX_LOG_LEVEL": "debug", + "HBOX_DEBUG_ENABLED": "true" + }, + "console": "integratedTerminal" + }, + { + "name": "Launch Frontend", + "type": "node", + "request": "launch", + "runtimeExecutable": "pnpm", + "runtimeArgs": ["run", "dev"], + "cwd": "${workspaceFolder}/frontend", + "serverReadyAction": { + "action": "debugWithChrome", + "pattern": "Local: +http://localhost:([0-9]+)", + "uriFormat": "http://localhost:%s", + "webRoot": "${workspaceFolder}/frontend" + }, + "console": "integratedTerminal" + } + ] } diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go index 1af68fee..4970f29a 100644 --- a/backend/app/api/static/docs/docs.go +++ b/backend/app/api/static/docs/docs.go @@ -195,6 +195,454 @@ const docTemplate = `{ } } }, + "/v1/entities/{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/entities/{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.EntityAttachmentUpdate" + } + } + ], + "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/entities/{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/entitytype": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Query All Entity Types", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Create Entity Type", + "parameters": [ + { + "description": "Entity Type Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.EntityTypeCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + } + }, + "/v1/entitytype/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Get One Entity Type", + "parameters": [ + { + "type": "string", + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Update Entity Type", + "parameters": [ + { + "type": "string", + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entity Type Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.EntityTypeUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Delete Entity Type", + "parameters": [ + { + "type": "string", + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entity Type Delete Options", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.EntityTypeDelete" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, "/v1/groups": { "get": { "security": [ @@ -416,7 +864,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Query All Items", + "summary": "(Deprecated) Query All Items", + "deprecated": true, "parameters": [ { "type": "string", @@ -482,6 +931,9 @@ const docTemplate = `{ "Bearer": [] } ], + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], @@ -489,6 +941,7 @@ const docTemplate = `{ "Items" ], "summary": "Create Item", + "deprecated": true, "parameters": [ { "description": "Item Data", @@ -520,7 +973,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Export Items", + "summary": "(Deprecated) Export Items", + "deprecated": true, "responses": { "200": { "description": "text/csv", @@ -544,7 +998,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Get All Custom Field Names", + "summary": "(Deprecated) Get All Custom Field Names", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -571,7 +1026,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Get All Custom Field Values", + "summary": "(Deprecated) Get All Custom Field Values", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -601,7 +1057,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Import Items", + "summary": "(Deprecated) Import Items", + "deprecated": true, "parameters": [ { "type": "file", @@ -631,7 +1088,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Get Item", + "summary": "(Deprecated) Get Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -662,7 +1120,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -702,7 +1161,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Delete Item", + "summary": "(Deprecated) Delete Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -730,7 +1190,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -776,6 +1237,7 @@ const docTemplate = `{ "Items Attachments" ], "summary": "Create Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -841,6 +1303,7 @@ const docTemplate = `{ "Items Attachments" ], "summary": "Get Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -876,6 +1339,7 @@ const docTemplate = `{ "Items Attachments" ], "summary": "Update Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -897,7 +1361,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/repo.ItemAttachmentUpdate" + "$ref": "#/definitions/repo.EntityAttachmentUpdate" } } ], @@ -920,6 +1384,7 @@ const docTemplate = `{ "Items Attachments" ], "summary": "Delete Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -999,6 +1464,7 @@ const docTemplate = `{ "Item Maintenance" ], "summary": "Get Maintenance Log", + "deprecated": true, "parameters": [ { "type": "string", @@ -1048,6 +1514,7 @@ const docTemplate = `{ "Item Maintenance" ], "summary": "Create Maintenance Entry", + "deprecated": true, "parameters": [ { "type": "string", @@ -1089,7 +1556,8 @@ const docTemplate = `{ "tags": [ "Items" ], - "summary": "Get the full path of an item", + "summary": "(Deprecated) Get the full path of an item", + "deprecated": true, "parameters": [ { "type": "string", @@ -1394,7 +1862,8 @@ const docTemplate = `{ "tags": [ "Locations" ], - "summary": "Get All Locations", + "summary": "(Deprecated) Get All Locations", + "deprecated": true, "parameters": [ { "type": "boolean", @@ -1427,7 +1896,8 @@ const docTemplate = `{ "tags": [ "Locations" ], - "summary": "Create Location", + "summary": "(Deprecated) Create Location", + "deprecated": true, "parameters": [ { "description": "Location Data", @@ -1462,7 +1932,8 @@ const docTemplate = `{ "tags": [ "Locations" ], - "summary": "Get Locations Tree", + "summary": "(Deprecated) Get Locations Tree", + "deprecated": true, "parameters": [ { "type": "boolean", @@ -1497,7 +1968,8 @@ const docTemplate = `{ "tags": [ "Locations" ], - "summary": "Get Location", + "summary": "(Deprecated) Get Location", + "deprecated": true, "parameters": [ { "type": "string", @@ -1528,7 +2000,8 @@ const docTemplate = `{ "tags": [ "Locations" ], - "summary": "Update Location", + "summary": "(Deprecated) Update Location", + "deprecated": true, "parameters": [ { "type": "string", @@ -1568,7 +2041,8 @@ const docTemplate = `{ "tags": [ "Locations" ], - "summary": "Delete Location", + "summary": "(Deprecated) Delete Location", + "deprecated": true, "parameters": [ { "type": "string", @@ -2560,11 +3034,11 @@ const docTemplate = `{ "ent.AttachmentEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" } ] }, @@ -2673,147 +3147,7 @@ const docTemplate = `{ } } }, - "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": { + "ent.Entity": { "type": "object", "properties": { "archived": { @@ -2833,10 +3167,10 @@ const docTemplate = `{ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/definitions/ent.ItemEdges" + "$ref": "#/definitions/ent.EntityEdges" } ] }, @@ -2908,8 +3242,8 @@ const docTemplate = `{ "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.", + "sync_child_entities_locations": { + "description": "SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.", "type": "boolean" }, "updated_at": { @@ -2926,7 +3260,7 @@ const docTemplate = `{ } } }, - "ent.ItemEdges": { + "ent.EntityEdges": { "type": "object", "properties": { "attachments": { @@ -2940,14 +3274,21 @@ const docTemplate = `{ "description": "Children holds the value of the children edge.", "type": "array", "items": { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" + } + }, + "entity": { + "description": "Entity holds the value of the entity edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Entity" } }, "fields": { "description": "Fields holds the value of the fields edge.", "type": "array", "items": { - "$ref": "#/definitions/ent.ItemField" + "$ref": "#/definitions/ent.EntityField" } }, "group": { @@ -2969,7 +3310,7 @@ const docTemplate = `{ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/definitions/ent.Location" + "$ref": "#/definitions/ent.Entity" } ] }, @@ -2984,13 +3325,21 @@ const docTemplate = `{ "description": "Parent holds the value of the parent edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" + } + ] + }, + "type": { + "description": "Type holds the value of the type edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.EntityType" } ] } } }, - "ent.ItemField": { + "ent.EntityField": { "type": "object", "properties": { "boolean_value": { @@ -3006,10 +3355,10 @@ const docTemplate = `{ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/definitions/ent.ItemFieldEdges" + "$ref": "#/definitions/ent.EntityFieldEdges" } ] }, @@ -3037,7 +3386,7 @@ const docTemplate = `{ "description": "Type holds the value of the \"type\" field.", "allOf": [ { - "$ref": "#/definitions/itemfield.Type" + "$ref": "#/definitions/entityfield.Type" } ] }, @@ -3047,14 +3396,219 @@ const docTemplate = `{ } } }, - "ent.ItemFieldEdges": { + "ent.EntityFieldEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" + } + ] + } + } + }, + "ent.EntityType": { + "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 EntityTypeQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.EntityTypeEdges" + } + ] + }, + "icon": { + "description": "Icon holds the value of the \"icon\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_location": { + "description": "IsLocation holds the value of the \"is_location\" 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" + } + } + }, + "ent.EntityTypeEdges": { + "type": "object", + "properties": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Entity" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + } + } + }, + "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": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Entity" + } + }, + "entity_types": { + "description": "EntityTypes holds the value of the entity_types edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.EntityType" + } + }, + "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" + } + }, + "labels": { + "description": "Labels holds the value of the labels edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "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" } ] } @@ -3170,7 +3724,7 @@ const docTemplate = `{ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/definitions/ent.Location" + "$ref": "#/definitions/ent.Entity" } ] } @@ -3216,64 +3770,11 @@ const docTemplate = `{ "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.", + "entities": { + "description": "Entities holds the value of the entities 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" + "$ref": "#/definitions/ent.Entity" } }, "group": { @@ -3283,21 +3784,6 @@ const docTemplate = `{ "$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" - } - ] } } }, @@ -3328,12 +3814,12 @@ const docTemplate = `{ } ] }, - "id": { - "description": "ID of the ent.", + "entity_id": { + "description": "EntityID holds the value of the \"entity_id\" field.", "type": "string" }, - "item_id": { - "description": "ItemID holds the value of the \"item_id\" field.", + "id": { + "description": "ID of the ent.", "type": "string" }, "name": { @@ -3353,11 +3839,11 @@ const docTemplate = `{ "ent.MaintenanceEntryEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" } ] } @@ -3571,7 +4057,7 @@ const docTemplate = `{ } } }, - "itemfield.Type": { + "entityfield.Type": { "type": "string", "enum": [ "text", @@ -3634,6 +4120,122 @@ const docTemplate = `{ } } }, + "repo.EntityAttachment": { + "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.EntityAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.EntityType": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeCreate": { + "type": "object", + "required": [ + "isLocation", + "name" + ], + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeDelete": { + "type": "object", + "properties": { + "replacementId": { + "$ref": "#/definitions/uuid.NullUUID" + } + } + }, + "repo.EntityTypeUpdate": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + } + } + }, "repo.Group": { "type": "object", "properties": { @@ -3688,55 +4290,10 @@ const docTemplate = `{ } } }, - "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": [ + "entityType", "name" ], "properties": { @@ -3744,6 +4301,9 @@ const docTemplate = `{ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "labelIds": { "type": "array", "items": { @@ -3804,7 +4364,7 @@ const docTemplate = `{ "attachments": { "type": "array", "items": { - "$ref": "#/definitions/repo.ItemAttachment" + "$ref": "#/definitions/repo.EntityAttachment" } }, "createdAt": { @@ -3813,6 +4373,9 @@ const docTemplate = `{ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -3976,6 +4539,9 @@ const docTemplate = `{ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4303,17 +4869,22 @@ const docTemplate = `{ "repo.ItemType": { "type": "string", "enum": [ + "location", + "item", "location", "item" ], "x-enum-varnames": [ "ItemTypeLocation", - "ItemTypeItem" + "ItemTypeItem", + "EntityTypeLocation", + "EntityTypeItem" ] }, "repo.ItemUpdate": { "type": "object", "required": [ + "entityType", "name" ], "properties": { @@ -4327,6 +4898,9 @@ const docTemplate = `{ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -4488,10 +5062,16 @@ const docTemplate = `{ }, "repo.LocationCreate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "name": { "type": "string" }, @@ -4516,6 +5096,9 @@ const docTemplate = `{ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4542,6 +5125,9 @@ const docTemplate = `{ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4565,6 +5151,9 @@ const docTemplate = `{ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4578,10 +5167,16 @@ const docTemplate = `{ }, "repo.LocationUpdate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4998,6 +5593,18 @@ const docTemplate = `{ "RoleOwner" ] }, + "uuid.NullUUID": { + "type": "object", + "properties": { + "uuid": { + "type": "string" + }, + "valid": { + "description": "Valid is true if UUID is not NULL", + "type": "boolean" + } + } + }, "v1.APISummary": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/openapi-3.json b/backend/app/api/static/docs/openapi-3.json index a80a6124..de365553 100644 --- a/backend/app/api/static/docs/openapi-3.json +++ b/backend/app/api/static/docs/openapi-3.json @@ -196,6 +196,456 @@ } } }, + "/v1/entities/{id}/attachments": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Create Item Attachment", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/postV1Entities_id_attachments" + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemOut" + } + } + } + }, + "422": { + "description": "Unprocessable Entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/validate.ErrorResponse" + } + } + } + } + } + } + }, + "/v1/entities/{id}/attachments/{attachment_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Get Item Attachment", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/v1.ItemAttachmentToken" + } + } + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Update Item Attachment", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/repo.EntityAttachmentUpdate" + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/repo.ItemOut" + } + } + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Delete Item Attachment", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/entities/{id}/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Get Maintenance Log", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query", + "schema": { + "type": "string", + "enum": [ + "scheduled", + "completed", + "both" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.MaintenanceEntryWithDetails" + } + } + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Create Maintenance Entry", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/repo.MaintenanceEntryCreate" + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.MaintenanceEntry" + } + } + } + } + } + } + }, + "/v1/entitytype": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Query All Entity Types", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.EntityType" + } + } + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Create Entity Type", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityTypeCreate" + } + } + }, + "description": "Entity Type Data", + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityType" + } + } + } + } + } + } + }, + "/v1/entitytype/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Get One Entity Type", + "parameters": [ + { + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityType" + } + } + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Update Entity Type", + "parameters": [ + { + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityTypeUpdate" + } + } + }, + "description": "Entity Type Data", + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityType" + } + } + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Delete Entity Type", + "parameters": [ + { + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityTypeDelete" + } + } + }, + "description": "Entity Type Delete Options", + "required": true + }, + "responses": { + "204": { + "description": "No Content" + } + } + } + }, "/v1/groups": { "get": { "security": [ @@ -425,7 +875,8 @@ "tags": [ "Items" ], - "summary": "Query All Items", + "summary": "(Deprecated) Query All Items", + "deprecated": true, "parameters": [ { "description": "search string", @@ -511,6 +962,7 @@ "Items" ], "summary": "Create Item", + "deprecated": true, "requestBody": { "content": { "application/json": { @@ -546,7 +998,8 @@ "tags": [ "Items" ], - "summary": "Export Items", + "summary": "(Deprecated) Export Items", + "deprecated": true, "responses": { "200": { "description": "text/csv", @@ -571,7 +1024,8 @@ "tags": [ "Items" ], - "summary": "Get All Custom Field Names", + "summary": "(Deprecated) Get All Custom Field Names", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -599,7 +1053,8 @@ "tags": [ "Items" ], - "summary": "Get All Custom Field Values", + "summary": "(Deprecated) Get All Custom Field Values", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -627,7 +1082,8 @@ "tags": [ "Items" ], - "summary": "Import Items", + "summary": "(Deprecated) Import Items", + "deprecated": true, "requestBody": { "content": { "multipart/form-data": { @@ -665,7 +1121,8 @@ "tags": [ "Items" ], - "summary": "Get Item", + "summary": "(Deprecated) Get Item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -699,7 +1156,8 @@ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -744,7 +1202,8 @@ "tags": [ "Items" ], - "summary": "Delete Item", + "summary": "(Deprecated) Delete Item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -771,7 +1230,8 @@ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -819,6 +1279,7 @@ "Items Attachments" ], "summary": "Create Item Attachment", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -831,37 +1292,7 @@ } ], "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "file": { - "description": "File attachment", - "type": "string", - "format": "binary" - }, - "type": { - "description": "Type of file", - "type": "string" - }, - "primary": { - "description": "Is this the primary attachment", - "type": "boolean" - }, - "name": { - "description": "name of the file including extension", - "type": "string" - } - }, - "required": [ - "file", - "name" - ] - } - } - }, - "required": true + "$ref": "#/components/requestBodies/postV1Entities_id_attachments" }, "responses": { "200": { @@ -898,6 +1329,7 @@ "Items Attachments" ], "summary": "Get Item Attachment", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -941,6 +1373,7 @@ "Items Attachments" ], "summary": "Update Item Attachment", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -962,15 +1395,7 @@ } ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.ItemAttachmentUpdate" - } - } - }, - "description": "Attachment Update", - "required": true + "$ref": "#/components/requestBodies/repo.EntityAttachmentUpdate" }, "responses": { "200": { @@ -995,6 +1420,7 @@ "Items Attachments" ], "summary": "Delete Item Attachment", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1080,6 +1506,7 @@ "Item Maintenance" ], "summary": "Get Maintenance Log", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1134,6 +1561,7 @@ "Item Maintenance" ], "summary": "Create Maintenance Entry", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1146,15 +1574,7 @@ } ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.MaintenanceEntryCreate" - } - } - }, - "description": "Entry Data", - "required": true + "$ref": "#/components/requestBodies/repo.MaintenanceEntryCreate" }, "responses": { "201": { @@ -1180,7 +1600,8 @@ "tags": [ "Items" ], - "summary": "Get the full path of an item", + "summary": "(Deprecated) Get the full path of an item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1510,7 +1931,8 @@ "tags": [ "Locations" ], - "summary": "Get All Locations", + "summary": "(Deprecated) Get All Locations", + "deprecated": true, "parameters": [ { "description": "Filter locations with parents", @@ -1546,7 +1968,8 @@ "tags": [ "Locations" ], - "summary": "Create Location", + "summary": "(Deprecated) Create Location", + "deprecated": true, "requestBody": { "content": { "application/json": { @@ -1582,7 +2005,8 @@ "tags": [ "Locations" ], - "summary": "Get Locations Tree", + "summary": "(Deprecated) Get Locations Tree", + "deprecated": true, "parameters": [ { "description": "include items in response tree", @@ -1620,7 +2044,8 @@ "tags": [ "Locations" ], - "summary": "Get Location", + "summary": "(Deprecated) Get Location", + "deprecated": true, "parameters": [ { "description": "Location ID", @@ -1654,7 +2079,8 @@ "tags": [ "Locations" ], - "summary": "Update Location", + "summary": "(Deprecated) Update Location", + "deprecated": true, "parameters": [ { "description": "Location ID", @@ -1699,7 +2125,8 @@ "tags": [ "Locations" ], - "summary": "Delete Location", + "summary": "(Deprecated) Delete Location", + "deprecated": true, "parameters": [ { "description": "Location ID", @@ -2640,6 +3067,63 @@ } ], "components": { + "requestBodies": { + "postV1Entities_id_attachments": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "description": "File attachment", + "type": "string", + "format": "binary" + }, + "type": { + "description": "Type of file", + "type": "string" + }, + "primary": { + "description": "Is this the primary attachment", + "type": "boolean" + }, + "name": { + "description": "name of the file including extension", + "type": "string" + } + }, + "required": [ + "file", + "name" + ] + } + } + }, + "required": true + }, + "repo.MaintenanceEntryCreate": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.MaintenanceEntryCreate" + } + } + }, + "description": "Entry Data", + "required": true + }, + "repo.EntityAttachmentUpdate": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityAttachmentUpdate" + } + } + }, + "description": "Attachment Update", + "required": true + } + }, "securitySchemes": { "Bearer": { "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"", @@ -2757,11 +3241,11 @@ "ent.AttachmentEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" } ] }, @@ -2870,147 +3354,7 @@ } } }, - "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": "#/components/schemas/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": "#/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", - "items": { - "$ref": "#/components/schemas/ent.Item" - } - }, - "labels": { - "description": "Labels holds the value of the labels edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Label" - } - }, - "locations": { - "description": "Locations holds the value of the locations edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Location" - } - }, - "notifiers": { - "description": "Notifiers holds the value of the notifiers edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Notifier" - } - }, - "users": { - "description": "Users holds the value of the users edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/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": "#/components/schemas/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": "#/components/schemas/ent.Group" - } - ] - } - } - }, - "ent.Item": { + "ent.Entity": { "type": "object", "properties": { "archived": { @@ -3030,10 +3374,10 @@ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/components/schemas/ent.ItemEdges" + "$ref": "#/components/schemas/ent.EntityEdges" } ] }, @@ -3105,8 +3449,8 @@ "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.", + "sync_child_entities_locations": { + "description": "SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.", "type": "boolean" }, "updated_at": { @@ -3123,7 +3467,7 @@ } } }, - "ent.ItemEdges": { + "ent.EntityEdges": { "type": "object", "properties": { "attachments": { @@ -3137,14 +3481,21 @@ "description": "Children holds the value of the children edge.", "type": "array", "items": { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" + } + }, + "entity": { + "description": "Entity holds the value of the entity edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Entity" } }, "fields": { "description": "Fields holds the value of the fields edge.", "type": "array", "items": { - "$ref": "#/components/schemas/ent.ItemField" + "$ref": "#/components/schemas/ent.EntityField" } }, "group": { @@ -3166,7 +3517,7 @@ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Location" + "$ref": "#/components/schemas/ent.Entity" } ] }, @@ -3181,13 +3532,21 @@ "description": "Parent holds the value of the parent edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" + } + ] + }, + "type": { + "description": "Type holds the value of the type edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.EntityType" } ] } } }, - "ent.ItemField": { + "ent.EntityField": { "type": "object", "properties": { "boolean_value": { @@ -3203,10 +3562,10 @@ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/components/schemas/ent.ItemFieldEdges" + "$ref": "#/components/schemas/ent.EntityFieldEdges" } ] }, @@ -3234,7 +3593,7 @@ "description": "Type holds the value of the \"type\" field.", "allOf": [ { - "$ref": "#/components/schemas/itemfield.Type" + "$ref": "#/components/schemas/entityfield.Type" } ] }, @@ -3244,14 +3603,219 @@ } } }, - "ent.ItemFieldEdges": { + "ent.EntityFieldEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" + } + ] + } + } + }, + "ent.EntityType": { + "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 EntityTypeQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.EntityTypeEdges" + } + ] + }, + "icon": { + "description": "Icon holds the value of the \"icon\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_location": { + "description": "IsLocation holds the value of the \"is_location\" 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" + } + } + }, + "ent.EntityTypeEdges": { + "type": "object", + "properties": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Entity" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Group" + } + ] + } + } + }, + "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": "#/components/schemas/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": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Entity" + } + }, + "entity_types": { + "description": "EntityTypes holds the value of the entity_types edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.EntityType" + } + }, + "invitation_tokens": { + "description": "InvitationTokens holds the value of the invitation_tokens edge.", + "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" + } + }, + "labels": { + "description": "Labels holds the value of the labels edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Label" + } + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Notifier" + } + }, + "users": { + "description": "Users holds the value of the users edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/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": "#/components/schemas/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": "#/components/schemas/ent.Group" } ] } @@ -3367,7 +3931,7 @@ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Location" + "$ref": "#/components/schemas/ent.Entity" } ] } @@ -3413,64 +3977,11 @@ "ent.LabelEdges": { "type": "object", "properties": { - "group": { - "description": "Group holds the value of the group edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Group" - } - ] - }, - "items": { - "description": "Items holds the value of the items edge.", + "entities": { + "description": "Entities holds the value of the entities edge.", "type": "array", "items": { - "$ref": "#/components/schemas/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": "#/components/schemas/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": "#/components/schemas/ent.Location" + "$ref": "#/components/schemas/ent.Entity" } }, "group": { @@ -3480,21 +3991,6 @@ "$ref": "#/components/schemas/ent.Group" } ] - }, - "items": { - "description": "Items holds the value of the items edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Item" - } - }, - "parent": { - "description": "Parent holds the value of the parent edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Location" - } - ] } } }, @@ -3525,12 +4021,12 @@ } ] }, - "id": { - "description": "ID of the ent.", + "entity_id": { + "description": "EntityID holds the value of the \"entity_id\" field.", "type": "string" }, - "item_id": { - "description": "ItemID holds the value of the \"item_id\" field.", + "id": { + "description": "ID of the ent.", "type": "string" }, "name": { @@ -3550,11 +4046,11 @@ "ent.MaintenanceEntryEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" } ] } @@ -3768,7 +4264,7 @@ } } }, - "itemfield.Type": { + "entityfield.Type": { "type": "string", "enum": [ "text", @@ -3831,6 +4327,122 @@ } } }, + "repo.EntityAttachment": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "path": { + "type": "string" + }, + "primary": { + "type": "boolean" + }, + "thumbnail": { + "$ref": "#/components/schemas/ent.Attachment" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.EntityAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.EntityType": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeCreate": { + "type": "object", + "required": [ + "isLocation", + "name" + ], + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeDelete": { + "type": "object", + "properties": { + "replacementId": { + "$ref": "#/components/schemas/uuid.NullUUID" + } + } + }, + "repo.EntityTypeUpdate": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + } + } + }, "repo.Group": { "type": "object", "properties": { @@ -3885,55 +4497,10 @@ } } }, - "repo.ItemAttachment": { - "type": "object", - "properties": { - "createdAt": { - "type": "string" - }, - "id": { - "type": "string" - }, - "mimeType": { - "type": "string" - }, - "path": { - "type": "string" - }, - "primary": { - "type": "boolean" - }, - "thumbnail": { - "$ref": "#/components/schemas/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": [ + "entityType", "name" ], "properties": { @@ -3941,6 +4508,9 @@ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "labelIds": { "type": "array", "items": { @@ -4001,7 +4571,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/components/schemas/repo.ItemAttachment" + "$ref": "#/components/schemas/repo.EntityAttachment" } }, "createdAt": { @@ -4010,6 +4580,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -4173,6 +4746,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4500,17 +5076,22 @@ "repo.ItemType": { "type": "string", "enum": [ + "location", + "item", "location", "item" ], "x-enum-varnames": [ "ItemTypeLocation", - "ItemTypeItem" + "ItemTypeItem", + "EntityTypeLocation", + "EntityTypeItem" ] }, "repo.ItemUpdate": { "type": "object", "required": [ + "entityType", "name" ], "properties": { @@ -4524,6 +5105,9 @@ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -4685,10 +5269,16 @@ }, "repo.LocationCreate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "name": { "type": "string" }, @@ -4713,6 +5303,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4739,6 +5332,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4762,6 +5358,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4775,10 +5374,16 @@ }, "repo.LocationUpdate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -5195,6 +5800,18 @@ "RoleOwner" ] }, + "uuid.NullUUID": { + "type": "object", + "properties": { + "uuid": { + "type": "string" + }, + "valid": { + "description": "Valid is true if UUID is not NULL", + "type": "boolean" + } + } + }, "v1.APISummary": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/openapi-3.yaml b/backend/app/api/static/docs/openapi-3.yaml index 0a6d2042..27e5caf7 100644 --- a/backend/app/api/static/docs/openapi-3.yaml +++ b/backend/app/api/static/docs/openapi-3.yaml @@ -115,6 +115,276 @@ paths: application/json: schema: $ref: "#/components/schemas/currencies.Currency" + "/v1/entities/{id}/attachments": + post: + security: + - Bearer: [] + tags: + - Items Attachments + summary: Create Item Attachment + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + requestBody: + $ref: "#/components/requestBodies/postV1Entities_id_attachments" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemOut" + "422": + description: Unprocessable Entity + content: + application/json: + schema: + $ref: "#/components/schemas/validate.ErrorResponse" + "/v1/entities/{id}/attachments/{attachment_id}": + get: + security: + - Bearer: [] + tags: + - Items Attachments + summary: Get Item Attachment + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + - description: Attachment ID + name: attachment_id + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/octet-stream: + schema: + $ref: "#/components/schemas/v1.ItemAttachmentToken" + put: + security: + - Bearer: [] + tags: + - Items Attachments + summary: Update Item Attachment + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + - description: Attachment ID + name: attachment_id + in: path + required: true + schema: + type: string + requestBody: + $ref: "#/components/requestBodies/repo.EntityAttachmentUpdate" + responses: + "200": + description: OK + content: + "*/*": + schema: + $ref: "#/components/schemas/repo.ItemOut" + delete: + security: + - Bearer: [] + tags: + - Items Attachments + summary: Delete Item Attachment + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + - description: Attachment ID + name: attachment_id + in: path + required: true + schema: + type: string + responses: + "204": + description: No Content + "/v1/entities/{id}/maintenance": + get: + security: + - Bearer: [] + tags: + - Item Maintenance + summary: Get Maintenance Log + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + - x-enum-varnames: + - MaintenanceFilterStatusScheduled + - MaintenanceFilterStatusCompleted + - MaintenanceFilterStatusBoth + name: status + in: query + schema: + type: string + enum: + - scheduled + - completed + - both + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/repo.MaintenanceEntryWithDetails" + post: + security: + - Bearer: [] + tags: + - Item Maintenance + summary: Create Maintenance Entry + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + requestBody: + $ref: "#/components/requestBodies/repo.MaintenanceEntryCreate" + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: "#/components/schemas/repo.MaintenanceEntry" + /v1/entitytype: + get: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Query All Entity Types + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/repo.EntityType" + post: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Create Entity Type + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityTypeCreate" + description: Entity Type Data + required: true + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityType" + "/v1/entitytype/{id}": + get: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Get One Entity Type + parameters: + - description: Entity Type ID + name: id + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityType" + put: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Update Entity Type + parameters: + - description: Entity Type ID + name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityTypeUpdate" + description: Entity Type Data + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityType" + delete: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Delete Entity Type + parameters: + - description: Entity Type ID + name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityTypeDelete" + description: Entity Type Delete Options + required: true + responses: + "204": + description: No Content /v1/groups: get: security: @@ -247,7 +517,8 @@ paths: - Bearer: [] tags: - Items - summary: Query All Items + summary: (Deprecated) Query All Items + deprecated: true parameters: - description: search string name: q @@ -301,6 +572,7 @@ paths: tags: - Items summary: Create Item + deprecated: true requestBody: content: application/json: @@ -321,7 +593,8 @@ paths: - Bearer: [] tags: - Items - summary: Export Items + summary: (Deprecated) Export Items + deprecated: true responses: "200": description: text/csv @@ -335,7 +608,8 @@ paths: - Bearer: [] tags: - Items - summary: Get All Custom Field Names + summary: (Deprecated) Get All Custom Field Names + deprecated: true responses: "200": description: OK @@ -351,7 +625,8 @@ paths: - Bearer: [] tags: - Items - summary: Get All Custom Field Values + summary: (Deprecated) Get All Custom Field Values + deprecated: true responses: "200": description: OK @@ -367,7 +642,8 @@ paths: - Bearer: [] tags: - Items - summary: Import Items + summary: (Deprecated) Import Items + deprecated: true requestBody: content: multipart/form-data: @@ -390,7 +666,8 @@ paths: - Bearer: [] tags: - Items - summary: Get Item + summary: (Deprecated) Get Item + deprecated: true parameters: - description: Item ID name: id @@ -410,7 +687,8 @@ paths: - Bearer: [] tags: - Items - summary: Update Item + summary: (Deprecated) Update Item + deprecated: true parameters: - description: Item ID name: id @@ -437,7 +715,8 @@ paths: - Bearer: [] tags: - Items - summary: Delete Item + summary: (Deprecated) Delete Item + deprecated: true parameters: - description: Item ID name: id @@ -453,7 +732,8 @@ paths: - Bearer: [] tags: - Items - summary: Update Item + summary: (Deprecated) Update Item + deprecated: true parameters: - description: Item ID name: id @@ -482,6 +762,7 @@ paths: tags: - Items Attachments summary: Create Item Attachment + deprecated: true parameters: - description: Item ID name: id @@ -490,28 +771,7 @@ paths: schema: type: string requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - file: - description: File attachment - type: string - format: binary - type: - description: Type of file - type: string - primary: - description: Is this the primary attachment - type: boolean - name: - description: name of the file including extension - type: string - required: - - file - - name - required: true + $ref: "#/components/requestBodies/postV1Entities_id_attachments" responses: "200": description: OK @@ -532,6 +792,7 @@ paths: tags: - Items Attachments summary: Get Item Attachment + deprecated: true parameters: - description: Item ID name: id @@ -558,6 +819,7 @@ paths: tags: - Items Attachments summary: Update Item Attachment + deprecated: true parameters: - description: Item ID name: id @@ -572,12 +834,7 @@ paths: schema: type: string requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.ItemAttachmentUpdate" - description: Attachment Update - required: true + $ref: "#/components/requestBodies/repo.EntityAttachmentUpdate" responses: "200": description: OK @@ -591,6 +848,7 @@ paths: tags: - Items Attachments summary: Delete Item Attachment + deprecated: true parameters: - description: Item ID name: id @@ -642,6 +900,7 @@ paths: tags: - Item Maintenance summary: Get Maintenance Log + deprecated: true parameters: - description: Item ID name: id @@ -676,6 +935,7 @@ paths: tags: - Item Maintenance summary: Create Maintenance Entry + deprecated: true parameters: - description: Item ID name: id @@ -684,12 +944,7 @@ paths: schema: type: string requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.MaintenanceEntryCreate" - description: Entry Data - required: true + $ref: "#/components/requestBodies/repo.MaintenanceEntryCreate" responses: "201": description: Created @@ -703,7 +958,8 @@ paths: - Bearer: [] tags: - Items - summary: Get the full path of an item + summary: (Deprecated) Get the full path of an item + deprecated: true parameters: - description: Item ID name: id @@ -897,7 +1153,8 @@ paths: - Bearer: [] tags: - Locations - summary: Get All Locations + summary: (Deprecated) Get All Locations + deprecated: true parameters: - description: Filter locations with parents name: filterChildren @@ -918,7 +1175,8 @@ paths: - Bearer: [] tags: - Locations - summary: Create Location + summary: (Deprecated) Create Location + deprecated: true requestBody: content: application/json: @@ -939,7 +1197,8 @@ paths: - Bearer: [] tags: - Locations - summary: Get Locations Tree + summary: (Deprecated) Get Locations Tree + deprecated: true parameters: - description: include items in response tree name: withItems @@ -961,7 +1220,8 @@ paths: - Bearer: [] tags: - Locations - summary: Get Location + summary: (Deprecated) Get Location + deprecated: true parameters: - description: Location ID name: id @@ -981,7 +1241,8 @@ paths: - Bearer: [] tags: - Locations - summary: Update Location + summary: (Deprecated) Update Location + deprecated: true parameters: - description: Location ID name: id @@ -1008,7 +1269,8 @@ paths: - Bearer: [] tags: - Locations - summary: Delete Location + summary: (Deprecated) Delete Location + deprecated: true parameters: - description: Location ID name: id @@ -1562,6 +1824,44 @@ servers: - url: https://demo.homebox.software/api - url: http://demo.homebox.software/api components: + requestBodies: + postV1Entities_id_attachments: + content: + multipart/form-data: + schema: + type: object + properties: + file: + description: File attachment + type: string + format: binary + type: + description: Type of file + type: string + primary: + description: Is this the primary attachment + type: boolean + name: + description: name of the file including extension + type: string + required: + - file + - name + required: true + repo.MaintenanceEntryCreate: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.MaintenanceEntryCreate" + description: Entry Data + required: true + repo.EntityAttachmentUpdate: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityAttachmentUpdate" + description: Attachment Update + required: true securitySchemes: Bearer: description: "\"Type 'Bearer TOKEN' to correctly set the API Key\"" @@ -1650,10 +1950,10 @@ components: ent.AttachmentEdges: type: object properties: - item: - description: Item holds the value of the item edge. + entity: + description: Entity holds the value of the entity edge. allOf: - - $ref: "#/components/schemas/ent.Item" + - $ref: "#/components/schemas/ent.Entity" thumbnail: description: Thumbnail holds the value of the thumbnail edge. allOf: @@ -1720,107 +2020,7 @@ components: description: User holds the value of the user edge. allOf: - $ref: "#/components/schemas/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. - - The values are being populated by the GroupQuery when eager-loading is set. - allOf: - - $ref: "#/components/schemas/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: "#/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 - items: - $ref: "#/components/schemas/ent.Item" - labels: - description: Labels holds the value of the labels edge. - type: array - items: - $ref: "#/components/schemas/ent.Label" - locations: - description: Locations holds the value of the locations edge. - type: array - items: - $ref: "#/components/schemas/ent.Location" - notifiers: - description: Notifiers holds the value of the notifiers edge. - type: array - items: - $ref: "#/components/schemas/ent.Notifier" - users: - description: Users holds the value of the users edge. - type: array - items: - $ref: "#/components/schemas/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. - - The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. - allOf: - - $ref: "#/components/schemas/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: "#/components/schemas/ent.Group" - ent.Item: + ent.Entity: type: object properties: archived: @@ -1839,9 +2039,9 @@ components: 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. + The values are being populated by the EntityQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.ItemEdges" + - $ref: "#/components/schemas/ent.EntityEdges" id: description: ID of the ent. type: string @@ -1893,9 +2093,9 @@ components: 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. + sync_child_entities_locations: + description: SyncChildEntitiesLocations holds the value of the + "sync_child_entities_locations" field. type: boolean updated_at: description: UpdatedAt holds the value of the "updated_at" field. @@ -1906,7 +2106,7 @@ components: warranty_expires: description: WarrantyExpires holds the value of the "warranty_expires" field. type: string - ent.ItemEdges: + ent.EntityEdges: type: object properties: attachments: @@ -1918,12 +2118,17 @@ components: description: Children holds the value of the children edge. type: array items: - $ref: "#/components/schemas/ent.Item" + $ref: "#/components/schemas/ent.Entity" + entity: + description: Entity holds the value of the entity edge. + type: array + items: + $ref: "#/components/schemas/ent.Entity" fields: description: Fields holds the value of the fields edge. type: array items: - $ref: "#/components/schemas/ent.ItemField" + $ref: "#/components/schemas/ent.EntityField" group: description: Group holds the value of the group edge. allOf: @@ -1936,7 +2141,7 @@ components: location: description: Location holds the value of the location edge. allOf: - - $ref: "#/components/schemas/ent.Location" + - $ref: "#/components/schemas/ent.Entity" maintenance_entries: description: MaintenanceEntries holds the value of the maintenance_entries edge. type: array @@ -1945,8 +2150,12 @@ components: parent: description: Parent holds the value of the parent edge. allOf: - - $ref: "#/components/schemas/ent.Item" - ent.ItemField: + - $ref: "#/components/schemas/ent.Entity" + type: + description: Type holds the value of the type edge. + allOf: + - $ref: "#/components/schemas/ent.EntityType" + ent.EntityField: type: object properties: boolean_value: @@ -1962,9 +2171,9 @@ components: 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. + The values are being populated by the EntityFieldQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.ItemFieldEdges" + - $ref: "#/components/schemas/ent.EntityFieldEdges" id: description: ID of the ent. type: string @@ -1983,17 +2192,163 @@ components: type: description: Type holds the value of the "type" field. allOf: - - $ref: "#/components/schemas/itemfield.Type" + - $ref: "#/components/schemas/entityfield.Type" updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string - ent.ItemFieldEdges: + ent.EntityFieldEdges: type: object properties: - item: - description: Item holds the value of the item edge. + entity: + description: Entity holds the value of the entity edge. allOf: - - $ref: "#/components/schemas/ent.Item" + - $ref: "#/components/schemas/ent.Entity" + ent.EntityType: + 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. + + The values are being populated by the EntityTypeQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.EntityTypeEdges" + icon: + description: Icon holds the value of the "icon" field. + type: string + id: + description: ID of the ent. + type: string + is_location: + description: IsLocation holds the value of the "is_location" 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 + ent.EntityTypeEdges: + type: object + properties: + entities: + description: Entities holds the value of the entities edge. + type: array + items: + $ref: "#/components/schemas/ent.Entity" + group: + description: Group holds the value of the group edge. + allOf: + - $ref: "#/components/schemas/ent.Group" + 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. + + The values are being populated by the GroupQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/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: + entities: + description: Entities holds the value of the entities edge. + type: array + items: + $ref: "#/components/schemas/ent.Entity" + entity_types: + description: EntityTypes holds the value of the entity_types edge. + type: array + items: + $ref: "#/components/schemas/ent.EntityType" + invitation_tokens: + description: InvitationTokens holds the value of the invitation_tokens edge. + 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" + labels: + description: Labels holds the value of the labels edge. + type: array + items: + $ref: "#/components/schemas/ent.Label" + notifiers: + description: Notifiers holds the value of the notifiers edge. + type: array + items: + $ref: "#/components/schemas/ent.Notifier" + users: + description: Users holds the value of the users edge. + type: array + items: + $ref: "#/components/schemas/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. + + The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/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: "#/components/schemas/ent.Group" ent.ItemTemplate: type: object properties: @@ -2080,7 +2435,7 @@ components: location: description: Location holds the value of the location edge. allOf: - - $ref: "#/components/schemas/ent.Location" + - $ref: "#/components/schemas/ent.Entity" ent.Label: type: object properties: @@ -2112,61 +2467,15 @@ components: ent.LabelEdges: type: object properties: + entities: + description: Entities holds the value of the entities edge. + type: array + items: + $ref: "#/components/schemas/ent.Entity" group: description: Group holds the value of the group edge. allOf: - $ref: "#/components/schemas/ent.Group" - items: - description: Items holds the value of the items edge. - type: array - items: - $ref: "#/components/schemas/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. - - The values are being populated by the LocationQuery when eager-loading is set. - allOf: - - $ref: "#/components/schemas/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: "#/components/schemas/ent.Location" - group: - description: Group holds the value of the group edge. - allOf: - - $ref: "#/components/schemas/ent.Group" - items: - description: Items holds the value of the items edge. - type: array - items: - $ref: "#/components/schemas/ent.Item" - parent: - description: Parent holds the value of the parent edge. - allOf: - - $ref: "#/components/schemas/ent.Location" ent.MaintenanceEntry: type: object properties: @@ -2189,12 +2498,12 @@ components: The values are being populated by the MaintenanceEntryQuery when eager-loading is set. allOf: - $ref: "#/components/schemas/ent.MaintenanceEntryEdges" + entity_id: + description: EntityID holds the value of the "entity_id" field. + type: string 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 @@ -2207,10 +2516,10 @@ components: ent.MaintenanceEntryEdges: type: object properties: - item: - description: Item holds the value of the item edge. + entity: + description: Entity holds the value of the entity edge. allOf: - - $ref: "#/components/schemas/ent.Item" + - $ref: "#/components/schemas/ent.Entity" ent.Notifier: type: object properties: @@ -2353,7 +2662,7 @@ components: type: array items: $ref: "#/components/schemas/ent.Notifier" - itemfield.Type: + entityfield.Type: type: string enum: - text @@ -2397,6 +2706,82 @@ components: type: boolean copyPrefix: type: string + repo.EntityAttachment: + type: object + properties: + createdAt: + type: string + id: + type: string + mimeType: + type: string + path: + type: string + primary: + type: boolean + thumbnail: + $ref: "#/components/schemas/ent.Attachment" + title: + type: string + type: + type: string + updatedAt: + type: string + repo.EntityAttachmentUpdate: + type: object + properties: + primary: + type: boolean + title: + type: string + type: + type: string + repo.EntityType: + type: object + properties: + color: + type: string + description: + type: string + icon: + type: string + isLocation: + type: boolean + name: + type: string + repo.EntityTypeCreate: + type: object + required: + - isLocation + - name + properties: + color: + type: string + description: + type: string + icon: + type: string + isLocation: + type: boolean + name: + type: string + repo.EntityTypeDelete: + type: object + properties: + replacementId: + $ref: "#/components/schemas/uuid.NullUUID" + repo.EntityTypeUpdate: + type: object + properties: + color: + type: string + description: + type: string + icon: + type: string + name: + type: string + minLength: 1 repo.Group: type: object properties: @@ -2432,44 +2817,17 @@ components: 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: "#/components/schemas/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: + - entityType - name properties: description: type: string maxLength: 1000 + entityType: + type: string labelIds: type: array items: @@ -2512,11 +2870,13 @@ components: attachments: type: array items: - $ref: "#/components/schemas/repo.ItemAttachment" + $ref: "#/components/schemas/repo.EntityAttachment" createdAt: type: string description: type: string + entityType: + type: string fields: type: array items: @@ -2628,6 +2988,8 @@ components: type: string description: type: string + entityType: + type: string id: type: string imageId: @@ -2861,12 +3223,17 @@ components: enum: - location - item + - location + - item x-enum-varnames: - ItemTypeLocation - ItemTypeItem + - EntityTypeLocation + - EntityTypeItem repo.ItemUpdate: type: object required: + - entityType - name properties: archived: @@ -2876,6 +3243,8 @@ components: description: type: string maxLength: 1000 + entityType: + type: string fields: type: array items: @@ -2988,9 +3357,13 @@ components: type: string repo.LocationCreate: type: object + required: + - entityType properties: description: type: string + entityType: + type: string name: type: string parentId: @@ -3007,6 +3380,8 @@ components: type: string description: type: string + entityType: + type: string id: type: string name: @@ -3024,6 +3399,8 @@ components: type: string description: type: string + entityType: + type: string id: type: string itemCount: @@ -3039,6 +3416,8 @@ components: type: string description: type: string + entityType: + type: string id: type: string name: @@ -3047,9 +3426,13 @@ components: type: string repo.LocationUpdate: type: object + required: + - entityType properties: description: type: string + entityType: + type: string id: type: string name: @@ -3326,6 +3709,14 @@ components: - DefaultRole - RoleUser - RoleOwner + uuid.NullUUID: + type: object + properties: + uuid: + type: string + valid: + description: Valid is true if UUID is not NULL + type: boolean v1.APISummary: type: object properties: diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json index 61b8612a..c0ef4e99 100644 --- a/backend/app/api/static/docs/swagger.json +++ b/backend/app/api/static/docs/swagger.json @@ -193,6 +193,454 @@ } } }, + "/v1/entities/{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/entities/{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.EntityAttachmentUpdate" + } + } + ], + "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/entities/{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/entitytype": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Query All Entity Types", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Create Entity Type", + "parameters": [ + { + "description": "Entity Type Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.EntityTypeCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + } + }, + "/v1/entitytype/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Get One Entity Type", + "parameters": [ + { + "type": "string", + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Update Entity Type", + "parameters": [ + { + "type": "string", + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entity Type Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.EntityTypeUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Delete Entity Type", + "parameters": [ + { + "type": "string", + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entity Type Delete Options", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.EntityTypeDelete" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, "/v1/groups": { "get": { "security": [ @@ -414,7 +862,8 @@ "tags": [ "Items" ], - "summary": "Query All Items", + "summary": "(Deprecated) Query All Items", + "deprecated": true, "parameters": [ { "type": "string", @@ -480,6 +929,9 @@ "Bearer": [] } ], + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], @@ -487,6 +939,7 @@ "Items" ], "summary": "Create Item", + "deprecated": true, "parameters": [ { "description": "Item Data", @@ -518,7 +971,8 @@ "tags": [ "Items" ], - "summary": "Export Items", + "summary": "(Deprecated) Export Items", + "deprecated": true, "responses": { "200": { "description": "text/csv", @@ -542,7 +996,8 @@ "tags": [ "Items" ], - "summary": "Get All Custom Field Names", + "summary": "(Deprecated) Get All Custom Field Names", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -569,7 +1024,8 @@ "tags": [ "Items" ], - "summary": "Get All Custom Field Values", + "summary": "(Deprecated) Get All Custom Field Values", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -599,7 +1055,8 @@ "tags": [ "Items" ], - "summary": "Import Items", + "summary": "(Deprecated) Import Items", + "deprecated": true, "parameters": [ { "type": "file", @@ -629,7 +1086,8 @@ "tags": [ "Items" ], - "summary": "Get Item", + "summary": "(Deprecated) Get Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -660,7 +1118,8 @@ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -700,7 +1159,8 @@ "tags": [ "Items" ], - "summary": "Delete Item", + "summary": "(Deprecated) Delete Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -728,7 +1188,8 @@ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -774,6 +1235,7 @@ "Items Attachments" ], "summary": "Create Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -839,6 +1301,7 @@ "Items Attachments" ], "summary": "Get Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -874,6 +1337,7 @@ "Items Attachments" ], "summary": "Update Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -895,7 +1359,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/repo.ItemAttachmentUpdate" + "$ref": "#/definitions/repo.EntityAttachmentUpdate" } } ], @@ -918,6 +1382,7 @@ "Items Attachments" ], "summary": "Delete Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -997,6 +1462,7 @@ "Item Maintenance" ], "summary": "Get Maintenance Log", + "deprecated": true, "parameters": [ { "type": "string", @@ -1046,6 +1512,7 @@ "Item Maintenance" ], "summary": "Create Maintenance Entry", + "deprecated": true, "parameters": [ { "type": "string", @@ -1087,7 +1554,8 @@ "tags": [ "Items" ], - "summary": "Get the full path of an item", + "summary": "(Deprecated) Get the full path of an item", + "deprecated": true, "parameters": [ { "type": "string", @@ -1392,7 +1860,8 @@ "tags": [ "Locations" ], - "summary": "Get All Locations", + "summary": "(Deprecated) Get All Locations", + "deprecated": true, "parameters": [ { "type": "boolean", @@ -1425,7 +1894,8 @@ "tags": [ "Locations" ], - "summary": "Create Location", + "summary": "(Deprecated) Create Location", + "deprecated": true, "parameters": [ { "description": "Location Data", @@ -1460,7 +1930,8 @@ "tags": [ "Locations" ], - "summary": "Get Locations Tree", + "summary": "(Deprecated) Get Locations Tree", + "deprecated": true, "parameters": [ { "type": "boolean", @@ -1495,7 +1966,8 @@ "tags": [ "Locations" ], - "summary": "Get Location", + "summary": "(Deprecated) Get Location", + "deprecated": true, "parameters": [ { "type": "string", @@ -1526,7 +1998,8 @@ "tags": [ "Locations" ], - "summary": "Update Location", + "summary": "(Deprecated) Update Location", + "deprecated": true, "parameters": [ { "type": "string", @@ -1566,7 +2039,8 @@ "tags": [ "Locations" ], - "summary": "Delete Location", + "summary": "(Deprecated) Delete Location", + "deprecated": true, "parameters": [ { "type": "string", @@ -2558,11 +3032,11 @@ "ent.AttachmentEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" } ] }, @@ -2671,147 +3145,7 @@ } } }, - "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": { + "ent.Entity": { "type": "object", "properties": { "archived": { @@ -2831,10 +3165,10 @@ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/definitions/ent.ItemEdges" + "$ref": "#/definitions/ent.EntityEdges" } ] }, @@ -2906,8 +3240,8 @@ "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.", + "sync_child_entities_locations": { + "description": "SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.", "type": "boolean" }, "updated_at": { @@ -2924,7 +3258,7 @@ } } }, - "ent.ItemEdges": { + "ent.EntityEdges": { "type": "object", "properties": { "attachments": { @@ -2938,14 +3272,21 @@ "description": "Children holds the value of the children edge.", "type": "array", "items": { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" + } + }, + "entity": { + "description": "Entity holds the value of the entity edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Entity" } }, "fields": { "description": "Fields holds the value of the fields edge.", "type": "array", "items": { - "$ref": "#/definitions/ent.ItemField" + "$ref": "#/definitions/ent.EntityField" } }, "group": { @@ -2967,7 +3308,7 @@ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/definitions/ent.Location" + "$ref": "#/definitions/ent.Entity" } ] }, @@ -2982,13 +3323,21 @@ "description": "Parent holds the value of the parent edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" + } + ] + }, + "type": { + "description": "Type holds the value of the type edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.EntityType" } ] } } }, - "ent.ItemField": { + "ent.EntityField": { "type": "object", "properties": { "boolean_value": { @@ -3004,10 +3353,10 @@ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/definitions/ent.ItemFieldEdges" + "$ref": "#/definitions/ent.EntityFieldEdges" } ] }, @@ -3035,7 +3384,7 @@ "description": "Type holds the value of the \"type\" field.", "allOf": [ { - "$ref": "#/definitions/itemfield.Type" + "$ref": "#/definitions/entityfield.Type" } ] }, @@ -3045,14 +3394,219 @@ } } }, - "ent.ItemFieldEdges": { + "ent.EntityFieldEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" + } + ] + } + } + }, + "ent.EntityType": { + "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 EntityTypeQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.EntityTypeEdges" + } + ] + }, + "icon": { + "description": "Icon holds the value of the \"icon\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_location": { + "description": "IsLocation holds the value of the \"is_location\" 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" + } + } + }, + "ent.EntityTypeEdges": { + "type": "object", + "properties": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Entity" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + } + } + }, + "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": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Entity" + } + }, + "entity_types": { + "description": "EntityTypes holds the value of the entity_types edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.EntityType" + } + }, + "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" + } + }, + "labels": { + "description": "Labels holds the value of the labels edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "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" } ] } @@ -3168,7 +3722,7 @@ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/definitions/ent.Location" + "$ref": "#/definitions/ent.Entity" } ] } @@ -3214,64 +3768,11 @@ "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.", + "entities": { + "description": "Entities holds the value of the entities 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" + "$ref": "#/definitions/ent.Entity" } }, "group": { @@ -3281,21 +3782,6 @@ "$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" - } - ] } } }, @@ -3326,12 +3812,12 @@ } ] }, - "id": { - "description": "ID of the ent.", + "entity_id": { + "description": "EntityID holds the value of the \"entity_id\" field.", "type": "string" }, - "item_id": { - "description": "ItemID holds the value of the \"item_id\" field.", + "id": { + "description": "ID of the ent.", "type": "string" }, "name": { @@ -3351,11 +3837,11 @@ "ent.MaintenanceEntryEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" } ] } @@ -3569,7 +4055,7 @@ } } }, - "itemfield.Type": { + "entityfield.Type": { "type": "string", "enum": [ "text", @@ -3632,6 +4118,122 @@ } } }, + "repo.EntityAttachment": { + "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.EntityAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.EntityType": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeCreate": { + "type": "object", + "required": [ + "isLocation", + "name" + ], + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeDelete": { + "type": "object", + "properties": { + "replacementId": { + "$ref": "#/definitions/uuid.NullUUID" + } + } + }, + "repo.EntityTypeUpdate": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + } + } + }, "repo.Group": { "type": "object", "properties": { @@ -3686,55 +4288,10 @@ } } }, - "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": [ + "entityType", "name" ], "properties": { @@ -3742,6 +4299,9 @@ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "labelIds": { "type": "array", "items": { @@ -3802,7 +4362,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/definitions/repo.ItemAttachment" + "$ref": "#/definitions/repo.EntityAttachment" } }, "createdAt": { @@ -3811,6 +4371,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -3974,6 +4537,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4301,17 +4867,22 @@ "repo.ItemType": { "type": "string", "enum": [ + "location", + "item", "location", "item" ], "x-enum-varnames": [ "ItemTypeLocation", - "ItemTypeItem" + "ItemTypeItem", + "EntityTypeLocation", + "EntityTypeItem" ] }, "repo.ItemUpdate": { "type": "object", "required": [ + "entityType", "name" ], "properties": { @@ -4325,6 +4896,9 @@ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -4486,10 +5060,16 @@ }, "repo.LocationCreate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "name": { "type": "string" }, @@ -4514,6 +5094,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4540,6 +5123,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4563,6 +5149,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4576,10 +5165,16 @@ }, "repo.LocationUpdate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4996,6 +5591,18 @@ "RoleOwner" ] }, + "uuid.NullUUID": { + "type": "object", + "properties": { + "uuid": { + "type": "string" + }, + "valid": { + "description": "Valid is true if UUID is not NULL", + "type": "boolean" + } + } + }, "v1.APISummary": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml index d18a8f45..e70a8f87 100644 --- a/backend/app/api/static/docs/swagger.yaml +++ b/backend/app/api/static/docs/swagger.yaml @@ -79,10 +79,10 @@ definitions: type: object ent.AttachmentEdges: properties: - item: + entity: allOf: - - $ref: '#/definitions/ent.Item' - description: Item holds the value of the item edge. + - $ref: '#/definitions/ent.Entity' + description: Entity holds the value of the entity edge. thumbnail: allOf: - $ref: '#/definitions/ent.Attachment' @@ -148,105 +148,7 @@ definitions: - $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: + ent.Entity: properties: archived: description: Archived holds the value of the "archived" field. @@ -262,10 +164,10 @@ definitions: type: string edges: allOf: - - $ref: '#/definitions/ent.ItemEdges' + - $ref: '#/definitions/ent.EntityEdges' 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. + The values are being populated by the EntityQuery when eager-loading is set. id: description: ID of the ent. type: string @@ -317,8 +219,8 @@ definitions: 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" + sync_child_entities_locations: + description: SyncChildEntitiesLocations holds the value of the "sync_child_entities_locations" field. type: boolean updated_at: @@ -331,7 +233,7 @@ definitions: description: WarrantyExpires holds the value of the "warranty_expires" field. type: string type: object - ent.ItemEdges: + ent.EntityEdges: properties: attachments: description: Attachments holds the value of the attachments edge. @@ -341,12 +243,17 @@ definitions: children: description: Children holds the value of the children edge. items: - $ref: '#/definitions/ent.Item' + $ref: '#/definitions/ent.Entity' + type: array + entity: + description: Entity holds the value of the entity edge. + items: + $ref: '#/definitions/ent.Entity' type: array fields: description: Fields holds the value of the fields edge. items: - $ref: '#/definitions/ent.ItemField' + $ref: '#/definitions/ent.EntityField' type: array group: allOf: @@ -359,7 +266,7 @@ definitions: type: array location: allOf: - - $ref: '#/definitions/ent.Location' + - $ref: '#/definitions/ent.Entity' description: Location holds the value of the location edge. maintenance_entries: description: MaintenanceEntries holds the value of the maintenance_entries @@ -369,10 +276,14 @@ definitions: type: array parent: allOf: - - $ref: '#/definitions/ent.Item' + - $ref: '#/definitions/ent.Entity' description: Parent holds the value of the parent edge. + type: + allOf: + - $ref: '#/definitions/ent.EntityType' + description: Type holds the value of the type edge. type: object - ent.ItemField: + ent.EntityField: properties: boolean_value: description: BooleanValue holds the value of the "boolean_value" field. @@ -385,10 +296,10 @@ definitions: type: string edges: allOf: - - $ref: '#/definitions/ent.ItemFieldEdges' + - $ref: '#/definitions/ent.EntityFieldEdges' 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. + The values are being populated by the EntityFieldQuery when eager-loading is set. id: description: ID of the ent. type: string @@ -406,18 +317,161 @@ definitions: type: string type: allOf: - - $ref: '#/definitions/itemfield.Type' + - $ref: '#/definitions/entityfield.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: + ent.EntityFieldEdges: properties: - item: + entity: allOf: - - $ref: '#/definitions/ent.Item' - description: Item holds the value of the item edge. + - $ref: '#/definitions/ent.Entity' + description: Entity holds the value of the entity edge. + type: object + ent.EntityType: + 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.EntityTypeEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the EntityTypeQuery when eager-loading is set. + icon: + description: Icon holds the value of the "icon" field. + type: string + id: + description: ID of the ent. + type: string + is_location: + description: IsLocation holds the value of the "is_location" 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 + type: object + ent.EntityTypeEdges: + properties: + entities: + description: Entities holds the value of the entities edge. + items: + $ref: '#/definitions/ent.Entity' + type: array + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group 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: + entities: + description: Entities holds the value of the entities edge. + items: + $ref: '#/definitions/ent.Entity' + type: array + entity_types: + description: EntityTypes holds the value of the entity_types edge. + items: + $ref: '#/definitions/ent.EntityType' + type: array + 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 + labels: + description: Labels holds the value of the labels edge. + items: + $ref: '#/definitions/ent.Label' + 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.ItemTemplate: properties: @@ -502,7 +556,7 @@ definitions: description: Group holds the value of the group edge. location: allOf: - - $ref: '#/definitions/ent.Location' + - $ref: '#/definitions/ent.Entity' description: Location holds the value of the location edge. type: object ent.Label: @@ -534,60 +588,15 @@ definitions: 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. + entities: + description: Entities holds the value of the entities 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' + $ref: '#/definitions/ent.Entity' 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: @@ -609,12 +618,12 @@ definitions: 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. + entity_id: + description: EntityID holds the value of the "entity_id" field. + type: string 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 @@ -627,10 +636,10 @@ definitions: type: object ent.MaintenanceEntryEdges: properties: - item: + entity: allOf: - - $ref: '#/definitions/ent.Item' - description: Item holds the value of the item edge. + - $ref: '#/definitions/ent.Entity' + description: Entity holds the value of the entity edge. type: object ent.Notifier: properties: @@ -771,7 +780,7 @@ definitions: $ref: '#/definitions/ent.Notifier' type: array type: object - itemfield.Type: + entityfield.Type: enum: - text - number @@ -815,6 +824,82 @@ definitions: copyPrefix: type: string type: object + repo.EntityAttachment: + 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.EntityAttachmentUpdate: + properties: + primary: + type: boolean + title: + type: string + type: + type: string + type: object + repo.EntityType: + properties: + color: + type: string + description: + type: string + icon: + type: string + isLocation: + type: boolean + name: + type: string + type: object + repo.EntityTypeCreate: + properties: + color: + type: string + description: + type: string + icon: + type: string + isLocation: + type: boolean + name: + type: string + required: + - isLocation + - name + type: object + repo.EntityTypeDelete: + properties: + replacementId: + $ref: '#/definitions/uuid.NullUUID' + type: object + repo.EntityTypeUpdate: + properties: + color: + type: string + description: + type: string + icon: + type: string + name: + minLength: 1 + type: string + type: object repo.Group: properties: createdAt: @@ -850,41 +935,13 @@ definitions: 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 + entityType: + type: string labelIds: items: type: string @@ -902,6 +959,7 @@ definitions: quantity: type: integer required: + - entityType - name type: object repo.ItemField: @@ -928,12 +986,14 @@ definitions: type: string attachments: items: - $ref: '#/definitions/repo.ItemAttachment' + $ref: '#/definitions/repo.EntityAttachment' type: array createdAt: type: string description: type: string + entityType: + type: string fields: items: $ref: '#/definitions/repo.ItemField' @@ -1045,6 +1105,8 @@ definitions: type: string description: type: string + entityType: + type: string id: type: string imageId: @@ -1278,10 +1340,14 @@ definitions: enum: - location - item + - location + - item type: string x-enum-varnames: - ItemTypeLocation - ItemTypeItem + - EntityTypeLocation + - EntityTypeItem repo.ItemUpdate: properties: archived: @@ -1291,6 +1357,8 @@ definitions: description: maxLength: 1000 type: string + entityType: + type: string fields: items: $ref: '#/definitions/repo.ItemField' @@ -1358,6 +1426,7 @@ definitions: warrantyExpires: type: string required: + - entityType - name type: object repo.LabelCreate: @@ -1408,11 +1477,15 @@ definitions: properties: description: type: string + entityType: + type: string name: type: string parentId: type: string x-nullable: true + required: + - entityType type: object repo.LocationOut: properties: @@ -1424,6 +1497,8 @@ definitions: type: string description: type: string + entityType: + type: string id: type: string name: @@ -1441,6 +1516,8 @@ definitions: type: string description: type: string + entityType: + type: string id: type: string itemCount: @@ -1456,6 +1533,8 @@ definitions: type: string description: type: string + entityType: + type: string id: type: string name: @@ -1467,6 +1546,8 @@ definitions: properties: description: type: string + entityType: + type: string id: type: string name: @@ -1474,6 +1555,8 @@ definitions: parentId: type: string x-nullable: true + required: + - entityType type: object repo.MaintenanceEntry: properties: @@ -1744,6 +1827,14 @@ definitions: - DefaultRole - RoleUser - RoleOwner + uuid.NullUUID: + properties: + uuid: + type: string + valid: + description: Valid is true if UUID is not NULL + type: boolean + type: object v1.APISummary: properties: allowRegistration: @@ -1994,6 +2085,287 @@ paths: summary: Currency tags: - Base + /v1/entities/{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/entities/{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.EntityAttachmentUpdate' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Update Item Attachment + tags: + - Items Attachments + /v1/entities/{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/entitytype: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.EntityType' + type: array + security: + - Bearer: [] + summary: Query All Entity Types + tags: + - EntityTypes + post: + consumes: + - application/json + parameters: + - description: Entity Type Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.EntityTypeCreate' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.EntityType' + security: + - Bearer: [] + summary: Create Entity Type + tags: + - EntityTypes + /v1/entitytype/{id}: + delete: + parameters: + - description: Entity Type ID + in: path + name: id + required: true + type: string + - description: Entity Type Delete Options + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.EntityTypeDelete' + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Entity Type + tags: + - EntityTypes + get: + parameters: + - description: Entity Type ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.EntityType' + security: + - Bearer: [] + summary: Get One Entity Type + tags: + - EntityTypes + put: + consumes: + - application/json + parameters: + - description: Entity Type ID + in: path + name: id + required: true + type: string + - description: Entity Type Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.EntityTypeUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.EntityType' + security: + - Bearer: [] + summary: Update Entity Type + tags: + - EntityTypes /v1/groups: get: produces: @@ -2120,6 +2492,7 @@ paths: - Statistics /v1/items: get: + deprecated: true parameters: - description: search string in: query @@ -2163,10 +2536,13 @@ paths: $ref: '#/definitions/repo.PaginationResult-repo_ItemSummary' security: - Bearer: [] - summary: Query All Items + summary: (Deprecated) Query All Items tags: - Items post: + consumes: + - application/json + deprecated: true parameters: - description: Item Data in: body @@ -2188,6 +2564,7 @@ paths: - Items /v1/items/{id}: delete: + deprecated: true parameters: - description: Item ID in: path @@ -2201,10 +2578,11 @@ paths: description: No Content security: - Bearer: [] - summary: Delete Item + summary: (Deprecated) Delete Item tags: - Items get: + deprecated: true parameters: - description: Item ID in: path @@ -2220,10 +2598,11 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: Get Item + summary: (Deprecated) Get Item tags: - Items patch: + deprecated: true parameters: - description: Item ID in: path @@ -2245,10 +2624,11 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: Update Item + summary: (Deprecated) Update Item tags: - Items put: + deprecated: true parameters: - description: Item ID in: path @@ -2270,13 +2650,14 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: Update Item + summary: (Deprecated) Update Item tags: - Items /v1/items/{id}/attachments: post: consumes: - multipart/form-data + deprecated: true parameters: - description: Item ID in: path @@ -2319,6 +2700,7 @@ paths: - Items Attachments /v1/items/{id}/attachments/{attachment_id}: delete: + deprecated: true parameters: - description: Item ID in: path @@ -2339,6 +2721,7 @@ paths: tags: - Items Attachments get: + deprecated: true parameters: - description: Item ID in: path @@ -2363,6 +2746,7 @@ paths: tags: - Items Attachments put: + deprecated: true parameters: - description: Item ID in: path @@ -2379,7 +2763,7 @@ paths: name: payload required: true schema: - $ref: '#/definitions/repo.ItemAttachmentUpdate' + $ref: '#/definitions/repo.EntityAttachmentUpdate' responses: "200": description: OK @@ -2418,6 +2802,7 @@ paths: - Items /v1/items/{id}/maintenance: get: + deprecated: true parameters: - description: Item ID in: path @@ -2450,6 +2835,7 @@ paths: tags: - Item Maintenance post: + deprecated: true parameters: - description: Item ID in: path @@ -2476,6 +2862,7 @@ paths: - Item Maintenance /v1/items/{id}/path: get: + deprecated: true parameters: - description: Item ID in: path @@ -2493,11 +2880,12 @@ paths: type: array security: - Bearer: [] - summary: Get the full path of an item + summary: (Deprecated) Get the full path of an item tags: - Items /v1/items/export: get: + deprecated: true responses: "200": description: text/csv @@ -2505,11 +2893,12 @@ paths: type: string security: - Bearer: [] - summary: Export Items + summary: (Deprecated) Export Items tags: - Items /v1/items/fields: get: + deprecated: true produces: - application/json responses: @@ -2521,11 +2910,12 @@ paths: type: array security: - Bearer: [] - summary: Get All Custom Field Names + summary: (Deprecated) Get All Custom Field Names tags: - Items /v1/items/fields/values: get: + deprecated: true produces: - application/json responses: @@ -2537,13 +2927,14 @@ paths: type: array security: - Bearer: [] - summary: Get All Custom Field Values + summary: (Deprecated) Get All Custom Field Values tags: - Items /v1/items/import: post: consumes: - multipart/form-data + deprecated: true parameters: - description: Image to upload in: formData @@ -2557,7 +2948,7 @@ paths: description: No Content security: - Bearer: [] - summary: Import Items + summary: (Deprecated) Import Items tags: - Items /v1/labelmaker/assets/{id}: @@ -2726,6 +3117,7 @@ paths: - Labels /v1/locations: get: + deprecated: true parameters: - description: Filter locations with parents in: query @@ -2742,10 +3134,11 @@ paths: type: array security: - Bearer: [] - summary: Get All Locations + summary: (Deprecated) Get All Locations tags: - Locations post: + deprecated: true parameters: - description: Location Data in: body @@ -2762,11 +3155,12 @@ paths: $ref: '#/definitions/repo.LocationSummary' security: - Bearer: [] - summary: Create Location + summary: (Deprecated) Create Location tags: - Locations /v1/locations/{id}: delete: + deprecated: true parameters: - description: Location ID in: path @@ -2780,10 +3174,11 @@ paths: description: No Content security: - Bearer: [] - summary: Delete Location + summary: (Deprecated) Delete Location tags: - Locations get: + deprecated: true parameters: - description: Location ID in: path @@ -2799,10 +3194,11 @@ paths: $ref: '#/definitions/repo.LocationOut' security: - Bearer: [] - summary: Get Location + summary: (Deprecated) Get Location tags: - Locations put: + deprecated: true parameters: - description: Location ID in: path @@ -2824,11 +3220,12 @@ paths: $ref: '#/definitions/repo.LocationOut' security: - Bearer: [] - summary: Update Location + summary: (Deprecated) Update Location tags: - Locations /v1/locations/tree: get: + deprecated: true parameters: - description: include items in response tree in: query @@ -2845,7 +3242,7 @@ paths: type: array security: - Bearer: [] - summary: Get Locations Tree + summary: (Deprecated) Get Locations Tree tags: - Locations /v1/maintenance: diff --git a/backend/go.mod b/backend/go.mod index 817da3d5..1d807d46 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -6,7 +6,7 @@ toolchain go1.24.3 require ( entgo.io/ent v0.14.5 - github.com/ardanlabs/conf/v3 v3.9.0 + github.com/ardanlabs/conf/v3 v3.10.0 github.com/containrrr/shoutrrr v0.8.0 github.com/coreos/go-oidc/v3 v3.17.0 github.com/evanoberholster/imagemeta v0.3.1 @@ -15,7 +15,7 @@ require ( github.com/gen2brain/jpegxl v0.4.5 github.com/gen2brain/webp v0.5.5 github.com/go-chi/chi/v5 v5.2.3 - github.com/go-playground/validator/v10 v10.28.0 + github.com/go-playground/validator/v10 v10.29.0 github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 github.com/google/uuid v1.6.0 @@ -40,10 +40,10 @@ require ( gocloud.dev/pubsub/kafkapubsub v0.44.0 gocloud.dev/pubsub/natspubsub v0.44.0 gocloud.dev/pubsub/rabbitpubsub v0.44.0 - golang.org/x/crypto v0.45.0 - golang.org/x/image v0.33.0 - golang.org/x/oauth2 v0.33.0 - golang.org/x/text v0.31.0 + golang.org/x/crypto v0.46.0 + golang.org/x/image v0.34.0 + golang.org/x/oauth2 v0.34.0 + golang.org/x/text v0.32.0 modernc.org/sqlite v1.40.1 ) @@ -111,15 +111,15 @@ require ( github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fogleman/gg v1.3.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.11 // indirect + github.com/gabriel-vasile/mimetype v1.4.12 // indirect github.com/go-jose/go-jose/v4 v4.1.3 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-openapi/inflect v0.19.0 // indirect - github.com/go-openapi/jsonpointer v0.22.3 // indirect - github.com/go-openapi/jsonreference v0.21.3 // indirect - github.com/go-openapi/spec v0.22.1 // indirect + github.com/go-openapi/jsonpointer v0.22.4 // indirect + github.com/go-openapi/jsonreference v0.21.4 // indirect + github.com/go-openapi/spec v0.22.2 // indirect github.com/go-openapi/swag/conv v0.25.4 // indirect github.com/go-openapi/swag/jsonname v0.25.4 // indirect github.com/go-openapi/swag/jsonutils v0.25.4 // indirect @@ -181,27 +181,27 @@ require ( go.opentelemetry.io/contrib/detectors/gcp v1.38.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect - go.opentelemetry.io/otel v1.38.0 // indirect - go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/sdk v1.38.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect - go.opentelemetry.io/otel/trace v1.38.0 // indirect + go.opentelemetry.io/otel v1.39.0 // indirect + go.opentelemetry.io/otel/metric v1.39.0 // indirect + go.opentelemetry.io/otel/sdk v1.39.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.39.0 // indirect + go.opentelemetry.io/otel/trace v1.39.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 // indirect - golang.org/x/mod v0.30.0 // indirect - golang.org/x/net v0.47.0 // indirect - golang.org/x/sync v0.18.0 // indirect - golang.org/x/sys v0.38.0 // indirect + golang.org/x/exp v0.0.0-20251209150349-8475f28825e9 // indirect + golang.org/x/mod v0.31.0 // indirect + golang.org/x/net v0.48.0 // indirect + golang.org/x/sync v0.19.0 // indirect + golang.org/x/sys v0.39.0 // indirect golang.org/x/time v0.14.0 // indirect - golang.org/x/tools v0.39.0 // indirect + golang.org/x/tools v0.40.0 // indirect golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect google.golang.org/api v0.257.0 // indirect google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20251213004720-97cd9d5aeac2 // indirect google.golang.org/grpc v1.77.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect + google.golang.org/protobuf v1.36.11 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect modernc.org/libc v1.67.1 // indirect modernc.org/mathutil v1.7.1 // indirect diff --git a/backend/go.sum b/backend/go.sum index 72192aaf..617e72d2 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -81,6 +81,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/ardanlabs/conf/v3 v3.9.0 h1:aRBYHeD39/OkuaEXYIEoi4wvF3OnS7jUAPxXyLfEu20= github.com/ardanlabs/conf/v3 v3.9.0/go.mod h1:XlL9P0quWP4m1weOVFmlezabinbZLI05niDof/+Ochk= +github.com/ardanlabs/conf/v3 v3.10.0 h1:qIrJ/WBmH/hFQ/IX4xH9LX9LzwK44T9aEOy78M+4S+0= +github.com/ardanlabs/conf/v3 v3.10.0/go.mod h1:XlL9P0quWP4m1weOVFmlezabinbZLI05niDof/+Ochk= github.com/aws/aws-sdk-go-v2 v1.39.6 h1:2JrPCVgWJm7bm83BDwY5z8ietmeJUbh3O2ACnn+Xsqk= github.com/aws/aws-sdk-go-v2 v1.39.6/go.mod h1:c9pm7VwuW0UPxAEYGyTmyurVcNrbF6Rt/wixFqDhcjE= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 h1:DHctwEM8P8iTXFxC/QK0MRjwEpWQeM9yzidCRjldUz0= @@ -174,6 +176,8 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8 github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/gabriel-vasile/mimetype v1.4.11 h1:AQvxbp830wPhHTqc1u7nzoLT+ZFxGY7emj5DR5DYFik= github.com/gabriel-vasile/mimetype v1.4.11/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= +github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw= +github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= github.com/gen2brain/avif v0.4.4 h1:Ga/ss7qcWWQm2bxFpnjYjhJsNfZrWs5RsyklgFjKRSE= github.com/gen2brain/avif v0.4.4/go.mod h1:/XCaJcjZraQwKVhpu9aEd9aLOssYOawLvhMBtmHVGqk= github.com/gen2brain/heic v0.4.6 h1:sNh3mfaEZLmDJnFc5WoLxCzh/wj5GwfJScPfvF5CNJE= @@ -197,10 +201,16 @@ github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNP github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= github.com/go-openapi/jsonpointer v0.22.3 h1:dKMwfV4fmt6Ah90zloTbUKWMD+0he+12XYAsPotrkn8= github.com/go-openapi/jsonpointer v0.22.3/go.mod h1:0lBbqeRsQ5lIanv3LHZBrmRGHLHcQoOXQnf88fHlGWo= +github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4= +github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80= github.com/go-openapi/jsonreference v0.21.3 h1:96Dn+MRPa0nYAR8DR1E03SblB5FJvh7W6krPI0Z7qMc= github.com/go-openapi/jsonreference v0.21.3/go.mod h1:RqkUP0MrLf37HqxZxrIAtTWW4ZJIK1VzduhXYBEeGc4= +github.com/go-openapi/jsonreference v0.21.4 h1:24qaE2y9bx/q3uRK/qN+TDwbok1NhbSmGjjySRCHtC8= +github.com/go-openapi/jsonreference v0.21.4/go.mod h1:rIENPTjDbLpzQmQWCj5kKj3ZlmEh+EFVbz3RTUh30/4= github.com/go-openapi/spec v0.22.1 h1:beZMa5AVQzRspNjvhe5aG1/XyBSMeX1eEOs7dMoXh/k= github.com/go-openapi/spec v0.22.1/go.mod h1:c7aeIQT175dVowfp7FeCvXXnjN/MrpaONStibD2WtDA= +github.com/go-openapi/spec v0.22.2 h1:KEU4Fb+Lp1qg0V4MxrSCPv403ZjBl8Lx1a83gIPU8Qc= +github.com/go-openapi/spec v0.22.2/go.mod h1:iIImLODL2loCh3Vnox8TY2YWYJZjMAKYyLH2Mu8lOZs= github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= github.com/go-openapi/swag/conv v0.25.4 h1:/Dd7p0LZXczgUcC/Ikm1+YqVzkEeCc9LnOWjfkpkfe4= github.com/go-openapi/swag/conv v0.25.4/go.mod h1:3LXfie/lwoAv0NHoEuY1hjoFAYkvlqI/Bn5EQDD3PPU= @@ -230,6 +240,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688= github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU= +github.com/go-playground/validator/v10 v10.29.0 h1:lQlF5VNJWNlRbRZNeOIkWElR+1LL/OuHcc0Kp14w1xk= +github.com/go-playground/validator/v10 v10.29.0/go.mod h1:D6QxqeMlgIPuT02L66f2ccrZ7AGgHkzKmmTMZhk/Kc4= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= @@ -455,16 +467,26 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 h1:Hf9xI/X go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0/go.mod h1:NfchwuyNoMcZ5MLHwPrODwUF1HWCXWrL31s8gSAdIKY= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= +go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.37.0 h1:6VjV6Et+1Hd2iLZEPtdV7vie80Yyqf7oikJLjQ/myi0= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.37.0/go.mod h1:u8hcp8ji5gaM/RfcOo8z9NMnf1pVLfVY7lBY2VOGuUU= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0= +go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs= go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= +go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18= +go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE= go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= +go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8= +go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= +go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI= +go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -485,13 +507,21 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= +golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= +golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 h1:DHNhtq3sNNzrvduZZIiFyXWOL9IWaDPHqTnLJp+rCBY= golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0= +golang.org/x/exp v0.0.0-20251209150349-8475f28825e9 h1:MDfG8Cvcqlt9XXrmEiD4epKn7VJHZO84hejP9Jmp0MM= +golang.org/x/exp v0.0.0-20251209150349-8475f28825e9/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU= golang.org/x/image v0.33.0 h1:LXRZRnv1+zGd5XBUVRFmYEphyyKJjQjCRiOuAP3sZfQ= golang.org/x/image v0.33.0/go.mod h1:DD3OsTYT9chzuzTQt+zMcOlBHgfoKQb1gry8p76Y1sc= +golang.org/x/image v0.34.0 h1:33gCkyw9hmwbZJeZkct8XyR11yH889EQt/QH4VmXMn8= +golang.org/x/image v0.34.0/go.mod h1:2RNFBZRB+vnwwFil8GkMdRvrJOFd1AzdZI6vOY+eJVU= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= +golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI= +golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -501,12 +531,18 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= golang.org/x/oauth2 v0.33.0 h1:4Q+qn+E5z8gPRJfmRy7C2gGG3T4jIprK6aSYgTXGRpo= golang.org/x/oauth2 v0.33.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= +golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw= +golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -522,6 +558,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -531,6 +569,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -538,6 +578,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= +golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= +golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= @@ -552,10 +594,14 @@ google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 h1: google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8/go.mod h1:fDMmzKV90WSg1NbozdqrE64fkuTv6mlq2zxo9ad+3yo= google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww= google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251213004720-97cd9d5aeac2 h1:2I6GHUeJ/4shcDpoUlLs/2WPnhg7yJwvXtqcMJt9liA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251213004720-97cd9d5aeac2/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM= google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= +google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/backend/internal/data/ent/attachment.go b/backend/internal/data/ent/attachment.go index c7fbdf3b..cc8f2017 100644 --- a/backend/internal/data/ent/attachment.go +++ b/backend/internal/data/ent/attachment.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" ) // Attachment is the model entity for the Attachment schema. @@ -37,14 +37,14 @@ type Attachment struct { // The values are being populated by the AttachmentQuery when eager-loading is set. Edges AttachmentEdges `json:"edges"` attachment_thumbnail *uuid.UUID - item_attachments *uuid.UUID + entity_attachments *uuid.UUID selectValues sql.SelectValues } // AttachmentEdges holds the relations/edges for other nodes in the graph. type AttachmentEdges struct { - // Item holds the value of the item edge. - Item *Item `json:"item,omitempty"` + // Entity holds the value of the entity edge. + Entity *Entity `json:"entity,omitempty"` // Thumbnail holds the value of the thumbnail edge. Thumbnail *Attachment `json:"thumbnail,omitempty"` // loadedTypes holds the information for reporting if a @@ -52,15 +52,15 @@ type AttachmentEdges struct { loadedTypes [2]bool } -// ItemOrErr returns the Item value or an error if the edge +// EntityOrErr returns the Entity value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e AttachmentEdges) ItemOrErr() (*Item, error) { - if e.Item != nil { - return e.Item, nil +func (e AttachmentEdges) EntityOrErr() (*Entity, error) { + if e.Entity != nil { + return e.Entity, nil } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: item.Label} + return nil, &NotFoundError{label: entity.Label} } - return nil, &NotLoadedError{edge: "item"} + return nil, &NotLoadedError{edge: "entity"} } // ThumbnailOrErr returns the Thumbnail value or an error if the edge @@ -89,7 +89,7 @@ func (*Attachment) scanValues(columns []string) ([]any, error) { values[i] = new(uuid.UUID) case attachment.ForeignKeys[0]: // attachment_thumbnail values[i] = &sql.NullScanner{S: new(uuid.UUID)} - case attachment.ForeignKeys[1]: // item_attachments + case attachment.ForeignKeys[1]: // entity_attachments values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) @@ -163,10 +163,10 @@ func (_m *Attachment) assignValues(columns []string, values []any) error { } case attachment.ForeignKeys[1]: if value, ok := values[i].(*sql.NullScanner); !ok { - return fmt.Errorf("unexpected type %T for field item_attachments", values[i]) + return fmt.Errorf("unexpected type %T for field entity_attachments", values[i]) } else if value.Valid { - _m.item_attachments = new(uuid.UUID) - *_m.item_attachments = *value.S.(*uuid.UUID) + _m.entity_attachments = new(uuid.UUID) + *_m.entity_attachments = *value.S.(*uuid.UUID) } default: _m.selectValues.Set(columns[i], values[i]) @@ -181,9 +181,9 @@ func (_m *Attachment) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } -// QueryItem queries the "item" edge of the Attachment entity. -func (_m *Attachment) QueryItem() *ItemQuery { - return NewAttachmentClient(_m.config).QueryItem(_m) +// QueryEntity queries the "entity" edge of the Attachment entity. +func (_m *Attachment) QueryEntity() *EntityQuery { + return NewAttachmentClient(_m.config).QueryEntity(_m) } // QueryThumbnail queries the "thumbnail" edge of the Attachment entity. diff --git a/backend/internal/data/ent/attachment_create.go b/backend/internal/data/ent/attachment_create.go index d46a71f9..25eb6ec4 100644 --- a/backend/internal/data/ent/attachment_create.go +++ b/backend/internal/data/ent/attachment_create.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/schema/field" "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" ) // AttachmentCreate is the builder for creating a Attachment entity. @@ -134,23 +134,23 @@ func (_c *AttachmentCreate) SetNillableID(v *uuid.UUID) *AttachmentCreate { return _c } -// SetItemID sets the "item" edge to the Item entity by ID. -func (_c *AttachmentCreate) SetItemID(id uuid.UUID) *AttachmentCreate { - _c.mutation.SetItemID(id) +// SetEntityID sets the "entity" edge to the Entity entity by ID. +func (_c *AttachmentCreate) SetEntityID(id uuid.UUID) *AttachmentCreate { + _c.mutation.SetEntityID(id) return _c } -// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil. -func (_c *AttachmentCreate) SetNillableItemID(id *uuid.UUID) *AttachmentCreate { +// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil. +func (_c *AttachmentCreate) SetNillableEntityID(id *uuid.UUID) *AttachmentCreate { if id != nil { - _c = _c.SetItemID(*id) + _c = _c.SetEntityID(*id) } return _c } -// SetItem sets the "item" edge to the Item entity. -func (_c *AttachmentCreate) SetItem(v *Item) *AttachmentCreate { - return _c.SetItemID(v.ID) +// SetEntity sets the "entity" edge to the Entity entity. +func (_c *AttachmentCreate) SetEntity(v *Entity) *AttachmentCreate { + return _c.SetEntityID(v.ID) } // SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID. @@ -332,21 +332,21 @@ func (_c *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { _spec.SetField(attachment.FieldMimeType, field.TypeString, value) _node.MimeType = value } - if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 { + if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.ItemTable, - Columns: []string{attachment.ItemColumn}, + Table: attachment.EntityTable, + Columns: []string{attachment.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.item_attachments = &nodes[0] + _node.entity_attachments = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.ThumbnailIDs(); len(nodes) > 0 { diff --git a/backend/internal/data/ent/attachment_query.go b/backend/internal/data/ent/attachment_query.go index 8eea544c..d69eeb24 100644 --- a/backend/internal/data/ent/attachment_query.go +++ b/backend/internal/data/ent/attachment_query.go @@ -13,7 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -24,7 +24,7 @@ type AttachmentQuery struct { order []attachment.OrderOption inters []Interceptor predicates []predicate.Attachment - withItem *ItemQuery + withEntity *EntityQuery withThumbnail *AttachmentQuery withFKs bool // intermediate query (i.e. traversal path). @@ -63,9 +63,9 @@ func (_q *AttachmentQuery) Order(o ...attachment.OrderOption) *AttachmentQuery { return _q } -// QueryItem chains the current query on the "item" edge. -func (_q *AttachmentQuery) QueryItem() *ItemQuery { - query := (&ItemClient{config: _q.config}).Query() +// QueryEntity chains the current query on the "entity" edge. +func (_q *AttachmentQuery) QueryEntity() *EntityQuery { + query := (&EntityClient{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 @@ -76,8 +76,8 @@ func (_q *AttachmentQuery) QueryItem() *ItemQuery { } step := sqlgraph.NewStep( sqlgraph.From(attachment.Table, attachment.FieldID, selector), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, attachment.ItemTable, attachment.ItemColumn), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -299,7 +299,7 @@ func (_q *AttachmentQuery) Clone() *AttachmentQuery { order: append([]attachment.OrderOption{}, _q.order...), inters: append([]Interceptor{}, _q.inters...), predicates: append([]predicate.Attachment{}, _q.predicates...), - withItem: _q.withItem.Clone(), + withEntity: _q.withEntity.Clone(), withThumbnail: _q.withThumbnail.Clone(), // clone intermediate query. sql: _q.sql.Clone(), @@ -307,14 +307,14 @@ func (_q *AttachmentQuery) Clone() *AttachmentQuery { } } -// WithItem tells the query-builder to eager-load the nodes that are connected to -// the "item" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *AttachmentQuery) WithItem(opts ...func(*ItemQuery)) *AttachmentQuery { - query := (&ItemClient{config: _q.config}).Query() +// WithEntity tells the query-builder to eager-load the nodes that are connected to +// the "entity" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AttachmentQuery) WithEntity(opts ...func(*EntityQuery)) *AttachmentQuery { + query := (&EntityClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withItem = query + _q.withEntity = query return _q } @@ -409,11 +409,11 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A withFKs = _q.withFKs _spec = _q.querySpec() loadedTypes = [2]bool{ - _q.withItem != nil, + _q.withEntity != nil, _q.withThumbnail != nil, } ) - if _q.withItem != nil || _q.withThumbnail != nil { + if _q.withEntity != nil || _q.withThumbnail != nil { withFKs = true } if withFKs { @@ -437,9 +437,9 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A if len(nodes) == 0 { return nodes, nil } - if query := _q.withItem; query != nil { - if err := _q.loadItem(ctx, query, nodes, nil, - func(n *Attachment, e *Item) { n.Edges.Item = e }); err != nil { + if query := _q.withEntity; query != nil { + if err := _q.loadEntity(ctx, query, nodes, nil, + func(n *Attachment, e *Entity) { n.Edges.Entity = e }); err != nil { return nil, err } } @@ -452,14 +452,14 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A return nodes, nil } -func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Item)) error { +func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Entity)) error { ids := make([]uuid.UUID, 0, len(nodes)) nodeids := make(map[uuid.UUID][]*Attachment) for i := range nodes { - if nodes[i].item_attachments == nil { + if nodes[i].entity_attachments == nil { continue } - fk := *nodes[i].item_attachments + fk := *nodes[i].entity_attachments if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -468,7 +468,7 @@ func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes if len(ids) == 0 { return nil } - query.Where(item.IDIn(ids...)) + query.Where(entity.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err @@ -476,7 +476,7 @@ func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "item_attachments" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "entity_attachments" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) diff --git a/backend/internal/data/ent/attachment_update.go b/backend/internal/data/ent/attachment_update.go index 6b2cdd35..0009a29f 100644 --- a/backend/internal/data/ent/attachment_update.go +++ b/backend/internal/data/ent/attachment_update.go @@ -13,7 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -106,23 +106,23 @@ func (_u *AttachmentUpdate) SetNillableMimeType(v *string) *AttachmentUpdate { return _u } -// SetItemID sets the "item" edge to the Item entity by ID. -func (_u *AttachmentUpdate) SetItemID(id uuid.UUID) *AttachmentUpdate { - _u.mutation.SetItemID(id) +// SetEntityID sets the "entity" edge to the Entity entity by ID. +func (_u *AttachmentUpdate) SetEntityID(id uuid.UUID) *AttachmentUpdate { + _u.mutation.SetEntityID(id) return _u } -// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil. -func (_u *AttachmentUpdate) SetNillableItemID(id *uuid.UUID) *AttachmentUpdate { +// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdate { if id != nil { - _u = _u.SetItemID(*id) + _u = _u.SetEntityID(*id) } return _u } -// SetItem sets the "item" edge to the Item entity. -func (_u *AttachmentUpdate) SetItem(v *Item) *AttachmentUpdate { - return _u.SetItemID(v.ID) +// SetEntity sets the "entity" edge to the Entity entity. +func (_u *AttachmentUpdate) SetEntity(v *Entity) *AttachmentUpdate { + return _u.SetEntityID(v.ID) } // SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID. @@ -149,9 +149,9 @@ func (_u *AttachmentUpdate) Mutation() *AttachmentMutation { return _u.mutation } -// ClearItem clears the "item" edge to the Item entity. -func (_u *AttachmentUpdate) ClearItem() *AttachmentUpdate { - _u.mutation.ClearItem() +// ClearEntity clears the "entity" edge to the Entity entity. +func (_u *AttachmentUpdate) ClearEntity() *AttachmentUpdate { + _u.mutation.ClearEntity() return _u } @@ -237,28 +237,28 @@ func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error) if value, ok := _u.mutation.MimeType(); ok { _spec.SetField(attachment.FieldMimeType, field.TypeString, value) } - if _u.mutation.ItemCleared() { + if _u.mutation.EntityCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.ItemTable, - Columns: []string{attachment.ItemColumn}, + Table: attachment.EntityTable, + Columns: []string{attachment.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { + if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.ItemTable, - Columns: []string{attachment.ItemColumn}, + Table: attachment.EntityTable, + Columns: []string{attachment.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -391,23 +391,23 @@ func (_u *AttachmentUpdateOne) SetNillableMimeType(v *string) *AttachmentUpdateO return _u } -// SetItemID sets the "item" edge to the Item entity by ID. -func (_u *AttachmentUpdateOne) SetItemID(id uuid.UUID) *AttachmentUpdateOne { - _u.mutation.SetItemID(id) +// SetEntityID sets the "entity" edge to the Entity entity by ID. +func (_u *AttachmentUpdateOne) SetEntityID(id uuid.UUID) *AttachmentUpdateOne { + _u.mutation.SetEntityID(id) return _u } -// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil. -func (_u *AttachmentUpdateOne) SetNillableItemID(id *uuid.UUID) *AttachmentUpdateOne { +// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdateOne { if id != nil { - _u = _u.SetItemID(*id) + _u = _u.SetEntityID(*id) } return _u } -// SetItem sets the "item" edge to the Item entity. -func (_u *AttachmentUpdateOne) SetItem(v *Item) *AttachmentUpdateOne { - return _u.SetItemID(v.ID) +// SetEntity sets the "entity" edge to the Entity entity. +func (_u *AttachmentUpdateOne) SetEntity(v *Entity) *AttachmentUpdateOne { + return _u.SetEntityID(v.ID) } // SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID. @@ -434,9 +434,9 @@ func (_u *AttachmentUpdateOne) Mutation() *AttachmentMutation { return _u.mutation } -// ClearItem clears the "item" edge to the Item entity. -func (_u *AttachmentUpdateOne) ClearItem() *AttachmentUpdateOne { - _u.mutation.ClearItem() +// ClearEntity clears the "entity" edge to the Entity entity. +func (_u *AttachmentUpdateOne) ClearEntity() *AttachmentUpdateOne { + _u.mutation.ClearEntity() return _u } @@ -552,28 +552,28 @@ func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, if value, ok := _u.mutation.MimeType(); ok { _spec.SetField(attachment.FieldMimeType, field.TypeString, value) } - if _u.mutation.ItemCleared() { + if _u.mutation.EntityCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.ItemTable, - Columns: []string{attachment.ItemColumn}, + Table: attachment.EntityTable, + Columns: []string{attachment.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { + if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.ItemTable, - Columns: []string{attachment.ItemColumn}, + Table: attachment.EntityTable, + Columns: []string{attachment.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/client.go b/backend/internal/data/ent/client.go index 7cd5830c..267312d6 100644 --- a/backend/internal/data/ent/client.go +++ b/backend/internal/data/ent/client.go @@ -19,13 +19,13 @@ import ( "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "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/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" @@ -43,20 +43,20 @@ type Client struct { AuthRoles *AuthRolesClient // AuthTokens is the client for interacting with the AuthTokens builders. AuthTokens *AuthTokensClient + // Entity is the client for interacting with the Entity builders. + Entity *EntityClient + // EntityField is the client for interacting with the EntityField builders. + EntityField *EntityFieldClient + // EntityType is the client for interacting with the EntityType builders. + EntityType *EntityTypeClient // Group is the client for interacting with the Group builders. Group *GroupClient // GroupInvitationToken is the client for interacting with the GroupInvitationToken builders. GroupInvitationToken *GroupInvitationTokenClient - // Item is the client for interacting with the Item builders. - 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. - Location *LocationClient // MaintenanceEntry is the client for interacting with the MaintenanceEntry builders. MaintenanceEntry *MaintenanceEntryClient // Notifier is the client for interacting with the Notifier builders. @@ -79,13 +79,13 @@ func (c *Client) init() { c.Attachment = NewAttachmentClient(c.config) c.AuthRoles = NewAuthRolesClient(c.config) c.AuthTokens = NewAuthTokensClient(c.config) + c.Entity = NewEntityClient(c.config) + c.EntityField = NewEntityFieldClient(c.config) + c.EntityType = NewEntityTypeClient(c.config) c.Group = NewGroupClient(c.config) 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) @@ -185,13 +185,13 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Attachment: NewAttachmentClient(cfg), AuthRoles: NewAuthRolesClient(cfg), AuthTokens: NewAuthTokensClient(cfg), + Entity: NewEntityClient(cfg), + EntityField: NewEntityFieldClient(cfg), + EntityType: NewEntityTypeClient(cfg), Group: NewGroupClient(cfg), 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), @@ -218,13 +218,13 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Attachment: NewAttachmentClient(cfg), AuthRoles: NewAuthRolesClient(cfg), AuthTokens: NewAuthTokensClient(cfg), + Entity: NewEntityClient(cfg), + EntityField: NewEntityFieldClient(cfg), + EntityType: NewEntityTypeClient(cfg), Group: NewGroupClient(cfg), 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), @@ -258,8 +258,8 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. 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.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry, + c.Attachment, c.AuthRoles, c.AuthTokens, c.Entity, c.EntityField, c.EntityType, + c.Group, c.GroupInvitationToken, c.ItemTemplate, c.Label, c.MaintenanceEntry, c.Notifier, c.TemplateField, c.User, } { n.Use(hooks...) @@ -270,8 +270,8 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. 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.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry, + c.Attachment, c.AuthRoles, c.AuthTokens, c.Entity, c.EntityField, c.EntityType, + c.Group, c.GroupInvitationToken, c.ItemTemplate, c.Label, c.MaintenanceEntry, c.Notifier, c.TemplateField, c.User, } { n.Intercept(interceptors...) @@ -287,20 +287,20 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.AuthRoles.mutate(ctx, m) case *AuthTokensMutation: return c.AuthTokens.mutate(ctx, m) + case *EntityMutation: + return c.Entity.mutate(ctx, m) + case *EntityFieldMutation: + return c.EntityField.mutate(ctx, m) + case *EntityTypeMutation: + return c.EntityType.mutate(ctx, m) case *GroupMutation: return c.Group.mutate(ctx, m) case *GroupInvitationTokenMutation: return c.GroupInvitationToken.mutate(ctx, m) - case *ItemMutation: - 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: - return c.Location.mutate(ctx, m) case *MaintenanceEntryMutation: return c.MaintenanceEntry.mutate(ctx, m) case *NotifierMutation: @@ -422,15 +422,15 @@ func (c *AttachmentClient) GetX(ctx context.Context, id uuid.UUID) *Attachment { return obj } -// QueryItem queries the item edge of a Attachment. -func (c *AttachmentClient) QueryItem(_m *Attachment) *ItemQuery { - query := (&ItemClient{config: c.config}).Query() +// QueryEntity queries the entity edge of a Attachment. +func (c *AttachmentClient) QueryEntity(_m *Attachment) *EntityQuery { + query := (&EntityClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(attachment.Table, attachment.FieldID, id), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, attachment.ItemTable, attachment.ItemColumn), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -793,6 +793,613 @@ func (c *AuthTokensClient) mutate(ctx context.Context, m *AuthTokensMutation) (V } } +// EntityClient is a client for the Entity schema. +type EntityClient struct { + config +} + +// NewEntityClient returns a client for the Entity from the given config. +func NewEntityClient(c config) *EntityClient { + return &EntityClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `entity.Hooks(f(g(h())))`. +func (c *EntityClient) Use(hooks ...Hook) { + c.hooks.Entity = append(c.hooks.Entity, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `entity.Intercept(f(g(h())))`. +func (c *EntityClient) Intercept(interceptors ...Interceptor) { + c.inters.Entity = append(c.inters.Entity, interceptors...) +} + +// Create returns a builder for creating a Entity entity. +func (c *EntityClient) Create() *EntityCreate { + mutation := newEntityMutation(c.config, OpCreate) + return &EntityCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Entity entities. +func (c *EntityClient) CreateBulk(builders ...*EntityCreate) *EntityCreateBulk { + return &EntityCreateBulk{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 *EntityClient) MapCreateBulk(slice any, setFunc func(*EntityCreate, int)) *EntityCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EntityCreateBulk{err: fmt.Errorf("calling to EntityClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EntityCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EntityCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Entity. +func (c *EntityClient) Update() *EntityUpdate { + mutation := newEntityMutation(c.config, OpUpdate) + return &EntityUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EntityClient) UpdateOne(_m *Entity) *EntityUpdateOne { + mutation := newEntityMutation(c.config, OpUpdateOne, withEntity(_m)) + return &EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EntityClient) UpdateOneID(id uuid.UUID) *EntityUpdateOne { + mutation := newEntityMutation(c.config, OpUpdateOne, withEntityID(id)) + return &EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Entity. +func (c *EntityClient) Delete() *EntityDelete { + mutation := newEntityMutation(c.config, OpDelete) + return &EntityDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EntityClient) DeleteOne(_m *Entity) *EntityDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EntityClient) DeleteOneID(id uuid.UUID) *EntityDeleteOne { + builder := c.Delete().Where(entity.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EntityDeleteOne{builder} +} + +// Query returns a query builder for Entity. +func (c *EntityClient) Query() *EntityQuery { + return &EntityQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEntity}, + inters: c.Interceptors(), + } +} + +// Get returns a Entity entity by its id. +func (c *EntityClient) Get(ctx context.Context, id uuid.UUID) (*Entity, error) { + return c.Query().Where(entity.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EntityClient) GetX(ctx context.Context, id uuid.UUID) *Entity { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryGroup queries the group edge of a Entity. +func (c *EntityClient) QueryGroup(_m *Entity) *GroupQuery { + query := (&GroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, entity.GroupTable, entity.GroupColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryChildren queries the children edge of a Entity. +func (c *EntityClient) QueryChildren(_m *Entity) *EntityQuery { + query := (&EntityClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, entity.ChildrenTable, entity.ChildrenColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryParent queries the parent edge of a Entity. +func (c *EntityClient) QueryParent(_m *Entity) *EntityQuery { + query := (&EntityClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, entity.ParentTable, entity.ParentColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryEntity queries the entity edge of a Entity. +func (c *EntityClient) QueryEntity(_m *Entity) *EntityQuery { + query := (&EntityClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, entity.EntityTable, entity.EntityColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryLocation queries the location edge of a Entity. +func (c *EntityClient) QueryLocation(_m *Entity) *EntityQuery { + query := (&EntityClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, entity.LocationTable, entity.LocationColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryLabel queries the label edge of a Entity. +func (c *EntityClient) QueryLabel(_m *Entity) *LabelQuery { + query := (&LabelClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(label.Table, label.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, entity.LabelTable, entity.LabelPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryType queries the type edge of a Entity. +func (c *EntityClient) QueryType(_m *Entity) *EntityTypeQuery { + query := (&EntityTypeClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(entitytype.Table, entitytype.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, entity.TypeTable, entity.TypeColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryFields queries the fields edge of a Entity. +func (c *EntityClient) QueryFields(_m *Entity) *EntityFieldQuery { + query := (&EntityFieldClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(entityfield.Table, entityfield.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, entity.FieldsTable, entity.FieldsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryMaintenanceEntries queries the maintenance_entries edge of a Entity. +func (c *EntityClient) QueryMaintenanceEntries(_m *Entity) *MaintenanceEntryQuery { + query := (&MaintenanceEntryClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(maintenanceentry.Table, maintenanceentry.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, entity.MaintenanceEntriesTable, entity.MaintenanceEntriesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryAttachments queries the attachments edge of a Entity. +func (c *EntityClient) QueryAttachments(_m *Entity) *AttachmentQuery { + query := (&AttachmentClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entity.Table, entity.FieldID, id), + sqlgraph.To(attachment.Table, attachment.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, entity.AttachmentsTable, entity.AttachmentsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *EntityClient) Hooks() []Hook { + return c.hooks.Entity +} + +// Interceptors returns the client interceptors. +func (c *EntityClient) Interceptors() []Interceptor { + return c.inters.Entity +} + +func (c *EntityClient) mutate(ctx context.Context, m *EntityMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EntityCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EntityUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EntityDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Entity mutation op: %q", m.Op()) + } +} + +// EntityFieldClient is a client for the EntityField schema. +type EntityFieldClient struct { + config +} + +// NewEntityFieldClient returns a client for the EntityField from the given config. +func NewEntityFieldClient(c config) *EntityFieldClient { + return &EntityFieldClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `entityfield.Hooks(f(g(h())))`. +func (c *EntityFieldClient) Use(hooks ...Hook) { + c.hooks.EntityField = append(c.hooks.EntityField, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `entityfield.Intercept(f(g(h())))`. +func (c *EntityFieldClient) Intercept(interceptors ...Interceptor) { + c.inters.EntityField = append(c.inters.EntityField, interceptors...) +} + +// Create returns a builder for creating a EntityField entity. +func (c *EntityFieldClient) Create() *EntityFieldCreate { + mutation := newEntityFieldMutation(c.config, OpCreate) + return &EntityFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EntityField entities. +func (c *EntityFieldClient) CreateBulk(builders ...*EntityFieldCreate) *EntityFieldCreateBulk { + return &EntityFieldCreateBulk{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 *EntityFieldClient) MapCreateBulk(slice any, setFunc func(*EntityFieldCreate, int)) *EntityFieldCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EntityFieldCreateBulk{err: fmt.Errorf("calling to EntityFieldClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EntityFieldCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EntityFieldCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EntityField. +func (c *EntityFieldClient) Update() *EntityFieldUpdate { + mutation := newEntityFieldMutation(c.config, OpUpdate) + return &EntityFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EntityFieldClient) UpdateOne(_m *EntityField) *EntityFieldUpdateOne { + mutation := newEntityFieldMutation(c.config, OpUpdateOne, withEntityField(_m)) + return &EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EntityFieldClient) UpdateOneID(id uuid.UUID) *EntityFieldUpdateOne { + mutation := newEntityFieldMutation(c.config, OpUpdateOne, withEntityFieldID(id)) + return &EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EntityField. +func (c *EntityFieldClient) Delete() *EntityFieldDelete { + mutation := newEntityFieldMutation(c.config, OpDelete) + return &EntityFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EntityFieldClient) DeleteOne(_m *EntityField) *EntityFieldDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EntityFieldClient) DeleteOneID(id uuid.UUID) *EntityFieldDeleteOne { + builder := c.Delete().Where(entityfield.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EntityFieldDeleteOne{builder} +} + +// Query returns a query builder for EntityField. +func (c *EntityFieldClient) Query() *EntityFieldQuery { + return &EntityFieldQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEntityField}, + inters: c.Interceptors(), + } +} + +// Get returns a EntityField entity by its id. +func (c *EntityFieldClient) Get(ctx context.Context, id uuid.UUID) (*EntityField, error) { + return c.Query().Where(entityfield.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EntityFieldClient) GetX(ctx context.Context, id uuid.UUID) *EntityField { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryEntity queries the entity edge of a EntityField. +func (c *EntityFieldClient) QueryEntity(_m *EntityField) *EntityQuery { + query := (&EntityClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entityfield.Table, entityfield.FieldID, id), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, entityfield.EntityTable, entityfield.EntityColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *EntityFieldClient) Hooks() []Hook { + return c.hooks.EntityField +} + +// Interceptors returns the client interceptors. +func (c *EntityFieldClient) Interceptors() []Interceptor { + return c.inters.EntityField +} + +func (c *EntityFieldClient) mutate(ctx context.Context, m *EntityFieldMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EntityFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EntityFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EntityFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EntityField mutation op: %q", m.Op()) + } +} + +// EntityTypeClient is a client for the EntityType schema. +type EntityTypeClient struct { + config +} + +// NewEntityTypeClient returns a client for the EntityType from the given config. +func NewEntityTypeClient(c config) *EntityTypeClient { + return &EntityTypeClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `entitytype.Hooks(f(g(h())))`. +func (c *EntityTypeClient) Use(hooks ...Hook) { + c.hooks.EntityType = append(c.hooks.EntityType, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `entitytype.Intercept(f(g(h())))`. +func (c *EntityTypeClient) Intercept(interceptors ...Interceptor) { + c.inters.EntityType = append(c.inters.EntityType, interceptors...) +} + +// Create returns a builder for creating a EntityType entity. +func (c *EntityTypeClient) Create() *EntityTypeCreate { + mutation := newEntityTypeMutation(c.config, OpCreate) + return &EntityTypeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EntityType entities. +func (c *EntityTypeClient) CreateBulk(builders ...*EntityTypeCreate) *EntityTypeCreateBulk { + return &EntityTypeCreateBulk{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 *EntityTypeClient) MapCreateBulk(slice any, setFunc func(*EntityTypeCreate, int)) *EntityTypeCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EntityTypeCreateBulk{err: fmt.Errorf("calling to EntityTypeClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EntityTypeCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EntityTypeCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EntityType. +func (c *EntityTypeClient) Update() *EntityTypeUpdate { + mutation := newEntityTypeMutation(c.config, OpUpdate) + return &EntityTypeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EntityTypeClient) UpdateOne(_m *EntityType) *EntityTypeUpdateOne { + mutation := newEntityTypeMutation(c.config, OpUpdateOne, withEntityType(_m)) + return &EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EntityTypeClient) UpdateOneID(id uuid.UUID) *EntityTypeUpdateOne { + mutation := newEntityTypeMutation(c.config, OpUpdateOne, withEntityTypeID(id)) + return &EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EntityType. +func (c *EntityTypeClient) Delete() *EntityTypeDelete { + mutation := newEntityTypeMutation(c.config, OpDelete) + return &EntityTypeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EntityTypeClient) DeleteOne(_m *EntityType) *EntityTypeDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EntityTypeClient) DeleteOneID(id uuid.UUID) *EntityTypeDeleteOne { + builder := c.Delete().Where(entitytype.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EntityTypeDeleteOne{builder} +} + +// Query returns a query builder for EntityType. +func (c *EntityTypeClient) Query() *EntityTypeQuery { + return &EntityTypeQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEntityType}, + inters: c.Interceptors(), + } +} + +// Get returns a EntityType entity by its id. +func (c *EntityTypeClient) Get(ctx context.Context, id uuid.UUID) (*EntityType, error) { + return c.Query().Where(entitytype.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EntityTypeClient) GetX(ctx context.Context, id uuid.UUID) *EntityType { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryGroup queries the group edge of a EntityType. +func (c *EntityTypeClient) QueryGroup(_m *EntityType) *GroupQuery { + query := (&GroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entitytype.Table, entitytype.FieldID, id), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, entitytype.GroupTable, entitytype.GroupColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryEntities queries the entities edge of a EntityType. +func (c *EntityTypeClient) QueryEntities(_m *EntityType) *EntityQuery { + query := (&EntityClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(entitytype.Table, entitytype.FieldID, id), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, entitytype.EntitiesTable, entitytype.EntitiesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *EntityTypeClient) Hooks() []Hook { + return c.hooks.EntityType +} + +// Interceptors returns the client interceptors. +func (c *EntityTypeClient) Interceptors() []Interceptor { + return c.inters.EntityType +} + +func (c *EntityTypeClient) mutate(ctx context.Context, m *EntityTypeMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EntityTypeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EntityTypeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EntityTypeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EntityType mutation op: %q", m.Op()) + } +} + // GroupClient is a client for the Group schema. type GroupClient struct { config @@ -917,31 +1524,15 @@ func (c *GroupClient) QueryUsers(_m *Group) *UserQuery { return query } -// QueryLocations queries the locations edge of a Group. -func (c *GroupClient) QueryLocations(_m *Group) *LocationQuery { - query := (&LocationClient{config: c.config}).Query() +// QueryEntities queries the entities edge of a Group. +func (c *GroupClient) QueryEntities(_m *Group) *EntityQuery { + query := (&EntityClient{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(location.Table, location.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, group.LocationsTable, group.LocationsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryItems queries the items edge of a Group. -func (c *GroupClient) QueryItems(_m *Group) *ItemQuery { - query := (&ItemClient{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(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, group.ItemsTable, group.ItemsColumn), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -997,6 +1588,22 @@ func (c *GroupClient) QueryNotifiers(_m *Group) *NotifierQuery { return query } +// QueryEntityTypes queries the entity_types edge of a Group. +func (c *GroupClient) QueryEntityTypes(_m *Group) *EntityTypeQuery { + query := (&EntityTypeClient{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(entitytype.Table, entitytype.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.EntityTypesTable, group.EntityTypesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryItemTemplates queries the item_templates edge of a Group. func (c *GroupClient) QueryItemTemplates(_m *Group) *ItemTemplateQuery { query := (&ItemTemplateClient{config: c.config}).Query() @@ -1187,416 +1794,6 @@ func (c *GroupInvitationTokenClient) mutate(ctx context.Context, m *GroupInvitat } } -// ItemClient is a client for the Item schema. -type ItemClient struct { - config -} - -// NewItemClient returns a client for the Item from the given config. -func NewItemClient(c config) *ItemClient { - return &ItemClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `item.Hooks(f(g(h())))`. -func (c *ItemClient) Use(hooks ...Hook) { - c.hooks.Item = append(c.hooks.Item, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `item.Intercept(f(g(h())))`. -func (c *ItemClient) Intercept(interceptors ...Interceptor) { - c.inters.Item = append(c.inters.Item, interceptors...) -} - -// Create returns a builder for creating a Item entity. -func (c *ItemClient) Create() *ItemCreate { - mutation := newItemMutation(c.config, OpCreate) - return &ItemCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Item entities. -func (c *ItemClient) CreateBulk(builders ...*ItemCreate) *ItemCreateBulk { - return &ItemCreateBulk{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 *ItemClient) MapCreateBulk(slice any, setFunc func(*ItemCreate, int)) *ItemCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &ItemCreateBulk{err: fmt.Errorf("calling to ItemClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*ItemCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &ItemCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Item. -func (c *ItemClient) Update() *ItemUpdate { - mutation := newItemMutation(c.config, OpUpdate) - return &ItemUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *ItemClient) UpdateOne(_m *Item) *ItemUpdateOne { - mutation := newItemMutation(c.config, OpUpdateOne, withItem(_m)) - return &ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *ItemClient) UpdateOneID(id uuid.UUID) *ItemUpdateOne { - mutation := newItemMutation(c.config, OpUpdateOne, withItemID(id)) - return &ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Item. -func (c *ItemClient) Delete() *ItemDelete { - mutation := newItemMutation(c.config, OpDelete) - return &ItemDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *ItemClient) DeleteOne(_m *Item) *ItemDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *ItemClient) DeleteOneID(id uuid.UUID) *ItemDeleteOne { - builder := c.Delete().Where(item.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &ItemDeleteOne{builder} -} - -// Query returns a query builder for Item. -func (c *ItemClient) Query() *ItemQuery { - return &ItemQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeItem}, - inters: c.Interceptors(), - } -} - -// Get returns a Item entity by its id. -func (c *ItemClient) Get(ctx context.Context, id uuid.UUID) (*Item, error) { - return c.Query().Where(item.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *ItemClient) GetX(ctx context.Context, id uuid.UUID) *Item { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryGroup queries the group edge of a Item. -func (c *ItemClient) QueryGroup(_m *Item) *GroupQuery { - query := (&GroupClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(item.Table, item.FieldID, id), - sqlgraph.To(group.Table, group.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, item.GroupTable, item.GroupColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryParent queries the parent edge of a Item. -func (c *ItemClient) QueryParent(_m *Item) *ItemQuery { - query := (&ItemClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(item.Table, item.FieldID, id), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, item.ParentTable, item.ParentColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryChildren queries the children edge of a Item. -func (c *ItemClient) QueryChildren(_m *Item) *ItemQuery { - query := (&ItemClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(item.Table, item.FieldID, id), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, item.ChildrenTable, item.ChildrenColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryLabel queries the label edge of a Item. -func (c *ItemClient) QueryLabel(_m *Item) *LabelQuery { - query := (&LabelClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(item.Table, item.FieldID, id), - sqlgraph.To(label.Table, label.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryLocation queries the location edge of a Item. -func (c *ItemClient) QueryLocation(_m *Item) *LocationQuery { - query := (&LocationClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(item.Table, item.FieldID, id), - sqlgraph.To(location.Table, location.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, item.LocationTable, item.LocationColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryFields queries the fields edge of a Item. -func (c *ItemClient) QueryFields(_m *Item) *ItemFieldQuery { - query := (&ItemFieldClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(item.Table, item.FieldID, id), - sqlgraph.To(itemfield.Table, itemfield.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, item.FieldsTable, item.FieldsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryMaintenanceEntries queries the maintenance_entries edge of a Item. -func (c *ItemClient) QueryMaintenanceEntries(_m *Item) *MaintenanceEntryQuery { - query := (&MaintenanceEntryClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(item.Table, item.FieldID, id), - sqlgraph.To(maintenanceentry.Table, maintenanceentry.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, item.MaintenanceEntriesTable, item.MaintenanceEntriesColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryAttachments queries the attachments edge of a Item. -func (c *ItemClient) QueryAttachments(_m *Item) *AttachmentQuery { - query := (&AttachmentClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(item.Table, item.FieldID, id), - sqlgraph.To(attachment.Table, attachment.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, item.AttachmentsTable, item.AttachmentsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *ItemClient) Hooks() []Hook { - return c.hooks.Item -} - -// Interceptors returns the client interceptors. -func (c *ItemClient) Interceptors() []Interceptor { - return c.inters.Item -} - -func (c *ItemClient) mutate(ctx context.Context, m *ItemMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&ItemCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&ItemUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&ItemDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown Item mutation op: %q", m.Op()) - } -} - -// ItemFieldClient is a client for the ItemField schema. -type ItemFieldClient struct { - config -} - -// NewItemFieldClient returns a client for the ItemField from the given config. -func NewItemFieldClient(c config) *ItemFieldClient { - return &ItemFieldClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `itemfield.Hooks(f(g(h())))`. -func (c *ItemFieldClient) Use(hooks ...Hook) { - c.hooks.ItemField = append(c.hooks.ItemField, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `itemfield.Intercept(f(g(h())))`. -func (c *ItemFieldClient) Intercept(interceptors ...Interceptor) { - c.inters.ItemField = append(c.inters.ItemField, interceptors...) -} - -// Create returns a builder for creating a ItemField entity. -func (c *ItemFieldClient) Create() *ItemFieldCreate { - mutation := newItemFieldMutation(c.config, OpCreate) - return &ItemFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of ItemField entities. -func (c *ItemFieldClient) CreateBulk(builders ...*ItemFieldCreate) *ItemFieldCreateBulk { - return &ItemFieldCreateBulk{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 *ItemFieldClient) MapCreateBulk(slice any, setFunc func(*ItemFieldCreate, int)) *ItemFieldCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &ItemFieldCreateBulk{err: fmt.Errorf("calling to ItemFieldClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*ItemFieldCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &ItemFieldCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for ItemField. -func (c *ItemFieldClient) Update() *ItemFieldUpdate { - mutation := newItemFieldMutation(c.config, OpUpdate) - return &ItemFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *ItemFieldClient) UpdateOne(_m *ItemField) *ItemFieldUpdateOne { - mutation := newItemFieldMutation(c.config, OpUpdateOne, withItemField(_m)) - return &ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *ItemFieldClient) UpdateOneID(id uuid.UUID) *ItemFieldUpdateOne { - mutation := newItemFieldMutation(c.config, OpUpdateOne, withItemFieldID(id)) - return &ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for ItemField. -func (c *ItemFieldClient) Delete() *ItemFieldDelete { - mutation := newItemFieldMutation(c.config, OpDelete) - return &ItemFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *ItemFieldClient) DeleteOne(_m *ItemField) *ItemFieldDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *ItemFieldClient) DeleteOneID(id uuid.UUID) *ItemFieldDeleteOne { - builder := c.Delete().Where(itemfield.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &ItemFieldDeleteOne{builder} -} - -// Query returns a query builder for ItemField. -func (c *ItemFieldClient) Query() *ItemFieldQuery { - return &ItemFieldQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeItemField}, - inters: c.Interceptors(), - } -} - -// Get returns a ItemField entity by its id. -func (c *ItemFieldClient) Get(ctx context.Context, id uuid.UUID) (*ItemField, error) { - return c.Query().Where(itemfield.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *ItemFieldClient) GetX(ctx context.Context, id uuid.UUID) *ItemField { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryItem queries the item edge of a ItemField. -func (c *ItemFieldClient) QueryItem(_m *ItemField) *ItemQuery { - query := (&ItemClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(itemfield.Table, itemfield.FieldID, id), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, itemfield.ItemTable, itemfield.ItemColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *ItemFieldClient) Hooks() []Hook { - return c.hooks.ItemField -} - -// Interceptors returns the client interceptors. -func (c *ItemFieldClient) Interceptors() []Interceptor { - return c.inters.ItemField -} - -func (c *ItemFieldClient) mutate(ctx context.Context, m *ItemFieldMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&ItemFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&ItemFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&ItemFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown ItemField mutation op: %q", m.Op()) - } -} - // ItemTemplateClient is a client for the ItemTemplate schema. type ItemTemplateClient struct { config @@ -1738,13 +1935,13 @@ func (c *ItemTemplateClient) QueryFields(_m *ItemTemplate) *TemplateFieldQuery { } // QueryLocation queries the location edge of a ItemTemplate. -func (c *ItemTemplateClient) QueryLocation(_m *ItemTemplate) *LocationQuery { - query := (&LocationClient{config: c.config}).Query() +func (c *ItemTemplateClient) QueryLocation(_m *ItemTemplate) *EntityQuery { + query := (&EntityClient{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.To(entity.Table, entity.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) @@ -1902,15 +2099,15 @@ func (c *LabelClient) QueryGroup(_m *Label) *GroupQuery { return query } -// QueryItems queries the items edge of a Label. -func (c *LabelClient) QueryItems(_m *Label) *ItemQuery { - query := (&ItemClient{config: c.config}).Query() +// QueryEntities queries the entities edge of a Label. +func (c *LabelClient) QueryEntities(_m *Label) *EntityQuery { + query := (&EntityClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(label.Table, label.FieldID, id), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -1943,203 +2140,6 @@ func (c *LabelClient) mutate(ctx context.Context, m *LabelMutation) (Value, erro } } -// LocationClient is a client for the Location schema. -type LocationClient struct { - config -} - -// NewLocationClient returns a client for the Location from the given config. -func NewLocationClient(c config) *LocationClient { - return &LocationClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `location.Hooks(f(g(h())))`. -func (c *LocationClient) Use(hooks ...Hook) { - c.hooks.Location = append(c.hooks.Location, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `location.Intercept(f(g(h())))`. -func (c *LocationClient) Intercept(interceptors ...Interceptor) { - c.inters.Location = append(c.inters.Location, interceptors...) -} - -// Create returns a builder for creating a Location entity. -func (c *LocationClient) Create() *LocationCreate { - mutation := newLocationMutation(c.config, OpCreate) - return &LocationCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Location entities. -func (c *LocationClient) CreateBulk(builders ...*LocationCreate) *LocationCreateBulk { - return &LocationCreateBulk{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 *LocationClient) MapCreateBulk(slice any, setFunc func(*LocationCreate, int)) *LocationCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &LocationCreateBulk{err: fmt.Errorf("calling to LocationClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*LocationCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &LocationCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Location. -func (c *LocationClient) Update() *LocationUpdate { - mutation := newLocationMutation(c.config, OpUpdate) - return &LocationUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *LocationClient) UpdateOne(_m *Location) *LocationUpdateOne { - mutation := newLocationMutation(c.config, OpUpdateOne, withLocation(_m)) - return &LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *LocationClient) UpdateOneID(id uuid.UUID) *LocationUpdateOne { - mutation := newLocationMutation(c.config, OpUpdateOne, withLocationID(id)) - return &LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Location. -func (c *LocationClient) Delete() *LocationDelete { - mutation := newLocationMutation(c.config, OpDelete) - return &LocationDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *LocationClient) DeleteOne(_m *Location) *LocationDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *LocationClient) DeleteOneID(id uuid.UUID) *LocationDeleteOne { - builder := c.Delete().Where(location.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &LocationDeleteOne{builder} -} - -// Query returns a query builder for Location. -func (c *LocationClient) Query() *LocationQuery { - return &LocationQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeLocation}, - inters: c.Interceptors(), - } -} - -// Get returns a Location entity by its id. -func (c *LocationClient) Get(ctx context.Context, id uuid.UUID) (*Location, error) { - return c.Query().Where(location.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *LocationClient) GetX(ctx context.Context, id uuid.UUID) *Location { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryGroup queries the group edge of a Location. -func (c *LocationClient) QueryGroup(_m *Location) *GroupQuery { - query := (&GroupClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(location.Table, location.FieldID, id), - sqlgraph.To(group.Table, group.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, location.GroupTable, location.GroupColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryParent queries the parent edge of a Location. -func (c *LocationClient) QueryParent(_m *Location) *LocationQuery { - query := (&LocationClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(location.Table, location.FieldID, id), - sqlgraph.To(location.Table, location.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, location.ParentTable, location.ParentColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryChildren queries the children edge of a Location. -func (c *LocationClient) QueryChildren(_m *Location) *LocationQuery { - query := (&LocationClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(location.Table, location.FieldID, id), - sqlgraph.To(location.Table, location.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, location.ChildrenTable, location.ChildrenColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryItems queries the items edge of a Location. -func (c *LocationClient) QueryItems(_m *Location) *ItemQuery { - query := (&ItemClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(location.Table, location.FieldID, id), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, location.ItemsTable, location.ItemsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *LocationClient) Hooks() []Hook { - return c.hooks.Location -} - -// Interceptors returns the client interceptors. -func (c *LocationClient) Interceptors() []Interceptor { - return c.inters.Location -} - -func (c *LocationClient) mutate(ctx context.Context, m *LocationMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&LocationCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&LocationUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&LocationDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown Location mutation op: %q", m.Op()) - } -} - // MaintenanceEntryClient is a client for the MaintenanceEntry schema. type MaintenanceEntryClient struct { config @@ -2248,15 +2248,15 @@ func (c *MaintenanceEntryClient) GetX(ctx context.Context, id uuid.UUID) *Mainte return obj } -// QueryItem queries the item edge of a MaintenanceEntry. -func (c *MaintenanceEntryClient) QueryItem(_m *MaintenanceEntry) *ItemQuery { - query := (&ItemClient{config: c.config}).Query() +// QueryEntity queries the entity edge of a MaintenanceEntry. +func (c *MaintenanceEntryClient) QueryEntity(_m *MaintenanceEntry) *EntityQuery { + query := (&EntityClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, id), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.ItemTable, maintenanceentry.ItemColumn), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -2787,13 +2787,13 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField, - ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField, - User []ent.Hook + Attachment, AuthRoles, AuthTokens, Entity, EntityField, EntityType, Group, + GroupInvitationToken, ItemTemplate, Label, MaintenanceEntry, Notifier, + TemplateField, User []ent.Hook } inters struct { - Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField, - ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField, - User []ent.Interceptor + Attachment, AuthRoles, AuthTokens, Entity, EntityField, EntityType, Group, + GroupInvitationToken, ItemTemplate, Label, MaintenanceEntry, Notifier, + TemplateField, User []ent.Interceptor } ) diff --git a/backend/internal/data/ent/ent.go b/backend/internal/data/ent/ent.go index ee3abfa7..4609d3f4 100644 --- a/backend/internal/data/ent/ent.go +++ b/backend/internal/data/ent/ent.go @@ -15,13 +15,13 @@ import ( "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "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/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" @@ -89,13 +89,13 @@ func checkColumn(t, c string) error { attachment.Table: attachment.ValidColumn, authroles.Table: authroles.ValidColumn, authtokens.Table: authtokens.ValidColumn, + entity.Table: entity.ValidColumn, + entityfield.Table: entityfield.ValidColumn, + entitytype.Table: entitytype.ValidColumn, group.Table: group.ValidColumn, 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, diff --git a/backend/internal/data/ent/entityfield.go b/backend/internal/data/ent/entityfield.go index 72342ef1..186fc4de 100644 --- a/backend/internal/data/ent/entityfield.go +++ b/backend/internal/data/ent/entityfield.go @@ -10,12 +10,12 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "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/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" ) -// ItemField is the model entity for the ItemField schema. -type ItemField struct { +// EntityField is the model entity for the EntityField schema. +type EntityField struct { config `json:"-"` // ID of the ent. ID uuid.UUID `json:"id,omitempty"` @@ -28,7 +28,7 @@ type ItemField struct { // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Type holds the value of the "type" field. - Type itemfield.Type `json:"type,omitempty"` + Type entityfield.Type `json:"type,omitempty"` // TextValue holds the value of the "text_value" field. TextValue string `json:"text_value,omitempty"` // NumberValue holds the value of the "number_value" field. @@ -38,48 +38,48 @@ type ItemField struct { // TimeValue holds the value of the "time_value" field. TimeValue time.Time `json:"time_value,omitempty"` // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the ItemFieldQuery when eager-loading is set. - Edges ItemFieldEdges `json:"edges"` - item_fields *uuid.UUID - selectValues sql.SelectValues + // The values are being populated by the EntityFieldQuery when eager-loading is set. + Edges EntityFieldEdges `json:"edges"` + entity_fields *uuid.UUID + selectValues sql.SelectValues } -// ItemFieldEdges holds the relations/edges for other nodes in the graph. -type ItemFieldEdges struct { - // Item holds the value of the item edge. - Item *Item `json:"item,omitempty"` +// EntityFieldEdges holds the relations/edges for other nodes in the graph. +type EntityFieldEdges struct { + // Entity holds the value of the entity edge. + Entity *Entity `json:"entity,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } -// ItemOrErr returns the Item value or an error if the edge +// EntityOrErr returns the Entity value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e ItemFieldEdges) ItemOrErr() (*Item, error) { - if e.Item != nil { - return e.Item, nil +func (e EntityFieldEdges) EntityOrErr() (*Entity, error) { + if e.Entity != nil { + return e.Entity, nil } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: item.Label} + return nil, &NotFoundError{label: entity.Label} } - return nil, &NotLoadedError{edge: "item"} + return nil, &NotLoadedError{edge: "entity"} } // scanValues returns the types for scanning values from sql.Rows. -func (*ItemField) scanValues(columns []string) ([]any, error) { +func (*EntityField) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case itemfield.FieldBooleanValue: + case entityfield.FieldBooleanValue: values[i] = new(sql.NullBool) - case itemfield.FieldNumberValue: + case entityfield.FieldNumberValue: values[i] = new(sql.NullInt64) - case itemfield.FieldName, itemfield.FieldDescription, itemfield.FieldType, itemfield.FieldTextValue: + case entityfield.FieldName, entityfield.FieldDescription, entityfield.FieldType, entityfield.FieldTextValue: values[i] = new(sql.NullString) - case itemfield.FieldCreatedAt, itemfield.FieldUpdatedAt, itemfield.FieldTimeValue: + case entityfield.FieldCreatedAt, entityfield.FieldUpdatedAt, entityfield.FieldTimeValue: values[i] = new(sql.NullTime) - case itemfield.FieldID: + case entityfield.FieldID: values[i] = new(uuid.UUID) - case itemfield.ForeignKeys[0]: // item_fields + case entityfield.ForeignKeys[0]: // entity_fields values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) @@ -89,79 +89,79 @@ func (*ItemField) scanValues(columns []string) ([]any, error) { } // assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the ItemField fields. -func (_m *ItemField) assignValues(columns []string, values []any) error { +// to the EntityField fields. +func (_m *EntityField) 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 itemfield.FieldID: + case entityfield.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 itemfield.FieldCreatedAt: + case entityfield.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 itemfield.FieldUpdatedAt: + case entityfield.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 itemfield.FieldName: + case entityfield.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 itemfield.FieldDescription: + case entityfield.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 itemfield.FieldType: + case entityfield.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 = itemfield.Type(value.String) + _m.Type = entityfield.Type(value.String) } - case itemfield.FieldTextValue: + case entityfield.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 itemfield.FieldNumberValue: + case entityfield.FieldNumberValue: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field number_value", values[i]) } else if value.Valid { _m.NumberValue = int(value.Int64) } - case itemfield.FieldBooleanValue: + case entityfield.FieldBooleanValue: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field boolean_value", values[i]) } else if value.Valid { _m.BooleanValue = value.Bool } - case itemfield.FieldTimeValue: + case entityfield.FieldTimeValue: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field time_value", values[i]) } else if value.Valid { _m.TimeValue = value.Time } - case itemfield.ForeignKeys[0]: + case entityfield.ForeignKeys[0]: if value, ok := values[i].(*sql.NullScanner); !ok { - return fmt.Errorf("unexpected type %T for field item_fields", values[i]) + return fmt.Errorf("unexpected type %T for field entity_fields", values[i]) } else if value.Valid { - _m.item_fields = new(uuid.UUID) - *_m.item_fields = *value.S.(*uuid.UUID) + _m.entity_fields = new(uuid.UUID) + *_m.entity_fields = *value.S.(*uuid.UUID) } default: _m.selectValues.Set(columns[i], values[i]) @@ -170,39 +170,39 @@ func (_m *ItemField) assignValues(columns []string, values []any) error { return nil } -// Value returns the ent.Value that was dynamically selected and assigned to the ItemField. +// Value returns the ent.Value that was dynamically selected and assigned to the EntityField. // This includes values selected through modifiers, order, etc. -func (_m *ItemField) Value(name string) (ent.Value, error) { +func (_m *EntityField) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } -// QueryItem queries the "item" edge of the ItemField entity. -func (_m *ItemField) QueryItem() *ItemQuery { - return NewItemFieldClient(_m.config).QueryItem(_m) +// QueryEntity queries the "entity" edge of the EntityField entity. +func (_m *EntityField) QueryEntity() *EntityQuery { + return NewEntityFieldClient(_m.config).QueryEntity(_m) } -// Update returns a builder for updating this ItemField. -// Note that you need to call ItemField.Unwrap() before calling this method if this ItemField +// Update returns a builder for updating this EntityField. +// Note that you need to call EntityField.Unwrap() before calling this method if this EntityField // was returned from a transaction, and the transaction was committed or rolled back. -func (_m *ItemField) Update() *ItemFieldUpdateOne { - return NewItemFieldClient(_m.config).UpdateOne(_m) +func (_m *EntityField) Update() *EntityFieldUpdateOne { + return NewEntityFieldClient(_m.config).UpdateOne(_m) } -// Unwrap unwraps the ItemField entity that was returned from a transaction after it was closed, +// Unwrap unwraps the EntityField 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 *ItemField) Unwrap() *ItemField { +func (_m *EntityField) Unwrap() *EntityField { _tx, ok := _m.config.driver.(*txDriver) if !ok { - panic("ent: ItemField is not a transactional entity") + panic("ent: EntityField is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. -func (_m *ItemField) String() string { +func (_m *EntityField) String() string { var builder strings.Builder - builder.WriteString("ItemField(") + builder.WriteString("EntityField(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) @@ -234,5 +234,5 @@ func (_m *ItemField) String() string { return builder.String() } -// ItemFields is a parsable slice of ItemField. -type ItemFields []*ItemField +// EntityFields is a parsable slice of EntityField. +type EntityFields []*EntityField diff --git a/backend/internal/data/ent/group.go b/backend/internal/data/ent/group.go index d20782b9..4d638aad 100644 --- a/backend/internal/data/ent/group.go +++ b/backend/internal/data/ent/group.go @@ -36,16 +36,16 @@ type Group struct { type GroupEdges struct { // Users holds the value of the users edge. Users []*User `json:"users,omitempty"` - // Locations holds the value of the locations edge. - Locations []*Location `json:"locations,omitempty"` - // Items holds the value of the items edge. - Items []*Item `json:"items,omitempty"` + // Entities holds the value of the entities edge. + Entities []*Entity `json:"entities,omitempty"` // Labels holds the value of the labels edge. Labels []*Label `json:"labels,omitempty"` // InvitationTokens holds the value of the invitation_tokens edge. InvitationTokens []*GroupInvitationToken `json:"invitation_tokens,omitempty"` // Notifiers holds the value of the notifiers edge. Notifiers []*Notifier `json:"notifiers,omitempty"` + // EntityTypes holds the value of the entity_types edge. + EntityTypes []*EntityType `json:"entity_types,omitempty"` // ItemTemplates holds the value of the item_templates edge. ItemTemplates []*ItemTemplate `json:"item_templates,omitempty"` // loadedTypes holds the information for reporting if a @@ -62,28 +62,19 @@ func (e GroupEdges) UsersOrErr() ([]*User, error) { return nil, &NotLoadedError{edge: "users"} } -// LocationsOrErr returns the Locations value or an error if the edge +// EntitiesOrErr returns the Entities value or an error if the edge // was not loaded in eager-loading. -func (e GroupEdges) LocationsOrErr() ([]*Location, error) { +func (e GroupEdges) EntitiesOrErr() ([]*Entity, error) { if e.loadedTypes[1] { - return e.Locations, nil + return e.Entities, nil } - return nil, &NotLoadedError{edge: "locations"} -} - -// ItemsOrErr returns the Items value or an error if the edge -// was not loaded in eager-loading. -func (e GroupEdges) ItemsOrErr() ([]*Item, error) { - if e.loadedTypes[2] { - return e.Items, nil - } - return nil, &NotLoadedError{edge: "items"} + return nil, &NotLoadedError{edge: "entities"} } // LabelsOrErr returns the Labels value or an error if the edge // was not loaded in eager-loading. func (e GroupEdges) LabelsOrErr() ([]*Label, error) { - if e.loadedTypes[3] { + if e.loadedTypes[2] { return e.Labels, nil } return nil, &NotLoadedError{edge: "labels"} @@ -92,7 +83,7 @@ func (e GroupEdges) LabelsOrErr() ([]*Label, error) { // InvitationTokensOrErr returns the InvitationTokens value or an error if the edge // was not loaded in eager-loading. func (e GroupEdges) InvitationTokensOrErr() ([]*GroupInvitationToken, error) { - if e.loadedTypes[4] { + if e.loadedTypes[3] { return e.InvitationTokens, nil } return nil, &NotLoadedError{edge: "invitation_tokens"} @@ -101,12 +92,21 @@ func (e GroupEdges) InvitationTokensOrErr() ([]*GroupInvitationToken, error) { // NotifiersOrErr returns the Notifiers value or an error if the edge // was not loaded in eager-loading. func (e GroupEdges) NotifiersOrErr() ([]*Notifier, error) { - if e.loadedTypes[5] { + if e.loadedTypes[4] { return e.Notifiers, nil } return nil, &NotLoadedError{edge: "notifiers"} } +// EntityTypesOrErr returns the EntityTypes value or an error if the edge +// was not loaded in eager-loading. +func (e GroupEdges) EntityTypesOrErr() ([]*EntityType, error) { + if e.loadedTypes[5] { + return e.EntityTypes, nil + } + return nil, &NotLoadedError{edge: "entity_types"} +} + // ItemTemplatesOrErr returns the ItemTemplates value or an error if the edge // was not loaded in eager-loading. func (e GroupEdges) ItemTemplatesOrErr() ([]*ItemTemplate, error) { @@ -190,14 +190,9 @@ func (_m *Group) QueryUsers() *UserQuery { return NewGroupClient(_m.config).QueryUsers(_m) } -// QueryLocations queries the "locations" edge of the Group entity. -func (_m *Group) QueryLocations() *LocationQuery { - return NewGroupClient(_m.config).QueryLocations(_m) -} - -// QueryItems queries the "items" edge of the Group entity. -func (_m *Group) QueryItems() *ItemQuery { - return NewGroupClient(_m.config).QueryItems(_m) +// QueryEntities queries the "entities" edge of the Group entity. +func (_m *Group) QueryEntities() *EntityQuery { + return NewGroupClient(_m.config).QueryEntities(_m) } // QueryLabels queries the "labels" edge of the Group entity. @@ -215,6 +210,11 @@ func (_m *Group) QueryNotifiers() *NotifierQuery { return NewGroupClient(_m.config).QueryNotifiers(_m) } +// QueryEntityTypes queries the "entity_types" edge of the Group entity. +func (_m *Group) QueryEntityTypes() *EntityTypeQuery { + return NewGroupClient(_m.config).QueryEntityTypes(_m) +} + // QueryItemTemplates queries the "item_templates" edge of the Group entity. func (_m *Group) QueryItemTemplates() *ItemTemplateQuery { return NewGroupClient(_m.config).QueryItemTemplates(_m) diff --git a/backend/internal/data/ent/group/group.go b/backend/internal/data/ent/group/group.go index 80dc3398..89c31e86 100644 --- a/backend/internal/data/ent/group/group.go +++ b/backend/internal/data/ent/group/group.go @@ -25,16 +25,16 @@ const ( FieldCurrency = "currency" // EdgeUsers holds the string denoting the users edge name in mutations. EdgeUsers = "users" - // EdgeLocations holds the string denoting the locations edge name in mutations. - EdgeLocations = "locations" - // EdgeItems holds the string denoting the items edge name in mutations. - EdgeItems = "items" + // EdgeEntities holds the string denoting the entities edge name in mutations. + EdgeEntities = "entities" // EdgeLabels holds the string denoting the labels edge name in mutations. EdgeLabels = "labels" // EdgeInvitationTokens holds the string denoting the invitation_tokens edge name in mutations. EdgeInvitationTokens = "invitation_tokens" // EdgeNotifiers holds the string denoting the notifiers edge name in mutations. EdgeNotifiers = "notifiers" + // EdgeEntityTypes holds the string denoting the entity_types edge name in mutations. + EdgeEntityTypes = "entity_types" // 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. @@ -46,20 +46,13 @@ const ( UsersInverseTable = "users" // UsersColumn is the table column denoting the users relation/edge. UsersColumn = "group_users" - // LocationsTable is the table that holds the locations relation/edge. - LocationsTable = "locations" - // LocationsInverseTable is the table name for the Location entity. - // It exists in this package in order to avoid circular dependency with the "location" package. - LocationsInverseTable = "locations" - // LocationsColumn is the table column denoting the locations relation/edge. - LocationsColumn = "group_locations" - // ItemsTable is the table that holds the items relation/edge. - ItemsTable = "items" - // ItemsInverseTable is the table name for the Item entity. - // It exists in this package in order to avoid circular dependency with the "item" package. - ItemsInverseTable = "items" - // ItemsColumn is the table column denoting the items relation/edge. - ItemsColumn = "group_items" + // EntitiesTable is the table that holds the entities relation/edge. + EntitiesTable = "entities" + // EntitiesInverseTable is the table name for the Entity entity. + // It exists in this package in order to avoid circular dependency with the "entity" package. + EntitiesInverseTable = "entities" + // EntitiesColumn is the table column denoting the entities relation/edge. + EntitiesColumn = "group_entities" // LabelsTable is the table that holds the labels relation/edge. LabelsTable = "labels" // LabelsInverseTable is the table name for the Label entity. @@ -81,6 +74,13 @@ const ( NotifiersInverseTable = "notifiers" // NotifiersColumn is the table column denoting the notifiers relation/edge. NotifiersColumn = "group_id" + // EntityTypesTable is the table that holds the entity_types relation/edge. + EntityTypesTable = "entity_types" + // EntityTypesInverseTable is the table name for the EntityType entity. + // It exists in this package in order to avoid circular dependency with the "entitytype" package. + EntityTypesInverseTable = "entity_types" + // EntityTypesColumn is the table column denoting the entity_types relation/edge. + EntityTypesColumn = "group_entity_types" // ItemTemplatesTable is the table that holds the item_templates relation/edge. ItemTemplatesTable = "item_templates" // ItemTemplatesInverseTable is the table name for the ItemTemplate entity. @@ -166,31 +166,17 @@ func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } -// ByLocationsCount orders the results by locations count. -func ByLocationsCount(opts ...sql.OrderTermOption) OrderOption { +// ByEntitiesCount orders the results by entities count. +func ByEntitiesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newLocationsStep(), opts...) + sqlgraph.OrderByNeighborsCount(s, newEntitiesStep(), opts...) } } -// ByLocations orders the results by locations terms. -func ByLocations(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { +// ByEntities orders the results by entities terms. +func ByEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newLocationsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByItemsCount orders the results by items count. -func ByItemsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newItemsStep(), opts...) - } -} - -// ByItems orders the results by items terms. -func ByItems(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newItemsStep(), append([]sql.OrderTerm{term}, terms...)...) + sqlgraph.OrderByNeighborTerms(s, newEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...) } } @@ -236,6 +222,20 @@ func ByNotifiers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } +// ByEntityTypesCount orders the results by entity_types count. +func ByEntityTypesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newEntityTypesStep(), opts...) + } +} + +// ByEntityTypes orders the results by entity_types terms. +func ByEntityTypes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newEntityTypesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByItemTemplatesCount orders the results by item_templates count. func ByItemTemplatesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -256,18 +256,11 @@ func newUsersStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn), ) } -func newLocationsStep() *sqlgraph.Step { +func newEntitiesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(LocationsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn), - ) -} -func newItemsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(ItemsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn), + sqlgraph.To(EntitiesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn), ) } func newLabelsStep() *sqlgraph.Step { @@ -291,6 +284,13 @@ func newNotifiersStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, NotifiersTable, NotifiersColumn), ) } +func newEntityTypesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(EntityTypesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, EntityTypesTable, EntityTypesColumn), + ) +} func newItemTemplatesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/backend/internal/data/ent/group/where.go b/backend/internal/data/ent/group/where.go index fec4b27c..b51de84b 100644 --- a/backend/internal/data/ent/group/where.go +++ b/backend/internal/data/ent/group/where.go @@ -309,44 +309,21 @@ func HasUsersWith(preds ...predicate.User) predicate.Group { }) } -// HasLocations applies the HasEdge predicate on the "locations" edge. -func HasLocations() predicate.Group { +// HasEntities applies the HasEdge predicate on the "entities" edge. +func HasEntities() predicate.Group { return predicate.Group(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn), + sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn), ) sqlgraph.HasNeighbors(s, step) }) } -// HasLocationsWith applies the HasEdge predicate on the "locations" edge with a given conditions (other predicates). -func HasLocationsWith(preds ...predicate.Location) predicate.Group { +// HasEntitiesWith applies the HasEdge predicate on the "entities" edge with a given conditions (other predicates). +func HasEntitiesWith(preds ...predicate.Entity) predicate.Group { return predicate.Group(func(s *sql.Selector) { - step := newLocationsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasItems applies the HasEdge predicate on the "items" edge. -func HasItems() predicate.Group { - return predicate.Group(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates). -func HasItemsWith(preds ...predicate.Item) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - step := newItemsStep() + step := newEntitiesStep() sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { for _, p := range preds { p(s) @@ -424,6 +401,29 @@ func HasNotifiersWith(preds ...predicate.Notifier) predicate.Group { }) } +// HasEntityTypes applies the HasEdge predicate on the "entity_types" edge. +func HasEntityTypes() predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, EntityTypesTable, EntityTypesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasEntityTypesWith applies the HasEdge predicate on the "entity_types" edge with a given conditions (other predicates). +func HasEntityTypesWith(preds ...predicate.EntityType) predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := newEntityTypesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasItemTemplates applies the HasEdge predicate on the "item_templates" edge. func HasItemTemplates() predicate.Group { return predicate.Group(func(s *sql.Selector) { diff --git a/backend/internal/data/ent/group_create.go b/backend/internal/data/ent/group_create.go index 9eb4bac1..95de21a4 100644 --- a/backend/internal/data/ent/group_create.go +++ b/backend/internal/data/ent/group_create.go @@ -11,12 +11,12 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "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" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" ) @@ -105,34 +105,19 @@ func (_c *GroupCreate) AddUsers(v ...*User) *GroupCreate { return _c.AddUserIDs(ids...) } -// AddLocationIDs adds the "locations" edge to the Location entity by IDs. -func (_c *GroupCreate) AddLocationIDs(ids ...uuid.UUID) *GroupCreate { - _c.mutation.AddLocationIDs(ids...) +// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. +func (_c *GroupCreate) AddEntityIDs(ids ...uuid.UUID) *GroupCreate { + _c.mutation.AddEntityIDs(ids...) return _c } -// AddLocations adds the "locations" edges to the Location entity. -func (_c *GroupCreate) AddLocations(v ...*Location) *GroupCreate { +// AddEntities adds the "entities" edges to the Entity entity. +func (_c *GroupCreate) AddEntities(v ...*Entity) *GroupCreate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _c.AddLocationIDs(ids...) -} - -// AddItemIDs adds the "items" edge to the Item entity by IDs. -func (_c *GroupCreate) AddItemIDs(ids ...uuid.UUID) *GroupCreate { - _c.mutation.AddItemIDs(ids...) - return _c -} - -// AddItems adds the "items" edges to the Item entity. -func (_c *GroupCreate) AddItems(v ...*Item) *GroupCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddItemIDs(ids...) + return _c.AddEntityIDs(ids...) } // AddLabelIDs adds the "labels" edge to the Label entity by IDs. @@ -180,6 +165,21 @@ func (_c *GroupCreate) AddNotifiers(v ...*Notifier) *GroupCreate { return _c.AddNotifierIDs(ids...) } +// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs. +func (_c *GroupCreate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupCreate { + _c.mutation.AddEntityTypeIDs(ids...) + return _c +} + +// AddEntityTypes adds the "entity_types" edges to the EntityType entity. +func (_c *GroupCreate) AddEntityTypes(v ...*EntityType) *GroupCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddEntityTypeIDs(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...) @@ -334,31 +334,15 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.LocationsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.LocationsTable, - Columns: []string{group.LocationsColumn}, + Table: group.EntitiesTable, + Columns: []string{group.EntitiesColumn}, 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 = append(_spec.Edges, edge) - } - if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: group.ItemsTable, - Columns: []string{group.ItemsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -414,6 +398,22 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := _c.mutation.EntityTypesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.EntityTypesTable, + Columns: []string{group.EntityTypesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(entitytype.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.ItemTemplatesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/backend/internal/data/ent/group_query.go b/backend/internal/data/ent/group_query.go index 20124988..e0fafaa0 100644 --- a/backend/internal/data/ent/group_query.go +++ b/backend/internal/data/ent/group_query.go @@ -13,12 +13,12 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "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" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" @@ -32,11 +32,11 @@ type GroupQuery struct { inters []Interceptor predicates []predicate.Group withUsers *UserQuery - withLocations *LocationQuery - withItems *ItemQuery + withEntities *EntityQuery withLabels *LabelQuery withInvitationTokens *GroupInvitationTokenQuery withNotifiers *NotifierQuery + withEntityTypes *EntityTypeQuery withItemTemplates *ItemTemplateQuery // intermediate query (i.e. traversal path). sql *sql.Selector @@ -96,9 +96,9 @@ func (_q *GroupQuery) QueryUsers() *UserQuery { return query } -// QueryLocations chains the current query on the "locations" edge. -func (_q *GroupQuery) QueryLocations() *LocationQuery { - query := (&LocationClient{config: _q.config}).Query() +// QueryEntities chains the current query on the "entities" edge. +func (_q *GroupQuery) QueryEntities() *EntityQuery { + query := (&EntityClient{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 @@ -109,30 +109,8 @@ func (_q *GroupQuery) QueryLocations() *LocationQuery { } step := sqlgraph.NewStep( sqlgraph.From(group.Table, group.FieldID, selector), - sqlgraph.To(location.Table, location.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, group.LocationsTable, group.LocationsColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryItems chains the current query on the "items" edge. -func (_q *GroupQuery) QueryItems() *ItemQuery { - query := (&ItemClient{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(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, group.ItemsTable, group.ItemsColumn), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -206,6 +184,28 @@ func (_q *GroupQuery) QueryNotifiers() *NotifierQuery { return query } +// QueryEntityTypes chains the current query on the "entity_types" edge. +func (_q *GroupQuery) QueryEntityTypes() *EntityTypeQuery { + query := (&EntityTypeClient{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(entitytype.Table, entitytype.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.EntityTypesTable, group.EntityTypesColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryItemTemplates chains the current query on the "item_templates" edge. func (_q *GroupQuery) QueryItemTemplates() *ItemTemplateQuery { query := (&ItemTemplateClient{config: _q.config}).Query() @@ -421,11 +421,11 @@ func (_q *GroupQuery) Clone() *GroupQuery { inters: append([]Interceptor{}, _q.inters...), predicates: append([]predicate.Group{}, _q.predicates...), withUsers: _q.withUsers.Clone(), - withLocations: _q.withLocations.Clone(), - withItems: _q.withItems.Clone(), + withEntities: _q.withEntities.Clone(), withLabels: _q.withLabels.Clone(), withInvitationTokens: _q.withInvitationTokens.Clone(), withNotifiers: _q.withNotifiers.Clone(), + withEntityTypes: _q.withEntityTypes.Clone(), withItemTemplates: _q.withItemTemplates.Clone(), // clone intermediate query. sql: _q.sql.Clone(), @@ -444,25 +444,14 @@ func (_q *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery { return _q } -// WithLocations tells the query-builder to eager-load the nodes that are connected to -// the "locations" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *GroupQuery) WithLocations(opts ...func(*LocationQuery)) *GroupQuery { - query := (&LocationClient{config: _q.config}).Query() +// WithEntities tells the query-builder to eager-load the nodes that are connected to +// the "entities" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *GroupQuery) WithEntities(opts ...func(*EntityQuery)) *GroupQuery { + query := (&EntityClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withLocations = query - return _q -} - -// WithItems tells the query-builder to eager-load the nodes that are connected to -// the "items" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *GroupQuery) WithItems(opts ...func(*ItemQuery)) *GroupQuery { - query := (&ItemClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withItems = query + _q.withEntities = query return _q } @@ -499,6 +488,17 @@ func (_q *GroupQuery) WithNotifiers(opts ...func(*NotifierQuery)) *GroupQuery { return _q } +// WithEntityTypes tells the query-builder to eager-load the nodes that are connected to +// the "entity_types" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *GroupQuery) WithEntityTypes(opts ...func(*EntityTypeQuery)) *GroupQuery { + query := (&EntityTypeClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withEntityTypes = query + 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 { @@ -590,11 +590,11 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, _spec = _q.querySpec() loadedTypes = [7]bool{ _q.withUsers != nil, - _q.withLocations != nil, - _q.withItems != nil, + _q.withEntities != nil, _q.withLabels != nil, _q.withInvitationTokens != nil, _q.withNotifiers != nil, + _q.withEntityTypes != nil, _q.withItemTemplates != nil, } ) @@ -623,17 +623,10 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, return nil, err } } - if query := _q.withLocations; query != nil { - if err := _q.loadLocations(ctx, query, nodes, - func(n *Group) { n.Edges.Locations = []*Location{} }, - func(n *Group, e *Location) { n.Edges.Locations = append(n.Edges.Locations, e) }); err != nil { - return nil, err - } - } - if query := _q.withItems; query != nil { - if err := _q.loadItems(ctx, query, nodes, - func(n *Group) { n.Edges.Items = []*Item{} }, - func(n *Group, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil { + if query := _q.withEntities; query != nil { + if err := _q.loadEntities(ctx, query, nodes, + func(n *Group) { n.Edges.Entities = []*Entity{} }, + func(n *Group, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil { return nil, err } } @@ -660,6 +653,13 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, return nil, err } } + if query := _q.withEntityTypes; query != nil { + if err := _q.loadEntityTypes(ctx, query, nodes, + func(n *Group) { n.Edges.EntityTypes = []*EntityType{} }, + func(n *Group, e *EntityType) { n.Edges.EntityTypes = append(n.Edges.EntityTypes, e) }); err != nil { + return nil, err + } + } if query := _q.withItemTemplates; query != nil { if err := _q.loadItemTemplates(ctx, query, nodes, func(n *Group) { n.Edges.ItemTemplates = []*ItemTemplate{} }, @@ -701,7 +701,7 @@ func (_q *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []* } return nil } -func (_q *GroupQuery) loadLocations(ctx context.Context, query *LocationQuery, nodes []*Group, init func(*Group), assign func(*Group, *Location)) error { +func (_q *GroupQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Group, init func(*Group), assign func(*Group, *Entity)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[uuid.UUID]*Group) for i := range nodes { @@ -712,52 +712,21 @@ func (_q *GroupQuery) loadLocations(ctx context.Context, query *LocationQuery, n } } query.withFKs = true - query.Where(predicate.Location(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(group.LocationsColumn), fks...)) + query.Where(predicate.Entity(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(group.EntitiesColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { - fk := n.group_locations + fk := n.group_entities if fk == nil { - return fmt.Errorf(`foreign-key "group_locations" is nil for node %v`, n.ID) + return fmt.Errorf(`foreign-key "group_entities" is nil for node %v`, n.ID) } node, ok := nodeids[*fk] if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "group_locations" returned %v for node %v`, *fk, n.ID) - } - assign(node, n) - } - return nil -} -func (_q *GroupQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Group, init func(*Group), assign func(*Group, *Item)) 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.Item(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(group.ItemsColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.group_items - if fk == nil { - return fmt.Errorf(`foreign-key "group_items" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "group_items" returned %v for node %v`, *fk, n.ID) + return fmt.Errorf(`unexpected referenced foreign-key "group_entities" returned %v for node %v`, *fk, n.ID) } assign(node, n) } @@ -855,6 +824,37 @@ func (_q *GroupQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, n } return nil } +func (_q *GroupQuery) loadEntityTypes(ctx context.Context, query *EntityTypeQuery, nodes []*Group, init func(*Group), assign func(*Group, *EntityType)) 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.EntityType(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(group.EntityTypesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.group_entity_types + if fk == nil { + return fmt.Errorf(`foreign-key "group_entity_types" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "group_entity_types" returned %v for node %v`, *fk, n.ID) + } + assign(node, 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) diff --git a/backend/internal/data/ent/group_update.go b/backend/internal/data/ent/group_update.go index d0190d49..1fbc2e0a 100644 --- a/backend/internal/data/ent/group_update.go +++ b/backend/internal/data/ent/group_update.go @@ -12,12 +12,12 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "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" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" @@ -85,34 +85,19 @@ func (_u *GroupUpdate) AddUsers(v ...*User) *GroupUpdate { return _u.AddUserIDs(ids...) } -// AddLocationIDs adds the "locations" edge to the Location entity by IDs. -func (_u *GroupUpdate) AddLocationIDs(ids ...uuid.UUID) *GroupUpdate { - _u.mutation.AddLocationIDs(ids...) +// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. +func (_u *GroupUpdate) AddEntityIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.AddEntityIDs(ids...) return _u } -// AddLocations adds the "locations" edges to the Location entity. -func (_u *GroupUpdate) AddLocations(v ...*Location) *GroupUpdate { +// AddEntities adds the "entities" edges to the Entity entity. +func (_u *GroupUpdate) AddEntities(v ...*Entity) *GroupUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddLocationIDs(ids...) -} - -// AddItemIDs adds the "items" edge to the Item entity by IDs. -func (_u *GroupUpdate) AddItemIDs(ids ...uuid.UUID) *GroupUpdate { - _u.mutation.AddItemIDs(ids...) - return _u -} - -// AddItems adds the "items" edges to the Item entity. -func (_u *GroupUpdate) AddItems(v ...*Item) *GroupUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddItemIDs(ids...) + return _u.AddEntityIDs(ids...) } // AddLabelIDs adds the "labels" edge to the Label entity by IDs. @@ -160,6 +145,21 @@ func (_u *GroupUpdate) AddNotifiers(v ...*Notifier) *GroupUpdate { return _u.AddNotifierIDs(ids...) } +// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs. +func (_u *GroupUpdate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.AddEntityTypeIDs(ids...) + return _u +} + +// AddEntityTypes adds the "entity_types" edges to the EntityType entity. +func (_u *GroupUpdate) AddEntityTypes(v ...*EntityType) *GroupUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddEntityTypeIDs(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...) @@ -201,46 +201,25 @@ func (_u *GroupUpdate) RemoveUsers(v ...*User) *GroupUpdate { return _u.RemoveUserIDs(ids...) } -// ClearLocations clears all "locations" edges to the Location entity. -func (_u *GroupUpdate) ClearLocations() *GroupUpdate { - _u.mutation.ClearLocations() +// ClearEntities clears all "entities" edges to the Entity entity. +func (_u *GroupUpdate) ClearEntities() *GroupUpdate { + _u.mutation.ClearEntities() return _u } -// RemoveLocationIDs removes the "locations" edge to Location entities by IDs. -func (_u *GroupUpdate) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdate { - _u.mutation.RemoveLocationIDs(ids...) +// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs. +func (_u *GroupUpdate) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.RemoveEntityIDs(ids...) return _u } -// RemoveLocations removes "locations" edges to Location entities. -func (_u *GroupUpdate) RemoveLocations(v ...*Location) *GroupUpdate { +// RemoveEntities removes "entities" edges to Entity entities. +func (_u *GroupUpdate) RemoveEntities(v ...*Entity) *GroupUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveLocationIDs(ids...) -} - -// ClearItems clears all "items" edges to the Item entity. -func (_u *GroupUpdate) ClearItems() *GroupUpdate { - _u.mutation.ClearItems() - return _u -} - -// RemoveItemIDs removes the "items" edge to Item entities by IDs. -func (_u *GroupUpdate) RemoveItemIDs(ids ...uuid.UUID) *GroupUpdate { - _u.mutation.RemoveItemIDs(ids...) - return _u -} - -// RemoveItems removes "items" edges to Item entities. -func (_u *GroupUpdate) RemoveItems(v ...*Item) *GroupUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveItemIDs(ids...) + return _u.RemoveEntityIDs(ids...) } // ClearLabels clears all "labels" edges to the Label entity. @@ -306,6 +285,27 @@ func (_u *GroupUpdate) RemoveNotifiers(v ...*Notifier) *GroupUpdate { return _u.RemoveNotifierIDs(ids...) } +// ClearEntityTypes clears all "entity_types" edges to the EntityType entity. +func (_u *GroupUpdate) ClearEntityTypes() *GroupUpdate { + _u.mutation.ClearEntityTypes() + return _u +} + +// RemoveEntityTypeIDs removes the "entity_types" edge to EntityType entities by IDs. +func (_u *GroupUpdate) RemoveEntityTypeIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.RemoveEntityTypeIDs(ids...) + return _u +} + +// RemoveEntityTypes removes "entity_types" edges to EntityType entities. +func (_u *GroupUpdate) RemoveEntityTypes(v ...*EntityType) *GroupUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveEntityTypeIDs(ids...) +} + // ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity. func (_u *GroupUpdate) ClearItemTemplates() *GroupUpdate { _u.mutation.ClearItemTemplates() @@ -439,28 +439,28 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.LocationsCleared() { + if _u.mutation.EntitiesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.LocationsTable, - Columns: []string{group.LocationsColumn}, + Table: group.EntitiesTable, + Columns: []string{group.EntitiesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() { + if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.LocationsTable, - Columns: []string{group.LocationsColumn}, + Table: group.EntitiesTable, + Columns: []string{group.EntitiesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -468,60 +468,15 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.LocationsTable, - Columns: []string{group.LocationsColumn}, + Table: group.EntitiesTable, + Columns: []string{group.EntitiesColumn}, 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 _u.mutation.ItemsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: group.ItemsTable, - Columns: []string{group.ItemsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: group.ItemsTable, - Columns: []string{group.ItemsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.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.ItemsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: group.ItemsTable, - Columns: []string{group.ItemsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -664,6 +619,51 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.EntityTypesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.EntityTypesTable, + Columns: []string{group.EntityTypesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedEntityTypesIDs(); len(nodes) > 0 && !_u.mutation.EntityTypesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.EntityTypesTable, + Columns: []string{group.EntityTypesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(entitytype.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.EntityTypesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.EntityTypesTable, + Columns: []string{group.EntityTypesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(entitytype.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.ItemTemplatesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -778,34 +778,19 @@ func (_u *GroupUpdateOne) AddUsers(v ...*User) *GroupUpdateOne { return _u.AddUserIDs(ids...) } -// AddLocationIDs adds the "locations" edge to the Location entity by IDs. -func (_u *GroupUpdateOne) AddLocationIDs(ids ...uuid.UUID) *GroupUpdateOne { - _u.mutation.AddLocationIDs(ids...) +// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. +func (_u *GroupUpdateOne) AddEntityIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.AddEntityIDs(ids...) return _u } -// AddLocations adds the "locations" edges to the Location entity. -func (_u *GroupUpdateOne) AddLocations(v ...*Location) *GroupUpdateOne { +// AddEntities adds the "entities" edges to the Entity entity. +func (_u *GroupUpdateOne) AddEntities(v ...*Entity) *GroupUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddLocationIDs(ids...) -} - -// AddItemIDs adds the "items" edge to the Item entity by IDs. -func (_u *GroupUpdateOne) AddItemIDs(ids ...uuid.UUID) *GroupUpdateOne { - _u.mutation.AddItemIDs(ids...) - return _u -} - -// AddItems adds the "items" edges to the Item entity. -func (_u *GroupUpdateOne) AddItems(v ...*Item) *GroupUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddItemIDs(ids...) + return _u.AddEntityIDs(ids...) } // AddLabelIDs adds the "labels" edge to the Label entity by IDs. @@ -853,6 +838,21 @@ func (_u *GroupUpdateOne) AddNotifiers(v ...*Notifier) *GroupUpdateOne { return _u.AddNotifierIDs(ids...) } +// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs. +func (_u *GroupUpdateOne) AddEntityTypeIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.AddEntityTypeIDs(ids...) + return _u +} + +// AddEntityTypes adds the "entity_types" edges to the EntityType entity. +func (_u *GroupUpdateOne) AddEntityTypes(v ...*EntityType) *GroupUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddEntityTypeIDs(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...) @@ -894,46 +894,25 @@ func (_u *GroupUpdateOne) RemoveUsers(v ...*User) *GroupUpdateOne { return _u.RemoveUserIDs(ids...) } -// ClearLocations clears all "locations" edges to the Location entity. -func (_u *GroupUpdateOne) ClearLocations() *GroupUpdateOne { - _u.mutation.ClearLocations() +// ClearEntities clears all "entities" edges to the Entity entity. +func (_u *GroupUpdateOne) ClearEntities() *GroupUpdateOne { + _u.mutation.ClearEntities() return _u } -// RemoveLocationIDs removes the "locations" edge to Location entities by IDs. -func (_u *GroupUpdateOne) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdateOne { - _u.mutation.RemoveLocationIDs(ids...) +// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs. +func (_u *GroupUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.RemoveEntityIDs(ids...) return _u } -// RemoveLocations removes "locations" edges to Location entities. -func (_u *GroupUpdateOne) RemoveLocations(v ...*Location) *GroupUpdateOne { +// RemoveEntities removes "entities" edges to Entity entities. +func (_u *GroupUpdateOne) RemoveEntities(v ...*Entity) *GroupUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveLocationIDs(ids...) -} - -// ClearItems clears all "items" edges to the Item entity. -func (_u *GroupUpdateOne) ClearItems() *GroupUpdateOne { - _u.mutation.ClearItems() - return _u -} - -// RemoveItemIDs removes the "items" edge to Item entities by IDs. -func (_u *GroupUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *GroupUpdateOne { - _u.mutation.RemoveItemIDs(ids...) - return _u -} - -// RemoveItems removes "items" edges to Item entities. -func (_u *GroupUpdateOne) RemoveItems(v ...*Item) *GroupUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveItemIDs(ids...) + return _u.RemoveEntityIDs(ids...) } // ClearLabels clears all "labels" edges to the Label entity. @@ -999,6 +978,27 @@ func (_u *GroupUpdateOne) RemoveNotifiers(v ...*Notifier) *GroupUpdateOne { return _u.RemoveNotifierIDs(ids...) } +// ClearEntityTypes clears all "entity_types" edges to the EntityType entity. +func (_u *GroupUpdateOne) ClearEntityTypes() *GroupUpdateOne { + _u.mutation.ClearEntityTypes() + return _u +} + +// RemoveEntityTypeIDs removes the "entity_types" edge to EntityType entities by IDs. +func (_u *GroupUpdateOne) RemoveEntityTypeIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.RemoveEntityTypeIDs(ids...) + return _u +} + +// RemoveEntityTypes removes "entity_types" edges to EntityType entities. +func (_u *GroupUpdateOne) RemoveEntityTypes(v ...*EntityType) *GroupUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveEntityTypeIDs(ids...) +} + // ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity. func (_u *GroupUpdateOne) ClearItemTemplates() *GroupUpdateOne { _u.mutation.ClearItemTemplates() @@ -1162,28 +1162,28 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.LocationsCleared() { + if _u.mutation.EntitiesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.LocationsTable, - Columns: []string{group.LocationsColumn}, + Table: group.EntitiesTable, + Columns: []string{group.EntitiesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() { + if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.LocationsTable, - Columns: []string{group.LocationsColumn}, + Table: group.EntitiesTable, + Columns: []string{group.EntitiesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -1191,60 +1191,15 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.LocationsTable, - Columns: []string{group.LocationsColumn}, + Table: group.EntitiesTable, + Columns: []string{group.EntitiesColumn}, 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 _u.mutation.ItemsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: group.ItemsTable, - Columns: []string{group.ItemsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: group.ItemsTable, - Columns: []string{group.ItemsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.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.ItemsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: group.ItemsTable, - Columns: []string{group.ItemsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -1387,6 +1342,51 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.EntityTypesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.EntityTypesTable, + Columns: []string{group.EntityTypesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedEntityTypesIDs(); len(nodes) > 0 && !_u.mutation.EntityTypesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.EntityTypesTable, + Columns: []string{group.EntityTypesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(entitytype.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.EntityTypesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.EntityTypesTable, + Columns: []string{group.EntityTypesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(entitytype.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.ItemTemplatesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/backend/internal/data/ent/has_id.go b/backend/internal/data/ent/has_id.go index faf28d4e..c2f228f5 100644 --- a/backend/internal/data/ent/has_id.go +++ b/backend/internal/data/ent/has_id.go @@ -16,6 +16,18 @@ func (_m *AuthTokens) GetID() uuid.UUID { return _m.ID } +func (_m *Entity) GetID() uuid.UUID { + return _m.ID +} + +func (_m *EntityField) GetID() uuid.UUID { + return _m.ID +} + +func (_m *EntityType) GetID() uuid.UUID { + return _m.ID +} + func (_m *Group) GetID() uuid.UUID { return _m.ID } @@ -24,14 +36,6 @@ func (_m *GroupInvitationToken) GetID() uuid.UUID { return _m.ID } -func (_m *Item) GetID() uuid.UUID { - return _m.ID -} - -func (_m *ItemField) GetID() uuid.UUID { - return _m.ID -} - func (_m *ItemTemplate) GetID() uuid.UUID { return _m.ID } @@ -40,10 +44,6 @@ func (_m *Label) GetID() uuid.UUID { return _m.ID } -func (_m *Location) GetID() uuid.UUID { - return _m.ID -} - func (_m *MaintenanceEntry) 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 6859da52..f375dd17 100644 --- a/backend/internal/data/ent/hook/hook.go +++ b/backend/internal/data/ent/hook/hook.go @@ -45,6 +45,42 @@ func (f AuthTokensFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthTokensMutation", m) } +// The EntityFunc type is an adapter to allow the use of ordinary +// function as Entity mutator. +type EntityFunc func(context.Context, *ent.EntityMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EntityFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EntityMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityMutation", m) +} + +// The EntityFieldFunc type is an adapter to allow the use of ordinary +// function as EntityField mutator. +type EntityFieldFunc func(context.Context, *ent.EntityFieldMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EntityFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EntityFieldMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityFieldMutation", m) +} + +// The EntityTypeFunc type is an adapter to allow the use of ordinary +// function as EntityType mutator. +type EntityTypeFunc func(context.Context, *ent.EntityTypeMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EntityTypeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EntityTypeMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityTypeMutation", m) +} + // The GroupFunc type is an adapter to allow the use of ordinary // function as Group mutator. type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error) @@ -69,30 +105,6 @@ func (f GroupInvitationTokenFunc) Mutate(ctx context.Context, m ent.Mutation) (e return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupInvitationTokenMutation", m) } -// The ItemFunc type is an adapter to allow the use of ordinary -// function as Item mutator. -type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f ItemFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.ItemMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemMutation", m) -} - -// The ItemFieldFunc type is an adapter to allow the use of ordinary -// function as ItemField mutator. -type ItemFieldFunc func(context.Context, *ent.ItemFieldMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f ItemFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.ItemFieldMutation); ok { - return f(ctx, mv) - } - 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) @@ -117,18 +129,6 @@ func (f LabelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LabelMutation", m) } -// The LocationFunc type is an adapter to allow the use of ordinary -// function as Location mutator. -type LocationFunc func(context.Context, *ent.LocationMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f LocationFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.LocationMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LocationMutation", m) -} - // The MaintenanceEntryFunc type is an adapter to allow the use of ordinary // function as MaintenanceEntry mutator. type MaintenanceEntryFunc func(context.Context, *ent.MaintenanceEntryMutation) (ent.Value, error) diff --git a/backend/internal/data/ent/itemtemplate.go b/backend/internal/data/ent/itemtemplate.go index 0d9f1f2f..c140004f 100644 --- a/backend/internal/data/ent/itemtemplate.go +++ b/backend/internal/data/ent/itemtemplate.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "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. @@ -70,7 +70,7 @@ type ItemTemplateEdges struct { // 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"` + Location *Entity `json:"location,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [3]bool @@ -98,11 +98,11 @@ func (e ItemTemplateEdges) FieldsOrErr() ([]*TemplateField, error) { // 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) { +func (e ItemTemplateEdges) LocationOrErr() (*Entity, error) { if e.Location != nil { return e.Location, nil } else if e.loadedTypes[2] { - return nil, &NotFoundError{label: location.Label} + return nil, &NotFoundError{label: entity.Label} } return nil, &NotLoadedError{edge: "location"} } @@ -291,7 +291,7 @@ func (_m *ItemTemplate) QueryFields() *TemplateFieldQuery { } // QueryLocation queries the "location" edge of the ItemTemplate entity. -func (_m *ItemTemplate) QueryLocation() *LocationQuery { +func (_m *ItemTemplate) QueryLocation() *EntityQuery { return NewItemTemplateClient(_m.config).QueryLocation(_m) } diff --git a/backend/internal/data/ent/itemtemplate/itemtemplate.go b/backend/internal/data/ent/itemtemplate/itemtemplate.go index ac308b9d..498e5705 100644 --- a/backend/internal/data/ent/itemtemplate/itemtemplate.go +++ b/backend/internal/data/ent/itemtemplate/itemtemplate.go @@ -73,9 +73,9 @@ const ( 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" + // LocationInverseTable is the table name for the Entity entity. + // It exists in this package in order to avoid circular dependency with the "entity" package. + LocationInverseTable = "entities" // LocationColumn is the table column denoting the location relation/edge. LocationColumn = "item_template_location" ) diff --git a/backend/internal/data/ent/itemtemplate/where.go b/backend/internal/data/ent/itemtemplate/where.go index 1ade7376..896a46ce 100644 --- a/backend/internal/data/ent/itemtemplate/where.go +++ b/backend/internal/data/ent/itemtemplate/where.go @@ -964,7 +964,7 @@ func HasLocation() predicate.ItemTemplate { } // HasLocationWith applies the HasEdge predicate on the "location" edge with a given conditions (other predicates). -func HasLocationWith(preds ...predicate.Location) predicate.ItemTemplate { +func HasLocationWith(preds ...predicate.Entity) predicate.ItemTemplate { return predicate.ItemTemplate(func(s *sql.Selector) { step := newLocationStep() sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/backend/internal/data/ent/itemtemplate_create.go b/backend/internal/data/ent/itemtemplate_create.go index 30abd074..f3f43b7a 100644 --- a/backend/internal/data/ent/itemtemplate_create.go +++ b/backend/internal/data/ent/itemtemplate_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "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" ) @@ -286,13 +286,13 @@ func (_c *ItemTemplateCreate) AddFields(v ...*TemplateField) *ItemTemplateCreate return _c.AddFieldIDs(ids...) } -// SetLocationID sets the "location" edge to the Location entity by ID. +// SetLocationID sets the "location" edge to the Entity 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. +// SetNillableLocationID sets the "location" edge to the Entity 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) @@ -300,8 +300,8 @@ func (_c *ItemTemplateCreate) SetNillableLocationID(id *uuid.UUID) *ItemTemplate return _c } -// SetLocation sets the "location" edge to the Location entity. -func (_c *ItemTemplateCreate) SetLocation(v *Location) *ItemTemplateCreate { +// SetLocation sets the "location" edge to the Entity entity. +func (_c *ItemTemplateCreate) SetLocation(v *Entity) *ItemTemplateCreate { return _c.SetLocationID(v.ID) } @@ -594,7 +594,7 @@ func (_c *ItemTemplateCreate) createSpec() (*ItemTemplate, *sqlgraph.CreateSpec) Columns: []string{itemtemplate.LocationColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/itemtemplate_query.go b/backend/internal/data/ent/itemtemplate_query.go index 5e339f1f..c4541e16 100644 --- a/backend/internal/data/ent/itemtemplate_query.go +++ b/backend/internal/data/ent/itemtemplate_query.go @@ -13,9 +13,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "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" ) @@ -29,7 +29,7 @@ type ItemTemplateQuery struct { predicates []predicate.ItemTemplate withGroup *GroupQuery withFields *TemplateFieldQuery - withLocation *LocationQuery + withLocation *EntityQuery withFKs bool // intermediate query (i.e. traversal path). sql *sql.Selector @@ -112,8 +112,8 @@ func (_q *ItemTemplateQuery) QueryFields() *TemplateFieldQuery { } // QueryLocation chains the current query on the "location" edge. -func (_q *ItemTemplateQuery) QueryLocation() *LocationQuery { - query := (&LocationClient{config: _q.config}).Query() +func (_q *ItemTemplateQuery) QueryLocation() *EntityQuery { + query := (&EntityClient{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 @@ -124,7 +124,7 @@ func (_q *ItemTemplateQuery) QueryLocation() *LocationQuery { } step := sqlgraph.NewStep( sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector), - sqlgraph.To(location.Table, location.FieldID), + sqlgraph.To(entity.Table, entity.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) @@ -358,8 +358,8 @@ func (_q *ItemTemplateQuery) WithFields(opts ...func(*TemplateFieldQuery)) *Item // 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() +func (_q *ItemTemplateQuery) WithLocation(opts ...func(*EntityQuery)) *ItemTemplateQuery { + query := (&EntityClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } @@ -491,7 +491,7 @@ func (_q *ItemTemplateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] } 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 { + func(n *ItemTemplate, e *Entity) { n.Edges.Location = e }); err != nil { return nil, err } } @@ -561,7 +561,7 @@ func (_q *ItemTemplateQuery) loadFields(ctx context.Context, query *TemplateFiel } return nil } -func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Location)) error { +func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *EntityQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Entity)) error { ids := make([]uuid.UUID, 0, len(nodes)) nodeids := make(map[uuid.UUID][]*ItemTemplate) for i := range nodes { @@ -577,7 +577,7 @@ func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQu if len(ids) == 0 { return nil } - query.Where(location.IDIn(ids...)) + query.Where(entity.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err diff --git a/backend/internal/data/ent/itemtemplate_update.go b/backend/internal/data/ent/itemtemplate_update.go index 768505ba..8e63285b 100644 --- a/backend/internal/data/ent/itemtemplate_update.go +++ b/backend/internal/data/ent/itemtemplate_update.go @@ -13,9 +13,9 @@ import ( "entgo.io/ent/dialect/sql/sqljson" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "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" ) @@ -328,13 +328,13 @@ func (_u *ItemTemplateUpdate) AddFields(v ...*TemplateField) *ItemTemplateUpdate return _u.AddFieldIDs(ids...) } -// SetLocationID sets the "location" edge to the Location entity by ID. +// SetLocationID sets the "location" edge to the Entity 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. +// SetNillableLocationID sets the "location" edge to the Entity 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) @@ -342,8 +342,8 @@ func (_u *ItemTemplateUpdate) SetNillableLocationID(id *uuid.UUID) *ItemTemplate return _u } -// SetLocation sets the "location" edge to the Location entity. -func (_u *ItemTemplateUpdate) SetLocation(v *Location) *ItemTemplateUpdate { +// SetLocation sets the "location" edge to the Entity entity. +func (_u *ItemTemplateUpdate) SetLocation(v *Entity) *ItemTemplateUpdate { return _u.SetLocationID(v.ID) } @@ -379,7 +379,7 @@ func (_u *ItemTemplateUpdate) RemoveFields(v ...*TemplateField) *ItemTemplateUpd return _u.RemoveFieldIDs(ids...) } -// ClearLocation clears the "location" edge to the Location entity. +// ClearLocation clears the "location" edge to the Entity entity. func (_u *ItemTemplateUpdate) ClearLocation() *ItemTemplateUpdate { _u.mutation.ClearLocation() return _u @@ -643,7 +643,7 @@ func (_u *ItemTemplateUpdate) sqlSave(ctx context.Context) (_node int, err error Columns: []string{itemtemplate.LocationColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -656,7 +656,7 @@ func (_u *ItemTemplateUpdate) sqlSave(ctx context.Context) (_node int, err error Columns: []string{itemtemplate.LocationColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -979,13 +979,13 @@ func (_u *ItemTemplateUpdateOne) AddFields(v ...*TemplateField) *ItemTemplateUpd return _u.AddFieldIDs(ids...) } -// SetLocationID sets the "location" edge to the Location entity by ID. +// SetLocationID sets the "location" edge to the Entity 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. +// SetNillableLocationID sets the "location" edge to the Entity 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) @@ -993,8 +993,8 @@ func (_u *ItemTemplateUpdateOne) SetNillableLocationID(id *uuid.UUID) *ItemTempl return _u } -// SetLocation sets the "location" edge to the Location entity. -func (_u *ItemTemplateUpdateOne) SetLocation(v *Location) *ItemTemplateUpdateOne { +// SetLocation sets the "location" edge to the Entity entity. +func (_u *ItemTemplateUpdateOne) SetLocation(v *Entity) *ItemTemplateUpdateOne { return _u.SetLocationID(v.ID) } @@ -1030,7 +1030,7 @@ func (_u *ItemTemplateUpdateOne) RemoveFields(v ...*TemplateField) *ItemTemplate return _u.RemoveFieldIDs(ids...) } -// ClearLocation clears the "location" edge to the Location entity. +// ClearLocation clears the "location" edge to the Entity entity. func (_u *ItemTemplateUpdateOne) ClearLocation() *ItemTemplateUpdateOne { _u.mutation.ClearLocation() return _u @@ -1324,7 +1324,7 @@ func (_u *ItemTemplateUpdateOne) sqlSave(ctx context.Context) (_node *ItemTempla Columns: []string{itemtemplate.LocationColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -1337,7 +1337,7 @@ func (_u *ItemTemplateUpdateOne) sqlSave(ctx context.Context) (_node *ItemTempla Columns: []string{itemtemplate.LocationColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/label.go b/backend/internal/data/ent/label.go index 8203bd5d..92eccd32 100644 --- a/backend/internal/data/ent/label.go +++ b/backend/internal/data/ent/label.go @@ -40,8 +40,8 @@ type Label struct { type LabelEdges struct { // Group holds the value of the group edge. Group *Group `json:"group,omitempty"` - // Items holds the value of the items edge. - Items []*Item `json:"items,omitempty"` + // Entities holds the value of the entities edge. + Entities []*Entity `json:"entities,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [2]bool @@ -58,13 +58,13 @@ func (e LabelEdges) GroupOrErr() (*Group, error) { return nil, &NotLoadedError{edge: "group"} } -// ItemsOrErr returns the Items value or an error if the edge +// EntitiesOrErr returns the Entities value or an error if the edge // was not loaded in eager-loading. -func (e LabelEdges) ItemsOrErr() ([]*Item, error) { +func (e LabelEdges) EntitiesOrErr() ([]*Entity, error) { if e.loadedTypes[1] { - return e.Items, nil + return e.Entities, nil } - return nil, &NotLoadedError{edge: "items"} + return nil, &NotLoadedError{edge: "entities"} } // scanValues returns the types for scanning values from sql.Rows. @@ -156,9 +156,9 @@ func (_m *Label) QueryGroup() *GroupQuery { return NewLabelClient(_m.config).QueryGroup(_m) } -// QueryItems queries the "items" edge of the Label entity. -func (_m *Label) QueryItems() *ItemQuery { - return NewLabelClient(_m.config).QueryItems(_m) +// QueryEntities queries the "entities" edge of the Label entity. +func (_m *Label) QueryEntities() *EntityQuery { + return NewLabelClient(_m.config).QueryEntities(_m) } // Update returns a builder for updating this Label. diff --git a/backend/internal/data/ent/label_create.go b/backend/internal/data/ent/label_create.go index a1cdf28c..d2fa95f6 100644 --- a/backend/internal/data/ent/label_create.go +++ b/backend/internal/data/ent/label_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" ) @@ -110,19 +110,19 @@ func (_c *LabelCreate) SetGroup(v *Group) *LabelCreate { return _c.SetGroupID(v.ID) } -// AddItemIDs adds the "items" edge to the Item entity by IDs. -func (_c *LabelCreate) AddItemIDs(ids ...uuid.UUID) *LabelCreate { - _c.mutation.AddItemIDs(ids...) +// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. +func (_c *LabelCreate) AddEntityIDs(ids ...uuid.UUID) *LabelCreate { + _c.mutation.AddEntityIDs(ids...) return _c } -// AddItems adds the "items" edges to the Item entity. -func (_c *LabelCreate) AddItems(v ...*Item) *LabelCreate { +// AddEntities adds the "entities" edges to the Entity entity. +func (_c *LabelCreate) AddEntities(v ...*Entity) *LabelCreate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _c.AddItemIDs(ids...) + return _c.AddEntityIDs(ids...) } // Mutation returns the LabelMutation object of the builder. @@ -275,15 +275,15 @@ func (_c *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) { _node.group_labels = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.ItemsTable, - Columns: label.ItemsPrimaryKey, + Table: label.EntitiesTable, + Columns: label.EntitiesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/label_query.go b/backend/internal/data/ent/label_query.go index f3661691..ada911cd 100644 --- a/backend/internal/data/ent/label_query.go +++ b/backend/internal/data/ent/label_query.go @@ -13,8 +13,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -22,13 +22,13 @@ import ( // LabelQuery is the builder for querying Label entities. type LabelQuery struct { config - ctx *QueryContext - order []label.OrderOption - inters []Interceptor - predicates []predicate.Label - withGroup *GroupQuery - withItems *ItemQuery - withFKs bool + ctx *QueryContext + order []label.OrderOption + inters []Interceptor + predicates []predicate.Label + withGroup *GroupQuery + withEntities *EntityQuery + withFKs bool // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -87,9 +87,9 @@ func (_q *LabelQuery) QueryGroup() *GroupQuery { return query } -// QueryItems chains the current query on the "items" edge. -func (_q *LabelQuery) QueryItems() *ItemQuery { - query := (&ItemClient{config: _q.config}).Query() +// QueryEntities chains the current query on the "entities" edge. +func (_q *LabelQuery) QueryEntities() *EntityQuery { + query := (&EntityClient{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 @@ -100,8 +100,8 @@ func (_q *LabelQuery) QueryItems() *ItemQuery { } step := sqlgraph.NewStep( sqlgraph.From(label.Table, label.FieldID, selector), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -296,13 +296,13 @@ func (_q *LabelQuery) Clone() *LabelQuery { return nil } return &LabelQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]label.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.Label{}, _q.predicates...), - withGroup: _q.withGroup.Clone(), - withItems: _q.withItems.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]label.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Label{}, _q.predicates...), + withGroup: _q.withGroup.Clone(), + withEntities: _q.withEntities.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -320,14 +320,14 @@ func (_q *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery { return _q } -// WithItems tells the query-builder to eager-load the nodes that are connected to -// the "items" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *LabelQuery) WithItems(opts ...func(*ItemQuery)) *LabelQuery { - query := (&ItemClient{config: _q.config}).Query() +// WithEntities tells the query-builder to eager-load the nodes that are connected to +// the "entities" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *LabelQuery) WithEntities(opts ...func(*EntityQuery)) *LabelQuery { + query := (&EntityClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withItems = query + _q.withEntities = query return _q } @@ -412,7 +412,7 @@ func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label, _spec = _q.querySpec() loadedTypes = [2]bool{ _q.withGroup != nil, - _q.withItems != nil, + _q.withEntities != nil, } ) if _q.withGroup != nil { @@ -445,10 +445,10 @@ func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label, return nil, err } } - if query := _q.withItems; query != nil { - if err := _q.loadItems(ctx, query, nodes, - func(n *Label) { n.Edges.Items = []*Item{} }, - func(n *Label, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil { + if query := _q.withEntities; query != nil { + if err := _q.loadEntities(ctx, query, nodes, + func(n *Label) { n.Edges.Entities = []*Entity{} }, + func(n *Label, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil { return nil, err } } @@ -487,7 +487,7 @@ func (_q *LabelQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes [] } return nil } -func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Label, init func(*Label), assign func(*Label, *Item)) error { +func (_q *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Label, init func(*Label), assign func(*Label, *Entity)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[uuid.UUID]*Label) nids := make(map[uuid.UUID]map[*Label]struct{}) @@ -499,11 +499,11 @@ func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []* } } query.Where(func(s *sql.Selector) { - joinT := sql.Table(label.ItemsTable) - s.Join(joinT).On(s.C(item.FieldID), joinT.C(label.ItemsPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(label.ItemsPrimaryKey[0]), edgeIDs...)) + joinT := sql.Table(label.EntitiesTable) + s.Join(joinT).On(s.C(entity.FieldID), joinT.C(label.EntitiesPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(label.EntitiesPrimaryKey[0]), edgeIDs...)) columns := s.SelectedColumns() - s.Select(joinT.C(label.ItemsPrimaryKey[0])) + s.Select(joinT.C(label.EntitiesPrimaryKey[0])) s.AppendSelect(columns...) s.SetDistinct(false) }) @@ -533,14 +533,14 @@ func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []* } }) }) - neighbors, err := withInterceptors[[]*Item](ctx, query, qr, query.inters) + neighbors, err := withInterceptors[[]*Entity](ctx, query, qr, query.inters) if err != nil { return err } for _, n := range neighbors { nodes, ok := nids[n.ID] if !ok { - return fmt.Errorf(`unexpected "items" node returned %v`, n.ID) + return fmt.Errorf(`unexpected "entities" node returned %v`, n.ID) } for kn := range nodes { assign(kn, n) diff --git a/backend/internal/data/ent/label_update.go b/backend/internal/data/ent/label_update.go index b9beb1ae..3fd6120f 100644 --- a/backend/internal/data/ent/label_update.go +++ b/backend/internal/data/ent/label_update.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -102,19 +102,19 @@ func (_u *LabelUpdate) SetGroup(v *Group) *LabelUpdate { return _u.SetGroupID(v.ID) } -// AddItemIDs adds the "items" edge to the Item entity by IDs. -func (_u *LabelUpdate) AddItemIDs(ids ...uuid.UUID) *LabelUpdate { - _u.mutation.AddItemIDs(ids...) +// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. +func (_u *LabelUpdate) AddEntityIDs(ids ...uuid.UUID) *LabelUpdate { + _u.mutation.AddEntityIDs(ids...) return _u } -// AddItems adds the "items" edges to the Item entity. -func (_u *LabelUpdate) AddItems(v ...*Item) *LabelUpdate { +// AddEntities adds the "entities" edges to the Entity entity. +func (_u *LabelUpdate) AddEntities(v ...*Entity) *LabelUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddItemIDs(ids...) + return _u.AddEntityIDs(ids...) } // Mutation returns the LabelMutation object of the builder. @@ -128,25 +128,25 @@ func (_u *LabelUpdate) ClearGroup() *LabelUpdate { return _u } -// ClearItems clears all "items" edges to the Item entity. -func (_u *LabelUpdate) ClearItems() *LabelUpdate { - _u.mutation.ClearItems() +// ClearEntities clears all "entities" edges to the Entity entity. +func (_u *LabelUpdate) ClearEntities() *LabelUpdate { + _u.mutation.ClearEntities() return _u } -// RemoveItemIDs removes the "items" edge to Item entities by IDs. -func (_u *LabelUpdate) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdate { - _u.mutation.RemoveItemIDs(ids...) +// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs. +func (_u *LabelUpdate) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdate { + _u.mutation.RemoveEntityIDs(ids...) return _u } -// RemoveItems removes "items" edges to Item entities. -func (_u *LabelUpdate) RemoveItems(v ...*Item) *LabelUpdate { +// RemoveEntities removes "entities" edges to Entity entities. +func (_u *LabelUpdate) RemoveEntities(v ...*Entity) *LabelUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveItemIDs(ids...) + return _u.RemoveEntityIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. @@ -267,28 +267,28 @@ func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.ItemsCleared() { + if _u.mutation.EntitiesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.ItemsTable, - Columns: label.ItemsPrimaryKey, + Table: label.EntitiesTable, + Columns: label.EntitiesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { + if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.ItemsTable, - Columns: label.ItemsPrimaryKey, + Table: label.EntitiesTable, + Columns: label.EntitiesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -296,15 +296,15 @@ func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.ItemsTable, - Columns: label.ItemsPrimaryKey, + Table: label.EntitiesTable, + Columns: label.EntitiesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -403,19 +403,19 @@ func (_u *LabelUpdateOne) SetGroup(v *Group) *LabelUpdateOne { return _u.SetGroupID(v.ID) } -// AddItemIDs adds the "items" edge to the Item entity by IDs. -func (_u *LabelUpdateOne) AddItemIDs(ids ...uuid.UUID) *LabelUpdateOne { - _u.mutation.AddItemIDs(ids...) +// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. +func (_u *LabelUpdateOne) AddEntityIDs(ids ...uuid.UUID) *LabelUpdateOne { + _u.mutation.AddEntityIDs(ids...) return _u } -// AddItems adds the "items" edges to the Item entity. -func (_u *LabelUpdateOne) AddItems(v ...*Item) *LabelUpdateOne { +// AddEntities adds the "entities" edges to the Entity entity. +func (_u *LabelUpdateOne) AddEntities(v ...*Entity) *LabelUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddItemIDs(ids...) + return _u.AddEntityIDs(ids...) } // Mutation returns the LabelMutation object of the builder. @@ -429,25 +429,25 @@ func (_u *LabelUpdateOne) ClearGroup() *LabelUpdateOne { return _u } -// ClearItems clears all "items" edges to the Item entity. -func (_u *LabelUpdateOne) ClearItems() *LabelUpdateOne { - _u.mutation.ClearItems() +// ClearEntities clears all "entities" edges to the Entity entity. +func (_u *LabelUpdateOne) ClearEntities() *LabelUpdateOne { + _u.mutation.ClearEntities() return _u } -// RemoveItemIDs removes the "items" edge to Item entities by IDs. -func (_u *LabelUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdateOne { - _u.mutation.RemoveItemIDs(ids...) +// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs. +func (_u *LabelUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdateOne { + _u.mutation.RemoveEntityIDs(ids...) return _u } -// RemoveItems removes "items" edges to Item entities. -func (_u *LabelUpdateOne) RemoveItems(v ...*Item) *LabelUpdateOne { +// RemoveEntities removes "entities" edges to Entity entities. +func (_u *LabelUpdateOne) RemoveEntities(v ...*Entity) *LabelUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveItemIDs(ids...) + return _u.RemoveEntityIDs(ids...) } // Where appends a list predicates to the LabelUpdate builder. @@ -598,28 +598,28 @@ func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.ItemsCleared() { + if _u.mutation.EntitiesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.ItemsTable, - Columns: label.ItemsPrimaryKey, + Table: label.EntitiesTable, + Columns: label.EntitiesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { + if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.ItemsTable, - Columns: label.ItemsPrimaryKey, + Table: label.EntitiesTable, + Columns: label.EntitiesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -627,15 +627,15 @@ func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.ItemsTable, - Columns: label.ItemsPrimaryKey, + Table: label.EntitiesTable, + Columns: label.EntitiesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/maintenanceentry.go b/backend/internal/data/ent/maintenanceentry.go index 9d870b78..700de400 100644 --- a/backend/internal/data/ent/maintenanceentry.go +++ b/backend/internal/data/ent/maintenanceentry.go @@ -10,7 +10,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" ) @@ -23,8 +23,8 @@ type MaintenanceEntry struct { CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` - // ItemID holds the value of the "item_id" field. - ItemID uuid.UUID `json:"item_id,omitempty"` + // EntityID holds the value of the "entity_id" field. + EntityID uuid.UUID `json:"entity_id,omitempty"` // Date holds the value of the "date" field. Date time.Time `json:"date,omitempty"` // ScheduledDate holds the value of the "scheduled_date" field. @@ -43,22 +43,22 @@ type MaintenanceEntry struct { // MaintenanceEntryEdges holds the relations/edges for other nodes in the graph. type MaintenanceEntryEdges struct { - // Item holds the value of the item edge. - Item *Item `json:"item,omitempty"` + // Entity holds the value of the entity edge. + Entity *Entity `json:"entity,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } -// ItemOrErr returns the Item value or an error if the edge +// EntityOrErr returns the Entity value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e MaintenanceEntryEdges) ItemOrErr() (*Item, error) { - if e.Item != nil { - return e.Item, nil +func (e MaintenanceEntryEdges) EntityOrErr() (*Entity, error) { + if e.Entity != nil { + return e.Entity, nil } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: item.Label} + return nil, &NotFoundError{label: entity.Label} } - return nil, &NotLoadedError{edge: "item"} + return nil, &NotLoadedError{edge: "entity"} } // scanValues returns the types for scanning values from sql.Rows. @@ -72,7 +72,7 @@ func (*MaintenanceEntry) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullString) case maintenanceentry.FieldCreatedAt, maintenanceentry.FieldUpdatedAt, maintenanceentry.FieldDate, maintenanceentry.FieldScheduledDate: values[i] = new(sql.NullTime) - case maintenanceentry.FieldID, maintenanceentry.FieldItemID: + case maintenanceentry.FieldID, maintenanceentry.FieldEntityID: values[i] = new(uuid.UUID) default: values[i] = new(sql.UnknownType) @@ -107,11 +107,11 @@ func (_m *MaintenanceEntry) assignValues(columns []string, values []any) error { } else if value.Valid { _m.UpdatedAt = value.Time } - case maintenanceentry.FieldItemID: + case maintenanceentry.FieldEntityID: if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field item_id", values[i]) + return fmt.Errorf("unexpected type %T for field entity_id", values[i]) } else if value != nil { - _m.ItemID = *value + _m.EntityID = *value } case maintenanceentry.FieldDate: if value, ok := values[i].(*sql.NullTime); !ok { @@ -156,9 +156,9 @@ func (_m *MaintenanceEntry) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } -// QueryItem queries the "item" edge of the MaintenanceEntry entity. -func (_m *MaintenanceEntry) QueryItem() *ItemQuery { - return NewMaintenanceEntryClient(_m.config).QueryItem(_m) +// QueryEntity queries the "entity" edge of the MaintenanceEntry entity. +func (_m *MaintenanceEntry) QueryEntity() *EntityQuery { + return NewMaintenanceEntryClient(_m.config).QueryEntity(_m) } // Update returns a builder for updating this MaintenanceEntry. @@ -190,8 +190,8 @@ func (_m *MaintenanceEntry) String() string { builder.WriteString("updated_at=") builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") - builder.WriteString("item_id=") - builder.WriteString(fmt.Sprintf("%v", _m.ItemID)) + builder.WriteString("entity_id=") + builder.WriteString(fmt.Sprintf("%v", _m.EntityID)) builder.WriteString(", ") builder.WriteString("date=") builder.WriteString(_m.Date.Format(time.ANSIC)) diff --git a/backend/internal/data/ent/maintenanceentry_create.go b/backend/internal/data/ent/maintenanceentry_create.go index 75d3bb82..8cb472eb 100644 --- a/backend/internal/data/ent/maintenanceentry_create.go +++ b/backend/internal/data/ent/maintenanceentry_create.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" ) @@ -50,9 +50,9 @@ func (_c *MaintenanceEntryCreate) SetNillableUpdatedAt(v *time.Time) *Maintenanc return _c } -// SetItemID sets the "item_id" field. -func (_c *MaintenanceEntryCreate) SetItemID(v uuid.UUID) *MaintenanceEntryCreate { - _c.mutation.SetItemID(v) +// SetEntityID sets the "entity_id" field. +func (_c *MaintenanceEntryCreate) SetEntityID(v uuid.UUID) *MaintenanceEntryCreate { + _c.mutation.SetEntityID(v) return _c } @@ -132,9 +132,9 @@ func (_c *MaintenanceEntryCreate) SetNillableID(v *uuid.UUID) *MaintenanceEntryC return _c } -// SetItem sets the "item" edge to the Item entity. -func (_c *MaintenanceEntryCreate) SetItem(v *Item) *MaintenanceEntryCreate { - return _c.SetItemID(v.ID) +// SetEntity sets the "entity" edge to the Entity entity. +func (_c *MaintenanceEntryCreate) SetEntity(v *Entity) *MaintenanceEntryCreate { + return _c.SetEntityID(v.ID) } // Mutation returns the MaintenanceEntryMutation object of the builder. @@ -198,8 +198,8 @@ func (_c *MaintenanceEntryCreate) check() error { if _, ok := _c.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "MaintenanceEntry.updated_at"`)} } - if _, ok := _c.mutation.ItemID(); !ok { - return &ValidationError{Name: "item_id", err: errors.New(`ent: missing required field "MaintenanceEntry.item_id"`)} + if _, ok := _c.mutation.EntityID(); !ok { + return &ValidationError{Name: "entity_id", err: errors.New(`ent: missing required field "MaintenanceEntry.entity_id"`)} } if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "MaintenanceEntry.name"`)} @@ -217,8 +217,8 @@ func (_c *MaintenanceEntryCreate) check() error { if _, ok := _c.mutation.Cost(); !ok { return &ValidationError{Name: "cost", err: errors.New(`ent: missing required field "MaintenanceEntry.cost"`)} } - if len(_c.mutation.ItemIDs()) == 0 { - return &ValidationError{Name: "item", err: errors.New(`ent: missing required edge "MaintenanceEntry.item"`)} + if len(_c.mutation.EntityIDs()) == 0 { + return &ValidationError{Name: "entity", err: errors.New(`ent: missing required edge "MaintenanceEntry.entity"`)} } return nil } @@ -283,21 +283,21 @@ func (_c *MaintenanceEntryCreate) createSpec() (*MaintenanceEntry, *sqlgraph.Cre _spec.SetField(maintenanceentry.FieldCost, field.TypeFloat64, value) _node.Cost = value } - if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 { + if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.ItemTable, - Columns: []string{maintenanceentry.ItemColumn}, + Table: maintenanceentry.EntityTable, + Columns: []string{maintenanceentry.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.ItemID = nodes[0] + _node.EntityID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } return _node, _spec diff --git a/backend/internal/data/ent/maintenanceentry_query.go b/backend/internal/data/ent/maintenanceentry_query.go index 99f60218..6b9eaabb 100644 --- a/backend/internal/data/ent/maintenanceentry_query.go +++ b/backend/internal/data/ent/maintenanceentry_query.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -24,7 +24,7 @@ type MaintenanceEntryQuery struct { order []maintenanceentry.OrderOption inters []Interceptor predicates []predicate.MaintenanceEntry - withItem *ItemQuery + withEntity *EntityQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -61,9 +61,9 @@ func (_q *MaintenanceEntryQuery) Order(o ...maintenanceentry.OrderOption) *Maint return _q } -// QueryItem chains the current query on the "item" edge. -func (_q *MaintenanceEntryQuery) QueryItem() *ItemQuery { - query := (&ItemClient{config: _q.config}).Query() +// QueryEntity chains the current query on the "entity" edge. +func (_q *MaintenanceEntryQuery) QueryEntity() *EntityQuery { + query := (&EntityClient{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 @@ -74,8 +74,8 @@ func (_q *MaintenanceEntryQuery) QueryItem() *ItemQuery { } step := sqlgraph.NewStep( sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, selector), - sqlgraph.To(item.Table, item.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.ItemTable, maintenanceentry.ItemColumn), + sqlgraph.To(entity.Table, entity.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -275,21 +275,21 @@ func (_q *MaintenanceEntryQuery) Clone() *MaintenanceEntryQuery { order: append([]maintenanceentry.OrderOption{}, _q.order...), inters: append([]Interceptor{}, _q.inters...), predicates: append([]predicate.MaintenanceEntry{}, _q.predicates...), - withItem: _q.withItem.Clone(), + withEntity: _q.withEntity.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, } } -// WithItem tells the query-builder to eager-load the nodes that are connected to -// the "item" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *MaintenanceEntryQuery) WithItem(opts ...func(*ItemQuery)) *MaintenanceEntryQuery { - query := (&ItemClient{config: _q.config}).Query() +// WithEntity tells the query-builder to eager-load the nodes that are connected to +// the "entity" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *MaintenanceEntryQuery) WithEntity(opts ...func(*EntityQuery)) *MaintenanceEntryQuery { + query := (&EntityClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withItem = query + _q.withEntity = query return _q } @@ -372,7 +372,7 @@ func (_q *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook) nodes = []*MaintenanceEntry{} _spec = _q.querySpec() loadedTypes = [1]bool{ - _q.withItem != nil, + _q.withEntity != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -393,20 +393,20 @@ func (_q *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook) if len(nodes) == 0 { return nodes, nil } - if query := _q.withItem; query != nil { - if err := _q.loadItem(ctx, query, nodes, nil, - func(n *MaintenanceEntry, e *Item) { n.Edges.Item = e }); err != nil { + if query := _q.withEntity; query != nil { + if err := _q.loadEntity(ctx, query, nodes, nil, + func(n *MaintenanceEntry, e *Entity) { n.Edges.Entity = e }); err != nil { return nil, err } } return nodes, nil } -func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Item)) error { +func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Entity)) error { ids := make([]uuid.UUID, 0, len(nodes)) nodeids := make(map[uuid.UUID][]*MaintenanceEntry) for i := range nodes { - fk := nodes[i].ItemID + fk := nodes[i].EntityID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -415,7 +415,7 @@ func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery, if len(ids) == 0 { return nil } - query.Where(item.IDIn(ids...)) + query.Where(entity.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err @@ -423,7 +423,7 @@ func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery, for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "item_id" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "entity_id" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) @@ -457,8 +457,8 @@ func (_q *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if _q.withItem != nil { - _spec.Node.AddColumnOnce(maintenanceentry.FieldItemID) + if _q.withEntity != nil { + _spec.Node.AddColumnOnce(maintenanceentry.FieldEntityID) } } if ps := _q.predicates; len(ps) > 0 { diff --git a/backend/internal/data/ent/maintenanceentry_update.go b/backend/internal/data/ent/maintenanceentry_update.go index bd27b50c..c57d688b 100644 --- a/backend/internal/data/ent/maintenanceentry_update.go +++ b/backend/internal/data/ent/maintenanceentry_update.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -36,16 +36,16 @@ func (_u *MaintenanceEntryUpdate) SetUpdatedAt(v time.Time) *MaintenanceEntryUpd return _u } -// SetItemID sets the "item_id" field. -func (_u *MaintenanceEntryUpdate) SetItemID(v uuid.UUID) *MaintenanceEntryUpdate { - _u.mutation.SetItemID(v) +// SetEntityID sets the "entity_id" field. +func (_u *MaintenanceEntryUpdate) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdate { + _u.mutation.SetEntityID(v) return _u } -// SetNillableItemID sets the "item_id" field if the given value is not nil. -func (_u *MaintenanceEntryUpdate) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdate { +// SetNillableEntityID sets the "entity_id" field if the given value is not nil. +func (_u *MaintenanceEntryUpdate) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdate { if v != nil { - _u.SetItemID(*v) + _u.SetEntityID(*v) } return _u } @@ -145,9 +145,9 @@ func (_u *MaintenanceEntryUpdate) AddCost(v float64) *MaintenanceEntryUpdate { return _u } -// SetItem sets the "item" edge to the Item entity. -func (_u *MaintenanceEntryUpdate) SetItem(v *Item) *MaintenanceEntryUpdate { - return _u.SetItemID(v.ID) +// SetEntity sets the "entity" edge to the Entity entity. +func (_u *MaintenanceEntryUpdate) SetEntity(v *Entity) *MaintenanceEntryUpdate { + return _u.SetEntityID(v.ID) } // Mutation returns the MaintenanceEntryMutation object of the builder. @@ -155,9 +155,9 @@ func (_u *MaintenanceEntryUpdate) Mutation() *MaintenanceEntryMutation { return _u.mutation } -// ClearItem clears the "item" edge to the Item entity. -func (_u *MaintenanceEntryUpdate) ClearItem() *MaintenanceEntryUpdate { - _u.mutation.ClearItem() +// ClearEntity clears the "entity" edge to the Entity entity. +func (_u *MaintenanceEntryUpdate) ClearEntity() *MaintenanceEntryUpdate { + _u.mutation.ClearEntity() return _u } @@ -209,8 +209,8 @@ func (_u *MaintenanceEntryUpdate) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)} } } - if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`) + if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`) } return nil } @@ -257,28 +257,28 @@ func (_u *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (_node int, err e if value, ok := _u.mutation.AddedCost(); ok { _spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value) } - if _u.mutation.ItemCleared() { + if _u.mutation.EntityCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.ItemTable, - Columns: []string{maintenanceentry.ItemColumn}, + Table: maintenanceentry.EntityTable, + Columns: []string{maintenanceentry.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { + if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.ItemTable, - Columns: []string{maintenanceentry.ItemColumn}, + Table: maintenanceentry.EntityTable, + Columns: []string{maintenanceentry.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -312,16 +312,16 @@ func (_u *MaintenanceEntryUpdateOne) SetUpdatedAt(v time.Time) *MaintenanceEntry return _u } -// SetItemID sets the "item_id" field. -func (_u *MaintenanceEntryUpdateOne) SetItemID(v uuid.UUID) *MaintenanceEntryUpdateOne { - _u.mutation.SetItemID(v) +// SetEntityID sets the "entity_id" field. +func (_u *MaintenanceEntryUpdateOne) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdateOne { + _u.mutation.SetEntityID(v) return _u } -// SetNillableItemID sets the "item_id" field if the given value is not nil. -func (_u *MaintenanceEntryUpdateOne) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdateOne { +// SetNillableEntityID sets the "entity_id" field if the given value is not nil. +func (_u *MaintenanceEntryUpdateOne) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdateOne { if v != nil { - _u.SetItemID(*v) + _u.SetEntityID(*v) } return _u } @@ -421,9 +421,9 @@ func (_u *MaintenanceEntryUpdateOne) AddCost(v float64) *MaintenanceEntryUpdateO return _u } -// SetItem sets the "item" edge to the Item entity. -func (_u *MaintenanceEntryUpdateOne) SetItem(v *Item) *MaintenanceEntryUpdateOne { - return _u.SetItemID(v.ID) +// SetEntity sets the "entity" edge to the Entity entity. +func (_u *MaintenanceEntryUpdateOne) SetEntity(v *Entity) *MaintenanceEntryUpdateOne { + return _u.SetEntityID(v.ID) } // Mutation returns the MaintenanceEntryMutation object of the builder. @@ -431,9 +431,9 @@ func (_u *MaintenanceEntryUpdateOne) Mutation() *MaintenanceEntryMutation { return _u.mutation } -// ClearItem clears the "item" edge to the Item entity. -func (_u *MaintenanceEntryUpdateOne) ClearItem() *MaintenanceEntryUpdateOne { - _u.mutation.ClearItem() +// ClearEntity clears the "entity" edge to the Entity entity. +func (_u *MaintenanceEntryUpdateOne) ClearEntity() *MaintenanceEntryUpdateOne { + _u.mutation.ClearEntity() return _u } @@ -498,8 +498,8 @@ func (_u *MaintenanceEntryUpdateOne) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)} } } - if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`) + if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`) } return nil } @@ -563,28 +563,28 @@ func (_u *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Mainte if value, ok := _u.mutation.AddedCost(); ok { _spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value) } - if _u.mutation.ItemCleared() { + if _u.mutation.EntityCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.ItemTable, - Columns: []string{maintenanceentry.ItemColumn}, + Table: maintenanceentry.EntityTable, + Columns: []string{maintenanceentry.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { + if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.ItemTable, - Columns: []string{maintenanceentry.ItemColumn}, + Table: maintenanceentry.EntityTable, + Columns: []string{maintenanceentry.EntityColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/migrate/schema.go b/backend/internal/data/ent/migrate/schema.go index ef6161d8..a864f1ee 100644 --- a/backend/internal/data/ent/migrate/schema.go +++ b/backend/internal/data/ent/migrate/schema.go @@ -19,7 +19,7 @@ var ( {Name: "path", Type: field.TypeString, Default: ""}, {Name: "mime_type", Type: field.TypeString, Default: "application/octet-stream"}, {Name: "attachment_thumbnail", Type: field.TypeUUID, Unique: true, Nullable: true}, - {Name: "item_attachments", Type: field.TypeUUID, Nullable: true}, + {Name: "entity_attachments", Type: field.TypeUUID, Nullable: true}, } // AttachmentsTable holds the schema information for the "attachments" table. AttachmentsTable = &schema.Table{ @@ -34,9 +34,9 @@ var ( OnDelete: schema.SetNull, }, { - Symbol: "attachments_items_attachments", + Symbol: "attachments_entities_attachments", Columns: []*schema.Column{AttachmentsColumns[9]}, - RefColumns: []*schema.Column{ItemsColumns[0]}, + RefColumns: []*schema.Column{EntitiesColumns[0]}, OnDelete: schema.Cascade, }, }, @@ -91,6 +91,168 @@ var ( }, }, } + // EntitiesColumns holds the columns for the "entities" table. + EntitiesColumns = []*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: "import_ref", Type: field.TypeString, Nullable: true, Size: 100}, + {Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "quantity", Type: field.TypeInt, Default: 1}, + {Name: "insured", Type: field.TypeBool, Default: false}, + {Name: "archived", Type: field.TypeBool, Default: false}, + {Name: "asset_id", Type: field.TypeInt, Default: 0}, + {Name: "sync_child_entities_locations", Type: field.TypeBool, Default: false}, + {Name: "serial_number", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "model_number", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "manufacturer", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "lifetime_warranty", Type: field.TypeBool, Default: false}, + {Name: "warranty_expires", Type: field.TypeTime, Nullable: true}, + {Name: "warranty_details", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "purchase_time", Type: field.TypeTime, Nullable: true}, + {Name: "purchase_from", Type: field.TypeString, Nullable: true}, + {Name: "purchase_price", Type: field.TypeFloat64, Default: 0}, + {Name: "sold_time", Type: field.TypeTime, Nullable: true}, + {Name: "sold_to", Type: field.TypeString, Nullable: true}, + {Name: "sold_price", Type: field.TypeFloat64, Default: 0}, + {Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "entity_parent", Type: field.TypeUUID, Nullable: true}, + {Name: "entity_location", Type: field.TypeUUID, Nullable: true}, + {Name: "entity_type_entities", Type: field.TypeUUID, Nullable: true}, + {Name: "group_entities", Type: field.TypeUUID}, + } + // EntitiesTable holds the schema information for the "entities" table. + EntitiesTable = &schema.Table{ + Name: "entities", + Columns: EntitiesColumns, + PrimaryKey: []*schema.Column{EntitiesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "entities_entities_parent", + Columns: []*schema.Column{EntitiesColumns[25]}, + RefColumns: []*schema.Column{EntitiesColumns[0]}, + OnDelete: schema.SetNull, + }, + { + Symbol: "entities_entities_location", + Columns: []*schema.Column{EntitiesColumns[26]}, + RefColumns: []*schema.Column{EntitiesColumns[0]}, + OnDelete: schema.SetNull, + }, + { + Symbol: "entities_entity_types_entities", + Columns: []*schema.Column{EntitiesColumns[27]}, + RefColumns: []*schema.Column{EntityTypesColumns[0]}, + OnDelete: schema.SetNull, + }, + { + Symbol: "entities_groups_entities", + Columns: []*schema.Column{EntitiesColumns[28]}, + RefColumns: []*schema.Column{GroupsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + Indexes: []*schema.Index{ + { + Name: "entity_name", + Unique: false, + Columns: []*schema.Column{EntitiesColumns[3]}, + }, + { + Name: "entity_manufacturer", + Unique: false, + Columns: []*schema.Column{EntitiesColumns[14]}, + }, + { + Name: "entity_model_number", + Unique: false, + Columns: []*schema.Column{EntitiesColumns[13]}, + }, + { + Name: "entity_serial_number", + Unique: false, + Columns: []*schema.Column{EntitiesColumns[12]}, + }, + { + Name: "entity_archived", + Unique: false, + Columns: []*schema.Column{EntitiesColumns[9]}, + }, + { + Name: "entity_asset_id", + Unique: false, + Columns: []*schema.Column{EntitiesColumns[10]}, + }, + }, + } + // EntityFieldsColumns holds the columns for the "entity_fields" table. + EntityFieldsColumns = []*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", "number", "boolean", "time"}}, + {Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500}, + {Name: "number_value", Type: field.TypeInt, Nullable: true}, + {Name: "boolean_value", Type: field.TypeBool, Default: false}, + {Name: "time_value", Type: field.TypeTime}, + {Name: "entity_fields", Type: field.TypeUUID, Nullable: true}, + } + // EntityFieldsTable holds the schema information for the "entity_fields" table. + EntityFieldsTable = &schema.Table{ + Name: "entity_fields", + Columns: EntityFieldsColumns, + PrimaryKey: []*schema.Column{EntityFieldsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "entity_fields_entities_fields", + Columns: []*schema.Column{EntityFieldsColumns[10]}, + RefColumns: []*schema.Column{EntitiesColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // EntityTypesColumns holds the columns for the "entity_types" table. + EntityTypesColumns = []*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: "icon", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "color", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "is_location", Type: field.TypeBool, Default: false}, + {Name: "group_entity_types", Type: field.TypeUUID}, + } + // EntityTypesTable holds the schema information for the "entity_types" table. + EntityTypesTable = &schema.Table{ + Name: "entity_types", + Columns: EntityTypesColumns, + PrimaryKey: []*schema.Column{EntityTypesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "entity_types_groups_entity_types", + Columns: []*schema.Column{EntityTypesColumns[8]}, + RefColumns: []*schema.Column{GroupsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + Indexes: []*schema.Index{ + { + Name: "entitytype_name", + Unique: false, + Columns: []*schema.Column{EntityTypesColumns[3]}, + }, + { + Name: "entitytype_is_location", + Unique: false, + Columns: []*schema.Column{EntityTypesColumns[7]}, + }, + }, + } // GroupsColumns holds the columns for the "groups" table. GroupsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -129,123 +291,6 @@ var ( }, }, } - // ItemsColumns holds the columns for the "items" table. - ItemsColumns = []*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: "import_ref", Type: field.TypeString, Nullable: true, Size: 100}, - {Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000}, - {Name: "quantity", Type: field.TypeInt, Default: 1}, - {Name: "insured", Type: field.TypeBool, Default: false}, - {Name: "archived", Type: field.TypeBool, Default: false}, - {Name: "asset_id", Type: field.TypeInt, Default: 0}, - {Name: "sync_child_items_locations", Type: field.TypeBool, Default: false}, - {Name: "serial_number", Type: field.TypeString, Nullable: true, Size: 255}, - {Name: "model_number", Type: field.TypeString, Nullable: true, Size: 255}, - {Name: "manufacturer", Type: field.TypeString, Nullable: true, Size: 255}, - {Name: "lifetime_warranty", Type: field.TypeBool, Default: false}, - {Name: "warranty_expires", Type: field.TypeTime, Nullable: true}, - {Name: "warranty_details", Type: field.TypeString, Nullable: true, Size: 1000}, - {Name: "purchase_time", Type: field.TypeTime, Nullable: true}, - {Name: "purchase_from", Type: field.TypeString, Nullable: true}, - {Name: "purchase_price", Type: field.TypeFloat64, Default: 0}, - {Name: "sold_time", Type: field.TypeTime, Nullable: true}, - {Name: "sold_to", Type: field.TypeString, Nullable: true}, - {Name: "sold_price", Type: field.TypeFloat64, Default: 0}, - {Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000}, - {Name: "group_items", Type: field.TypeUUID}, - {Name: "item_children", Type: field.TypeUUID, Nullable: true}, - {Name: "location_items", Type: field.TypeUUID, Nullable: true}, - } - // ItemsTable holds the schema information for the "items" table. - ItemsTable = &schema.Table{ - Name: "items", - Columns: ItemsColumns, - PrimaryKey: []*schema.Column{ItemsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "items_groups_items", - Columns: []*schema.Column{ItemsColumns[25]}, - RefColumns: []*schema.Column{GroupsColumns[0]}, - OnDelete: schema.Cascade, - }, - { - Symbol: "items_items_children", - Columns: []*schema.Column{ItemsColumns[26]}, - RefColumns: []*schema.Column{ItemsColumns[0]}, - OnDelete: schema.SetNull, - }, - { - Symbol: "items_locations_items", - Columns: []*schema.Column{ItemsColumns[27]}, - RefColumns: []*schema.Column{LocationsColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - Indexes: []*schema.Index{ - { - Name: "item_name", - Unique: false, - Columns: []*schema.Column{ItemsColumns[3]}, - }, - { - Name: "item_manufacturer", - Unique: false, - Columns: []*schema.Column{ItemsColumns[14]}, - }, - { - Name: "item_model_number", - Unique: false, - Columns: []*schema.Column{ItemsColumns[13]}, - }, - { - Name: "item_serial_number", - Unique: false, - Columns: []*schema.Column{ItemsColumns[12]}, - }, - { - Name: "item_archived", - Unique: false, - Columns: []*schema.Column{ItemsColumns[9]}, - }, - { - Name: "item_asset_id", - Unique: false, - Columns: []*schema.Column{ItemsColumns[10]}, - }, - }, - } - // ItemFieldsColumns holds the columns for the "item_fields" table. - ItemFieldsColumns = []*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", "number", "boolean", "time"}}, - {Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500}, - {Name: "number_value", Type: field.TypeInt, Nullable: true}, - {Name: "boolean_value", Type: field.TypeBool, Default: false}, - {Name: "time_value", Type: field.TypeTime}, - {Name: "item_fields", Type: field.TypeUUID, Nullable: true}, - } - // ItemFieldsTable holds the schema information for the "item_fields" table. - ItemFieldsTable = &schema.Table{ - Name: "item_fields", - Columns: ItemFieldsColumns, - PrimaryKey: []*schema.Column{ItemFieldsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "item_fields_items_fields", - Columns: []*schema.Column{ItemFieldsColumns[10]}, - RefColumns: []*schema.Column{ItemsColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - } // ItemTemplatesColumns holds the columns for the "item_templates" table. ItemTemplatesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -282,9 +327,9 @@ var ( OnDelete: schema.Cascade, }, { - Symbol: "item_templates_locations_location", + Symbol: "item_templates_entities_location", Columns: []*schema.Column{ItemTemplatesColumns[19]}, - RefColumns: []*schema.Column{LocationsColumns[0]}, + RefColumns: []*schema.Column{EntitiesColumns[0]}, OnDelete: schema.SetNull, }, }, @@ -320,36 +365,6 @@ var ( }, }, } - // LocationsColumns holds the columns for the "locations" table. - LocationsColumns = []*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: "group_locations", Type: field.TypeUUID}, - {Name: "location_children", Type: field.TypeUUID, Nullable: true}, - } - // LocationsTable holds the schema information for the "locations" table. - LocationsTable = &schema.Table{ - Name: "locations", - Columns: LocationsColumns, - PrimaryKey: []*schema.Column{LocationsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "locations_groups_locations", - Columns: []*schema.Column{LocationsColumns[5]}, - RefColumns: []*schema.Column{GroupsColumns[0]}, - OnDelete: schema.Cascade, - }, - { - Symbol: "locations_locations_children", - Columns: []*schema.Column{LocationsColumns[6]}, - RefColumns: []*schema.Column{LocationsColumns[0]}, - OnDelete: schema.SetNull, - }, - }, - } // MaintenanceEntriesColumns holds the columns for the "maintenance_entries" table. MaintenanceEntriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -360,7 +375,7 @@ var ( {Name: "name", Type: field.TypeString, Size: 255}, {Name: "description", Type: field.TypeString, Nullable: true, Size: 2500}, {Name: "cost", Type: field.TypeFloat64, Default: 0}, - {Name: "item_id", Type: field.TypeUUID}, + {Name: "entity_id", Type: field.TypeUUID}, } // MaintenanceEntriesTable holds the schema information for the "maintenance_entries" table. MaintenanceEntriesTable = &schema.Table{ @@ -369,9 +384,9 @@ var ( PrimaryKey: []*schema.Column{MaintenanceEntriesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "maintenance_entries_items_maintenance_entries", + Symbol: "maintenance_entries_entities_maintenance_entries", Columns: []*schema.Column{MaintenanceEntriesColumns[8]}, - RefColumns: []*schema.Column{ItemsColumns[0]}, + RefColumns: []*schema.Column{EntitiesColumns[0]}, OnDelete: schema.Cascade, }, }, @@ -491,27 +506,27 @@ var ( }, }, } - // LabelItemsColumns holds the columns for the "label_items" table. - LabelItemsColumns = []*schema.Column{ + // LabelEntitiesColumns holds the columns for the "label_entities" table. + LabelEntitiesColumns = []*schema.Column{ {Name: "label_id", Type: field.TypeUUID}, - {Name: "item_id", Type: field.TypeUUID}, + {Name: "entity_id", Type: field.TypeUUID}, } - // LabelItemsTable holds the schema information for the "label_items" table. - LabelItemsTable = &schema.Table{ - Name: "label_items", - Columns: LabelItemsColumns, - PrimaryKey: []*schema.Column{LabelItemsColumns[0], LabelItemsColumns[1]}, + // LabelEntitiesTable holds the schema information for the "label_entities" table. + LabelEntitiesTable = &schema.Table{ + Name: "label_entities", + Columns: LabelEntitiesColumns, + PrimaryKey: []*schema.Column{LabelEntitiesColumns[0], LabelEntitiesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "label_items_label_id", - Columns: []*schema.Column{LabelItemsColumns[0]}, + Symbol: "label_entities_label_id", + Columns: []*schema.Column{LabelEntitiesColumns[0]}, RefColumns: []*schema.Column{LabelsColumns[0]}, OnDelete: schema.Cascade, }, { - Symbol: "label_items_item_id", - Columns: []*schema.Column{LabelItemsColumns[1]}, - RefColumns: []*schema.Column{ItemsColumns[0]}, + Symbol: "label_entities_entity_id", + Columns: []*schema.Column{LabelEntitiesColumns[1]}, + RefColumns: []*schema.Column{EntitiesColumns[0]}, OnDelete: schema.Cascade, }, }, @@ -521,41 +536,41 @@ var ( AttachmentsTable, AuthRolesTable, AuthTokensTable, + EntitiesTable, + EntityFieldsTable, + EntityTypesTable, GroupsTable, GroupInvitationTokensTable, - ItemsTable, - ItemFieldsTable, ItemTemplatesTable, LabelsTable, - LocationsTable, MaintenanceEntriesTable, NotifiersTable, TemplateFieldsTable, UsersTable, - LabelItemsTable, + LabelEntitiesTable, } ) func init() { AttachmentsTable.ForeignKeys[0].RefTable = AttachmentsTable - AttachmentsTable.ForeignKeys[1].RefTable = ItemsTable + AttachmentsTable.ForeignKeys[1].RefTable = EntitiesTable AuthRolesTable.ForeignKeys[0].RefTable = AuthTokensTable AuthTokensTable.ForeignKeys[0].RefTable = UsersTable + EntitiesTable.ForeignKeys[0].RefTable = EntitiesTable + EntitiesTable.ForeignKeys[1].RefTable = EntitiesTable + EntitiesTable.ForeignKeys[2].RefTable = EntityTypesTable + EntitiesTable.ForeignKeys[3].RefTable = GroupsTable + EntityFieldsTable.ForeignKeys[0].RefTable = EntitiesTable + EntityTypesTable.ForeignKeys[0].RefTable = GroupsTable GroupInvitationTokensTable.ForeignKeys[0].RefTable = GroupsTable - ItemsTable.ForeignKeys[0].RefTable = GroupsTable - 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 + ItemTemplatesTable.ForeignKeys[1].RefTable = EntitiesTable LabelsTable.ForeignKeys[0].RefTable = GroupsTable - LocationsTable.ForeignKeys[0].RefTable = GroupsTable - LocationsTable.ForeignKeys[1].RefTable = LocationsTable - MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable + MaintenanceEntriesTable.ForeignKeys[0].RefTable = EntitiesTable 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 + LabelEntitiesTable.ForeignKeys[0].RefTable = LabelsTable + LabelEntitiesTable.ForeignKeys[1].RefTable = EntitiesTable } diff --git a/backend/internal/data/ent/mutation.go b/backend/internal/data/ent/mutation.go index f5a1b13d..e034f686 100644 --- a/backend/internal/data/ent/mutation.go +++ b/backend/internal/data/ent/mutation.go @@ -15,13 +15,13 @@ import ( "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "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/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" @@ -41,13 +41,13 @@ const ( TypeAttachment = "Attachment" TypeAuthRoles = "AuthRoles" TypeAuthTokens = "AuthTokens" + TypeEntity = "Entity" + TypeEntityField = "EntityField" + TypeEntityType = "EntityType" TypeGroup = "Group" TypeGroupInvitationToken = "GroupInvitationToken" - TypeItem = "Item" - TypeItemField = "ItemField" TypeItemTemplate = "ItemTemplate" TypeLabel = "Label" - TypeLocation = "Location" TypeMaintenanceEntry = "MaintenanceEntry" TypeNotifier = "Notifier" TypeTemplateField = "TemplateField" @@ -68,8 +68,8 @@ type AttachmentMutation struct { _path *string mime_type *string clearedFields map[string]struct{} - item *uuid.UUID - cleareditem bool + entity *uuid.UUID + clearedentity bool thumbnail *uuid.UUID clearedthumbnail bool done bool @@ -433,43 +433,43 @@ func (m *AttachmentMutation) ResetMimeType() { m.mime_type = nil } -// SetItemID sets the "item" edge to the Item entity by id. -func (m *AttachmentMutation) SetItemID(id uuid.UUID) { - m.item = &id +// SetEntityID sets the "entity" edge to the Entity entity by id. +func (m *AttachmentMutation) SetEntityID(id uuid.UUID) { + m.entity = &id } -// ClearItem clears the "item" edge to the Item entity. -func (m *AttachmentMutation) ClearItem() { - m.cleareditem = true +// ClearEntity clears the "entity" edge to the Entity entity. +func (m *AttachmentMutation) ClearEntity() { + m.clearedentity = true } -// ItemCleared reports if the "item" edge to the Item entity was cleared. -func (m *AttachmentMutation) ItemCleared() bool { - return m.cleareditem +// EntityCleared reports if the "entity" edge to the Entity entity was cleared. +func (m *AttachmentMutation) EntityCleared() bool { + return m.clearedentity } -// ItemID returns the "item" edge ID in the mutation. -func (m *AttachmentMutation) ItemID() (id uuid.UUID, exists bool) { - if m.item != nil { - return *m.item, true +// EntityID returns the "entity" edge ID in the mutation. +func (m *AttachmentMutation) EntityID() (id uuid.UUID, exists bool) { + if m.entity != nil { + return *m.entity, true } return } -// ItemIDs returns the "item" edge IDs in the mutation. +// EntityIDs returns the "entity" 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 *AttachmentMutation) ItemIDs() (ids []uuid.UUID) { - if id := m.item; id != nil { +// EntityID instead. It exists only for internal usage by the builders. +func (m *AttachmentMutation) EntityIDs() (ids []uuid.UUID) { + if id := m.entity; id != nil { ids = append(ids, *id) } return } -// ResetItem resets all changes to the "item" edge. -func (m *AttachmentMutation) ResetItem() { - m.item = nil - m.cleareditem = false +// ResetEntity resets all changes to the "entity" edge. +func (m *AttachmentMutation) ResetEntity() { + m.entity = nil + m.clearedentity = false } // SetThumbnailID sets the "thumbnail" edge to the Attachment entity by id. @@ -747,8 +747,8 @@ func (m *AttachmentMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *AttachmentMutation) AddedEdges() []string { edges := make([]string, 0, 2) - if m.item != nil { - edges = append(edges, attachment.EdgeItem) + if m.entity != nil { + edges = append(edges, attachment.EdgeEntity) } if m.thumbnail != nil { edges = append(edges, attachment.EdgeThumbnail) @@ -760,8 +760,8 @@ func (m *AttachmentMutation) AddedEdges() []string { // name in this mutation. func (m *AttachmentMutation) AddedIDs(name string) []ent.Value { switch name { - case attachment.EdgeItem: - if id := m.item; id != nil { + case attachment.EdgeEntity: + if id := m.entity; id != nil { return []ent.Value{*id} } case attachment.EdgeThumbnail: @@ -787,8 +787,8 @@ func (m *AttachmentMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *AttachmentMutation) ClearedEdges() []string { edges := make([]string, 0, 2) - if m.cleareditem { - edges = append(edges, attachment.EdgeItem) + if m.clearedentity { + edges = append(edges, attachment.EdgeEntity) } if m.clearedthumbnail { edges = append(edges, attachment.EdgeThumbnail) @@ -800,8 +800,8 @@ func (m *AttachmentMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *AttachmentMutation) EdgeCleared(name string) bool { switch name { - case attachment.EdgeItem: - return m.cleareditem + case attachment.EdgeEntity: + return m.clearedentity case attachment.EdgeThumbnail: return m.clearedthumbnail } @@ -812,8 +812,8 @@ func (m *AttachmentMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *AttachmentMutation) ClearEdge(name string) error { switch name { - case attachment.EdgeItem: - m.ClearItem() + case attachment.EdgeEntity: + m.ClearEntity() return nil case attachment.EdgeThumbnail: m.ClearThumbnail() @@ -826,8 +826,8 @@ func (m *AttachmentMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *AttachmentMutation) ResetEdge(name string) error { switch name { - case attachment.EdgeItem: - m.ResetItem() + case attachment.EdgeEntity: + m.ResetEntity() return nil case attachment.EdgeThumbnail: m.ResetThumbnail() @@ -1849,6 +1849,4505 @@ func (m *AuthTokensMutation) ResetEdge(name string) error { return fmt.Errorf("unknown AuthTokens edge %s", name) } +// EntityMutation represents an operation that mutates the Entity nodes in the graph. +type EntityMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + updated_at *time.Time + name *string + description *string + import_ref *string + notes *string + quantity *int + addquantity *int + insured *bool + archived *bool + asset_id *int + addasset_id *int + sync_child_entities_locations *bool + serial_number *string + model_number *string + manufacturer *string + lifetime_warranty *bool + warranty_expires *time.Time + warranty_details *string + purchase_time *time.Time + purchase_from *string + purchase_price *float64 + addpurchase_price *float64 + sold_time *time.Time + sold_to *string + sold_price *float64 + addsold_price *float64 + sold_notes *string + clearedFields map[string]struct{} + group *uuid.UUID + clearedgroup bool + children map[uuid.UUID]struct{} + removedchildren map[uuid.UUID]struct{} + clearedchildren bool + parent *uuid.UUID + clearedparent bool + entity map[uuid.UUID]struct{} + removedentity map[uuid.UUID]struct{} + clearedentity bool + location *uuid.UUID + clearedlocation bool + label map[uuid.UUID]struct{} + removedlabel map[uuid.UUID]struct{} + clearedlabel bool + _type *uuid.UUID + cleared_type bool + fields map[uuid.UUID]struct{} + removedfields map[uuid.UUID]struct{} + clearedfields bool + maintenance_entries map[uuid.UUID]struct{} + removedmaintenance_entries map[uuid.UUID]struct{} + clearedmaintenance_entries bool + attachments map[uuid.UUID]struct{} + removedattachments map[uuid.UUID]struct{} + clearedattachments bool + done bool + oldValue func(context.Context) (*Entity, error) + predicates []predicate.Entity +} + +var _ ent.Mutation = (*EntityMutation)(nil) + +// entityOption allows management of the mutation configuration using functional options. +type entityOption func(*EntityMutation) + +// newEntityMutation creates new mutation for the Entity entity. +func newEntityMutation(c config, op Op, opts ...entityOption) *EntityMutation { + m := &EntityMutation{ + config: c, + op: op, + typ: TypeEntity, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEntityID sets the ID field of the mutation. +func withEntityID(id uuid.UUID) entityOption { + return func(m *EntityMutation) { + var ( + err error + once sync.Once + value *Entity + ) + m.oldValue = func(ctx context.Context) (*Entity, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Entity.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEntity sets the old Entity of the mutation. +func withEntity(node *Entity) entityOption { + return func(m *EntityMutation) { + m.oldValue = func(context.Context) (*Entity, 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 EntityMutation) 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 EntityMutation) 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 Entity entities. +func (m *EntityMutation) 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 *EntityMutation) 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 *EntityMutation) 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().Entity.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 *EntityMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *EntityMutation) 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 Entity entity. +// If the Entity 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 *EntityMutation) 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 *EntityMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *EntityMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *EntityMutation) 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 Entity entity. +// If the Entity 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 *EntityMutation) 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 *EntityMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *EntityMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *EntityMutation) 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 Entity entity. +// If the Entity 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 *EntityMutation) 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 *EntityMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *EntityMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *EntityMutation) 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 Entity entity. +// If the Entity 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 *EntityMutation) 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 *EntityMutation) ClearDescription() { + m.description = nil + m.clearedFields[entity.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *EntityMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[entity.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *EntityMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, entity.FieldDescription) +} + +// SetImportRef sets the "import_ref" field. +func (m *EntityMutation) SetImportRef(s string) { + m.import_ref = &s +} + +// ImportRef returns the value of the "import_ref" field in the mutation. +func (m *EntityMutation) ImportRef() (r string, exists bool) { + v := m.import_ref + if v == nil { + return + } + return *v, true +} + +// OldImportRef returns the old "import_ref" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldImportRef(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldImportRef is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldImportRef requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldImportRef: %w", err) + } + return oldValue.ImportRef, nil +} + +// ClearImportRef clears the value of the "import_ref" field. +func (m *EntityMutation) ClearImportRef() { + m.import_ref = nil + m.clearedFields[entity.FieldImportRef] = struct{}{} +} + +// ImportRefCleared returns if the "import_ref" field was cleared in this mutation. +func (m *EntityMutation) ImportRefCleared() bool { + _, ok := m.clearedFields[entity.FieldImportRef] + return ok +} + +// ResetImportRef resets all changes to the "import_ref" field. +func (m *EntityMutation) ResetImportRef() { + m.import_ref = nil + delete(m.clearedFields, entity.FieldImportRef) +} + +// SetNotes sets the "notes" field. +func (m *EntityMutation) SetNotes(s string) { + m.notes = &s +} + +// Notes returns the value of the "notes" field in the mutation. +func (m *EntityMutation) Notes() (r string, exists bool) { + v := m.notes + if v == nil { + return + } + return *v, true +} + +// OldNotes returns the old "notes" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldNotes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNotes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + 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 OldNotes: %w", err) + } + return oldValue.Notes, nil +} + +// ClearNotes clears the value of the "notes" field. +func (m *EntityMutation) ClearNotes() { + m.notes = nil + m.clearedFields[entity.FieldNotes] = struct{}{} +} + +// NotesCleared returns if the "notes" field was cleared in this mutation. +func (m *EntityMutation) NotesCleared() bool { + _, ok := m.clearedFields[entity.FieldNotes] + return ok +} + +// ResetNotes resets all changes to the "notes" field. +func (m *EntityMutation) ResetNotes() { + m.notes = nil + delete(m.clearedFields, entity.FieldNotes) +} + +// SetQuantity sets the "quantity" field. +func (m *EntityMutation) SetQuantity(i int) { + m.quantity = &i + m.addquantity = nil +} + +// Quantity returns the value of the "quantity" field in the mutation. +func (m *EntityMutation) Quantity() (r int, exists bool) { + v := m.quantity + if v == nil { + return + } + return *v, true +} + +// OldQuantity returns the old "quantity" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldQuantity(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldQuantity is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldQuantity requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldQuantity: %w", err) + } + return oldValue.Quantity, nil +} + +// AddQuantity adds i to the "quantity" field. +func (m *EntityMutation) AddQuantity(i int) { + if m.addquantity != nil { + *m.addquantity += i + } else { + m.addquantity = &i + } +} + +// AddedQuantity returns the value that was added to the "quantity" field in this mutation. +func (m *EntityMutation) AddedQuantity() (r int, exists bool) { + v := m.addquantity + if v == nil { + return + } + return *v, true +} + +// ResetQuantity resets all changes to the "quantity" field. +func (m *EntityMutation) ResetQuantity() { + m.quantity = nil + m.addquantity = nil +} + +// SetInsured sets the "insured" field. +func (m *EntityMutation) SetInsured(b bool) { + m.insured = &b +} + +// Insured returns the value of the "insured" field in the mutation. +func (m *EntityMutation) Insured() (r bool, exists bool) { + v := m.insured + if v == nil { + return + } + return *v, true +} + +// OldInsured returns the old "insured" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldInsured(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInsured is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInsured requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInsured: %w", err) + } + return oldValue.Insured, nil +} + +// ResetInsured resets all changes to the "insured" field. +func (m *EntityMutation) ResetInsured() { + m.insured = nil +} + +// SetArchived sets the "archived" field. +func (m *EntityMutation) SetArchived(b bool) { + m.archived = &b +} + +// Archived returns the value of the "archived" field in the mutation. +func (m *EntityMutation) Archived() (r bool, exists bool) { + v := m.archived + if v == nil { + return + } + return *v, true +} + +// OldArchived returns the old "archived" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldArchived(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArchived is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArchived requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArchived: %w", err) + } + return oldValue.Archived, nil +} + +// ResetArchived resets all changes to the "archived" field. +func (m *EntityMutation) ResetArchived() { + m.archived = nil +} + +// SetAssetID sets the "asset_id" field. +func (m *EntityMutation) SetAssetID(i int) { + m.asset_id = &i + m.addasset_id = nil +} + +// AssetID returns the value of the "asset_id" field in the mutation. +func (m *EntityMutation) AssetID() (r int, exists bool) { + v := m.asset_id + if v == nil { + return + } + return *v, true +} + +// OldAssetID returns the old "asset_id" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldAssetID(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAssetID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAssetID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAssetID: %w", err) + } + return oldValue.AssetID, nil +} + +// AddAssetID adds i to the "asset_id" field. +func (m *EntityMutation) AddAssetID(i int) { + if m.addasset_id != nil { + *m.addasset_id += i + } else { + m.addasset_id = &i + } +} + +// AddedAssetID returns the value that was added to the "asset_id" field in this mutation. +func (m *EntityMutation) AddedAssetID() (r int, exists bool) { + v := m.addasset_id + if v == nil { + return + } + return *v, true +} + +// ResetAssetID resets all changes to the "asset_id" field. +func (m *EntityMutation) ResetAssetID() { + m.asset_id = nil + m.addasset_id = nil +} + +// SetSyncChildEntitiesLocations sets the "sync_child_entities_locations" field. +func (m *EntityMutation) SetSyncChildEntitiesLocations(b bool) { + m.sync_child_entities_locations = &b +} + +// SyncChildEntitiesLocations returns the value of the "sync_child_entities_locations" field in the mutation. +func (m *EntityMutation) SyncChildEntitiesLocations() (r bool, exists bool) { + v := m.sync_child_entities_locations + if v == nil { + return + } + return *v, true +} + +// OldSyncChildEntitiesLocations returns the old "sync_child_entities_locations" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldSyncChildEntitiesLocations(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSyncChildEntitiesLocations is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSyncChildEntitiesLocations requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSyncChildEntitiesLocations: %w", err) + } + return oldValue.SyncChildEntitiesLocations, nil +} + +// ResetSyncChildEntitiesLocations resets all changes to the "sync_child_entities_locations" field. +func (m *EntityMutation) ResetSyncChildEntitiesLocations() { + m.sync_child_entities_locations = nil +} + +// SetSerialNumber sets the "serial_number" field. +func (m *EntityMutation) SetSerialNumber(s string) { + m.serial_number = &s +} + +// SerialNumber returns the value of the "serial_number" field in the mutation. +func (m *EntityMutation) SerialNumber() (r string, exists bool) { + v := m.serial_number + if v == nil { + return + } + return *v, true +} + +// OldSerialNumber returns the old "serial_number" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldSerialNumber(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSerialNumber is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSerialNumber requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSerialNumber: %w", err) + } + return oldValue.SerialNumber, nil +} + +// ClearSerialNumber clears the value of the "serial_number" field. +func (m *EntityMutation) ClearSerialNumber() { + m.serial_number = nil + m.clearedFields[entity.FieldSerialNumber] = struct{}{} +} + +// SerialNumberCleared returns if the "serial_number" field was cleared in this mutation. +func (m *EntityMutation) SerialNumberCleared() bool { + _, ok := m.clearedFields[entity.FieldSerialNumber] + return ok +} + +// ResetSerialNumber resets all changes to the "serial_number" field. +func (m *EntityMutation) ResetSerialNumber() { + m.serial_number = nil + delete(m.clearedFields, entity.FieldSerialNumber) +} + +// SetModelNumber sets the "model_number" field. +func (m *EntityMutation) SetModelNumber(s string) { + m.model_number = &s +} + +// ModelNumber returns the value of the "model_number" field in the mutation. +func (m *EntityMutation) ModelNumber() (r string, exists bool) { + v := m.model_number + if v == nil { + return + } + return *v, true +} + +// OldModelNumber returns the old "model_number" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldModelNumber(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModelNumber is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModelNumber requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModelNumber: %w", err) + } + return oldValue.ModelNumber, nil +} + +// ClearModelNumber clears the value of the "model_number" field. +func (m *EntityMutation) ClearModelNumber() { + m.model_number = nil + m.clearedFields[entity.FieldModelNumber] = struct{}{} +} + +// ModelNumberCleared returns if the "model_number" field was cleared in this mutation. +func (m *EntityMutation) ModelNumberCleared() bool { + _, ok := m.clearedFields[entity.FieldModelNumber] + return ok +} + +// ResetModelNumber resets all changes to the "model_number" field. +func (m *EntityMutation) ResetModelNumber() { + m.model_number = nil + delete(m.clearedFields, entity.FieldModelNumber) +} + +// SetManufacturer sets the "manufacturer" field. +func (m *EntityMutation) SetManufacturer(s string) { + m.manufacturer = &s +} + +// Manufacturer returns the value of the "manufacturer" field in the mutation. +func (m *EntityMutation) Manufacturer() (r string, exists bool) { + v := m.manufacturer + if v == nil { + return + } + return *v, true +} + +// OldManufacturer returns the old "manufacturer" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldManufacturer(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldManufacturer requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) + } + return oldValue.Manufacturer, nil +} + +// ClearManufacturer clears the value of the "manufacturer" field. +func (m *EntityMutation) ClearManufacturer() { + m.manufacturer = nil + m.clearedFields[entity.FieldManufacturer] = struct{}{} +} + +// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. +func (m *EntityMutation) ManufacturerCleared() bool { + _, ok := m.clearedFields[entity.FieldManufacturer] + return ok +} + +// ResetManufacturer resets all changes to the "manufacturer" field. +func (m *EntityMutation) ResetManufacturer() { + m.manufacturer = nil + delete(m.clearedFields, entity.FieldManufacturer) +} + +// SetLifetimeWarranty sets the "lifetime_warranty" field. +func (m *EntityMutation) SetLifetimeWarranty(b bool) { + m.lifetime_warranty = &b +} + +// LifetimeWarranty returns the value of the "lifetime_warranty" field in the mutation. +func (m *EntityMutation) LifetimeWarranty() (r bool, exists bool) { + v := m.lifetime_warranty + if v == nil { + return + } + return *v, true +} + +// OldLifetimeWarranty returns the old "lifetime_warranty" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldLifetimeWarranty(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLifetimeWarranty is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLifetimeWarranty requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLifetimeWarranty: %w", err) + } + return oldValue.LifetimeWarranty, nil +} + +// ResetLifetimeWarranty resets all changes to the "lifetime_warranty" field. +func (m *EntityMutation) ResetLifetimeWarranty() { + m.lifetime_warranty = nil +} + +// SetWarrantyExpires sets the "warranty_expires" field. +func (m *EntityMutation) SetWarrantyExpires(t time.Time) { + m.warranty_expires = &t +} + +// WarrantyExpires returns the value of the "warranty_expires" field in the mutation. +func (m *EntityMutation) WarrantyExpires() (r time.Time, exists bool) { + v := m.warranty_expires + if v == nil { + return + } + return *v, true +} + +// OldWarrantyExpires returns the old "warranty_expires" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldWarrantyExpires(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWarrantyExpires is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWarrantyExpires requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWarrantyExpires: %w", err) + } + return oldValue.WarrantyExpires, nil +} + +// ClearWarrantyExpires clears the value of the "warranty_expires" field. +func (m *EntityMutation) ClearWarrantyExpires() { + m.warranty_expires = nil + m.clearedFields[entity.FieldWarrantyExpires] = struct{}{} +} + +// WarrantyExpiresCleared returns if the "warranty_expires" field was cleared in this mutation. +func (m *EntityMutation) WarrantyExpiresCleared() bool { + _, ok := m.clearedFields[entity.FieldWarrantyExpires] + return ok +} + +// ResetWarrantyExpires resets all changes to the "warranty_expires" field. +func (m *EntityMutation) ResetWarrantyExpires() { + m.warranty_expires = nil + delete(m.clearedFields, entity.FieldWarrantyExpires) +} + +// SetWarrantyDetails sets the "warranty_details" field. +func (m *EntityMutation) SetWarrantyDetails(s string) { + m.warranty_details = &s +} + +// WarrantyDetails returns the value of the "warranty_details" field in the mutation. +func (m *EntityMutation) WarrantyDetails() (r string, exists bool) { + v := m.warranty_details + if v == nil { + return + } + return *v, true +} + +// OldWarrantyDetails returns the old "warranty_details" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldWarrantyDetails(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWarrantyDetails is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWarrantyDetails requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWarrantyDetails: %w", err) + } + return oldValue.WarrantyDetails, nil +} + +// ClearWarrantyDetails clears the value of the "warranty_details" field. +func (m *EntityMutation) ClearWarrantyDetails() { + m.warranty_details = nil + m.clearedFields[entity.FieldWarrantyDetails] = struct{}{} +} + +// WarrantyDetailsCleared returns if the "warranty_details" field was cleared in this mutation. +func (m *EntityMutation) WarrantyDetailsCleared() bool { + _, ok := m.clearedFields[entity.FieldWarrantyDetails] + return ok +} + +// ResetWarrantyDetails resets all changes to the "warranty_details" field. +func (m *EntityMutation) ResetWarrantyDetails() { + m.warranty_details = nil + delete(m.clearedFields, entity.FieldWarrantyDetails) +} + +// SetPurchaseTime sets the "purchase_time" field. +func (m *EntityMutation) SetPurchaseTime(t time.Time) { + m.purchase_time = &t +} + +// PurchaseTime returns the value of the "purchase_time" field in the mutation. +func (m *EntityMutation) PurchaseTime() (r time.Time, exists bool) { + v := m.purchase_time + if v == nil { + return + } + return *v, true +} + +// OldPurchaseTime returns the old "purchase_time" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldPurchaseTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPurchaseTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPurchaseTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPurchaseTime: %w", err) + } + return oldValue.PurchaseTime, nil +} + +// ClearPurchaseTime clears the value of the "purchase_time" field. +func (m *EntityMutation) ClearPurchaseTime() { + m.purchase_time = nil + m.clearedFields[entity.FieldPurchaseTime] = struct{}{} +} + +// PurchaseTimeCleared returns if the "purchase_time" field was cleared in this mutation. +func (m *EntityMutation) PurchaseTimeCleared() bool { + _, ok := m.clearedFields[entity.FieldPurchaseTime] + return ok +} + +// ResetPurchaseTime resets all changes to the "purchase_time" field. +func (m *EntityMutation) ResetPurchaseTime() { + m.purchase_time = nil + delete(m.clearedFields, entity.FieldPurchaseTime) +} + +// SetPurchaseFrom sets the "purchase_from" field. +func (m *EntityMutation) SetPurchaseFrom(s string) { + m.purchase_from = &s +} + +// PurchaseFrom returns the value of the "purchase_from" field in the mutation. +func (m *EntityMutation) PurchaseFrom() (r string, exists bool) { + v := m.purchase_from + if v == nil { + return + } + return *v, true +} + +// OldPurchaseFrom returns the old "purchase_from" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldPurchaseFrom(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPurchaseFrom is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPurchaseFrom requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPurchaseFrom: %w", err) + } + return oldValue.PurchaseFrom, nil +} + +// ClearPurchaseFrom clears the value of the "purchase_from" field. +func (m *EntityMutation) ClearPurchaseFrom() { + m.purchase_from = nil + m.clearedFields[entity.FieldPurchaseFrom] = struct{}{} +} + +// PurchaseFromCleared returns if the "purchase_from" field was cleared in this mutation. +func (m *EntityMutation) PurchaseFromCleared() bool { + _, ok := m.clearedFields[entity.FieldPurchaseFrom] + return ok +} + +// ResetPurchaseFrom resets all changes to the "purchase_from" field. +func (m *EntityMutation) ResetPurchaseFrom() { + m.purchase_from = nil + delete(m.clearedFields, entity.FieldPurchaseFrom) +} + +// SetPurchasePrice sets the "purchase_price" field. +func (m *EntityMutation) SetPurchasePrice(f float64) { + m.purchase_price = &f + m.addpurchase_price = nil +} + +// PurchasePrice returns the value of the "purchase_price" field in the mutation. +func (m *EntityMutation) PurchasePrice() (r float64, exists bool) { + v := m.purchase_price + if v == nil { + return + } + return *v, true +} + +// OldPurchasePrice returns the old "purchase_price" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldPurchasePrice(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPurchasePrice is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPurchasePrice requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPurchasePrice: %w", err) + } + return oldValue.PurchasePrice, nil +} + +// AddPurchasePrice adds f to the "purchase_price" field. +func (m *EntityMutation) AddPurchasePrice(f float64) { + if m.addpurchase_price != nil { + *m.addpurchase_price += f + } else { + m.addpurchase_price = &f + } +} + +// AddedPurchasePrice returns the value that was added to the "purchase_price" field in this mutation. +func (m *EntityMutation) AddedPurchasePrice() (r float64, exists bool) { + v := m.addpurchase_price + if v == nil { + return + } + return *v, true +} + +// ResetPurchasePrice resets all changes to the "purchase_price" field. +func (m *EntityMutation) ResetPurchasePrice() { + m.purchase_price = nil + m.addpurchase_price = nil +} + +// SetSoldTime sets the "sold_time" field. +func (m *EntityMutation) SetSoldTime(t time.Time) { + m.sold_time = &t +} + +// SoldTime returns the value of the "sold_time" field in the mutation. +func (m *EntityMutation) SoldTime() (r time.Time, exists bool) { + v := m.sold_time + if v == nil { + return + } + return *v, true +} + +// OldSoldTime returns the old "sold_time" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldSoldTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSoldTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSoldTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSoldTime: %w", err) + } + return oldValue.SoldTime, nil +} + +// ClearSoldTime clears the value of the "sold_time" field. +func (m *EntityMutation) ClearSoldTime() { + m.sold_time = nil + m.clearedFields[entity.FieldSoldTime] = struct{}{} +} + +// SoldTimeCleared returns if the "sold_time" field was cleared in this mutation. +func (m *EntityMutation) SoldTimeCleared() bool { + _, ok := m.clearedFields[entity.FieldSoldTime] + return ok +} + +// ResetSoldTime resets all changes to the "sold_time" field. +func (m *EntityMutation) ResetSoldTime() { + m.sold_time = nil + delete(m.clearedFields, entity.FieldSoldTime) +} + +// SetSoldTo sets the "sold_to" field. +func (m *EntityMutation) SetSoldTo(s string) { + m.sold_to = &s +} + +// SoldTo returns the value of the "sold_to" field in the mutation. +func (m *EntityMutation) SoldTo() (r string, exists bool) { + v := m.sold_to + if v == nil { + return + } + return *v, true +} + +// OldSoldTo returns the old "sold_to" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldSoldTo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSoldTo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSoldTo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSoldTo: %w", err) + } + return oldValue.SoldTo, nil +} + +// ClearSoldTo clears the value of the "sold_to" field. +func (m *EntityMutation) ClearSoldTo() { + m.sold_to = nil + m.clearedFields[entity.FieldSoldTo] = struct{}{} +} + +// SoldToCleared returns if the "sold_to" field was cleared in this mutation. +func (m *EntityMutation) SoldToCleared() bool { + _, ok := m.clearedFields[entity.FieldSoldTo] + return ok +} + +// ResetSoldTo resets all changes to the "sold_to" field. +func (m *EntityMutation) ResetSoldTo() { + m.sold_to = nil + delete(m.clearedFields, entity.FieldSoldTo) +} + +// SetSoldPrice sets the "sold_price" field. +func (m *EntityMutation) SetSoldPrice(f float64) { + m.sold_price = &f + m.addsold_price = nil +} + +// SoldPrice returns the value of the "sold_price" field in the mutation. +func (m *EntityMutation) SoldPrice() (r float64, exists bool) { + v := m.sold_price + if v == nil { + return + } + return *v, true +} + +// OldSoldPrice returns the old "sold_price" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldSoldPrice(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSoldPrice is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSoldPrice requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSoldPrice: %w", err) + } + return oldValue.SoldPrice, nil +} + +// AddSoldPrice adds f to the "sold_price" field. +func (m *EntityMutation) AddSoldPrice(f float64) { + if m.addsold_price != nil { + *m.addsold_price += f + } else { + m.addsold_price = &f + } +} + +// AddedSoldPrice returns the value that was added to the "sold_price" field in this mutation. +func (m *EntityMutation) AddedSoldPrice() (r float64, exists bool) { + v := m.addsold_price + if v == nil { + return + } + return *v, true +} + +// ResetSoldPrice resets all changes to the "sold_price" field. +func (m *EntityMutation) ResetSoldPrice() { + m.sold_price = nil + m.addsold_price = nil +} + +// SetSoldNotes sets the "sold_notes" field. +func (m *EntityMutation) SetSoldNotes(s string) { + m.sold_notes = &s +} + +// SoldNotes returns the value of the "sold_notes" field in the mutation. +func (m *EntityMutation) SoldNotes() (r string, exists bool) { + v := m.sold_notes + if v == nil { + return + } + return *v, true +} + +// OldSoldNotes returns the old "sold_notes" field's value of the Entity entity. +// If the Entity 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 *EntityMutation) OldSoldNotes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSoldNotes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSoldNotes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSoldNotes: %w", err) + } + return oldValue.SoldNotes, nil +} + +// ClearSoldNotes clears the value of the "sold_notes" field. +func (m *EntityMutation) ClearSoldNotes() { + m.sold_notes = nil + m.clearedFields[entity.FieldSoldNotes] = struct{}{} +} + +// SoldNotesCleared returns if the "sold_notes" field was cleared in this mutation. +func (m *EntityMutation) SoldNotesCleared() bool { + _, ok := m.clearedFields[entity.FieldSoldNotes] + return ok +} + +// ResetSoldNotes resets all changes to the "sold_notes" field. +func (m *EntityMutation) ResetSoldNotes() { + m.sold_notes = nil + delete(m.clearedFields, entity.FieldSoldNotes) +} + +// SetGroupID sets the "group" edge to the Group entity by id. +func (m *EntityMutation) SetGroupID(id uuid.UUID) { + m.group = &id +} + +// ClearGroup clears the "group" edge to the Group entity. +func (m *EntityMutation) ClearGroup() { + m.clearedgroup = true +} + +// GroupCleared reports if the "group" edge to the Group entity was cleared. +func (m *EntityMutation) GroupCleared() bool { + return m.clearedgroup +} + +// GroupID returns the "group" edge ID in the mutation. +func (m *EntityMutation) 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 *EntityMutation) 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 *EntityMutation) ResetGroup() { + m.group = nil + m.clearedgroup = false +} + +// AddChildIDs adds the "children" edge to the Entity entity by ids. +func (m *EntityMutation) 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 Entity entity. +func (m *EntityMutation) ClearChildren() { + m.clearedchildren = true +} + +// ChildrenCleared reports if the "children" edge to the Entity entity was cleared. +func (m *EntityMutation) ChildrenCleared() bool { + return m.clearedchildren +} + +// RemoveChildIDs removes the "children" edge to the Entity entity by IDs. +func (m *EntityMutation) 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 Entity entity. +func (m *EntityMutation) 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 *EntityMutation) ChildrenIDs() (ids []uuid.UUID) { + for id := range m.children { + ids = append(ids, id) + } + return +} + +// ResetChildren resets all changes to the "children" edge. +func (m *EntityMutation) ResetChildren() { + m.children = nil + m.clearedchildren = false + m.removedchildren = nil +} + +// SetParentID sets the "parent" edge to the Entity entity by id. +func (m *EntityMutation) SetParentID(id uuid.UUID) { + m.parent = &id +} + +// ClearParent clears the "parent" edge to the Entity entity. +func (m *EntityMutation) ClearParent() { + m.clearedparent = true +} + +// ParentCleared reports if the "parent" edge to the Entity entity was cleared. +func (m *EntityMutation) ParentCleared() bool { + return m.clearedparent +} + +// ParentID returns the "parent" edge ID in the mutation. +func (m *EntityMutation) 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 *EntityMutation) 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 *EntityMutation) ResetParent() { + m.parent = nil + m.clearedparent = false +} + +// AddEntityIDs adds the "entity" edge to the Entity entity by ids. +func (m *EntityMutation) AddEntityIDs(ids ...uuid.UUID) { + if m.entity == nil { + m.entity = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.entity[ids[i]] = struct{}{} + } +} + +// ClearEntity clears the "entity" edge to the Entity entity. +func (m *EntityMutation) ClearEntity() { + m.clearedentity = true +} + +// EntityCleared reports if the "entity" edge to the Entity entity was cleared. +func (m *EntityMutation) EntityCleared() bool { + return m.clearedentity +} + +// RemoveEntityIDs removes the "entity" edge to the Entity entity by IDs. +func (m *EntityMutation) RemoveEntityIDs(ids ...uuid.UUID) { + if m.removedentity == nil { + m.removedentity = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.entity, ids[i]) + m.removedentity[ids[i]] = struct{}{} + } +} + +// RemovedEntity returns the removed IDs of the "entity" edge to the Entity entity. +func (m *EntityMutation) RemovedEntityIDs() (ids []uuid.UUID) { + for id := range m.removedentity { + ids = append(ids, id) + } + return +} + +// EntityIDs returns the "entity" edge IDs in the mutation. +func (m *EntityMutation) EntityIDs() (ids []uuid.UUID) { + for id := range m.entity { + ids = append(ids, id) + } + return +} + +// ResetEntity resets all changes to the "entity" edge. +func (m *EntityMutation) ResetEntity() { + m.entity = nil + m.clearedentity = false + m.removedentity = nil +} + +// SetLocationID sets the "location" edge to the Entity entity by id. +func (m *EntityMutation) SetLocationID(id uuid.UUID) { + m.location = &id +} + +// ClearLocation clears the "location" edge to the Entity entity. +func (m *EntityMutation) ClearLocation() { + m.clearedlocation = true +} + +// LocationCleared reports if the "location" edge to the Entity entity was cleared. +func (m *EntityMutation) LocationCleared() bool { + return m.clearedlocation +} + +// LocationID returns the "location" edge ID in the mutation. +func (m *EntityMutation) 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 *EntityMutation) 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 *EntityMutation) ResetLocation() { + m.location = nil + m.clearedlocation = false +} + +// AddLabelIDs adds the "label" edge to the Label entity by ids. +func (m *EntityMutation) AddLabelIDs(ids ...uuid.UUID) { + if m.label == nil { + m.label = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.label[ids[i]] = struct{}{} + } +} + +// ClearLabel clears the "label" edge to the Label entity. +func (m *EntityMutation) ClearLabel() { + m.clearedlabel = true +} + +// LabelCleared reports if the "label" edge to the Label entity was cleared. +func (m *EntityMutation) LabelCleared() bool { + return m.clearedlabel +} + +// RemoveLabelIDs removes the "label" edge to the Label entity by IDs. +func (m *EntityMutation) RemoveLabelIDs(ids ...uuid.UUID) { + if m.removedlabel == nil { + m.removedlabel = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.label, ids[i]) + m.removedlabel[ids[i]] = struct{}{} + } +} + +// RemovedLabel returns the removed IDs of the "label" edge to the Label entity. +func (m *EntityMutation) RemovedLabelIDs() (ids []uuid.UUID) { + for id := range m.removedlabel { + ids = append(ids, id) + } + return +} + +// LabelIDs returns the "label" edge IDs in the mutation. +func (m *EntityMutation) LabelIDs() (ids []uuid.UUID) { + for id := range m.label { + ids = append(ids, id) + } + return +} + +// ResetLabel resets all changes to the "label" edge. +func (m *EntityMutation) ResetLabel() { + m.label = nil + m.clearedlabel = false + m.removedlabel = nil +} + +// SetTypeID sets the "type" edge to the EntityType entity by id. +func (m *EntityMutation) SetTypeID(id uuid.UUID) { + m._type = &id +} + +// ClearType clears the "type" edge to the EntityType entity. +func (m *EntityMutation) ClearType() { + m.cleared_type = true +} + +// TypeCleared reports if the "type" edge to the EntityType entity was cleared. +func (m *EntityMutation) TypeCleared() bool { + return m.cleared_type +} + +// TypeID returns the "type" edge ID in the mutation. +func (m *EntityMutation) TypeID() (id uuid.UUID, exists bool) { + if m._type != nil { + return *m._type, true + } + return +} + +// TypeIDs returns the "type" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TypeID instead. It exists only for internal usage by the builders. +func (m *EntityMutation) TypeIDs() (ids []uuid.UUID) { + if id := m._type; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetType resets all changes to the "type" edge. +func (m *EntityMutation) ResetType() { + m._type = nil + m.cleared_type = false +} + +// AddFieldIDs adds the "fields" edge to the EntityField entity by ids. +func (m *EntityMutation) 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 EntityField entity. +func (m *EntityMutation) ClearFields() { + m.clearedfields = true +} + +// FieldsCleared reports if the "fields" edge to the EntityField entity was cleared. +func (m *EntityMutation) FieldsCleared() bool { + return m.clearedfields +} + +// RemoveFieldIDs removes the "fields" edge to the EntityField entity by IDs. +func (m *EntityMutation) 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 EntityField entity. +func (m *EntityMutation) 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 *EntityMutation) FieldsIDs() (ids []uuid.UUID) { + for id := range m.fields { + ids = append(ids, id) + } + return +} + +// ResetFields resets all changes to the "fields" edge. +func (m *EntityMutation) ResetFields() { + m.fields = nil + m.clearedfields = false + m.removedfields = nil +} + +// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by ids. +func (m *EntityMutation) AddMaintenanceEntryIDs(ids ...uuid.UUID) { + if m.maintenance_entries == nil { + m.maintenance_entries = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.maintenance_entries[ids[i]] = struct{}{} + } +} + +// ClearMaintenanceEntries clears the "maintenance_entries" edge to the MaintenanceEntry entity. +func (m *EntityMutation) ClearMaintenanceEntries() { + m.clearedmaintenance_entries = true +} + +// MaintenanceEntriesCleared reports if the "maintenance_entries" edge to the MaintenanceEntry entity was cleared. +func (m *EntityMutation) MaintenanceEntriesCleared() bool { + return m.clearedmaintenance_entries +} + +// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to the MaintenanceEntry entity by IDs. +func (m *EntityMutation) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) { + if m.removedmaintenance_entries == nil { + m.removedmaintenance_entries = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.maintenance_entries, ids[i]) + m.removedmaintenance_entries[ids[i]] = struct{}{} + } +} + +// RemovedMaintenanceEntries returns the removed IDs of the "maintenance_entries" edge to the MaintenanceEntry entity. +func (m *EntityMutation) RemovedMaintenanceEntriesIDs() (ids []uuid.UUID) { + for id := range m.removedmaintenance_entries { + ids = append(ids, id) + } + return +} + +// MaintenanceEntriesIDs returns the "maintenance_entries" edge IDs in the mutation. +func (m *EntityMutation) MaintenanceEntriesIDs() (ids []uuid.UUID) { + for id := range m.maintenance_entries { + ids = append(ids, id) + } + return +} + +// ResetMaintenanceEntries resets all changes to the "maintenance_entries" edge. +func (m *EntityMutation) ResetMaintenanceEntries() { + m.maintenance_entries = nil + m.clearedmaintenance_entries = false + m.removedmaintenance_entries = nil +} + +// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by ids. +func (m *EntityMutation) AddAttachmentIDs(ids ...uuid.UUID) { + if m.attachments == nil { + m.attachments = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.attachments[ids[i]] = struct{}{} + } +} + +// ClearAttachments clears the "attachments" edge to the Attachment entity. +func (m *EntityMutation) ClearAttachments() { + m.clearedattachments = true +} + +// AttachmentsCleared reports if the "attachments" edge to the Attachment entity was cleared. +func (m *EntityMutation) AttachmentsCleared() bool { + return m.clearedattachments +} + +// RemoveAttachmentIDs removes the "attachments" edge to the Attachment entity by IDs. +func (m *EntityMutation) RemoveAttachmentIDs(ids ...uuid.UUID) { + if m.removedattachments == nil { + m.removedattachments = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.attachments, ids[i]) + m.removedattachments[ids[i]] = struct{}{} + } +} + +// RemovedAttachments returns the removed IDs of the "attachments" edge to the Attachment entity. +func (m *EntityMutation) RemovedAttachmentsIDs() (ids []uuid.UUID) { + for id := range m.removedattachments { + ids = append(ids, id) + } + return +} + +// AttachmentsIDs returns the "attachments" edge IDs in the mutation. +func (m *EntityMutation) AttachmentsIDs() (ids []uuid.UUID) { + for id := range m.attachments { + ids = append(ids, id) + } + return +} + +// ResetAttachments resets all changes to the "attachments" edge. +func (m *EntityMutation) ResetAttachments() { + m.attachments = nil + m.clearedattachments = false + m.removedattachments = nil +} + +// Where appends a list predicates to the EntityMutation builder. +func (m *EntityMutation) Where(ps ...predicate.Entity) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EntityMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EntityMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Entity, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EntityMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EntityMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Entity). +func (m *EntityMutation) 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 *EntityMutation) Fields() []string { + fields := make([]string, 0, 24) + if m.created_at != nil { + fields = append(fields, entity.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, entity.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, entity.FieldName) + } + if m.description != nil { + fields = append(fields, entity.FieldDescription) + } + if m.import_ref != nil { + fields = append(fields, entity.FieldImportRef) + } + if m.notes != nil { + fields = append(fields, entity.FieldNotes) + } + if m.quantity != nil { + fields = append(fields, entity.FieldQuantity) + } + if m.insured != nil { + fields = append(fields, entity.FieldInsured) + } + if m.archived != nil { + fields = append(fields, entity.FieldArchived) + } + if m.asset_id != nil { + fields = append(fields, entity.FieldAssetID) + } + if m.sync_child_entities_locations != nil { + fields = append(fields, entity.FieldSyncChildEntitiesLocations) + } + if m.serial_number != nil { + fields = append(fields, entity.FieldSerialNumber) + } + if m.model_number != nil { + fields = append(fields, entity.FieldModelNumber) + } + if m.manufacturer != nil { + fields = append(fields, entity.FieldManufacturer) + } + if m.lifetime_warranty != nil { + fields = append(fields, entity.FieldLifetimeWarranty) + } + if m.warranty_expires != nil { + fields = append(fields, entity.FieldWarrantyExpires) + } + if m.warranty_details != nil { + fields = append(fields, entity.FieldWarrantyDetails) + } + if m.purchase_time != nil { + fields = append(fields, entity.FieldPurchaseTime) + } + if m.purchase_from != nil { + fields = append(fields, entity.FieldPurchaseFrom) + } + if m.purchase_price != nil { + fields = append(fields, entity.FieldPurchasePrice) + } + if m.sold_time != nil { + fields = append(fields, entity.FieldSoldTime) + } + if m.sold_to != nil { + fields = append(fields, entity.FieldSoldTo) + } + if m.sold_price != nil { + fields = append(fields, entity.FieldSoldPrice) + } + if m.sold_notes != nil { + fields = append(fields, entity.FieldSoldNotes) + } + 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 *EntityMutation) Field(name string) (ent.Value, bool) { + switch name { + case entity.FieldCreatedAt: + return m.CreatedAt() + case entity.FieldUpdatedAt: + return m.UpdatedAt() + case entity.FieldName: + return m.Name() + case entity.FieldDescription: + return m.Description() + case entity.FieldImportRef: + return m.ImportRef() + case entity.FieldNotes: + return m.Notes() + case entity.FieldQuantity: + return m.Quantity() + case entity.FieldInsured: + return m.Insured() + case entity.FieldArchived: + return m.Archived() + case entity.FieldAssetID: + return m.AssetID() + case entity.FieldSyncChildEntitiesLocations: + return m.SyncChildEntitiesLocations() + case entity.FieldSerialNumber: + return m.SerialNumber() + case entity.FieldModelNumber: + return m.ModelNumber() + case entity.FieldManufacturer: + return m.Manufacturer() + case entity.FieldLifetimeWarranty: + return m.LifetimeWarranty() + case entity.FieldWarrantyExpires: + return m.WarrantyExpires() + case entity.FieldWarrantyDetails: + return m.WarrantyDetails() + case entity.FieldPurchaseTime: + return m.PurchaseTime() + case entity.FieldPurchaseFrom: + return m.PurchaseFrom() + case entity.FieldPurchasePrice: + return m.PurchasePrice() + case entity.FieldSoldTime: + return m.SoldTime() + case entity.FieldSoldTo: + return m.SoldTo() + case entity.FieldSoldPrice: + return m.SoldPrice() + case entity.FieldSoldNotes: + return m.SoldNotes() + } + 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 *EntityMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case entity.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case entity.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case entity.FieldName: + return m.OldName(ctx) + case entity.FieldDescription: + return m.OldDescription(ctx) + case entity.FieldImportRef: + return m.OldImportRef(ctx) + case entity.FieldNotes: + return m.OldNotes(ctx) + case entity.FieldQuantity: + return m.OldQuantity(ctx) + case entity.FieldInsured: + return m.OldInsured(ctx) + case entity.FieldArchived: + return m.OldArchived(ctx) + case entity.FieldAssetID: + return m.OldAssetID(ctx) + case entity.FieldSyncChildEntitiesLocations: + return m.OldSyncChildEntitiesLocations(ctx) + case entity.FieldSerialNumber: + return m.OldSerialNumber(ctx) + case entity.FieldModelNumber: + return m.OldModelNumber(ctx) + case entity.FieldManufacturer: + return m.OldManufacturer(ctx) + case entity.FieldLifetimeWarranty: + return m.OldLifetimeWarranty(ctx) + case entity.FieldWarrantyExpires: + return m.OldWarrantyExpires(ctx) + case entity.FieldWarrantyDetails: + return m.OldWarrantyDetails(ctx) + case entity.FieldPurchaseTime: + return m.OldPurchaseTime(ctx) + case entity.FieldPurchaseFrom: + return m.OldPurchaseFrom(ctx) + case entity.FieldPurchasePrice: + return m.OldPurchasePrice(ctx) + case entity.FieldSoldTime: + return m.OldSoldTime(ctx) + case entity.FieldSoldTo: + return m.OldSoldTo(ctx) + case entity.FieldSoldPrice: + return m.OldSoldPrice(ctx) + case entity.FieldSoldNotes: + return m.OldSoldNotes(ctx) + } + return nil, fmt.Errorf("unknown Entity 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 *EntityMutation) SetField(name string, value ent.Value) error { + switch name { + case entity.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 entity.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 entity.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case entity.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case entity.FieldImportRef: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetImportRef(v) + return nil + case entity.FieldNotes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotes(v) + return nil + case entity.FieldQuantity: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetQuantity(v) + return nil + case entity.FieldInsured: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInsured(v) + return nil + case entity.FieldArchived: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArchived(v) + return nil + case entity.FieldAssetID: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAssetID(v) + return nil + case entity.FieldSyncChildEntitiesLocations: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSyncChildEntitiesLocations(v) + return nil + case entity.FieldSerialNumber: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSerialNumber(v) + return nil + case entity.FieldModelNumber: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModelNumber(v) + return nil + case entity.FieldManufacturer: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetManufacturer(v) + return nil + case entity.FieldLifetimeWarranty: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLifetimeWarranty(v) + return nil + case entity.FieldWarrantyExpires: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWarrantyExpires(v) + return nil + case entity.FieldWarrantyDetails: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWarrantyDetails(v) + return nil + case entity.FieldPurchaseTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPurchaseTime(v) + return nil + case entity.FieldPurchaseFrom: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPurchaseFrom(v) + return nil + case entity.FieldPurchasePrice: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPurchasePrice(v) + return nil + case entity.FieldSoldTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSoldTime(v) + return nil + case entity.FieldSoldTo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSoldTo(v) + return nil + case entity.FieldSoldPrice: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSoldPrice(v) + return nil + case entity.FieldSoldNotes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSoldNotes(v) + return nil + } + return fmt.Errorf("unknown Entity field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EntityMutation) AddedFields() []string { + var fields []string + if m.addquantity != nil { + fields = append(fields, entity.FieldQuantity) + } + if m.addasset_id != nil { + fields = append(fields, entity.FieldAssetID) + } + if m.addpurchase_price != nil { + fields = append(fields, entity.FieldPurchasePrice) + } + if m.addsold_price != nil { + fields = append(fields, entity.FieldSoldPrice) + } + 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 *EntityMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case entity.FieldQuantity: + return m.AddedQuantity() + case entity.FieldAssetID: + return m.AddedAssetID() + case entity.FieldPurchasePrice: + return m.AddedPurchasePrice() + case entity.FieldSoldPrice: + return m.AddedSoldPrice() + } + 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 *EntityMutation) AddField(name string, value ent.Value) error { + switch name { + case entity.FieldQuantity: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddQuantity(v) + return nil + case entity.FieldAssetID: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddAssetID(v) + return nil + case entity.FieldPurchasePrice: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPurchasePrice(v) + return nil + case entity.FieldSoldPrice: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSoldPrice(v) + return nil + } + return fmt.Errorf("unknown Entity numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EntityMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(entity.FieldDescription) { + fields = append(fields, entity.FieldDescription) + } + if m.FieldCleared(entity.FieldImportRef) { + fields = append(fields, entity.FieldImportRef) + } + if m.FieldCleared(entity.FieldNotes) { + fields = append(fields, entity.FieldNotes) + } + if m.FieldCleared(entity.FieldSerialNumber) { + fields = append(fields, entity.FieldSerialNumber) + } + if m.FieldCleared(entity.FieldModelNumber) { + fields = append(fields, entity.FieldModelNumber) + } + if m.FieldCleared(entity.FieldManufacturer) { + fields = append(fields, entity.FieldManufacturer) + } + if m.FieldCleared(entity.FieldWarrantyExpires) { + fields = append(fields, entity.FieldWarrantyExpires) + } + if m.FieldCleared(entity.FieldWarrantyDetails) { + fields = append(fields, entity.FieldWarrantyDetails) + } + if m.FieldCleared(entity.FieldPurchaseTime) { + fields = append(fields, entity.FieldPurchaseTime) + } + if m.FieldCleared(entity.FieldPurchaseFrom) { + fields = append(fields, entity.FieldPurchaseFrom) + } + if m.FieldCleared(entity.FieldSoldTime) { + fields = append(fields, entity.FieldSoldTime) + } + if m.FieldCleared(entity.FieldSoldTo) { + fields = append(fields, entity.FieldSoldTo) + } + if m.FieldCleared(entity.FieldSoldNotes) { + fields = append(fields, entity.FieldSoldNotes) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EntityMutation) 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 *EntityMutation) ClearField(name string) error { + switch name { + case entity.FieldDescription: + m.ClearDescription() + return nil + case entity.FieldImportRef: + m.ClearImportRef() + return nil + case entity.FieldNotes: + m.ClearNotes() + return nil + case entity.FieldSerialNumber: + m.ClearSerialNumber() + return nil + case entity.FieldModelNumber: + m.ClearModelNumber() + return nil + case entity.FieldManufacturer: + m.ClearManufacturer() + return nil + case entity.FieldWarrantyExpires: + m.ClearWarrantyExpires() + return nil + case entity.FieldWarrantyDetails: + m.ClearWarrantyDetails() + return nil + case entity.FieldPurchaseTime: + m.ClearPurchaseTime() + return nil + case entity.FieldPurchaseFrom: + m.ClearPurchaseFrom() + return nil + case entity.FieldSoldTime: + m.ClearSoldTime() + return nil + case entity.FieldSoldTo: + m.ClearSoldTo() + return nil + case entity.FieldSoldNotes: + m.ClearSoldNotes() + return nil + } + return fmt.Errorf("unknown Entity 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 *EntityMutation) ResetField(name string) error { + switch name { + case entity.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case entity.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case entity.FieldName: + m.ResetName() + return nil + case entity.FieldDescription: + m.ResetDescription() + return nil + case entity.FieldImportRef: + m.ResetImportRef() + return nil + case entity.FieldNotes: + m.ResetNotes() + return nil + case entity.FieldQuantity: + m.ResetQuantity() + return nil + case entity.FieldInsured: + m.ResetInsured() + return nil + case entity.FieldArchived: + m.ResetArchived() + return nil + case entity.FieldAssetID: + m.ResetAssetID() + return nil + case entity.FieldSyncChildEntitiesLocations: + m.ResetSyncChildEntitiesLocations() + return nil + case entity.FieldSerialNumber: + m.ResetSerialNumber() + return nil + case entity.FieldModelNumber: + m.ResetModelNumber() + return nil + case entity.FieldManufacturer: + m.ResetManufacturer() + return nil + case entity.FieldLifetimeWarranty: + m.ResetLifetimeWarranty() + return nil + case entity.FieldWarrantyExpires: + m.ResetWarrantyExpires() + return nil + case entity.FieldWarrantyDetails: + m.ResetWarrantyDetails() + return nil + case entity.FieldPurchaseTime: + m.ResetPurchaseTime() + return nil + case entity.FieldPurchaseFrom: + m.ResetPurchaseFrom() + return nil + case entity.FieldPurchasePrice: + m.ResetPurchasePrice() + return nil + case entity.FieldSoldTime: + m.ResetSoldTime() + return nil + case entity.FieldSoldTo: + m.ResetSoldTo() + return nil + case entity.FieldSoldPrice: + m.ResetSoldPrice() + return nil + case entity.FieldSoldNotes: + m.ResetSoldNotes() + return nil + } + return fmt.Errorf("unknown Entity field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EntityMutation) AddedEdges() []string { + edges := make([]string, 0, 10) + if m.group != nil { + edges = append(edges, entity.EdgeGroup) + } + if m.children != nil { + edges = append(edges, entity.EdgeChildren) + } + if m.parent != nil { + edges = append(edges, entity.EdgeParent) + } + if m.entity != nil { + edges = append(edges, entity.EdgeEntity) + } + if m.location != nil { + edges = append(edges, entity.EdgeLocation) + } + if m.label != nil { + edges = append(edges, entity.EdgeLabel) + } + if m._type != nil { + edges = append(edges, entity.EdgeType) + } + if m.fields != nil { + edges = append(edges, entity.EdgeFields) + } + if m.maintenance_entries != nil { + edges = append(edges, entity.EdgeMaintenanceEntries) + } + if m.attachments != nil { + edges = append(edges, entity.EdgeAttachments) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EntityMutation) AddedIDs(name string) []ent.Value { + switch name { + case entity.EdgeGroup: + if id := m.group; id != nil { + return []ent.Value{*id} + } + case entity.EdgeChildren: + ids := make([]ent.Value, 0, len(m.children)) + for id := range m.children { + ids = append(ids, id) + } + return ids + case entity.EdgeParent: + if id := m.parent; id != nil { + return []ent.Value{*id} + } + case entity.EdgeEntity: + ids := make([]ent.Value, 0, len(m.entity)) + for id := range m.entity { + ids = append(ids, id) + } + return ids + case entity.EdgeLocation: + if id := m.location; id != nil { + return []ent.Value{*id} + } + case entity.EdgeLabel: + ids := make([]ent.Value, 0, len(m.label)) + for id := range m.label { + ids = append(ids, id) + } + return ids + case entity.EdgeType: + if id := m._type; id != nil { + return []ent.Value{*id} + } + case entity.EdgeFields: + ids := make([]ent.Value, 0, len(m.fields)) + for id := range m.fields { + ids = append(ids, id) + } + return ids + case entity.EdgeMaintenanceEntries: + ids := make([]ent.Value, 0, len(m.maintenance_entries)) + for id := range m.maintenance_entries { + ids = append(ids, id) + } + return ids + case entity.EdgeAttachments: + ids := make([]ent.Value, 0, len(m.attachments)) + for id := range m.attachments { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EntityMutation) RemovedEdges() []string { + edges := make([]string, 0, 10) + if m.removedchildren != nil { + edges = append(edges, entity.EdgeChildren) + } + if m.removedentity != nil { + edges = append(edges, entity.EdgeEntity) + } + if m.removedlabel != nil { + edges = append(edges, entity.EdgeLabel) + } + if m.removedfields != nil { + edges = append(edges, entity.EdgeFields) + } + if m.removedmaintenance_entries != nil { + edges = append(edges, entity.EdgeMaintenanceEntries) + } + if m.removedattachments != nil { + edges = append(edges, entity.EdgeAttachments) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EntityMutation) RemovedIDs(name string) []ent.Value { + switch name { + case entity.EdgeChildren: + ids := make([]ent.Value, 0, len(m.removedchildren)) + for id := range m.removedchildren { + ids = append(ids, id) + } + return ids + case entity.EdgeEntity: + ids := make([]ent.Value, 0, len(m.removedentity)) + for id := range m.removedentity { + ids = append(ids, id) + } + return ids + case entity.EdgeLabel: + ids := make([]ent.Value, 0, len(m.removedlabel)) + for id := range m.removedlabel { + ids = append(ids, id) + } + return ids + case entity.EdgeFields: + ids := make([]ent.Value, 0, len(m.removedfields)) + for id := range m.removedfields { + ids = append(ids, id) + } + return ids + case entity.EdgeMaintenanceEntries: + ids := make([]ent.Value, 0, len(m.removedmaintenance_entries)) + for id := range m.removedmaintenance_entries { + ids = append(ids, id) + } + return ids + case entity.EdgeAttachments: + ids := make([]ent.Value, 0, len(m.removedattachments)) + for id := range m.removedattachments { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EntityMutation) ClearedEdges() []string { + edges := make([]string, 0, 10) + if m.clearedgroup { + edges = append(edges, entity.EdgeGroup) + } + if m.clearedchildren { + edges = append(edges, entity.EdgeChildren) + } + if m.clearedparent { + edges = append(edges, entity.EdgeParent) + } + if m.clearedentity { + edges = append(edges, entity.EdgeEntity) + } + if m.clearedlocation { + edges = append(edges, entity.EdgeLocation) + } + if m.clearedlabel { + edges = append(edges, entity.EdgeLabel) + } + if m.cleared_type { + edges = append(edges, entity.EdgeType) + } + if m.clearedfields { + edges = append(edges, entity.EdgeFields) + } + if m.clearedmaintenance_entries { + edges = append(edges, entity.EdgeMaintenanceEntries) + } + if m.clearedattachments { + edges = append(edges, entity.EdgeAttachments) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EntityMutation) EdgeCleared(name string) bool { + switch name { + case entity.EdgeGroup: + return m.clearedgroup + case entity.EdgeChildren: + return m.clearedchildren + case entity.EdgeParent: + return m.clearedparent + case entity.EdgeEntity: + return m.clearedentity + case entity.EdgeLocation: + return m.clearedlocation + case entity.EdgeLabel: + return m.clearedlabel + case entity.EdgeType: + return m.cleared_type + case entity.EdgeFields: + return m.clearedfields + case entity.EdgeMaintenanceEntries: + return m.clearedmaintenance_entries + case entity.EdgeAttachments: + return m.clearedattachments + } + 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 *EntityMutation) ClearEdge(name string) error { + switch name { + case entity.EdgeGroup: + m.ClearGroup() + return nil + case entity.EdgeParent: + m.ClearParent() + return nil + case entity.EdgeLocation: + m.ClearLocation() + return nil + case entity.EdgeType: + m.ClearType() + return nil + } + return fmt.Errorf("unknown Entity 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 *EntityMutation) ResetEdge(name string) error { + switch name { + case entity.EdgeGroup: + m.ResetGroup() + return nil + case entity.EdgeChildren: + m.ResetChildren() + return nil + case entity.EdgeParent: + m.ResetParent() + return nil + case entity.EdgeEntity: + m.ResetEntity() + return nil + case entity.EdgeLocation: + m.ResetLocation() + return nil + case entity.EdgeLabel: + m.ResetLabel() + return nil + case entity.EdgeType: + m.ResetType() + return nil + case entity.EdgeFields: + m.ResetFields() + return nil + case entity.EdgeMaintenanceEntries: + m.ResetMaintenanceEntries() + return nil + case entity.EdgeAttachments: + m.ResetAttachments() + return nil + } + return fmt.Errorf("unknown Entity edge %s", name) +} + +// EntityFieldMutation represents an operation that mutates the EntityField nodes in the graph. +type EntityFieldMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + updated_at *time.Time + name *string + description *string + _type *entityfield.Type + text_value *string + number_value *int + addnumber_value *int + boolean_value *bool + time_value *time.Time + clearedFields map[string]struct{} + entity *uuid.UUID + clearedentity bool + done bool + oldValue func(context.Context) (*EntityField, error) + predicates []predicate.EntityField +} + +var _ ent.Mutation = (*EntityFieldMutation)(nil) + +// entityfieldOption allows management of the mutation configuration using functional options. +type entityfieldOption func(*EntityFieldMutation) + +// newEntityFieldMutation creates new mutation for the EntityField entity. +func newEntityFieldMutation(c config, op Op, opts ...entityfieldOption) *EntityFieldMutation { + m := &EntityFieldMutation{ + config: c, + op: op, + typ: TypeEntityField, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEntityFieldID sets the ID field of the mutation. +func withEntityFieldID(id uuid.UUID) entityfieldOption { + return func(m *EntityFieldMutation) { + var ( + err error + once sync.Once + value *EntityField + ) + m.oldValue = func(ctx context.Context) (*EntityField, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EntityField.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEntityField sets the old EntityField of the mutation. +func withEntityField(node *EntityField) entityfieldOption { + return func(m *EntityFieldMutation) { + m.oldValue = func(context.Context) (*EntityField, 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 EntityFieldMutation) 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 EntityFieldMutation) 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 EntityField entities. +func (m *EntityFieldMutation) 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 *EntityFieldMutation) 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 *EntityFieldMutation) 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().EntityField.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 *EntityFieldMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *EntityFieldMutation) 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 EntityField entity. +// If the EntityField 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 *EntityFieldMutation) 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 *EntityFieldMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *EntityFieldMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *EntityFieldMutation) 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 EntityField entity. +// If the EntityField 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 *EntityFieldMutation) 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 *EntityFieldMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *EntityFieldMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *EntityFieldMutation) 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 EntityField entity. +// If the EntityField 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 *EntityFieldMutation) 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 *EntityFieldMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *EntityFieldMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *EntityFieldMutation) 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 EntityField entity. +// If the EntityField 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 *EntityFieldMutation) 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 *EntityFieldMutation) ClearDescription() { + m.description = nil + m.clearedFields[entityfield.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *EntityFieldMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[entityfield.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *EntityFieldMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, entityfield.FieldDescription) +} + +// SetType sets the "type" field. +func (m *EntityFieldMutation) SetType(e entityfield.Type) { + m._type = &e +} + +// GetType returns the value of the "type" field in the mutation. +func (m *EntityFieldMutation) GetType() (r entityfield.Type, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the EntityField entity. +// If the EntityField 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 *EntityFieldMutation) OldType(ctx context.Context) (v entityfield.Type, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + 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 OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *EntityFieldMutation) ResetType() { + m._type = nil +} + +// SetTextValue sets the "text_value" field. +func (m *EntityFieldMutation) SetTextValue(s string) { + m.text_value = &s +} + +// TextValue returns the value of the "text_value" field in the mutation. +func (m *EntityFieldMutation) TextValue() (r string, exists bool) { + v := m.text_value + if v == nil { + return + } + return *v, true +} + +// OldTextValue returns the old "text_value" field's value of the EntityField entity. +// If the EntityField 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 *EntityFieldMutation) OldTextValue(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTextValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + 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 OldTextValue: %w", err) + } + return oldValue.TextValue, nil +} + +// ClearTextValue clears the value of the "text_value" field. +func (m *EntityFieldMutation) ClearTextValue() { + m.text_value = nil + m.clearedFields[entityfield.FieldTextValue] = struct{}{} +} + +// TextValueCleared returns if the "text_value" field was cleared in this mutation. +func (m *EntityFieldMutation) TextValueCleared() bool { + _, ok := m.clearedFields[entityfield.FieldTextValue] + return ok +} + +// ResetTextValue resets all changes to the "text_value" field. +func (m *EntityFieldMutation) ResetTextValue() { + m.text_value = nil + delete(m.clearedFields, entityfield.FieldTextValue) +} + +// SetNumberValue sets the "number_value" field. +func (m *EntityFieldMutation) SetNumberValue(i int) { + m.number_value = &i + m.addnumber_value = nil +} + +// NumberValue returns the value of the "number_value" field in the mutation. +func (m *EntityFieldMutation) NumberValue() (r int, exists bool) { + v := m.number_value + if v == nil { + return + } + return *v, true +} + +// OldNumberValue returns the old "number_value" field's value of the EntityField entity. +// If the EntityField 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 *EntityFieldMutation) OldNumberValue(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNumberValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNumberValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNumberValue: %w", err) + } + return oldValue.NumberValue, nil +} + +// AddNumberValue adds i to the "number_value" field. +func (m *EntityFieldMutation) AddNumberValue(i int) { + if m.addnumber_value != nil { + *m.addnumber_value += i + } else { + m.addnumber_value = &i + } +} + +// AddedNumberValue returns the value that was added to the "number_value" field in this mutation. +func (m *EntityFieldMutation) AddedNumberValue() (r int, exists bool) { + v := m.addnumber_value + if v == nil { + return + } + return *v, true +} + +// ClearNumberValue clears the value of the "number_value" field. +func (m *EntityFieldMutation) ClearNumberValue() { + m.number_value = nil + m.addnumber_value = nil + m.clearedFields[entityfield.FieldNumberValue] = struct{}{} +} + +// NumberValueCleared returns if the "number_value" field was cleared in this mutation. +func (m *EntityFieldMutation) NumberValueCleared() bool { + _, ok := m.clearedFields[entityfield.FieldNumberValue] + return ok +} + +// ResetNumberValue resets all changes to the "number_value" field. +func (m *EntityFieldMutation) ResetNumberValue() { + m.number_value = nil + m.addnumber_value = nil + delete(m.clearedFields, entityfield.FieldNumberValue) +} + +// SetBooleanValue sets the "boolean_value" field. +func (m *EntityFieldMutation) SetBooleanValue(b bool) { + m.boolean_value = &b +} + +// BooleanValue returns the value of the "boolean_value" field in the mutation. +func (m *EntityFieldMutation) BooleanValue() (r bool, exists bool) { + v := m.boolean_value + if v == nil { + return + } + return *v, true +} + +// OldBooleanValue returns the old "boolean_value" field's value of the EntityField entity. +// If the EntityField 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 *EntityFieldMutation) OldBooleanValue(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBooleanValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBooleanValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBooleanValue: %w", err) + } + return oldValue.BooleanValue, nil +} + +// ResetBooleanValue resets all changes to the "boolean_value" field. +func (m *EntityFieldMutation) ResetBooleanValue() { + m.boolean_value = nil +} + +// SetTimeValue sets the "time_value" field. +func (m *EntityFieldMutation) SetTimeValue(t time.Time) { + m.time_value = &t +} + +// TimeValue returns the value of the "time_value" field in the mutation. +func (m *EntityFieldMutation) TimeValue() (r time.Time, exists bool) { + v := m.time_value + if v == nil { + return + } + return *v, true +} + +// OldTimeValue returns the old "time_value" field's value of the EntityField entity. +// If the EntityField 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 *EntityFieldMutation) OldTimeValue(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTimeValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTimeValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTimeValue: %w", err) + } + return oldValue.TimeValue, nil +} + +// ResetTimeValue resets all changes to the "time_value" field. +func (m *EntityFieldMutation) ResetTimeValue() { + m.time_value = nil +} + +// SetEntityID sets the "entity" edge to the Entity entity by id. +func (m *EntityFieldMutation) SetEntityID(id uuid.UUID) { + m.entity = &id +} + +// ClearEntity clears the "entity" edge to the Entity entity. +func (m *EntityFieldMutation) ClearEntity() { + m.clearedentity = true +} + +// EntityCleared reports if the "entity" edge to the Entity entity was cleared. +func (m *EntityFieldMutation) EntityCleared() bool { + return m.clearedentity +} + +// EntityID returns the "entity" edge ID in the mutation. +func (m *EntityFieldMutation) EntityID() (id uuid.UUID, exists bool) { + if m.entity != nil { + return *m.entity, true + } + return +} + +// EntityIDs returns the "entity" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// EntityID instead. It exists only for internal usage by the builders. +func (m *EntityFieldMutation) EntityIDs() (ids []uuid.UUID) { + if id := m.entity; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetEntity resets all changes to the "entity" edge. +func (m *EntityFieldMutation) ResetEntity() { + m.entity = nil + m.clearedentity = false +} + +// Where appends a list predicates to the EntityFieldMutation builder. +func (m *EntityFieldMutation) Where(ps ...predicate.EntityField) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EntityFieldMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EntityFieldMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EntityField, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EntityFieldMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EntityFieldMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EntityField). +func (m *EntityFieldMutation) 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 *EntityFieldMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.created_at != nil { + fields = append(fields, entityfield.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, entityfield.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, entityfield.FieldName) + } + if m.description != nil { + fields = append(fields, entityfield.FieldDescription) + } + if m._type != nil { + fields = append(fields, entityfield.FieldType) + } + if m.text_value != nil { + fields = append(fields, entityfield.FieldTextValue) + } + if m.number_value != nil { + fields = append(fields, entityfield.FieldNumberValue) + } + if m.boolean_value != nil { + fields = append(fields, entityfield.FieldBooleanValue) + } + if m.time_value != nil { + fields = append(fields, entityfield.FieldTimeValue) + } + 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 *EntityFieldMutation) Field(name string) (ent.Value, bool) { + switch name { + case entityfield.FieldCreatedAt: + return m.CreatedAt() + case entityfield.FieldUpdatedAt: + return m.UpdatedAt() + case entityfield.FieldName: + return m.Name() + case entityfield.FieldDescription: + return m.Description() + case entityfield.FieldType: + return m.GetType() + case entityfield.FieldTextValue: + return m.TextValue() + case entityfield.FieldNumberValue: + return m.NumberValue() + case entityfield.FieldBooleanValue: + return m.BooleanValue() + case entityfield.FieldTimeValue: + return m.TimeValue() + } + 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 *EntityFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case entityfield.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case entityfield.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case entityfield.FieldName: + return m.OldName(ctx) + case entityfield.FieldDescription: + return m.OldDescription(ctx) + case entityfield.FieldType: + return m.OldType(ctx) + case entityfield.FieldTextValue: + return m.OldTextValue(ctx) + case entityfield.FieldNumberValue: + return m.OldNumberValue(ctx) + case entityfield.FieldBooleanValue: + return m.OldBooleanValue(ctx) + case entityfield.FieldTimeValue: + return m.OldTimeValue(ctx) + } + return nil, fmt.Errorf("unknown EntityField 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 *EntityFieldMutation) SetField(name string, value ent.Value) error { + switch name { + case entityfield.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 entityfield.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 entityfield.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case entityfield.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case entityfield.FieldType: + v, ok := value.(entityfield.Type) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case entityfield.FieldTextValue: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTextValue(v) + return nil + case entityfield.FieldNumberValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNumberValue(v) + return nil + case entityfield.FieldBooleanValue: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBooleanValue(v) + return nil + case entityfield.FieldTimeValue: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTimeValue(v) + return nil + } + return fmt.Errorf("unknown EntityField field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EntityFieldMutation) AddedFields() []string { + var fields []string + if m.addnumber_value != nil { + fields = append(fields, entityfield.FieldNumberValue) + } + 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 *EntityFieldMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case entityfield.FieldNumberValue: + return m.AddedNumberValue() + } + 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 *EntityFieldMutation) AddField(name string, value ent.Value) error { + switch name { + case entityfield.FieldNumberValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddNumberValue(v) + return nil + } + return fmt.Errorf("unknown EntityField numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EntityFieldMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(entityfield.FieldDescription) { + fields = append(fields, entityfield.FieldDescription) + } + if m.FieldCleared(entityfield.FieldTextValue) { + fields = append(fields, entityfield.FieldTextValue) + } + if m.FieldCleared(entityfield.FieldNumberValue) { + fields = append(fields, entityfield.FieldNumberValue) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EntityFieldMutation) 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 *EntityFieldMutation) ClearField(name string) error { + switch name { + case entityfield.FieldDescription: + m.ClearDescription() + return nil + case entityfield.FieldTextValue: + m.ClearTextValue() + return nil + case entityfield.FieldNumberValue: + m.ClearNumberValue() + return nil + } + return fmt.Errorf("unknown EntityField 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 *EntityFieldMutation) ResetField(name string) error { + switch name { + case entityfield.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case entityfield.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case entityfield.FieldName: + m.ResetName() + return nil + case entityfield.FieldDescription: + m.ResetDescription() + return nil + case entityfield.FieldType: + m.ResetType() + return nil + case entityfield.FieldTextValue: + m.ResetTextValue() + return nil + case entityfield.FieldNumberValue: + m.ResetNumberValue() + return nil + case entityfield.FieldBooleanValue: + m.ResetBooleanValue() + return nil + case entityfield.FieldTimeValue: + m.ResetTimeValue() + return nil + } + return fmt.Errorf("unknown EntityField field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EntityFieldMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.entity != nil { + edges = append(edges, entityfield.EdgeEntity) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EntityFieldMutation) AddedIDs(name string) []ent.Value { + switch name { + case entityfield.EdgeEntity: + if id := m.entity; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EntityFieldMutation) 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 *EntityFieldMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EntityFieldMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedentity { + edges = append(edges, entityfield.EdgeEntity) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EntityFieldMutation) EdgeCleared(name string) bool { + switch name { + case entityfield.EdgeEntity: + return m.clearedentity + } + 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 *EntityFieldMutation) ClearEdge(name string) error { + switch name { + case entityfield.EdgeEntity: + m.ClearEntity() + return nil + } + return fmt.Errorf("unknown EntityField 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 *EntityFieldMutation) ResetEdge(name string) error { + switch name { + case entityfield.EdgeEntity: + m.ResetEntity() + return nil + } + return fmt.Errorf("unknown EntityField edge %s", name) +} + +// EntityTypeMutation represents an operation that mutates the EntityType nodes in the graph. +type EntityTypeMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + updated_at *time.Time + name *string + description *string + icon *string + color *string + is_location *bool + clearedFields map[string]struct{} + group *uuid.UUID + clearedgroup bool + entities map[uuid.UUID]struct{} + removedentities map[uuid.UUID]struct{} + clearedentities bool + done bool + oldValue func(context.Context) (*EntityType, error) + predicates []predicate.EntityType +} + +var _ ent.Mutation = (*EntityTypeMutation)(nil) + +// entitytypeOption allows management of the mutation configuration using functional options. +type entitytypeOption func(*EntityTypeMutation) + +// newEntityTypeMutation creates new mutation for the EntityType entity. +func newEntityTypeMutation(c config, op Op, opts ...entitytypeOption) *EntityTypeMutation { + m := &EntityTypeMutation{ + config: c, + op: op, + typ: TypeEntityType, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEntityTypeID sets the ID field of the mutation. +func withEntityTypeID(id uuid.UUID) entitytypeOption { + return func(m *EntityTypeMutation) { + var ( + err error + once sync.Once + value *EntityType + ) + m.oldValue = func(ctx context.Context) (*EntityType, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EntityType.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEntityType sets the old EntityType of the mutation. +func withEntityType(node *EntityType) entitytypeOption { + return func(m *EntityTypeMutation) { + m.oldValue = func(context.Context) (*EntityType, 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 EntityTypeMutation) 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 EntityTypeMutation) 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 EntityType entities. +func (m *EntityTypeMutation) 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 *EntityTypeMutation) 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 *EntityTypeMutation) 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().EntityType.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 *EntityTypeMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *EntityTypeMutation) 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 EntityType entity. +// If the EntityType 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 *EntityTypeMutation) 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 *EntityTypeMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *EntityTypeMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *EntityTypeMutation) 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 EntityType entity. +// If the EntityType 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 *EntityTypeMutation) 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 *EntityTypeMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *EntityTypeMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *EntityTypeMutation) 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 EntityType entity. +// If the EntityType 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 *EntityTypeMutation) 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 *EntityTypeMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *EntityTypeMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *EntityTypeMutation) 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 EntityType entity. +// If the EntityType 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 *EntityTypeMutation) 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 *EntityTypeMutation) ClearDescription() { + m.description = nil + m.clearedFields[entitytype.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *EntityTypeMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[entitytype.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *EntityTypeMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, entitytype.FieldDescription) +} + +// SetIcon sets the "icon" field. +func (m *EntityTypeMutation) SetIcon(s string) { + m.icon = &s +} + +// Icon returns the value of the "icon" field in the mutation. +func (m *EntityTypeMutation) Icon() (r string, exists bool) { + v := m.icon + if v == nil { + return + } + return *v, true +} + +// OldIcon returns the old "icon" field's value of the EntityType entity. +// If the EntityType 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 *EntityTypeMutation) OldIcon(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIcon is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIcon requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIcon: %w", err) + } + return oldValue.Icon, nil +} + +// ClearIcon clears the value of the "icon" field. +func (m *EntityTypeMutation) ClearIcon() { + m.icon = nil + m.clearedFields[entitytype.FieldIcon] = struct{}{} +} + +// IconCleared returns if the "icon" field was cleared in this mutation. +func (m *EntityTypeMutation) IconCleared() bool { + _, ok := m.clearedFields[entitytype.FieldIcon] + return ok +} + +// ResetIcon resets all changes to the "icon" field. +func (m *EntityTypeMutation) ResetIcon() { + m.icon = nil + delete(m.clearedFields, entitytype.FieldIcon) +} + +// SetColor sets the "color" field. +func (m *EntityTypeMutation) SetColor(s string) { + m.color = &s +} + +// Color returns the value of the "color" field in the mutation. +func (m *EntityTypeMutation) 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 EntityType entity. +// If the EntityType 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 *EntityTypeMutation) 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 *EntityTypeMutation) ClearColor() { + m.color = nil + m.clearedFields[entitytype.FieldColor] = struct{}{} +} + +// ColorCleared returns if the "color" field was cleared in this mutation. +func (m *EntityTypeMutation) ColorCleared() bool { + _, ok := m.clearedFields[entitytype.FieldColor] + return ok +} + +// ResetColor resets all changes to the "color" field. +func (m *EntityTypeMutation) ResetColor() { + m.color = nil + delete(m.clearedFields, entitytype.FieldColor) +} + +// SetIsLocation sets the "is_location" field. +func (m *EntityTypeMutation) SetIsLocation(b bool) { + m.is_location = &b +} + +// IsLocation returns the value of the "is_location" field in the mutation. +func (m *EntityTypeMutation) IsLocation() (r bool, exists bool) { + v := m.is_location + if v == nil { + return + } + return *v, true +} + +// OldIsLocation returns the old "is_location" field's value of the EntityType entity. +// If the EntityType 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 *EntityTypeMutation) OldIsLocation(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsLocation is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsLocation requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsLocation: %w", err) + } + return oldValue.IsLocation, nil +} + +// ResetIsLocation resets all changes to the "is_location" field. +func (m *EntityTypeMutation) ResetIsLocation() { + m.is_location = nil +} + +// SetGroupID sets the "group" edge to the Group entity by id. +func (m *EntityTypeMutation) SetGroupID(id uuid.UUID) { + m.group = &id +} + +// ClearGroup clears the "group" edge to the Group entity. +func (m *EntityTypeMutation) ClearGroup() { + m.clearedgroup = true +} + +// GroupCleared reports if the "group" edge to the Group entity was cleared. +func (m *EntityTypeMutation) GroupCleared() bool { + return m.clearedgroup +} + +// GroupID returns the "group" edge ID in the mutation. +func (m *EntityTypeMutation) 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 *EntityTypeMutation) 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 *EntityTypeMutation) ResetGroup() { + m.group = nil + m.clearedgroup = false +} + +// AddEntityIDs adds the "entities" edge to the Entity entity by ids. +func (m *EntityTypeMutation) AddEntityIDs(ids ...uuid.UUID) { + if m.entities == nil { + m.entities = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.entities[ids[i]] = struct{}{} + } +} + +// ClearEntities clears the "entities" edge to the Entity entity. +func (m *EntityTypeMutation) ClearEntities() { + m.clearedentities = true +} + +// EntitiesCleared reports if the "entities" edge to the Entity entity was cleared. +func (m *EntityTypeMutation) EntitiesCleared() bool { + return m.clearedentities +} + +// RemoveEntityIDs removes the "entities" edge to the Entity entity by IDs. +func (m *EntityTypeMutation) RemoveEntityIDs(ids ...uuid.UUID) { + if m.removedentities == nil { + m.removedentities = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.entities, ids[i]) + m.removedentities[ids[i]] = struct{}{} + } +} + +// RemovedEntities returns the removed IDs of the "entities" edge to the Entity entity. +func (m *EntityTypeMutation) RemovedEntitiesIDs() (ids []uuid.UUID) { + for id := range m.removedentities { + ids = append(ids, id) + } + return +} + +// EntitiesIDs returns the "entities" edge IDs in the mutation. +func (m *EntityTypeMutation) EntitiesIDs() (ids []uuid.UUID) { + for id := range m.entities { + ids = append(ids, id) + } + return +} + +// ResetEntities resets all changes to the "entities" edge. +func (m *EntityTypeMutation) ResetEntities() { + m.entities = nil + m.clearedentities = false + m.removedentities = nil +} + +// Where appends a list predicates to the EntityTypeMutation builder. +func (m *EntityTypeMutation) Where(ps ...predicate.EntityType) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EntityTypeMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EntityTypeMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EntityType, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EntityTypeMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EntityTypeMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EntityType). +func (m *EntityTypeMutation) 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 *EntityTypeMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.created_at != nil { + fields = append(fields, entitytype.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, entitytype.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, entitytype.FieldName) + } + if m.description != nil { + fields = append(fields, entitytype.FieldDescription) + } + if m.icon != nil { + fields = append(fields, entitytype.FieldIcon) + } + if m.color != nil { + fields = append(fields, entitytype.FieldColor) + } + if m.is_location != nil { + fields = append(fields, entitytype.FieldIsLocation) + } + 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 *EntityTypeMutation) Field(name string) (ent.Value, bool) { + switch name { + case entitytype.FieldCreatedAt: + return m.CreatedAt() + case entitytype.FieldUpdatedAt: + return m.UpdatedAt() + case entitytype.FieldName: + return m.Name() + case entitytype.FieldDescription: + return m.Description() + case entitytype.FieldIcon: + return m.Icon() + case entitytype.FieldColor: + return m.Color() + case entitytype.FieldIsLocation: + return m.IsLocation() + } + 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 *EntityTypeMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case entitytype.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case entitytype.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case entitytype.FieldName: + return m.OldName(ctx) + case entitytype.FieldDescription: + return m.OldDescription(ctx) + case entitytype.FieldIcon: + return m.OldIcon(ctx) + case entitytype.FieldColor: + return m.OldColor(ctx) + case entitytype.FieldIsLocation: + return m.OldIsLocation(ctx) + } + return nil, fmt.Errorf("unknown EntityType 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 *EntityTypeMutation) SetField(name string, value ent.Value) error { + switch name { + case entitytype.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 entitytype.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 entitytype.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case entitytype.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case entitytype.FieldIcon: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIcon(v) + return nil + case entitytype.FieldColor: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetColor(v) + return nil + case entitytype.FieldIsLocation: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsLocation(v) + return nil + } + return fmt.Errorf("unknown EntityType field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EntityTypeMutation) 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 *EntityTypeMutation) 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 *EntityTypeMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown EntityType numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EntityTypeMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(entitytype.FieldDescription) { + fields = append(fields, entitytype.FieldDescription) + } + if m.FieldCleared(entitytype.FieldIcon) { + fields = append(fields, entitytype.FieldIcon) + } + if m.FieldCleared(entitytype.FieldColor) { + fields = append(fields, entitytype.FieldColor) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EntityTypeMutation) 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 *EntityTypeMutation) ClearField(name string) error { + switch name { + case entitytype.FieldDescription: + m.ClearDescription() + return nil + case entitytype.FieldIcon: + m.ClearIcon() + return nil + case entitytype.FieldColor: + m.ClearColor() + return nil + } + return fmt.Errorf("unknown EntityType 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 *EntityTypeMutation) ResetField(name string) error { + switch name { + case entitytype.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case entitytype.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case entitytype.FieldName: + m.ResetName() + return nil + case entitytype.FieldDescription: + m.ResetDescription() + return nil + case entitytype.FieldIcon: + m.ResetIcon() + return nil + case entitytype.FieldColor: + m.ResetColor() + return nil + case entitytype.FieldIsLocation: + m.ResetIsLocation() + return nil + } + return fmt.Errorf("unknown EntityType field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EntityTypeMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.group != nil { + edges = append(edges, entitytype.EdgeGroup) + } + if m.entities != nil { + edges = append(edges, entitytype.EdgeEntities) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EntityTypeMutation) AddedIDs(name string) []ent.Value { + switch name { + case entitytype.EdgeGroup: + if id := m.group; id != nil { + return []ent.Value{*id} + } + case entitytype.EdgeEntities: + ids := make([]ent.Value, 0, len(m.entities)) + for id := range m.entities { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EntityTypeMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedentities != nil { + edges = append(edges, entitytype.EdgeEntities) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EntityTypeMutation) RemovedIDs(name string) []ent.Value { + switch name { + case entitytype.EdgeEntities: + ids := make([]ent.Value, 0, len(m.removedentities)) + for id := range m.removedentities { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EntityTypeMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedgroup { + edges = append(edges, entitytype.EdgeGroup) + } + if m.clearedentities { + edges = append(edges, entitytype.EdgeEntities) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EntityTypeMutation) EdgeCleared(name string) bool { + switch name { + case entitytype.EdgeGroup: + return m.clearedgroup + case entitytype.EdgeEntities: + return m.clearedentities + } + 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 *EntityTypeMutation) ClearEdge(name string) error { + switch name { + case entitytype.EdgeGroup: + m.ClearGroup() + return nil + } + return fmt.Errorf("unknown EntityType 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 *EntityTypeMutation) ResetEdge(name string) error { + switch name { + case entitytype.EdgeGroup: + m.ResetGroup() + return nil + case entitytype.EdgeEntities: + m.ResetEntities() + return nil + } + return fmt.Errorf("unknown EntityType edge %s", name) +} + // GroupMutation represents an operation that mutates the Group nodes in the graph. type GroupMutation struct { config @@ -1863,12 +6362,9 @@ type GroupMutation struct { users map[uuid.UUID]struct{} removedusers map[uuid.UUID]struct{} clearedusers bool - locations map[uuid.UUID]struct{} - removedlocations map[uuid.UUID]struct{} - clearedlocations bool - items map[uuid.UUID]struct{} - removeditems map[uuid.UUID]struct{} - cleareditems bool + entities map[uuid.UUID]struct{} + removedentities map[uuid.UUID]struct{} + clearedentities bool labels map[uuid.UUID]struct{} removedlabels map[uuid.UUID]struct{} clearedlabels bool @@ -1878,6 +6374,9 @@ type GroupMutation struct { notifiers map[uuid.UUID]struct{} removednotifiers map[uuid.UUID]struct{} clearednotifiers bool + entity_types map[uuid.UUID]struct{} + removedentity_types map[uuid.UUID]struct{} + clearedentity_types bool item_templates map[uuid.UUID]struct{} removeditem_templates map[uuid.UUID]struct{} cleareditem_templates bool @@ -2188,112 +6687,58 @@ func (m *GroupMutation) ResetUsers() { m.removedusers = nil } -// AddLocationIDs adds the "locations" edge to the Location entity by ids. -func (m *GroupMutation) AddLocationIDs(ids ...uuid.UUID) { - if m.locations == nil { - m.locations = make(map[uuid.UUID]struct{}) +// AddEntityIDs adds the "entities" edge to the Entity entity by ids. +func (m *GroupMutation) AddEntityIDs(ids ...uuid.UUID) { + if m.entities == nil { + m.entities = make(map[uuid.UUID]struct{}) } for i := range ids { - m.locations[ids[i]] = struct{}{} + m.entities[ids[i]] = struct{}{} } } -// ClearLocations clears the "locations" edge to the Location entity. -func (m *GroupMutation) ClearLocations() { - m.clearedlocations = true +// ClearEntities clears the "entities" edge to the Entity entity. +func (m *GroupMutation) ClearEntities() { + m.clearedentities = true } -// LocationsCleared reports if the "locations" edge to the Location entity was cleared. -func (m *GroupMutation) LocationsCleared() bool { - return m.clearedlocations +// EntitiesCleared reports if the "entities" edge to the Entity entity was cleared. +func (m *GroupMutation) EntitiesCleared() bool { + return m.clearedentities } -// RemoveLocationIDs removes the "locations" edge to the Location entity by IDs. -func (m *GroupMutation) RemoveLocationIDs(ids ...uuid.UUID) { - if m.removedlocations == nil { - m.removedlocations = make(map[uuid.UUID]struct{}) +// RemoveEntityIDs removes the "entities" edge to the Entity entity by IDs. +func (m *GroupMutation) RemoveEntityIDs(ids ...uuid.UUID) { + if m.removedentities == nil { + m.removedentities = make(map[uuid.UUID]struct{}) } for i := range ids { - delete(m.locations, ids[i]) - m.removedlocations[ids[i]] = struct{}{} + delete(m.entities, ids[i]) + m.removedentities[ids[i]] = struct{}{} } } -// RemovedLocations returns the removed IDs of the "locations" edge to the Location entity. -func (m *GroupMutation) RemovedLocationsIDs() (ids []uuid.UUID) { - for id := range m.removedlocations { +// RemovedEntities returns the removed IDs of the "entities" edge to the Entity entity. +func (m *GroupMutation) RemovedEntitiesIDs() (ids []uuid.UUID) { + for id := range m.removedentities { ids = append(ids, id) } return } -// LocationsIDs returns the "locations" edge IDs in the mutation. -func (m *GroupMutation) LocationsIDs() (ids []uuid.UUID) { - for id := range m.locations { +// EntitiesIDs returns the "entities" edge IDs in the mutation. +func (m *GroupMutation) EntitiesIDs() (ids []uuid.UUID) { + for id := range m.entities { ids = append(ids, id) } return } -// ResetLocations resets all changes to the "locations" edge. -func (m *GroupMutation) ResetLocations() { - m.locations = nil - m.clearedlocations = false - m.removedlocations = nil -} - -// AddItemIDs adds the "items" edge to the Item entity by ids. -func (m *GroupMutation) 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 *GroupMutation) ClearItems() { - m.cleareditems = true -} - -// ItemsCleared reports if the "items" edge to the Item entity was cleared. -func (m *GroupMutation) ItemsCleared() bool { - return m.cleareditems -} - -// RemoveItemIDs removes the "items" edge to the Item entity by IDs. -func (m *GroupMutation) 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 *GroupMutation) 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 *GroupMutation) ItemsIDs() (ids []uuid.UUID) { - for id := range m.items { - ids = append(ids, id) - } - return -} - -// ResetItems resets all changes to the "items" edge. -func (m *GroupMutation) ResetItems() { - m.items = nil - m.cleareditems = false - m.removeditems = nil +// ResetEntities resets all changes to the "entities" edge. +func (m *GroupMutation) ResetEntities() { + m.entities = nil + m.clearedentities = false + m.removedentities = nil } // AddLabelIDs adds the "labels" edge to the Label entity by ids. @@ -2458,6 +6903,60 @@ func (m *GroupMutation) ResetNotifiers() { m.removednotifiers = nil } +// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by ids. +func (m *GroupMutation) AddEntityTypeIDs(ids ...uuid.UUID) { + if m.entity_types == nil { + m.entity_types = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.entity_types[ids[i]] = struct{}{} + } +} + +// ClearEntityTypes clears the "entity_types" edge to the EntityType entity. +func (m *GroupMutation) ClearEntityTypes() { + m.clearedentity_types = true +} + +// EntityTypesCleared reports if the "entity_types" edge to the EntityType entity was cleared. +func (m *GroupMutation) EntityTypesCleared() bool { + return m.clearedentity_types +} + +// RemoveEntityTypeIDs removes the "entity_types" edge to the EntityType entity by IDs. +func (m *GroupMutation) RemoveEntityTypeIDs(ids ...uuid.UUID) { + if m.removedentity_types == nil { + m.removedentity_types = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.entity_types, ids[i]) + m.removedentity_types[ids[i]] = struct{}{} + } +} + +// RemovedEntityTypes returns the removed IDs of the "entity_types" edge to the EntityType entity. +func (m *GroupMutation) RemovedEntityTypesIDs() (ids []uuid.UUID) { + for id := range m.removedentity_types { + ids = append(ids, id) + } + return +} + +// EntityTypesIDs returns the "entity_types" edge IDs in the mutation. +func (m *GroupMutation) EntityTypesIDs() (ids []uuid.UUID) { + for id := range m.entity_types { + ids = append(ids, id) + } + return +} + +// ResetEntityTypes resets all changes to the "entity_types" edge. +func (m *GroupMutation) ResetEntityTypes() { + m.entity_types = nil + m.clearedentity_types = false + m.removedentity_types = 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 { @@ -2700,11 +7199,8 @@ func (m *GroupMutation) AddedEdges() []string { if m.users != nil { edges = append(edges, group.EdgeUsers) } - if m.locations != nil { - edges = append(edges, group.EdgeLocations) - } - if m.items != nil { - edges = append(edges, group.EdgeItems) + if m.entities != nil { + edges = append(edges, group.EdgeEntities) } if m.labels != nil { edges = append(edges, group.EdgeLabels) @@ -2715,6 +7211,9 @@ func (m *GroupMutation) AddedEdges() []string { if m.notifiers != nil { edges = append(edges, group.EdgeNotifiers) } + if m.entity_types != nil { + edges = append(edges, group.EdgeEntityTypes) + } if m.item_templates != nil { edges = append(edges, group.EdgeItemTemplates) } @@ -2731,15 +7230,9 @@ func (m *GroupMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case group.EdgeLocations: - ids := make([]ent.Value, 0, len(m.locations)) - for id := range m.locations { - ids = append(ids, id) - } - return ids - case group.EdgeItems: - ids := make([]ent.Value, 0, len(m.items)) - for id := range m.items { + case group.EdgeEntities: + ids := make([]ent.Value, 0, len(m.entities)) + for id := range m.entities { ids = append(ids, id) } return ids @@ -2761,6 +7254,12 @@ func (m *GroupMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case group.EdgeEntityTypes: + ids := make([]ent.Value, 0, len(m.entity_types)) + for id := range m.entity_types { + ids = append(ids, id) + } + return ids case group.EdgeItemTemplates: ids := make([]ent.Value, 0, len(m.item_templates)) for id := range m.item_templates { @@ -2777,11 +7276,8 @@ func (m *GroupMutation) RemovedEdges() []string { if m.removedusers != nil { edges = append(edges, group.EdgeUsers) } - if m.removedlocations != nil { - edges = append(edges, group.EdgeLocations) - } - if m.removeditems != nil { - edges = append(edges, group.EdgeItems) + if m.removedentities != nil { + edges = append(edges, group.EdgeEntities) } if m.removedlabels != nil { edges = append(edges, group.EdgeLabels) @@ -2792,6 +7288,9 @@ func (m *GroupMutation) RemovedEdges() []string { if m.removednotifiers != nil { edges = append(edges, group.EdgeNotifiers) } + if m.removedentity_types != nil { + edges = append(edges, group.EdgeEntityTypes) + } if m.removeditem_templates != nil { edges = append(edges, group.EdgeItemTemplates) } @@ -2808,15 +7307,9 @@ func (m *GroupMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case group.EdgeLocations: - ids := make([]ent.Value, 0, len(m.removedlocations)) - for id := range m.removedlocations { - ids = append(ids, id) - } - return ids - case group.EdgeItems: - ids := make([]ent.Value, 0, len(m.removeditems)) - for id := range m.removeditems { + case group.EdgeEntities: + ids := make([]ent.Value, 0, len(m.removedentities)) + for id := range m.removedentities { ids = append(ids, id) } return ids @@ -2838,6 +7331,12 @@ func (m *GroupMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case group.EdgeEntityTypes: + ids := make([]ent.Value, 0, len(m.removedentity_types)) + for id := range m.removedentity_types { + ids = append(ids, id) + } + return ids case group.EdgeItemTemplates: ids := make([]ent.Value, 0, len(m.removeditem_templates)) for id := range m.removeditem_templates { @@ -2854,11 +7353,8 @@ func (m *GroupMutation) ClearedEdges() []string { if m.clearedusers { edges = append(edges, group.EdgeUsers) } - if m.clearedlocations { - edges = append(edges, group.EdgeLocations) - } - if m.cleareditems { - edges = append(edges, group.EdgeItems) + if m.clearedentities { + edges = append(edges, group.EdgeEntities) } if m.clearedlabels { edges = append(edges, group.EdgeLabels) @@ -2869,6 +7365,9 @@ func (m *GroupMutation) ClearedEdges() []string { if m.clearednotifiers { edges = append(edges, group.EdgeNotifiers) } + if m.clearedentity_types { + edges = append(edges, group.EdgeEntityTypes) + } if m.cleareditem_templates { edges = append(edges, group.EdgeItemTemplates) } @@ -2881,16 +7380,16 @@ func (m *GroupMutation) EdgeCleared(name string) bool { switch name { case group.EdgeUsers: return m.clearedusers - case group.EdgeLocations: - return m.clearedlocations - case group.EdgeItems: - return m.cleareditems + case group.EdgeEntities: + return m.clearedentities case group.EdgeLabels: return m.clearedlabels case group.EdgeInvitationTokens: return m.clearedinvitation_tokens case group.EdgeNotifiers: return m.clearednotifiers + case group.EdgeEntityTypes: + return m.clearedentity_types case group.EdgeItemTemplates: return m.cleareditem_templates } @@ -2912,11 +7411,8 @@ func (m *GroupMutation) ResetEdge(name string) error { case group.EdgeUsers: m.ResetUsers() return nil - case group.EdgeLocations: - m.ResetLocations() - return nil - case group.EdgeItems: - m.ResetItems() + case group.EdgeEntities: + m.ResetEntities() return nil case group.EdgeLabels: m.ResetLabels() @@ -2927,6 +7423,9 @@ func (m *GroupMutation) ResetEdge(name string) error { case group.EdgeNotifiers: m.ResetNotifiers() return nil + case group.EdgeEntityTypes: + m.ResetEntityTypes() + return nil case group.EdgeItemTemplates: m.ResetItemTemplates() return nil @@ -3585,3495 +8084,6 @@ func (m *GroupInvitationTokenMutation) ResetEdge(name string) error { return fmt.Errorf("unknown GroupInvitationToken edge %s", name) } -// ItemMutation represents an operation that mutates the Item nodes in the graph. -type ItemMutation struct { - config - op Op - typ string - id *uuid.UUID - created_at *time.Time - updated_at *time.Time - name *string - description *string - import_ref *string - notes *string - quantity *int - addquantity *int - insured *bool - archived *bool - asset_id *int - addasset_id *int - sync_child_items_locations *bool - serial_number *string - model_number *string - manufacturer *string - lifetime_warranty *bool - warranty_expires *time.Time - warranty_details *string - purchase_time *time.Time - purchase_from *string - purchase_price *float64 - addpurchase_price *float64 - sold_time *time.Time - sold_to *string - sold_price *float64 - addsold_price *float64 - sold_notes *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 - label map[uuid.UUID]struct{} - removedlabel map[uuid.UUID]struct{} - clearedlabel bool - location *uuid.UUID - clearedlocation bool - fields map[uuid.UUID]struct{} - removedfields map[uuid.UUID]struct{} - clearedfields bool - maintenance_entries map[uuid.UUID]struct{} - removedmaintenance_entries map[uuid.UUID]struct{} - clearedmaintenance_entries bool - attachments map[uuid.UUID]struct{} - removedattachments map[uuid.UUID]struct{} - clearedattachments bool - done bool - oldValue func(context.Context) (*Item, error) - predicates []predicate.Item -} - -var _ ent.Mutation = (*ItemMutation)(nil) - -// itemOption allows management of the mutation configuration using functional options. -type itemOption func(*ItemMutation) - -// newItemMutation creates new mutation for the Item entity. -func newItemMutation(c config, op Op, opts ...itemOption) *ItemMutation { - m := &ItemMutation{ - config: c, - op: op, - typ: TypeItem, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withItemID sets the ID field of the mutation. -func withItemID(id uuid.UUID) itemOption { - return func(m *ItemMutation) { - var ( - err error - once sync.Once - value *Item - ) - m.oldValue = func(ctx context.Context) (*Item, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Item.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withItem sets the old Item of the mutation. -func withItem(node *Item) itemOption { - return func(m *ItemMutation) { - m.oldValue = func(context.Context) (*Item, 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 ItemMutation) 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 ItemMutation) 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 Item entities. -func (m *ItemMutation) 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 *ItemMutation) 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 *ItemMutation) 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().Item.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 *ItemMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ItemMutation) 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 Item entity. -// If the Item 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 *ItemMutation) 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 *ItemMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *ItemMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *ItemMutation) 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 Item entity. -// If the Item 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 *ItemMutation) 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 *ItemMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetName sets the "name" field. -func (m *ItemMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *ItemMutation) 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 Item entity. -// If the Item 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 *ItemMutation) 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 *ItemMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *ItemMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *ItemMutation) 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 Item entity. -// If the Item 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 *ItemMutation) 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 *ItemMutation) ClearDescription() { - m.description = nil - m.clearedFields[item.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *ItemMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[item.FieldDescription] - return ok -} - -// ResetDescription resets all changes to the "description" field. -func (m *ItemMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, item.FieldDescription) -} - -// SetImportRef sets the "import_ref" field. -func (m *ItemMutation) SetImportRef(s string) { - m.import_ref = &s -} - -// ImportRef returns the value of the "import_ref" field in the mutation. -func (m *ItemMutation) ImportRef() (r string, exists bool) { - v := m.import_ref - if v == nil { - return - } - return *v, true -} - -// OldImportRef returns the old "import_ref" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldImportRef(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldImportRef is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldImportRef requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldImportRef: %w", err) - } - return oldValue.ImportRef, nil -} - -// ClearImportRef clears the value of the "import_ref" field. -func (m *ItemMutation) ClearImportRef() { - m.import_ref = nil - m.clearedFields[item.FieldImportRef] = struct{}{} -} - -// ImportRefCleared returns if the "import_ref" field was cleared in this mutation. -func (m *ItemMutation) ImportRefCleared() bool { - _, ok := m.clearedFields[item.FieldImportRef] - return ok -} - -// ResetImportRef resets all changes to the "import_ref" field. -func (m *ItemMutation) ResetImportRef() { - m.import_ref = nil - delete(m.clearedFields, item.FieldImportRef) -} - -// SetNotes sets the "notes" field. -func (m *ItemMutation) SetNotes(s string) { - m.notes = &s -} - -// Notes returns the value of the "notes" field in the mutation. -func (m *ItemMutation) Notes() (r string, exists bool) { - v := m.notes - if v == nil { - return - } - return *v, true -} - -// OldNotes returns the old "notes" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldNotes(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNotes is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - 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 OldNotes: %w", err) - } - return oldValue.Notes, nil -} - -// ClearNotes clears the value of the "notes" field. -func (m *ItemMutation) ClearNotes() { - m.notes = nil - m.clearedFields[item.FieldNotes] = struct{}{} -} - -// NotesCleared returns if the "notes" field was cleared in this mutation. -func (m *ItemMutation) NotesCleared() bool { - _, ok := m.clearedFields[item.FieldNotes] - return ok -} - -// ResetNotes resets all changes to the "notes" field. -func (m *ItemMutation) ResetNotes() { - m.notes = nil - delete(m.clearedFields, item.FieldNotes) -} - -// SetQuantity sets the "quantity" field. -func (m *ItemMutation) SetQuantity(i int) { - m.quantity = &i - m.addquantity = nil -} - -// Quantity returns the value of the "quantity" field in the mutation. -func (m *ItemMutation) Quantity() (r int, exists bool) { - v := m.quantity - if v == nil { - return - } - return *v, true -} - -// OldQuantity returns the old "quantity" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldQuantity(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldQuantity is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldQuantity requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldQuantity: %w", err) - } - return oldValue.Quantity, nil -} - -// AddQuantity adds i to the "quantity" field. -func (m *ItemMutation) AddQuantity(i int) { - if m.addquantity != nil { - *m.addquantity += i - } else { - m.addquantity = &i - } -} - -// AddedQuantity returns the value that was added to the "quantity" field in this mutation. -func (m *ItemMutation) AddedQuantity() (r int, exists bool) { - v := m.addquantity - if v == nil { - return - } - return *v, true -} - -// ResetQuantity resets all changes to the "quantity" field. -func (m *ItemMutation) ResetQuantity() { - m.quantity = nil - m.addquantity = nil -} - -// SetInsured sets the "insured" field. -func (m *ItemMutation) SetInsured(b bool) { - m.insured = &b -} - -// Insured returns the value of the "insured" field in the mutation. -func (m *ItemMutation) Insured() (r bool, exists bool) { - v := m.insured - if v == nil { - return - } - return *v, true -} - -// OldInsured returns the old "insured" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldInsured(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInsured is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInsured requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInsured: %w", err) - } - return oldValue.Insured, nil -} - -// ResetInsured resets all changes to the "insured" field. -func (m *ItemMutation) ResetInsured() { - m.insured = nil -} - -// SetArchived sets the "archived" field. -func (m *ItemMutation) SetArchived(b bool) { - m.archived = &b -} - -// Archived returns the value of the "archived" field in the mutation. -func (m *ItemMutation) Archived() (r bool, exists bool) { - v := m.archived - if v == nil { - return - } - return *v, true -} - -// OldArchived returns the old "archived" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldArchived(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldArchived is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldArchived requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldArchived: %w", err) - } - return oldValue.Archived, nil -} - -// ResetArchived resets all changes to the "archived" field. -func (m *ItemMutation) ResetArchived() { - m.archived = nil -} - -// SetAssetID sets the "asset_id" field. -func (m *ItemMutation) SetAssetID(i int) { - m.asset_id = &i - m.addasset_id = nil -} - -// AssetID returns the value of the "asset_id" field in the mutation. -func (m *ItemMutation) AssetID() (r int, exists bool) { - v := m.asset_id - if v == nil { - return - } - return *v, true -} - -// OldAssetID returns the old "asset_id" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldAssetID(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAssetID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAssetID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAssetID: %w", err) - } - return oldValue.AssetID, nil -} - -// AddAssetID adds i to the "asset_id" field. -func (m *ItemMutation) AddAssetID(i int) { - if m.addasset_id != nil { - *m.addasset_id += i - } else { - m.addasset_id = &i - } -} - -// AddedAssetID returns the value that was added to the "asset_id" field in this mutation. -func (m *ItemMutation) AddedAssetID() (r int, exists bool) { - v := m.addasset_id - if v == nil { - return - } - return *v, true -} - -// ResetAssetID resets all changes to the "asset_id" field. -func (m *ItemMutation) ResetAssetID() { - m.asset_id = nil - m.addasset_id = nil -} - -// SetSyncChildItemsLocations sets the "sync_child_items_locations" field. -func (m *ItemMutation) SetSyncChildItemsLocations(b bool) { - m.sync_child_items_locations = &b -} - -// SyncChildItemsLocations returns the value of the "sync_child_items_locations" field in the mutation. -func (m *ItemMutation) SyncChildItemsLocations() (r bool, exists bool) { - v := m.sync_child_items_locations - if v == nil { - return - } - return *v, true -} - -// OldSyncChildItemsLocations returns the old "sync_child_items_locations" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldSyncChildItemsLocations(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSyncChildItemsLocations is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSyncChildItemsLocations requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSyncChildItemsLocations: %w", err) - } - return oldValue.SyncChildItemsLocations, nil -} - -// ResetSyncChildItemsLocations resets all changes to the "sync_child_items_locations" field. -func (m *ItemMutation) ResetSyncChildItemsLocations() { - m.sync_child_items_locations = nil -} - -// SetSerialNumber sets the "serial_number" field. -func (m *ItemMutation) SetSerialNumber(s string) { - m.serial_number = &s -} - -// SerialNumber returns the value of the "serial_number" field in the mutation. -func (m *ItemMutation) SerialNumber() (r string, exists bool) { - v := m.serial_number - if v == nil { - return - } - return *v, true -} - -// OldSerialNumber returns the old "serial_number" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldSerialNumber(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSerialNumber is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSerialNumber requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSerialNumber: %w", err) - } - return oldValue.SerialNumber, nil -} - -// ClearSerialNumber clears the value of the "serial_number" field. -func (m *ItemMutation) ClearSerialNumber() { - m.serial_number = nil - m.clearedFields[item.FieldSerialNumber] = struct{}{} -} - -// SerialNumberCleared returns if the "serial_number" field was cleared in this mutation. -func (m *ItemMutation) SerialNumberCleared() bool { - _, ok := m.clearedFields[item.FieldSerialNumber] - return ok -} - -// ResetSerialNumber resets all changes to the "serial_number" field. -func (m *ItemMutation) ResetSerialNumber() { - m.serial_number = nil - delete(m.clearedFields, item.FieldSerialNumber) -} - -// SetModelNumber sets the "model_number" field. -func (m *ItemMutation) SetModelNumber(s string) { - m.model_number = &s -} - -// ModelNumber returns the value of the "model_number" field in the mutation. -func (m *ItemMutation) ModelNumber() (r string, exists bool) { - v := m.model_number - if v == nil { - return - } - return *v, true -} - -// OldModelNumber returns the old "model_number" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldModelNumber(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModelNumber is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModelNumber requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModelNumber: %w", err) - } - return oldValue.ModelNumber, nil -} - -// ClearModelNumber clears the value of the "model_number" field. -func (m *ItemMutation) ClearModelNumber() { - m.model_number = nil - m.clearedFields[item.FieldModelNumber] = struct{}{} -} - -// ModelNumberCleared returns if the "model_number" field was cleared in this mutation. -func (m *ItemMutation) ModelNumberCleared() bool { - _, ok := m.clearedFields[item.FieldModelNumber] - return ok -} - -// ResetModelNumber resets all changes to the "model_number" field. -func (m *ItemMutation) ResetModelNumber() { - m.model_number = nil - delete(m.clearedFields, item.FieldModelNumber) -} - -// SetManufacturer sets the "manufacturer" field. -func (m *ItemMutation) SetManufacturer(s string) { - m.manufacturer = &s -} - -// Manufacturer returns the value of the "manufacturer" field in the mutation. -func (m *ItemMutation) Manufacturer() (r string, exists bool) { - v := m.manufacturer - if v == nil { - return - } - return *v, true -} - -// OldManufacturer returns the old "manufacturer" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldManufacturer(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManufacturer requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) - } - return oldValue.Manufacturer, nil -} - -// ClearManufacturer clears the value of the "manufacturer" field. -func (m *ItemMutation) ClearManufacturer() { - m.manufacturer = nil - m.clearedFields[item.FieldManufacturer] = struct{}{} -} - -// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. -func (m *ItemMutation) ManufacturerCleared() bool { - _, ok := m.clearedFields[item.FieldManufacturer] - return ok -} - -// ResetManufacturer resets all changes to the "manufacturer" field. -func (m *ItemMutation) ResetManufacturer() { - m.manufacturer = nil - delete(m.clearedFields, item.FieldManufacturer) -} - -// SetLifetimeWarranty sets the "lifetime_warranty" field. -func (m *ItemMutation) SetLifetimeWarranty(b bool) { - m.lifetime_warranty = &b -} - -// LifetimeWarranty returns the value of the "lifetime_warranty" field in the mutation. -func (m *ItemMutation) LifetimeWarranty() (r bool, exists bool) { - v := m.lifetime_warranty - if v == nil { - return - } - return *v, true -} - -// OldLifetimeWarranty returns the old "lifetime_warranty" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldLifetimeWarranty(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLifetimeWarranty is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLifetimeWarranty requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLifetimeWarranty: %w", err) - } - return oldValue.LifetimeWarranty, nil -} - -// ResetLifetimeWarranty resets all changes to the "lifetime_warranty" field. -func (m *ItemMutation) ResetLifetimeWarranty() { - m.lifetime_warranty = nil -} - -// SetWarrantyExpires sets the "warranty_expires" field. -func (m *ItemMutation) SetWarrantyExpires(t time.Time) { - m.warranty_expires = &t -} - -// WarrantyExpires returns the value of the "warranty_expires" field in the mutation. -func (m *ItemMutation) WarrantyExpires() (r time.Time, exists bool) { - v := m.warranty_expires - if v == nil { - return - } - return *v, true -} - -// OldWarrantyExpires returns the old "warranty_expires" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldWarrantyExpires(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWarrantyExpires is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWarrantyExpires requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldWarrantyExpires: %w", err) - } - return oldValue.WarrantyExpires, nil -} - -// ClearWarrantyExpires clears the value of the "warranty_expires" field. -func (m *ItemMutation) ClearWarrantyExpires() { - m.warranty_expires = nil - m.clearedFields[item.FieldWarrantyExpires] = struct{}{} -} - -// WarrantyExpiresCleared returns if the "warranty_expires" field was cleared in this mutation. -func (m *ItemMutation) WarrantyExpiresCleared() bool { - _, ok := m.clearedFields[item.FieldWarrantyExpires] - return ok -} - -// ResetWarrantyExpires resets all changes to the "warranty_expires" field. -func (m *ItemMutation) ResetWarrantyExpires() { - m.warranty_expires = nil - delete(m.clearedFields, item.FieldWarrantyExpires) -} - -// SetWarrantyDetails sets the "warranty_details" field. -func (m *ItemMutation) SetWarrantyDetails(s string) { - m.warranty_details = &s -} - -// WarrantyDetails returns the value of the "warranty_details" field in the mutation. -func (m *ItemMutation) WarrantyDetails() (r string, exists bool) { - v := m.warranty_details - if v == nil { - return - } - return *v, true -} - -// OldWarrantyDetails returns the old "warranty_details" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldWarrantyDetails(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWarrantyDetails is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWarrantyDetails requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldWarrantyDetails: %w", err) - } - return oldValue.WarrantyDetails, nil -} - -// ClearWarrantyDetails clears the value of the "warranty_details" field. -func (m *ItemMutation) ClearWarrantyDetails() { - m.warranty_details = nil - m.clearedFields[item.FieldWarrantyDetails] = struct{}{} -} - -// WarrantyDetailsCleared returns if the "warranty_details" field was cleared in this mutation. -func (m *ItemMutation) WarrantyDetailsCleared() bool { - _, ok := m.clearedFields[item.FieldWarrantyDetails] - return ok -} - -// ResetWarrantyDetails resets all changes to the "warranty_details" field. -func (m *ItemMutation) ResetWarrantyDetails() { - m.warranty_details = nil - delete(m.clearedFields, item.FieldWarrantyDetails) -} - -// SetPurchaseTime sets the "purchase_time" field. -func (m *ItemMutation) SetPurchaseTime(t time.Time) { - m.purchase_time = &t -} - -// PurchaseTime returns the value of the "purchase_time" field in the mutation. -func (m *ItemMutation) PurchaseTime() (r time.Time, exists bool) { - v := m.purchase_time - if v == nil { - return - } - return *v, true -} - -// OldPurchaseTime returns the old "purchase_time" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldPurchaseTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPurchaseTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPurchaseTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPurchaseTime: %w", err) - } - return oldValue.PurchaseTime, nil -} - -// ClearPurchaseTime clears the value of the "purchase_time" field. -func (m *ItemMutation) ClearPurchaseTime() { - m.purchase_time = nil - m.clearedFields[item.FieldPurchaseTime] = struct{}{} -} - -// PurchaseTimeCleared returns if the "purchase_time" field was cleared in this mutation. -func (m *ItemMutation) PurchaseTimeCleared() bool { - _, ok := m.clearedFields[item.FieldPurchaseTime] - return ok -} - -// ResetPurchaseTime resets all changes to the "purchase_time" field. -func (m *ItemMutation) ResetPurchaseTime() { - m.purchase_time = nil - delete(m.clearedFields, item.FieldPurchaseTime) -} - -// SetPurchaseFrom sets the "purchase_from" field. -func (m *ItemMutation) SetPurchaseFrom(s string) { - m.purchase_from = &s -} - -// PurchaseFrom returns the value of the "purchase_from" field in the mutation. -func (m *ItemMutation) PurchaseFrom() (r string, exists bool) { - v := m.purchase_from - if v == nil { - return - } - return *v, true -} - -// OldPurchaseFrom returns the old "purchase_from" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldPurchaseFrom(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPurchaseFrom is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPurchaseFrom requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPurchaseFrom: %w", err) - } - return oldValue.PurchaseFrom, nil -} - -// ClearPurchaseFrom clears the value of the "purchase_from" field. -func (m *ItemMutation) ClearPurchaseFrom() { - m.purchase_from = nil - m.clearedFields[item.FieldPurchaseFrom] = struct{}{} -} - -// PurchaseFromCleared returns if the "purchase_from" field was cleared in this mutation. -func (m *ItemMutation) PurchaseFromCleared() bool { - _, ok := m.clearedFields[item.FieldPurchaseFrom] - return ok -} - -// ResetPurchaseFrom resets all changes to the "purchase_from" field. -func (m *ItemMutation) ResetPurchaseFrom() { - m.purchase_from = nil - delete(m.clearedFields, item.FieldPurchaseFrom) -} - -// SetPurchasePrice sets the "purchase_price" field. -func (m *ItemMutation) SetPurchasePrice(f float64) { - m.purchase_price = &f - m.addpurchase_price = nil -} - -// PurchasePrice returns the value of the "purchase_price" field in the mutation. -func (m *ItemMutation) PurchasePrice() (r float64, exists bool) { - v := m.purchase_price - if v == nil { - return - } - return *v, true -} - -// OldPurchasePrice returns the old "purchase_price" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldPurchasePrice(ctx context.Context) (v float64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPurchasePrice is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPurchasePrice requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPurchasePrice: %w", err) - } - return oldValue.PurchasePrice, nil -} - -// AddPurchasePrice adds f to the "purchase_price" field. -func (m *ItemMutation) AddPurchasePrice(f float64) { - if m.addpurchase_price != nil { - *m.addpurchase_price += f - } else { - m.addpurchase_price = &f - } -} - -// AddedPurchasePrice returns the value that was added to the "purchase_price" field in this mutation. -func (m *ItemMutation) AddedPurchasePrice() (r float64, exists bool) { - v := m.addpurchase_price - if v == nil { - return - } - return *v, true -} - -// ResetPurchasePrice resets all changes to the "purchase_price" field. -func (m *ItemMutation) ResetPurchasePrice() { - m.purchase_price = nil - m.addpurchase_price = nil -} - -// SetSoldTime sets the "sold_time" field. -func (m *ItemMutation) SetSoldTime(t time.Time) { - m.sold_time = &t -} - -// SoldTime returns the value of the "sold_time" field in the mutation. -func (m *ItemMutation) SoldTime() (r time.Time, exists bool) { - v := m.sold_time - if v == nil { - return - } - return *v, true -} - -// OldSoldTime returns the old "sold_time" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldSoldTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSoldTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSoldTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSoldTime: %w", err) - } - return oldValue.SoldTime, nil -} - -// ClearSoldTime clears the value of the "sold_time" field. -func (m *ItemMutation) ClearSoldTime() { - m.sold_time = nil - m.clearedFields[item.FieldSoldTime] = struct{}{} -} - -// SoldTimeCleared returns if the "sold_time" field was cleared in this mutation. -func (m *ItemMutation) SoldTimeCleared() bool { - _, ok := m.clearedFields[item.FieldSoldTime] - return ok -} - -// ResetSoldTime resets all changes to the "sold_time" field. -func (m *ItemMutation) ResetSoldTime() { - m.sold_time = nil - delete(m.clearedFields, item.FieldSoldTime) -} - -// SetSoldTo sets the "sold_to" field. -func (m *ItemMutation) SetSoldTo(s string) { - m.sold_to = &s -} - -// SoldTo returns the value of the "sold_to" field in the mutation. -func (m *ItemMutation) SoldTo() (r string, exists bool) { - v := m.sold_to - if v == nil { - return - } - return *v, true -} - -// OldSoldTo returns the old "sold_to" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldSoldTo(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSoldTo is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSoldTo requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSoldTo: %w", err) - } - return oldValue.SoldTo, nil -} - -// ClearSoldTo clears the value of the "sold_to" field. -func (m *ItemMutation) ClearSoldTo() { - m.sold_to = nil - m.clearedFields[item.FieldSoldTo] = struct{}{} -} - -// SoldToCleared returns if the "sold_to" field was cleared in this mutation. -func (m *ItemMutation) SoldToCleared() bool { - _, ok := m.clearedFields[item.FieldSoldTo] - return ok -} - -// ResetSoldTo resets all changes to the "sold_to" field. -func (m *ItemMutation) ResetSoldTo() { - m.sold_to = nil - delete(m.clearedFields, item.FieldSoldTo) -} - -// SetSoldPrice sets the "sold_price" field. -func (m *ItemMutation) SetSoldPrice(f float64) { - m.sold_price = &f - m.addsold_price = nil -} - -// SoldPrice returns the value of the "sold_price" field in the mutation. -func (m *ItemMutation) SoldPrice() (r float64, exists bool) { - v := m.sold_price - if v == nil { - return - } - return *v, true -} - -// OldSoldPrice returns the old "sold_price" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldSoldPrice(ctx context.Context) (v float64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSoldPrice is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSoldPrice requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSoldPrice: %w", err) - } - return oldValue.SoldPrice, nil -} - -// AddSoldPrice adds f to the "sold_price" field. -func (m *ItemMutation) AddSoldPrice(f float64) { - if m.addsold_price != nil { - *m.addsold_price += f - } else { - m.addsold_price = &f - } -} - -// AddedSoldPrice returns the value that was added to the "sold_price" field in this mutation. -func (m *ItemMutation) AddedSoldPrice() (r float64, exists bool) { - v := m.addsold_price - if v == nil { - return - } - return *v, true -} - -// ResetSoldPrice resets all changes to the "sold_price" field. -func (m *ItemMutation) ResetSoldPrice() { - m.sold_price = nil - m.addsold_price = nil -} - -// SetSoldNotes sets the "sold_notes" field. -func (m *ItemMutation) SetSoldNotes(s string) { - m.sold_notes = &s -} - -// SoldNotes returns the value of the "sold_notes" field in the mutation. -func (m *ItemMutation) SoldNotes() (r string, exists bool) { - v := m.sold_notes - if v == nil { - return - } - return *v, true -} - -// OldSoldNotes returns the old "sold_notes" field's value of the Item entity. -// If the Item 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 *ItemMutation) OldSoldNotes(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSoldNotes is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSoldNotes requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSoldNotes: %w", err) - } - return oldValue.SoldNotes, nil -} - -// ClearSoldNotes clears the value of the "sold_notes" field. -func (m *ItemMutation) ClearSoldNotes() { - m.sold_notes = nil - m.clearedFields[item.FieldSoldNotes] = struct{}{} -} - -// SoldNotesCleared returns if the "sold_notes" field was cleared in this mutation. -func (m *ItemMutation) SoldNotesCleared() bool { - _, ok := m.clearedFields[item.FieldSoldNotes] - return ok -} - -// ResetSoldNotes resets all changes to the "sold_notes" field. -func (m *ItemMutation) ResetSoldNotes() { - m.sold_notes = nil - delete(m.clearedFields, item.FieldSoldNotes) -} - -// SetGroupID sets the "group" edge to the Group entity by id. -func (m *ItemMutation) SetGroupID(id uuid.UUID) { - m.group = &id -} - -// ClearGroup clears the "group" edge to the Group entity. -func (m *ItemMutation) ClearGroup() { - m.clearedgroup = true -} - -// GroupCleared reports if the "group" edge to the Group entity was cleared. -func (m *ItemMutation) GroupCleared() bool { - return m.clearedgroup -} - -// GroupID returns the "group" edge ID in the mutation. -func (m *ItemMutation) 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 *ItemMutation) 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 *ItemMutation) ResetGroup() { - m.group = nil - m.clearedgroup = false -} - -// SetParentID sets the "parent" edge to the Item entity by id. -func (m *ItemMutation) SetParentID(id uuid.UUID) { - m.parent = &id -} - -// ClearParent clears the "parent" edge to the Item entity. -func (m *ItemMutation) ClearParent() { - m.clearedparent = true -} - -// ParentCleared reports if the "parent" edge to the Item entity was cleared. -func (m *ItemMutation) ParentCleared() bool { - return m.clearedparent -} - -// ParentID returns the "parent" edge ID in the mutation. -func (m *ItemMutation) 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 *ItemMutation) 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 *ItemMutation) ResetParent() { - m.parent = nil - m.clearedparent = false -} - -// AddChildIDs adds the "children" edge to the Item entity by ids. -func (m *ItemMutation) 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 Item entity. -func (m *ItemMutation) ClearChildren() { - m.clearedchildren = true -} - -// ChildrenCleared reports if the "children" edge to the Item entity was cleared. -func (m *ItemMutation) ChildrenCleared() bool { - return m.clearedchildren -} - -// RemoveChildIDs removes the "children" edge to the Item entity by IDs. -func (m *ItemMutation) 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 Item entity. -func (m *ItemMutation) 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 *ItemMutation) ChildrenIDs() (ids []uuid.UUID) { - for id := range m.children { - ids = append(ids, id) - } - return -} - -// ResetChildren resets all changes to the "children" edge. -func (m *ItemMutation) ResetChildren() { - m.children = nil - m.clearedchildren = false - m.removedchildren = nil -} - -// AddLabelIDs adds the "label" edge to the Label entity by ids. -func (m *ItemMutation) AddLabelIDs(ids ...uuid.UUID) { - if m.label == nil { - m.label = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.label[ids[i]] = struct{}{} - } -} - -// ClearLabel clears the "label" edge to the Label entity. -func (m *ItemMutation) ClearLabel() { - m.clearedlabel = true -} - -// LabelCleared reports if the "label" edge to the Label entity was cleared. -func (m *ItemMutation) LabelCleared() bool { - return m.clearedlabel -} - -// RemoveLabelIDs removes the "label" edge to the Label entity by IDs. -func (m *ItemMutation) RemoveLabelIDs(ids ...uuid.UUID) { - if m.removedlabel == nil { - m.removedlabel = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.label, ids[i]) - m.removedlabel[ids[i]] = struct{}{} - } -} - -// RemovedLabel returns the removed IDs of the "label" edge to the Label entity. -func (m *ItemMutation) RemovedLabelIDs() (ids []uuid.UUID) { - for id := range m.removedlabel { - ids = append(ids, id) - } - return -} - -// LabelIDs returns the "label" edge IDs in the mutation. -func (m *ItemMutation) LabelIDs() (ids []uuid.UUID) { - for id := range m.label { - ids = append(ids, id) - } - return -} - -// ResetLabel resets all changes to the "label" edge. -func (m *ItemMutation) ResetLabel() { - m.label = nil - m.clearedlabel = false - m.removedlabel = nil -} - -// SetLocationID sets the "location" edge to the Location entity by id. -func (m *ItemMutation) SetLocationID(id uuid.UUID) { - m.location = &id -} - -// ClearLocation clears the "location" edge to the Location entity. -func (m *ItemMutation) ClearLocation() { - m.clearedlocation = true -} - -// LocationCleared reports if the "location" edge to the Location entity was cleared. -func (m *ItemMutation) LocationCleared() bool { - return m.clearedlocation -} - -// LocationID returns the "location" edge ID in the mutation. -func (m *ItemMutation) 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 *ItemMutation) 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 *ItemMutation) ResetLocation() { - m.location = nil - m.clearedlocation = false -} - -// AddFieldIDs adds the "fields" edge to the ItemField entity by ids. -func (m *ItemMutation) 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 ItemField entity. -func (m *ItemMutation) ClearFields() { - m.clearedfields = true -} - -// FieldsCleared reports if the "fields" edge to the ItemField entity was cleared. -func (m *ItemMutation) FieldsCleared() bool { - return m.clearedfields -} - -// RemoveFieldIDs removes the "fields" edge to the ItemField entity by IDs. -func (m *ItemMutation) 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 ItemField entity. -func (m *ItemMutation) 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 *ItemMutation) FieldsIDs() (ids []uuid.UUID) { - for id := range m.fields { - ids = append(ids, id) - } - return -} - -// ResetFields resets all changes to the "fields" edge. -func (m *ItemMutation) ResetFields() { - m.fields = nil - m.clearedfields = false - m.removedfields = nil -} - -// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by ids. -func (m *ItemMutation) AddMaintenanceEntryIDs(ids ...uuid.UUID) { - if m.maintenance_entries == nil { - m.maintenance_entries = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.maintenance_entries[ids[i]] = struct{}{} - } -} - -// ClearMaintenanceEntries clears the "maintenance_entries" edge to the MaintenanceEntry entity. -func (m *ItemMutation) ClearMaintenanceEntries() { - m.clearedmaintenance_entries = true -} - -// MaintenanceEntriesCleared reports if the "maintenance_entries" edge to the MaintenanceEntry entity was cleared. -func (m *ItemMutation) MaintenanceEntriesCleared() bool { - return m.clearedmaintenance_entries -} - -// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to the MaintenanceEntry entity by IDs. -func (m *ItemMutation) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) { - if m.removedmaintenance_entries == nil { - m.removedmaintenance_entries = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.maintenance_entries, ids[i]) - m.removedmaintenance_entries[ids[i]] = struct{}{} - } -} - -// RemovedMaintenanceEntries returns the removed IDs of the "maintenance_entries" edge to the MaintenanceEntry entity. -func (m *ItemMutation) RemovedMaintenanceEntriesIDs() (ids []uuid.UUID) { - for id := range m.removedmaintenance_entries { - ids = append(ids, id) - } - return -} - -// MaintenanceEntriesIDs returns the "maintenance_entries" edge IDs in the mutation. -func (m *ItemMutation) MaintenanceEntriesIDs() (ids []uuid.UUID) { - for id := range m.maintenance_entries { - ids = append(ids, id) - } - return -} - -// ResetMaintenanceEntries resets all changes to the "maintenance_entries" edge. -func (m *ItemMutation) ResetMaintenanceEntries() { - m.maintenance_entries = nil - m.clearedmaintenance_entries = false - m.removedmaintenance_entries = nil -} - -// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by ids. -func (m *ItemMutation) AddAttachmentIDs(ids ...uuid.UUID) { - if m.attachments == nil { - m.attachments = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.attachments[ids[i]] = struct{}{} - } -} - -// ClearAttachments clears the "attachments" edge to the Attachment entity. -func (m *ItemMutation) ClearAttachments() { - m.clearedattachments = true -} - -// AttachmentsCleared reports if the "attachments" edge to the Attachment entity was cleared. -func (m *ItemMutation) AttachmentsCleared() bool { - return m.clearedattachments -} - -// RemoveAttachmentIDs removes the "attachments" edge to the Attachment entity by IDs. -func (m *ItemMutation) RemoveAttachmentIDs(ids ...uuid.UUID) { - if m.removedattachments == nil { - m.removedattachments = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.attachments, ids[i]) - m.removedattachments[ids[i]] = struct{}{} - } -} - -// RemovedAttachments returns the removed IDs of the "attachments" edge to the Attachment entity. -func (m *ItemMutation) RemovedAttachmentsIDs() (ids []uuid.UUID) { - for id := range m.removedattachments { - ids = append(ids, id) - } - return -} - -// AttachmentsIDs returns the "attachments" edge IDs in the mutation. -func (m *ItemMutation) AttachmentsIDs() (ids []uuid.UUID) { - for id := range m.attachments { - ids = append(ids, id) - } - return -} - -// ResetAttachments resets all changes to the "attachments" edge. -func (m *ItemMutation) ResetAttachments() { - m.attachments = nil - m.clearedattachments = false - m.removedattachments = nil -} - -// Where appends a list predicates to the ItemMutation builder. -func (m *ItemMutation) Where(ps ...predicate.Item) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the ItemMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ItemMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Item, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *ItemMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *ItemMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Item). -func (m *ItemMutation) 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 *ItemMutation) Fields() []string { - fields := make([]string, 0, 24) - if m.created_at != nil { - fields = append(fields, item.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, item.FieldUpdatedAt) - } - if m.name != nil { - fields = append(fields, item.FieldName) - } - if m.description != nil { - fields = append(fields, item.FieldDescription) - } - if m.import_ref != nil { - fields = append(fields, item.FieldImportRef) - } - if m.notes != nil { - fields = append(fields, item.FieldNotes) - } - if m.quantity != nil { - fields = append(fields, item.FieldQuantity) - } - if m.insured != nil { - fields = append(fields, item.FieldInsured) - } - if m.archived != nil { - fields = append(fields, item.FieldArchived) - } - if m.asset_id != nil { - fields = append(fields, item.FieldAssetID) - } - if m.sync_child_items_locations != nil { - fields = append(fields, item.FieldSyncChildItemsLocations) - } - if m.serial_number != nil { - fields = append(fields, item.FieldSerialNumber) - } - if m.model_number != nil { - fields = append(fields, item.FieldModelNumber) - } - if m.manufacturer != nil { - fields = append(fields, item.FieldManufacturer) - } - if m.lifetime_warranty != nil { - fields = append(fields, item.FieldLifetimeWarranty) - } - if m.warranty_expires != nil { - fields = append(fields, item.FieldWarrantyExpires) - } - if m.warranty_details != nil { - fields = append(fields, item.FieldWarrantyDetails) - } - if m.purchase_time != nil { - fields = append(fields, item.FieldPurchaseTime) - } - if m.purchase_from != nil { - fields = append(fields, item.FieldPurchaseFrom) - } - if m.purchase_price != nil { - fields = append(fields, item.FieldPurchasePrice) - } - if m.sold_time != nil { - fields = append(fields, item.FieldSoldTime) - } - if m.sold_to != nil { - fields = append(fields, item.FieldSoldTo) - } - if m.sold_price != nil { - fields = append(fields, item.FieldSoldPrice) - } - if m.sold_notes != nil { - fields = append(fields, item.FieldSoldNotes) - } - 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 *ItemMutation) Field(name string) (ent.Value, bool) { - switch name { - case item.FieldCreatedAt: - return m.CreatedAt() - case item.FieldUpdatedAt: - return m.UpdatedAt() - case item.FieldName: - return m.Name() - case item.FieldDescription: - return m.Description() - case item.FieldImportRef: - return m.ImportRef() - case item.FieldNotes: - return m.Notes() - case item.FieldQuantity: - return m.Quantity() - case item.FieldInsured: - return m.Insured() - case item.FieldArchived: - return m.Archived() - case item.FieldAssetID: - return m.AssetID() - case item.FieldSyncChildItemsLocations: - return m.SyncChildItemsLocations() - case item.FieldSerialNumber: - return m.SerialNumber() - case item.FieldModelNumber: - return m.ModelNumber() - case item.FieldManufacturer: - return m.Manufacturer() - case item.FieldLifetimeWarranty: - return m.LifetimeWarranty() - case item.FieldWarrantyExpires: - return m.WarrantyExpires() - case item.FieldWarrantyDetails: - return m.WarrantyDetails() - case item.FieldPurchaseTime: - return m.PurchaseTime() - case item.FieldPurchaseFrom: - return m.PurchaseFrom() - case item.FieldPurchasePrice: - return m.PurchasePrice() - case item.FieldSoldTime: - return m.SoldTime() - case item.FieldSoldTo: - return m.SoldTo() - case item.FieldSoldPrice: - return m.SoldPrice() - case item.FieldSoldNotes: - return m.SoldNotes() - } - 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 *ItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case item.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case item.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - case item.FieldName: - return m.OldName(ctx) - case item.FieldDescription: - return m.OldDescription(ctx) - case item.FieldImportRef: - return m.OldImportRef(ctx) - case item.FieldNotes: - return m.OldNotes(ctx) - case item.FieldQuantity: - return m.OldQuantity(ctx) - case item.FieldInsured: - return m.OldInsured(ctx) - case item.FieldArchived: - return m.OldArchived(ctx) - case item.FieldAssetID: - return m.OldAssetID(ctx) - case item.FieldSyncChildItemsLocations: - return m.OldSyncChildItemsLocations(ctx) - case item.FieldSerialNumber: - return m.OldSerialNumber(ctx) - case item.FieldModelNumber: - return m.OldModelNumber(ctx) - case item.FieldManufacturer: - return m.OldManufacturer(ctx) - case item.FieldLifetimeWarranty: - return m.OldLifetimeWarranty(ctx) - case item.FieldWarrantyExpires: - return m.OldWarrantyExpires(ctx) - case item.FieldWarrantyDetails: - return m.OldWarrantyDetails(ctx) - case item.FieldPurchaseTime: - return m.OldPurchaseTime(ctx) - case item.FieldPurchaseFrom: - return m.OldPurchaseFrom(ctx) - case item.FieldPurchasePrice: - return m.OldPurchasePrice(ctx) - case item.FieldSoldTime: - return m.OldSoldTime(ctx) - case item.FieldSoldTo: - return m.OldSoldTo(ctx) - case item.FieldSoldPrice: - return m.OldSoldPrice(ctx) - case item.FieldSoldNotes: - return m.OldSoldNotes(ctx) - } - return nil, fmt.Errorf("unknown Item 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 *ItemMutation) SetField(name string, value ent.Value) error { - switch name { - case item.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 item.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 item.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case item.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case item.FieldImportRef: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetImportRef(v) - return nil - case item.FieldNotes: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNotes(v) - return nil - case item.FieldQuantity: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetQuantity(v) - return nil - case item.FieldInsured: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInsured(v) - return nil - case item.FieldArchived: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetArchived(v) - return nil - case item.FieldAssetID: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAssetID(v) - return nil - case item.FieldSyncChildItemsLocations: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSyncChildItemsLocations(v) - return nil - case item.FieldSerialNumber: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSerialNumber(v) - return nil - case item.FieldModelNumber: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetModelNumber(v) - return nil - case item.FieldManufacturer: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetManufacturer(v) - return nil - case item.FieldLifetimeWarranty: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLifetimeWarranty(v) - return nil - case item.FieldWarrantyExpires: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetWarrantyExpires(v) - return nil - case item.FieldWarrantyDetails: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetWarrantyDetails(v) - return nil - case item.FieldPurchaseTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPurchaseTime(v) - return nil - case item.FieldPurchaseFrom: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPurchaseFrom(v) - return nil - case item.FieldPurchasePrice: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPurchasePrice(v) - return nil - case item.FieldSoldTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSoldTime(v) - return nil - case item.FieldSoldTo: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSoldTo(v) - return nil - case item.FieldSoldPrice: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSoldPrice(v) - return nil - case item.FieldSoldNotes: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSoldNotes(v) - return nil - } - return fmt.Errorf("unknown Item field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *ItemMutation) AddedFields() []string { - var fields []string - if m.addquantity != nil { - fields = append(fields, item.FieldQuantity) - } - if m.addasset_id != nil { - fields = append(fields, item.FieldAssetID) - } - if m.addpurchase_price != nil { - fields = append(fields, item.FieldPurchasePrice) - } - if m.addsold_price != nil { - fields = append(fields, item.FieldSoldPrice) - } - 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 *ItemMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case item.FieldQuantity: - return m.AddedQuantity() - case item.FieldAssetID: - return m.AddedAssetID() - case item.FieldPurchasePrice: - return m.AddedPurchasePrice() - case item.FieldSoldPrice: - return m.AddedSoldPrice() - } - 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 *ItemMutation) AddField(name string, value ent.Value) error { - switch name { - case item.FieldQuantity: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddQuantity(v) - return nil - case item.FieldAssetID: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddAssetID(v) - return nil - case item.FieldPurchasePrice: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddPurchasePrice(v) - return nil - case item.FieldSoldPrice: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSoldPrice(v) - return nil - } - return fmt.Errorf("unknown Item numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *ItemMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(item.FieldDescription) { - fields = append(fields, item.FieldDescription) - } - if m.FieldCleared(item.FieldImportRef) { - fields = append(fields, item.FieldImportRef) - } - if m.FieldCleared(item.FieldNotes) { - fields = append(fields, item.FieldNotes) - } - if m.FieldCleared(item.FieldSerialNumber) { - fields = append(fields, item.FieldSerialNumber) - } - if m.FieldCleared(item.FieldModelNumber) { - fields = append(fields, item.FieldModelNumber) - } - if m.FieldCleared(item.FieldManufacturer) { - fields = append(fields, item.FieldManufacturer) - } - if m.FieldCleared(item.FieldWarrantyExpires) { - fields = append(fields, item.FieldWarrantyExpires) - } - if m.FieldCleared(item.FieldWarrantyDetails) { - fields = append(fields, item.FieldWarrantyDetails) - } - if m.FieldCleared(item.FieldPurchaseTime) { - fields = append(fields, item.FieldPurchaseTime) - } - if m.FieldCleared(item.FieldPurchaseFrom) { - fields = append(fields, item.FieldPurchaseFrom) - } - if m.FieldCleared(item.FieldSoldTime) { - fields = append(fields, item.FieldSoldTime) - } - if m.FieldCleared(item.FieldSoldTo) { - fields = append(fields, item.FieldSoldTo) - } - if m.FieldCleared(item.FieldSoldNotes) { - fields = append(fields, item.FieldSoldNotes) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *ItemMutation) 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 *ItemMutation) ClearField(name string) error { - switch name { - case item.FieldDescription: - m.ClearDescription() - return nil - case item.FieldImportRef: - m.ClearImportRef() - return nil - case item.FieldNotes: - m.ClearNotes() - return nil - case item.FieldSerialNumber: - m.ClearSerialNumber() - return nil - case item.FieldModelNumber: - m.ClearModelNumber() - return nil - case item.FieldManufacturer: - m.ClearManufacturer() - return nil - case item.FieldWarrantyExpires: - m.ClearWarrantyExpires() - return nil - case item.FieldWarrantyDetails: - m.ClearWarrantyDetails() - return nil - case item.FieldPurchaseTime: - m.ClearPurchaseTime() - return nil - case item.FieldPurchaseFrom: - m.ClearPurchaseFrom() - return nil - case item.FieldSoldTime: - m.ClearSoldTime() - return nil - case item.FieldSoldTo: - m.ClearSoldTo() - return nil - case item.FieldSoldNotes: - m.ClearSoldNotes() - return nil - } - return fmt.Errorf("unknown Item 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 *ItemMutation) ResetField(name string) error { - switch name { - case item.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case item.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - case item.FieldName: - m.ResetName() - return nil - case item.FieldDescription: - m.ResetDescription() - return nil - case item.FieldImportRef: - m.ResetImportRef() - return nil - case item.FieldNotes: - m.ResetNotes() - return nil - case item.FieldQuantity: - m.ResetQuantity() - return nil - case item.FieldInsured: - m.ResetInsured() - return nil - case item.FieldArchived: - m.ResetArchived() - return nil - case item.FieldAssetID: - m.ResetAssetID() - return nil - case item.FieldSyncChildItemsLocations: - m.ResetSyncChildItemsLocations() - return nil - case item.FieldSerialNumber: - m.ResetSerialNumber() - return nil - case item.FieldModelNumber: - m.ResetModelNumber() - return nil - case item.FieldManufacturer: - m.ResetManufacturer() - return nil - case item.FieldLifetimeWarranty: - m.ResetLifetimeWarranty() - return nil - case item.FieldWarrantyExpires: - m.ResetWarrantyExpires() - return nil - case item.FieldWarrantyDetails: - m.ResetWarrantyDetails() - return nil - case item.FieldPurchaseTime: - m.ResetPurchaseTime() - return nil - case item.FieldPurchaseFrom: - m.ResetPurchaseFrom() - return nil - case item.FieldPurchasePrice: - m.ResetPurchasePrice() - return nil - case item.FieldSoldTime: - m.ResetSoldTime() - return nil - case item.FieldSoldTo: - m.ResetSoldTo() - return nil - case item.FieldSoldPrice: - m.ResetSoldPrice() - return nil - case item.FieldSoldNotes: - m.ResetSoldNotes() - return nil - } - return fmt.Errorf("unknown Item field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *ItemMutation) AddedEdges() []string { - edges := make([]string, 0, 8) - if m.group != nil { - edges = append(edges, item.EdgeGroup) - } - if m.parent != nil { - edges = append(edges, item.EdgeParent) - } - if m.children != nil { - edges = append(edges, item.EdgeChildren) - } - if m.label != nil { - edges = append(edges, item.EdgeLabel) - } - if m.location != nil { - edges = append(edges, item.EdgeLocation) - } - if m.fields != nil { - edges = append(edges, item.EdgeFields) - } - if m.maintenance_entries != nil { - edges = append(edges, item.EdgeMaintenanceEntries) - } - if m.attachments != nil { - edges = append(edges, item.EdgeAttachments) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *ItemMutation) AddedIDs(name string) []ent.Value { - switch name { - case item.EdgeGroup: - if id := m.group; id != nil { - return []ent.Value{*id} - } - case item.EdgeParent: - if id := m.parent; id != nil { - return []ent.Value{*id} - } - case item.EdgeChildren: - ids := make([]ent.Value, 0, len(m.children)) - for id := range m.children { - ids = append(ids, id) - } - return ids - case item.EdgeLabel: - ids := make([]ent.Value, 0, len(m.label)) - for id := range m.label { - ids = append(ids, id) - } - return ids - case item.EdgeLocation: - if id := m.location; id != nil { - return []ent.Value{*id} - } - case item.EdgeFields: - ids := make([]ent.Value, 0, len(m.fields)) - for id := range m.fields { - ids = append(ids, id) - } - return ids - case item.EdgeMaintenanceEntries: - ids := make([]ent.Value, 0, len(m.maintenance_entries)) - for id := range m.maintenance_entries { - ids = append(ids, id) - } - return ids - case item.EdgeAttachments: - ids := make([]ent.Value, 0, len(m.attachments)) - for id := range m.attachments { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *ItemMutation) RemovedEdges() []string { - edges := make([]string, 0, 8) - if m.removedchildren != nil { - edges = append(edges, item.EdgeChildren) - } - if m.removedlabel != nil { - edges = append(edges, item.EdgeLabel) - } - if m.removedfields != nil { - edges = append(edges, item.EdgeFields) - } - if m.removedmaintenance_entries != nil { - edges = append(edges, item.EdgeMaintenanceEntries) - } - if m.removedattachments != nil { - edges = append(edges, item.EdgeAttachments) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *ItemMutation) RemovedIDs(name string) []ent.Value { - switch name { - case item.EdgeChildren: - ids := make([]ent.Value, 0, len(m.removedchildren)) - for id := range m.removedchildren { - ids = append(ids, id) - } - return ids - case item.EdgeLabel: - ids := make([]ent.Value, 0, len(m.removedlabel)) - for id := range m.removedlabel { - ids = append(ids, id) - } - return ids - case item.EdgeFields: - ids := make([]ent.Value, 0, len(m.removedfields)) - for id := range m.removedfields { - ids = append(ids, id) - } - return ids - case item.EdgeMaintenanceEntries: - ids := make([]ent.Value, 0, len(m.removedmaintenance_entries)) - for id := range m.removedmaintenance_entries { - ids = append(ids, id) - } - return ids - case item.EdgeAttachments: - ids := make([]ent.Value, 0, len(m.removedattachments)) - for id := range m.removedattachments { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ItemMutation) ClearedEdges() []string { - edges := make([]string, 0, 8) - if m.clearedgroup { - edges = append(edges, item.EdgeGroup) - } - if m.clearedparent { - edges = append(edges, item.EdgeParent) - } - if m.clearedchildren { - edges = append(edges, item.EdgeChildren) - } - if m.clearedlabel { - edges = append(edges, item.EdgeLabel) - } - if m.clearedlocation { - edges = append(edges, item.EdgeLocation) - } - if m.clearedfields { - edges = append(edges, item.EdgeFields) - } - if m.clearedmaintenance_entries { - edges = append(edges, item.EdgeMaintenanceEntries) - } - if m.clearedattachments { - edges = append(edges, item.EdgeAttachments) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *ItemMutation) EdgeCleared(name string) bool { - switch name { - case item.EdgeGroup: - return m.clearedgroup - case item.EdgeParent: - return m.clearedparent - case item.EdgeChildren: - return m.clearedchildren - case item.EdgeLabel: - return m.clearedlabel - case item.EdgeLocation: - return m.clearedlocation - case item.EdgeFields: - return m.clearedfields - case item.EdgeMaintenanceEntries: - return m.clearedmaintenance_entries - case item.EdgeAttachments: - return m.clearedattachments - } - 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 *ItemMutation) ClearEdge(name string) error { - switch name { - case item.EdgeGroup: - m.ClearGroup() - return nil - case item.EdgeParent: - m.ClearParent() - return nil - case item.EdgeLocation: - m.ClearLocation() - return nil - } - return fmt.Errorf("unknown Item 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 *ItemMutation) ResetEdge(name string) error { - switch name { - case item.EdgeGroup: - m.ResetGroup() - return nil - case item.EdgeParent: - m.ResetParent() - return nil - case item.EdgeChildren: - m.ResetChildren() - return nil - case item.EdgeLabel: - m.ResetLabel() - return nil - case item.EdgeLocation: - m.ResetLocation() - return nil - case item.EdgeFields: - m.ResetFields() - return nil - case item.EdgeMaintenanceEntries: - m.ResetMaintenanceEntries() - return nil - case item.EdgeAttachments: - m.ResetAttachments() - return nil - } - return fmt.Errorf("unknown Item edge %s", name) -} - -// ItemFieldMutation represents an operation that mutates the ItemField nodes in the graph. -type ItemFieldMutation struct { - config - op Op - typ string - id *uuid.UUID - created_at *time.Time - updated_at *time.Time - name *string - description *string - _type *itemfield.Type - text_value *string - number_value *int - addnumber_value *int - boolean_value *bool - time_value *time.Time - clearedFields map[string]struct{} - item *uuid.UUID - cleareditem bool - done bool - oldValue func(context.Context) (*ItemField, error) - predicates []predicate.ItemField -} - -var _ ent.Mutation = (*ItemFieldMutation)(nil) - -// itemfieldOption allows management of the mutation configuration using functional options. -type itemfieldOption func(*ItemFieldMutation) - -// newItemFieldMutation creates new mutation for the ItemField entity. -func newItemFieldMutation(c config, op Op, opts ...itemfieldOption) *ItemFieldMutation { - m := &ItemFieldMutation{ - config: c, - op: op, - typ: TypeItemField, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withItemFieldID sets the ID field of the mutation. -func withItemFieldID(id uuid.UUID) itemfieldOption { - return func(m *ItemFieldMutation) { - var ( - err error - once sync.Once - value *ItemField - ) - m.oldValue = func(ctx context.Context) (*ItemField, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().ItemField.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withItemField sets the old ItemField of the mutation. -func withItemField(node *ItemField) itemfieldOption { - return func(m *ItemFieldMutation) { - m.oldValue = func(context.Context) (*ItemField, 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 ItemFieldMutation) 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 ItemFieldMutation) 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 ItemField entities. -func (m *ItemFieldMutation) 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 *ItemFieldMutation) 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 *ItemFieldMutation) 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().ItemField.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 *ItemFieldMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ItemFieldMutation) 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 ItemField entity. -// If the ItemField 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 *ItemFieldMutation) 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 *ItemFieldMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *ItemFieldMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *ItemFieldMutation) 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 ItemField entity. -// If the ItemField 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 *ItemFieldMutation) 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 *ItemFieldMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetName sets the "name" field. -func (m *ItemFieldMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *ItemFieldMutation) 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 ItemField entity. -// If the ItemField 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 *ItemFieldMutation) 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 *ItemFieldMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *ItemFieldMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *ItemFieldMutation) 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 ItemField entity. -// If the ItemField 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 *ItemFieldMutation) 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 *ItemFieldMutation) ClearDescription() { - m.description = nil - m.clearedFields[itemfield.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *ItemFieldMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[itemfield.FieldDescription] - return ok -} - -// ResetDescription resets all changes to the "description" field. -func (m *ItemFieldMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, itemfield.FieldDescription) -} - -// SetType sets the "type" field. -func (m *ItemFieldMutation) SetType(i itemfield.Type) { - m._type = &i -} - -// GetType returns the value of the "type" field in the mutation. -func (m *ItemFieldMutation) GetType() (r itemfield.Type, exists bool) { - v := m._type - if v == nil { - return - } - return *v, true -} - -// OldType returns the old "type" field's value of the ItemField entity. -// If the ItemField 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 *ItemFieldMutation) OldType(ctx context.Context) (v itemfield.Type, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - 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 OldType: %w", err) - } - return oldValue.Type, nil -} - -// ResetType resets all changes to the "type" field. -func (m *ItemFieldMutation) ResetType() { - m._type = nil -} - -// SetTextValue sets the "text_value" field. -func (m *ItemFieldMutation) SetTextValue(s string) { - m.text_value = &s -} - -// TextValue returns the value of the "text_value" field in the mutation. -func (m *ItemFieldMutation) TextValue() (r string, exists bool) { - v := m.text_value - if v == nil { - return - } - return *v, true -} - -// OldTextValue returns the old "text_value" field's value of the ItemField entity. -// If the ItemField 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 *ItemFieldMutation) OldTextValue(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTextValue is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - 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 OldTextValue: %w", err) - } - return oldValue.TextValue, nil -} - -// ClearTextValue clears the value of the "text_value" field. -func (m *ItemFieldMutation) ClearTextValue() { - m.text_value = nil - m.clearedFields[itemfield.FieldTextValue] = struct{}{} -} - -// TextValueCleared returns if the "text_value" field was cleared in this mutation. -func (m *ItemFieldMutation) TextValueCleared() bool { - _, ok := m.clearedFields[itemfield.FieldTextValue] - return ok -} - -// ResetTextValue resets all changes to the "text_value" field. -func (m *ItemFieldMutation) ResetTextValue() { - m.text_value = nil - delete(m.clearedFields, itemfield.FieldTextValue) -} - -// SetNumberValue sets the "number_value" field. -func (m *ItemFieldMutation) SetNumberValue(i int) { - m.number_value = &i - m.addnumber_value = nil -} - -// NumberValue returns the value of the "number_value" field in the mutation. -func (m *ItemFieldMutation) NumberValue() (r int, exists bool) { - v := m.number_value - if v == nil { - return - } - return *v, true -} - -// OldNumberValue returns the old "number_value" field's value of the ItemField entity. -// If the ItemField 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 *ItemFieldMutation) OldNumberValue(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNumberValue is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNumberValue requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldNumberValue: %w", err) - } - return oldValue.NumberValue, nil -} - -// AddNumberValue adds i to the "number_value" field. -func (m *ItemFieldMutation) AddNumberValue(i int) { - if m.addnumber_value != nil { - *m.addnumber_value += i - } else { - m.addnumber_value = &i - } -} - -// AddedNumberValue returns the value that was added to the "number_value" field in this mutation. -func (m *ItemFieldMutation) AddedNumberValue() (r int, exists bool) { - v := m.addnumber_value - if v == nil { - return - } - return *v, true -} - -// ClearNumberValue clears the value of the "number_value" field. -func (m *ItemFieldMutation) ClearNumberValue() { - m.number_value = nil - m.addnumber_value = nil - m.clearedFields[itemfield.FieldNumberValue] = struct{}{} -} - -// NumberValueCleared returns if the "number_value" field was cleared in this mutation. -func (m *ItemFieldMutation) NumberValueCleared() bool { - _, ok := m.clearedFields[itemfield.FieldNumberValue] - return ok -} - -// ResetNumberValue resets all changes to the "number_value" field. -func (m *ItemFieldMutation) ResetNumberValue() { - m.number_value = nil - m.addnumber_value = nil - delete(m.clearedFields, itemfield.FieldNumberValue) -} - -// SetBooleanValue sets the "boolean_value" field. -func (m *ItemFieldMutation) SetBooleanValue(b bool) { - m.boolean_value = &b -} - -// BooleanValue returns the value of the "boolean_value" field in the mutation. -func (m *ItemFieldMutation) BooleanValue() (r bool, exists bool) { - v := m.boolean_value - if v == nil { - return - } - return *v, true -} - -// OldBooleanValue returns the old "boolean_value" field's value of the ItemField entity. -// If the ItemField 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 *ItemFieldMutation) OldBooleanValue(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBooleanValue is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBooleanValue requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldBooleanValue: %w", err) - } - return oldValue.BooleanValue, nil -} - -// ResetBooleanValue resets all changes to the "boolean_value" field. -func (m *ItemFieldMutation) ResetBooleanValue() { - m.boolean_value = nil -} - -// SetTimeValue sets the "time_value" field. -func (m *ItemFieldMutation) SetTimeValue(t time.Time) { - m.time_value = &t -} - -// TimeValue returns the value of the "time_value" field in the mutation. -func (m *ItemFieldMutation) TimeValue() (r time.Time, exists bool) { - v := m.time_value - if v == nil { - return - } - return *v, true -} - -// OldTimeValue returns the old "time_value" field's value of the ItemField entity. -// If the ItemField 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 *ItemFieldMutation) OldTimeValue(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTimeValue is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTimeValue requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTimeValue: %w", err) - } - return oldValue.TimeValue, nil -} - -// ResetTimeValue resets all changes to the "time_value" field. -func (m *ItemFieldMutation) ResetTimeValue() { - m.time_value = nil -} - -// SetItemID sets the "item" edge to the Item entity by id. -func (m *ItemFieldMutation) SetItemID(id uuid.UUID) { - m.item = &id -} - -// ClearItem clears the "item" edge to the Item entity. -func (m *ItemFieldMutation) ClearItem() { - m.cleareditem = true -} - -// ItemCleared reports if the "item" edge to the Item entity was cleared. -func (m *ItemFieldMutation) ItemCleared() bool { - return m.cleareditem -} - -// ItemID returns the "item" edge ID in the mutation. -func (m *ItemFieldMutation) ItemID() (id uuid.UUID, exists bool) { - if m.item != nil { - return *m.item, true - } - return -} - -// 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 *ItemFieldMutation) ItemIDs() (ids []uuid.UUID) { - if id := m.item; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetItem resets all changes to the "item" edge. -func (m *ItemFieldMutation) ResetItem() { - m.item = nil - m.cleareditem = false -} - -// Where appends a list predicates to the ItemFieldMutation builder. -func (m *ItemFieldMutation) Where(ps ...predicate.ItemField) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the ItemFieldMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ItemFieldMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ItemField, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *ItemFieldMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *ItemFieldMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (ItemField). -func (m *ItemFieldMutation) 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 *ItemFieldMutation) Fields() []string { - fields := make([]string, 0, 9) - if m.created_at != nil { - fields = append(fields, itemfield.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, itemfield.FieldUpdatedAt) - } - if m.name != nil { - fields = append(fields, itemfield.FieldName) - } - if m.description != nil { - fields = append(fields, itemfield.FieldDescription) - } - if m._type != nil { - fields = append(fields, itemfield.FieldType) - } - if m.text_value != nil { - fields = append(fields, itemfield.FieldTextValue) - } - if m.number_value != nil { - fields = append(fields, itemfield.FieldNumberValue) - } - if m.boolean_value != nil { - fields = append(fields, itemfield.FieldBooleanValue) - } - if m.time_value != nil { - fields = append(fields, itemfield.FieldTimeValue) - } - 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 *ItemFieldMutation) Field(name string) (ent.Value, bool) { - switch name { - case itemfield.FieldCreatedAt: - return m.CreatedAt() - case itemfield.FieldUpdatedAt: - return m.UpdatedAt() - case itemfield.FieldName: - return m.Name() - case itemfield.FieldDescription: - return m.Description() - case itemfield.FieldType: - return m.GetType() - case itemfield.FieldTextValue: - return m.TextValue() - case itemfield.FieldNumberValue: - return m.NumberValue() - case itemfield.FieldBooleanValue: - return m.BooleanValue() - case itemfield.FieldTimeValue: - return m.TimeValue() - } - 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 *ItemFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case itemfield.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case itemfield.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - case itemfield.FieldName: - return m.OldName(ctx) - case itemfield.FieldDescription: - return m.OldDescription(ctx) - case itemfield.FieldType: - return m.OldType(ctx) - case itemfield.FieldTextValue: - return m.OldTextValue(ctx) - case itemfield.FieldNumberValue: - return m.OldNumberValue(ctx) - case itemfield.FieldBooleanValue: - return m.OldBooleanValue(ctx) - case itemfield.FieldTimeValue: - return m.OldTimeValue(ctx) - } - return nil, fmt.Errorf("unknown ItemField 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 *ItemFieldMutation) SetField(name string, value ent.Value) error { - switch name { - case itemfield.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 itemfield.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 itemfield.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case itemfield.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case itemfield.FieldType: - v, ok := value.(itemfield.Type) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case itemfield.FieldTextValue: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTextValue(v) - return nil - case itemfield.FieldNumberValue: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNumberValue(v) - return nil - case itemfield.FieldBooleanValue: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBooleanValue(v) - return nil - case itemfield.FieldTimeValue: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTimeValue(v) - return nil - } - return fmt.Errorf("unknown ItemField field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *ItemFieldMutation) AddedFields() []string { - var fields []string - if m.addnumber_value != nil { - fields = append(fields, itemfield.FieldNumberValue) - } - 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 *ItemFieldMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case itemfield.FieldNumberValue: - return m.AddedNumberValue() - } - 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 *ItemFieldMutation) AddField(name string, value ent.Value) error { - switch name { - case itemfield.FieldNumberValue: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddNumberValue(v) - return nil - } - return fmt.Errorf("unknown ItemField numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *ItemFieldMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(itemfield.FieldDescription) { - fields = append(fields, itemfield.FieldDescription) - } - if m.FieldCleared(itemfield.FieldTextValue) { - fields = append(fields, itemfield.FieldTextValue) - } - if m.FieldCleared(itemfield.FieldNumberValue) { - fields = append(fields, itemfield.FieldNumberValue) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *ItemFieldMutation) 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 *ItemFieldMutation) ClearField(name string) error { - switch name { - case itemfield.FieldDescription: - m.ClearDescription() - return nil - case itemfield.FieldTextValue: - m.ClearTextValue() - return nil - case itemfield.FieldNumberValue: - m.ClearNumberValue() - return nil - } - return fmt.Errorf("unknown ItemField 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 *ItemFieldMutation) ResetField(name string) error { - switch name { - case itemfield.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case itemfield.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - case itemfield.FieldName: - m.ResetName() - return nil - case itemfield.FieldDescription: - m.ResetDescription() - return nil - case itemfield.FieldType: - m.ResetType() - return nil - case itemfield.FieldTextValue: - m.ResetTextValue() - return nil - case itemfield.FieldNumberValue: - m.ResetNumberValue() - return nil - case itemfield.FieldBooleanValue: - m.ResetBooleanValue() - return nil - case itemfield.FieldTimeValue: - m.ResetTimeValue() - return nil - } - return fmt.Errorf("unknown ItemField field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *ItemFieldMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.item != nil { - edges = append(edges, itemfield.EdgeItem) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *ItemFieldMutation) AddedIDs(name string) []ent.Value { - switch name { - case itemfield.EdgeItem: - if id := m.item; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *ItemFieldMutation) 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 *ItemFieldMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ItemFieldMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.cleareditem { - edges = append(edges, itemfield.EdgeItem) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *ItemFieldMutation) EdgeCleared(name string) bool { - switch name { - case itemfield.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 *ItemFieldMutation) ClearEdge(name string) error { - switch name { - case itemfield.EdgeItem: - m.ClearItem() - return nil - } - return fmt.Errorf("unknown ItemField 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 *ItemFieldMutation) ResetEdge(name string) error { - switch name { - case itemfield.EdgeItem: - m.ResetItem() - return nil - } - return fmt.Errorf("unknown ItemField edge %s", name) -} - // ItemTemplateMutation represents an operation that mutates the ItemTemplate nodes in the graph. type ItemTemplateMutation struct { config @@ -8061,17 +9071,17 @@ func (m *ItemTemplateMutation) ResetFields() { m.removedfields = nil } -// SetLocationID sets the "location" edge to the Location entity by id. +// SetLocationID sets the "location" edge to the Entity entity by id. func (m *ItemTemplateMutation) SetLocationID(id uuid.UUID) { m.location = &id } -// ClearLocation clears the "location" edge to the Location entity. +// ClearLocation clears the "location" edge to the Entity entity. func (m *ItemTemplateMutation) ClearLocation() { m.clearedlocation = true } -// LocationCleared reports if the "location" edge to the Location entity was cleared. +// LocationCleared reports if the "location" edge to the Entity entity was cleared. func (m *ItemTemplateMutation) LocationCleared() bool { return m.clearedlocation } @@ -8692,23 +9702,23 @@ func (m *ItemTemplateMutation) ResetEdge(name string) error { // 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 + 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 + entities map[uuid.UUID]struct{} + removedentities map[uuid.UUID]struct{} + clearedentities bool + done bool + oldValue func(context.Context) (*Label, error) + predicates []predicate.Label } var _ ent.Mutation = (*LabelMutation)(nil) @@ -9060,58 +10070,58 @@ func (m *LabelMutation) ResetGroup() { 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{}) +// AddEntityIDs adds the "entities" edge to the Entity entity by ids. +func (m *LabelMutation) AddEntityIDs(ids ...uuid.UUID) { + if m.entities == nil { + m.entities = make(map[uuid.UUID]struct{}) } for i := range ids { - m.items[ids[i]] = struct{}{} + m.entities[ids[i]] = struct{}{} } } -// ClearItems clears the "items" edge to the Item entity. -func (m *LabelMutation) ClearItems() { - m.cleareditems = true +// ClearEntities clears the "entities" edge to the Entity entity. +func (m *LabelMutation) ClearEntities() { + m.clearedentities = true } -// ItemsCleared reports if the "items" edge to the Item entity was cleared. -func (m *LabelMutation) ItemsCleared() bool { - return m.cleareditems +// EntitiesCleared reports if the "entities" edge to the Entity entity was cleared. +func (m *LabelMutation) EntitiesCleared() bool { + return m.clearedentities } -// 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{}) +// RemoveEntityIDs removes the "entities" edge to the Entity entity by IDs. +func (m *LabelMutation) RemoveEntityIDs(ids ...uuid.UUID) { + if m.removedentities == nil { + m.removedentities = make(map[uuid.UUID]struct{}) } for i := range ids { - delete(m.items, ids[i]) - m.removeditems[ids[i]] = struct{}{} + delete(m.entities, ids[i]) + m.removedentities[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 { +// RemovedEntities returns the removed IDs of the "entities" edge to the Entity entity. +func (m *LabelMutation) RemovedEntitiesIDs() (ids []uuid.UUID) { + for id := range m.removedentities { 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 { +// EntitiesIDs returns the "entities" edge IDs in the mutation. +func (m *LabelMutation) EntitiesIDs() (ids []uuid.UUID) { + for id := range m.entities { 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 +// ResetEntities resets all changes to the "entities" edge. +func (m *LabelMutation) ResetEntities() { + m.entities = nil + m.clearedentities = false + m.removedentities = nil } // Where appends a list predicates to the LabelMutation builder. @@ -9334,8 +10344,8 @@ func (m *LabelMutation) AddedEdges() []string { if m.group != nil { edges = append(edges, label.EdgeGroup) } - if m.items != nil { - edges = append(edges, label.EdgeItems) + if m.entities != nil { + edges = append(edges, label.EdgeEntities) } return edges } @@ -9348,9 +10358,9 @@ func (m *LabelMutation) AddedIDs(name string) []ent.Value { 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 { + case label.EdgeEntities: + ids := make([]ent.Value, 0, len(m.entities)) + for id := range m.entities { ids = append(ids, id) } return ids @@ -9361,8 +10371,8 @@ 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) - if m.removeditems != nil { - edges = append(edges, label.EdgeItems) + if m.removedentities != nil { + edges = append(edges, label.EdgeEntities) } return edges } @@ -9371,9 +10381,9 @@ func (m *LabelMutation) RemovedEdges() []string { // 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 { + case label.EdgeEntities: + ids := make([]ent.Value, 0, len(m.removedentities)) + for id := range m.removedentities { ids = append(ids, id) } return ids @@ -9387,8 +10397,8 @@ func (m *LabelMutation) ClearedEdges() []string { if m.clearedgroup { edges = append(edges, label.EdgeGroup) } - if m.cleareditems { - edges = append(edges, label.EdgeItems) + if m.clearedentities { + edges = append(edges, label.EdgeEntities) } return edges } @@ -9399,8 +10409,8 @@ func (m *LabelMutation) EdgeCleared(name string) bool { switch name { case label.EdgeGroup: return m.clearedgroup - case label.EdgeItems: - return m.cleareditems + case label.EdgeEntities: + return m.clearedentities } return false } @@ -9423,823 +10433,13 @@ func (m *LabelMutation) ResetEdge(name string) error { case label.EdgeGroup: m.ResetGroup() return nil - case label.EdgeItems: - m.ResetItems() + case label.EdgeEntities: + m.ResetEntities() 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 *LocationMutation) SetOp(op Op) { - m.op = op -} - -// 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 *LocationMutation) Fields() []string { - fields := make([]string, 0, 4) - if m.created_at != nil { - fields = append(fields, location.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, location.FieldUpdatedAt) - } - if m.name != nil { - fields = append(fields, location.FieldName) - } - if m.description != nil { - fields = append(fields, location.FieldDescription) - } - 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 *LocationMutation) Field(name string) (ent.Value, bool) { - switch name { - case location.FieldCreatedAt: - return m.CreatedAt() - case location.FieldUpdatedAt: - return m.UpdatedAt() - case location.FieldName: - return m.Name() - case location.FieldDescription: - return m.Description() - } - 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 *LocationMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case location.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case location.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - case location.FieldName: - return m.OldName(ctx) - case location.FieldDescription: - return m.OldDescription(ctx) - } - 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 *LocationMutation) SetField(name string, value ent.Value) error { - switch name { - 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 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 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 location.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - } - return fmt.Errorf("unknown Location field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -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 *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 *LocationMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown Location numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *LocationMutation) ClearedFields() []string { - var fields []string - 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 *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 *LocationMutation) ClearField(name string) error { - switch name { - case location.FieldDescription: - m.ClearDescription() - return nil - } - 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 *LocationMutation) ResetField(name string) error { - switch name { - case location.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case location.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - case location.FieldName: - m.ResetName() - return nil - case location.FieldDescription: - m.ResetDescription() - return nil - } - return fmt.Errorf("unknown Location 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) - } - 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 { - switch name { - case location.EdgeGroup: - if id := m.group; id != nil { - return []ent.Value{*id} - } - 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) - } - 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) - } - 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 - } - 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) - } - 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 { - 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 - } - 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 { - switch name { - case location.EdgeGroup: - m.ClearGroup() - return nil - case location.EdgeParent: - m.ClearParent() - return nil - } - 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 *LocationMutation) 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() - return nil - } - return fmt.Errorf("unknown Location edge %s", name) -} - // MaintenanceEntryMutation represents an operation that mutates the MaintenanceEntry nodes in the graph. type MaintenanceEntryMutation struct { config @@ -10255,8 +10455,8 @@ type MaintenanceEntryMutation struct { cost *float64 addcost *float64 clearedFields map[string]struct{} - item *uuid.UUID - cleareditem bool + entity *uuid.UUID + clearedentity bool done bool oldValue func(context.Context) (*MaintenanceEntry, error) predicates []predicate.MaintenanceEntry @@ -10438,40 +10638,40 @@ func (m *MaintenanceEntryMutation) ResetUpdatedAt() { m.updated_at = nil } -// SetItemID sets the "item_id" field. -func (m *MaintenanceEntryMutation) SetItemID(u uuid.UUID) { - m.item = &u +// SetEntityID sets the "entity_id" field. +func (m *MaintenanceEntryMutation) SetEntityID(u uuid.UUID) { + m.entity = &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 +// EntityID returns the value of the "entity_id" field in the mutation. +func (m *MaintenanceEntryMutation) EntityID() (r uuid.UUID, exists bool) { + v := m.entity if v == nil { return } return *v, true } -// OldItemID returns the old "item_id" field's value of the MaintenanceEntry entity. +// OldEntityID returns the old "entity_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) { +func (m *MaintenanceEntryMutation) OldEntityID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldItemID is only allowed on UpdateOne operations") + return v, errors.New("OldEntityID 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") + return v, errors.New("OldEntityID 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 v, fmt.Errorf("querying old value for OldEntityID: %w", err) } - return oldValue.ItemID, nil + return oldValue.EntityID, nil } -// ResetItemID resets all changes to the "item_id" field. -func (m *MaintenanceEntryMutation) ResetItemID() { - m.item = nil +// ResetEntityID resets all changes to the "entity_id" field. +func (m *MaintenanceEntryMutation) ResetEntityID() { + m.entity = nil } // SetDate sets the "date" field. @@ -10713,31 +10913,31 @@ func (m *MaintenanceEntryMutation) ResetCost() { m.addcost = nil } -// ClearItem clears the "item" edge to the Item entity. -func (m *MaintenanceEntryMutation) ClearItem() { - m.cleareditem = true - m.clearedFields[maintenanceentry.FieldItemID] = struct{}{} +// ClearEntity clears the "entity" edge to the Entity entity. +func (m *MaintenanceEntryMutation) ClearEntity() { + m.clearedentity = true + m.clearedFields[maintenanceentry.FieldEntityID] = struct{}{} } -// ItemCleared reports if the "item" edge to the Item entity was cleared. -func (m *MaintenanceEntryMutation) ItemCleared() bool { - return m.cleareditem +// EntityCleared reports if the "entity" edge to the Entity entity was cleared. +func (m *MaintenanceEntryMutation) EntityCleared() bool { + return m.clearedentity } -// ItemIDs returns the "item" edge IDs in the mutation. +// EntityIDs returns the "entity" 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 { +// EntityID instead. It exists only for internal usage by the builders. +func (m *MaintenanceEntryMutation) EntityIDs() (ids []uuid.UUID) { + if id := m.entity; 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 +// ResetEntity resets all changes to the "entity" edge. +func (m *MaintenanceEntryMutation) ResetEntity() { + m.entity = nil + m.clearedentity = false } // Where appends a list predicates to the MaintenanceEntryMutation builder. @@ -10781,8 +10981,8 @@ func (m *MaintenanceEntryMutation) Fields() []string { if m.updated_at != nil { fields = append(fields, maintenanceentry.FieldUpdatedAt) } - if m.item != nil { - fields = append(fields, maintenanceentry.FieldItemID) + if m.entity != nil { + fields = append(fields, maintenanceentry.FieldEntityID) } if m.date != nil { fields = append(fields, maintenanceentry.FieldDate) @@ -10811,8 +11011,8 @@ func (m *MaintenanceEntryMutation) Field(name string) (ent.Value, bool) { return m.CreatedAt() case maintenanceentry.FieldUpdatedAt: return m.UpdatedAt() - case maintenanceentry.FieldItemID: - return m.ItemID() + case maintenanceentry.FieldEntityID: + return m.EntityID() case maintenanceentry.FieldDate: return m.Date() case maintenanceentry.FieldScheduledDate: @@ -10836,8 +11036,8 @@ func (m *MaintenanceEntryMutation) OldField(ctx context.Context, name string) (e return m.OldCreatedAt(ctx) case maintenanceentry.FieldUpdatedAt: return m.OldUpdatedAt(ctx) - case maintenanceentry.FieldItemID: - return m.OldItemID(ctx) + case maintenanceentry.FieldEntityID: + return m.OldEntityID(ctx) case maintenanceentry.FieldDate: return m.OldDate(ctx) case maintenanceentry.FieldScheduledDate: @@ -10871,12 +11071,12 @@ func (m *MaintenanceEntryMutation) SetField(name string, value ent.Value) error } m.SetUpdatedAt(v) return nil - case maintenanceentry.FieldItemID: + case maintenanceentry.FieldEntityID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetItemID(v) + m.SetEntityID(v) return nil case maintenanceentry.FieldDate: v, ok := value.(time.Time) @@ -11004,8 +11204,8 @@ func (m *MaintenanceEntryMutation) ResetField(name string) error { case maintenanceentry.FieldUpdatedAt: m.ResetUpdatedAt() return nil - case maintenanceentry.FieldItemID: - m.ResetItemID() + case maintenanceentry.FieldEntityID: + m.ResetEntityID() return nil case maintenanceentry.FieldDate: m.ResetDate() @@ -11029,8 +11229,8 @@ func (m *MaintenanceEntryMutation) ResetField(name string) error { // 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) + if m.entity != nil { + edges = append(edges, maintenanceentry.EdgeEntity) } return edges } @@ -11039,8 +11239,8 @@ func (m *MaintenanceEntryMutation) AddedEdges() []string { // name in this mutation. func (m *MaintenanceEntryMutation) AddedIDs(name string) []ent.Value { switch name { - case maintenanceentry.EdgeItem: - if id := m.item; id != nil { + case maintenanceentry.EdgeEntity: + if id := m.entity; id != nil { return []ent.Value{*id} } } @@ -11062,8 +11262,8 @@ func (m *MaintenanceEntryMutation) RemovedIDs(name string) []ent.Value { // 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) + if m.clearedentity { + edges = append(edges, maintenanceentry.EdgeEntity) } return edges } @@ -11072,8 +11272,8 @@ func (m *MaintenanceEntryMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *MaintenanceEntryMutation) EdgeCleared(name string) bool { switch name { - case maintenanceentry.EdgeItem: - return m.cleareditem + case maintenanceentry.EdgeEntity: + return m.clearedentity } return false } @@ -11082,8 +11282,8 @@ func (m *MaintenanceEntryMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *MaintenanceEntryMutation) ClearEdge(name string) error { switch name { - case maintenanceentry.EdgeItem: - m.ClearItem() + case maintenanceentry.EdgeEntity: + m.ClearEntity() return nil } return fmt.Errorf("unknown MaintenanceEntry unique edge %s", name) @@ -11093,8 +11293,8 @@ func (m *MaintenanceEntryMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *MaintenanceEntryMutation) ResetEdge(name string) error { switch name { - case maintenanceentry.EdgeItem: - m.ResetItem() + case maintenanceentry.EdgeEntity: + m.ResetEntity() return nil } return fmt.Errorf("unknown MaintenanceEntry edge %s", name) diff --git a/backend/internal/data/ent/predicate/predicate.go b/backend/internal/data/ent/predicate/predicate.go index 0d9d47f5..53d00ead 100644 --- a/backend/internal/data/ent/predicate/predicate.go +++ b/backend/internal/data/ent/predicate/predicate.go @@ -15,27 +15,27 @@ type AuthRoles func(*sql.Selector) // AuthTokens is the predicate function for authtokens builders. type AuthTokens func(*sql.Selector) +// Entity is the predicate function for entity builders. +type Entity func(*sql.Selector) + +// EntityField is the predicate function for entityfield builders. +type EntityField func(*sql.Selector) + +// EntityType is the predicate function for entitytype builders. +type EntityType func(*sql.Selector) + // Group is the predicate function for group builders. type Group func(*sql.Selector) // GroupInvitationToken is the predicate function for groupinvitationtoken builders. type GroupInvitationToken func(*sql.Selector) -// Item is the predicate function for item builders. -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) -// Location is the predicate function for location builders. -type Location func(*sql.Selector) - // MaintenanceEntry is the predicate function for maintenanceentry builders. type MaintenanceEntry func(*sql.Selector) diff --git a/backend/internal/data/ent/runtime.go b/backend/internal/data/ent/runtime.go index 0476c5c6..88ecc90b 100644 --- a/backend/internal/data/ent/runtime.go +++ b/backend/internal/data/ent/runtime.go @@ -8,13 +8,13 @@ import ( "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "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/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" @@ -86,6 +86,219 @@ func init() { authtokensDescID := authtokensMixinFields0[0].Descriptor() // authtokens.DefaultID holds the default value on creation for the id field. authtokens.DefaultID = authtokensDescID.Default.(func() uuid.UUID) + entityMixin := schema.Entity{}.Mixin() + entityMixinFields0 := entityMixin[0].Fields() + _ = entityMixinFields0 + entityMixinFields1 := entityMixin[1].Fields() + _ = entityMixinFields1 + entityFields := schema.Entity{}.Fields() + _ = entityFields + // entityDescCreatedAt is the schema descriptor for created_at field. + entityDescCreatedAt := entityMixinFields0[1].Descriptor() + // entity.DefaultCreatedAt holds the default value on creation for the created_at field. + entity.DefaultCreatedAt = entityDescCreatedAt.Default.(func() time.Time) + // entityDescUpdatedAt is the schema descriptor for updated_at field. + entityDescUpdatedAt := entityMixinFields0[2].Descriptor() + // entity.DefaultUpdatedAt holds the default value on creation for the updated_at field. + entity.DefaultUpdatedAt = entityDescUpdatedAt.Default.(func() time.Time) + // entity.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + entity.UpdateDefaultUpdatedAt = entityDescUpdatedAt.UpdateDefault.(func() time.Time) + // entityDescName is the schema descriptor for name field. + entityDescName := entityMixinFields1[0].Descriptor() + // entity.NameValidator is a validator for the "name" field. It is called by the builders before save. + entity.NameValidator = func() func(string) error { + validators := entityDescName.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 + } + }() + // entityDescDescription is the schema descriptor for description field. + entityDescDescription := entityMixinFields1[1].Descriptor() + // entity.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + entity.DescriptionValidator = entityDescDescription.Validators[0].(func(string) error) + // entityDescImportRef is the schema descriptor for import_ref field. + entityDescImportRef := entityFields[0].Descriptor() + // entity.ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save. + entity.ImportRefValidator = entityDescImportRef.Validators[0].(func(string) error) + // entityDescNotes is the schema descriptor for notes field. + entityDescNotes := entityFields[1].Descriptor() + // entity.NotesValidator is a validator for the "notes" field. It is called by the builders before save. + entity.NotesValidator = entityDescNotes.Validators[0].(func(string) error) + // entityDescQuantity is the schema descriptor for quantity field. + entityDescQuantity := entityFields[2].Descriptor() + // entity.DefaultQuantity holds the default value on creation for the quantity field. + entity.DefaultQuantity = entityDescQuantity.Default.(int) + // entityDescInsured is the schema descriptor for insured field. + entityDescInsured := entityFields[3].Descriptor() + // entity.DefaultInsured holds the default value on creation for the insured field. + entity.DefaultInsured = entityDescInsured.Default.(bool) + // entityDescArchived is the schema descriptor for archived field. + entityDescArchived := entityFields[4].Descriptor() + // entity.DefaultArchived holds the default value on creation for the archived field. + entity.DefaultArchived = entityDescArchived.Default.(bool) + // entityDescAssetID is the schema descriptor for asset_id field. + entityDescAssetID := entityFields[5].Descriptor() + // entity.DefaultAssetID holds the default value on creation for the asset_id field. + entity.DefaultAssetID = entityDescAssetID.Default.(int) + // entityDescSyncChildEntitiesLocations is the schema descriptor for sync_child_entities_locations field. + entityDescSyncChildEntitiesLocations := entityFields[6].Descriptor() + // entity.DefaultSyncChildEntitiesLocations holds the default value on creation for the sync_child_entities_locations field. + entity.DefaultSyncChildEntitiesLocations = entityDescSyncChildEntitiesLocations.Default.(bool) + // entityDescSerialNumber is the schema descriptor for serial_number field. + entityDescSerialNumber := entityFields[7].Descriptor() + // entity.SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save. + entity.SerialNumberValidator = entityDescSerialNumber.Validators[0].(func(string) error) + // entityDescModelNumber is the schema descriptor for model_number field. + entityDescModelNumber := entityFields[8].Descriptor() + // entity.ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save. + entity.ModelNumberValidator = entityDescModelNumber.Validators[0].(func(string) error) + // entityDescManufacturer is the schema descriptor for manufacturer field. + entityDescManufacturer := entityFields[9].Descriptor() + // entity.ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save. + entity.ManufacturerValidator = entityDescManufacturer.Validators[0].(func(string) error) + // entityDescLifetimeWarranty is the schema descriptor for lifetime_warranty field. + entityDescLifetimeWarranty := entityFields[10].Descriptor() + // entity.DefaultLifetimeWarranty holds the default value on creation for the lifetime_warranty field. + entity.DefaultLifetimeWarranty = entityDescLifetimeWarranty.Default.(bool) + // entityDescWarrantyDetails is the schema descriptor for warranty_details field. + entityDescWarrantyDetails := entityFields[12].Descriptor() + // entity.WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save. + entity.WarrantyDetailsValidator = entityDescWarrantyDetails.Validators[0].(func(string) error) + // entityDescPurchasePrice is the schema descriptor for purchase_price field. + entityDescPurchasePrice := entityFields[15].Descriptor() + // entity.DefaultPurchasePrice holds the default value on creation for the purchase_price field. + entity.DefaultPurchasePrice = entityDescPurchasePrice.Default.(float64) + // entityDescSoldPrice is the schema descriptor for sold_price field. + entityDescSoldPrice := entityFields[18].Descriptor() + // entity.DefaultSoldPrice holds the default value on creation for the sold_price field. + entity.DefaultSoldPrice = entityDescSoldPrice.Default.(float64) + // entityDescSoldNotes is the schema descriptor for sold_notes field. + entityDescSoldNotes := entityFields[19].Descriptor() + // entity.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save. + entity.SoldNotesValidator = entityDescSoldNotes.Validators[0].(func(string) error) + // entityDescID is the schema descriptor for id field. + entityDescID := entityMixinFields0[0].Descriptor() + // entity.DefaultID holds the default value on creation for the id field. + entity.DefaultID = entityDescID.Default.(func() uuid.UUID) + entityfieldMixin := schema.EntityField{}.Mixin() + entityfieldMixinFields0 := entityfieldMixin[0].Fields() + _ = entityfieldMixinFields0 + entityfieldMixinFields1 := entityfieldMixin[1].Fields() + _ = entityfieldMixinFields1 + entityfieldFields := schema.EntityField{}.Fields() + _ = entityfieldFields + // entityfieldDescCreatedAt is the schema descriptor for created_at field. + entityfieldDescCreatedAt := entityfieldMixinFields0[1].Descriptor() + // entityfield.DefaultCreatedAt holds the default value on creation for the created_at field. + entityfield.DefaultCreatedAt = entityfieldDescCreatedAt.Default.(func() time.Time) + // entityfieldDescUpdatedAt is the schema descriptor for updated_at field. + entityfieldDescUpdatedAt := entityfieldMixinFields0[2].Descriptor() + // entityfield.DefaultUpdatedAt holds the default value on creation for the updated_at field. + entityfield.DefaultUpdatedAt = entityfieldDescUpdatedAt.Default.(func() time.Time) + // entityfield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + entityfield.UpdateDefaultUpdatedAt = entityfieldDescUpdatedAt.UpdateDefault.(func() time.Time) + // entityfieldDescName is the schema descriptor for name field. + entityfieldDescName := entityfieldMixinFields1[0].Descriptor() + // entityfield.NameValidator is a validator for the "name" field. It is called by the builders before save. + entityfield.NameValidator = func() func(string) error { + validators := entityfieldDescName.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 + } + }() + // entityfieldDescDescription is the schema descriptor for description field. + entityfieldDescDescription := entityfieldMixinFields1[1].Descriptor() + // entityfield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + entityfield.DescriptionValidator = entityfieldDescDescription.Validators[0].(func(string) error) + // entityfieldDescTextValue is the schema descriptor for text_value field. + entityfieldDescTextValue := entityfieldFields[1].Descriptor() + // entityfield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save. + entityfield.TextValueValidator = entityfieldDescTextValue.Validators[0].(func(string) error) + // entityfieldDescBooleanValue is the schema descriptor for boolean_value field. + entityfieldDescBooleanValue := entityfieldFields[3].Descriptor() + // entityfield.DefaultBooleanValue holds the default value on creation for the boolean_value field. + entityfield.DefaultBooleanValue = entityfieldDescBooleanValue.Default.(bool) + // entityfieldDescTimeValue is the schema descriptor for time_value field. + entityfieldDescTimeValue := entityfieldFields[4].Descriptor() + // entityfield.DefaultTimeValue holds the default value on creation for the time_value field. + entityfield.DefaultTimeValue = entityfieldDescTimeValue.Default.(func() time.Time) + // entityfieldDescID is the schema descriptor for id field. + entityfieldDescID := entityfieldMixinFields0[0].Descriptor() + // entityfield.DefaultID holds the default value on creation for the id field. + entityfield.DefaultID = entityfieldDescID.Default.(func() uuid.UUID) + entitytypeMixin := schema.EntityType{}.Mixin() + entitytypeMixinFields0 := entitytypeMixin[0].Fields() + _ = entitytypeMixinFields0 + entitytypeMixinFields1 := entitytypeMixin[1].Fields() + _ = entitytypeMixinFields1 + entitytypeFields := schema.EntityType{}.Fields() + _ = entitytypeFields + // entitytypeDescCreatedAt is the schema descriptor for created_at field. + entitytypeDescCreatedAt := entitytypeMixinFields0[1].Descriptor() + // entitytype.DefaultCreatedAt holds the default value on creation for the created_at field. + entitytype.DefaultCreatedAt = entitytypeDescCreatedAt.Default.(func() time.Time) + // entitytypeDescUpdatedAt is the schema descriptor for updated_at field. + entitytypeDescUpdatedAt := entitytypeMixinFields0[2].Descriptor() + // entitytype.DefaultUpdatedAt holds the default value on creation for the updated_at field. + entitytype.DefaultUpdatedAt = entitytypeDescUpdatedAt.Default.(func() time.Time) + // entitytype.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + entitytype.UpdateDefaultUpdatedAt = entitytypeDescUpdatedAt.UpdateDefault.(func() time.Time) + // entitytypeDescName is the schema descriptor for name field. + entitytypeDescName := entitytypeMixinFields1[0].Descriptor() + // entitytype.NameValidator is a validator for the "name" field. It is called by the builders before save. + entitytype.NameValidator = func() func(string) error { + validators := entitytypeDescName.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 + } + }() + // entitytypeDescDescription is the schema descriptor for description field. + entitytypeDescDescription := entitytypeMixinFields1[1].Descriptor() + // entitytype.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + entitytype.DescriptionValidator = entitytypeDescDescription.Validators[0].(func(string) error) + // entitytypeDescIcon is the schema descriptor for icon field. + entitytypeDescIcon := entitytypeFields[0].Descriptor() + // entitytype.IconValidator is a validator for the "icon" field. It is called by the builders before save. + entitytype.IconValidator = entitytypeDescIcon.Validators[0].(func(string) error) + // entitytypeDescColor is the schema descriptor for color field. + entitytypeDescColor := entitytypeFields[1].Descriptor() + // entitytype.ColorValidator is a validator for the "color" field. It is called by the builders before save. + entitytype.ColorValidator = entitytypeDescColor.Validators[0].(func(string) error) + // entitytypeDescIsLocation is the schema descriptor for is_location field. + entitytypeDescIsLocation := entitytypeFields[2].Descriptor() + // entitytype.DefaultIsLocation holds the default value on creation for the is_location field. + entitytype.DefaultIsLocation = entitytypeDescIsLocation.Default.(bool) + // entitytypeDescID is the schema descriptor for id field. + entitytypeDescID := entitytypeMixinFields0[0].Descriptor() + // entitytype.DefaultID holds the default value on creation for the id field. + entitytype.DefaultID = entitytypeDescID.Default.(func() uuid.UUID) groupMixin := schema.Group{}.Mixin() groupMixinFields0 := groupMixin[0].Fields() _ = groupMixinFields0 @@ -154,164 +367,6 @@ func init() { groupinvitationtokenDescID := groupinvitationtokenMixinFields0[0].Descriptor() // groupinvitationtoken.DefaultID holds the default value on creation for the id field. groupinvitationtoken.DefaultID = groupinvitationtokenDescID.Default.(func() uuid.UUID) - itemMixin := schema.Item{}.Mixin() - itemMixinFields0 := itemMixin[0].Fields() - _ = itemMixinFields0 - itemMixinFields1 := itemMixin[1].Fields() - _ = itemMixinFields1 - itemFields := schema.Item{}.Fields() - _ = itemFields - // itemDescCreatedAt is the schema descriptor for created_at field. - itemDescCreatedAt := itemMixinFields0[1].Descriptor() - // item.DefaultCreatedAt holds the default value on creation for the created_at field. - item.DefaultCreatedAt = itemDescCreatedAt.Default.(func() time.Time) - // itemDescUpdatedAt is the schema descriptor for updated_at field. - itemDescUpdatedAt := itemMixinFields0[2].Descriptor() - // item.DefaultUpdatedAt holds the default value on creation for the updated_at field. - item.DefaultUpdatedAt = itemDescUpdatedAt.Default.(func() time.Time) - // item.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. - item.UpdateDefaultUpdatedAt = itemDescUpdatedAt.UpdateDefault.(func() time.Time) - // itemDescName is the schema descriptor for name field. - itemDescName := itemMixinFields1[0].Descriptor() - // item.NameValidator is a validator for the "name" field. It is called by the builders before save. - item.NameValidator = func() func(string) error { - validators := itemDescName.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 - } - }() - // itemDescDescription is the schema descriptor for description field. - itemDescDescription := itemMixinFields1[1].Descriptor() - // item.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - item.DescriptionValidator = itemDescDescription.Validators[0].(func(string) error) - // itemDescImportRef is the schema descriptor for import_ref field. - itemDescImportRef := itemFields[0].Descriptor() - // item.ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save. - item.ImportRefValidator = itemDescImportRef.Validators[0].(func(string) error) - // itemDescNotes is the schema descriptor for notes field. - itemDescNotes := itemFields[1].Descriptor() - // item.NotesValidator is a validator for the "notes" field. It is called by the builders before save. - item.NotesValidator = itemDescNotes.Validators[0].(func(string) error) - // itemDescQuantity is the schema descriptor for quantity field. - itemDescQuantity := itemFields[2].Descriptor() - // item.DefaultQuantity holds the default value on creation for the quantity field. - item.DefaultQuantity = itemDescQuantity.Default.(int) - // itemDescInsured is the schema descriptor for insured field. - itemDescInsured := itemFields[3].Descriptor() - // item.DefaultInsured holds the default value on creation for the insured field. - item.DefaultInsured = itemDescInsured.Default.(bool) - // itemDescArchived is the schema descriptor for archived field. - itemDescArchived := itemFields[4].Descriptor() - // item.DefaultArchived holds the default value on creation for the archived field. - item.DefaultArchived = itemDescArchived.Default.(bool) - // itemDescAssetID is the schema descriptor for asset_id field. - itemDescAssetID := itemFields[5].Descriptor() - // item.DefaultAssetID holds the default value on creation for the asset_id field. - item.DefaultAssetID = itemDescAssetID.Default.(int) - // itemDescSyncChildItemsLocations is the schema descriptor for sync_child_items_locations field. - itemDescSyncChildItemsLocations := itemFields[6].Descriptor() - // item.DefaultSyncChildItemsLocations holds the default value on creation for the sync_child_items_locations field. - item.DefaultSyncChildItemsLocations = itemDescSyncChildItemsLocations.Default.(bool) - // itemDescSerialNumber is the schema descriptor for serial_number field. - itemDescSerialNumber := itemFields[7].Descriptor() - // item.SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save. - item.SerialNumberValidator = itemDescSerialNumber.Validators[0].(func(string) error) - // itemDescModelNumber is the schema descriptor for model_number field. - itemDescModelNumber := itemFields[8].Descriptor() - // item.ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save. - item.ModelNumberValidator = itemDescModelNumber.Validators[0].(func(string) error) - // itemDescManufacturer is the schema descriptor for manufacturer field. - itemDescManufacturer := itemFields[9].Descriptor() - // item.ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save. - item.ManufacturerValidator = itemDescManufacturer.Validators[0].(func(string) error) - // itemDescLifetimeWarranty is the schema descriptor for lifetime_warranty field. - itemDescLifetimeWarranty := itemFields[10].Descriptor() - // item.DefaultLifetimeWarranty holds the default value on creation for the lifetime_warranty field. - item.DefaultLifetimeWarranty = itemDescLifetimeWarranty.Default.(bool) - // itemDescWarrantyDetails is the schema descriptor for warranty_details field. - itemDescWarrantyDetails := itemFields[12].Descriptor() - // item.WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save. - item.WarrantyDetailsValidator = itemDescWarrantyDetails.Validators[0].(func(string) error) - // itemDescPurchasePrice is the schema descriptor for purchase_price field. - itemDescPurchasePrice := itemFields[15].Descriptor() - // item.DefaultPurchasePrice holds the default value on creation for the purchase_price field. - item.DefaultPurchasePrice = itemDescPurchasePrice.Default.(float64) - // itemDescSoldPrice is the schema descriptor for sold_price field. - itemDescSoldPrice := itemFields[18].Descriptor() - // item.DefaultSoldPrice holds the default value on creation for the sold_price field. - item.DefaultSoldPrice = itemDescSoldPrice.Default.(float64) - // itemDescSoldNotes is the schema descriptor for sold_notes field. - itemDescSoldNotes := itemFields[19].Descriptor() - // item.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save. - item.SoldNotesValidator = itemDescSoldNotes.Validators[0].(func(string) error) - // itemDescID is the schema descriptor for id field. - itemDescID := itemMixinFields0[0].Descriptor() - // item.DefaultID holds the default value on creation for the id field. - item.DefaultID = itemDescID.Default.(func() uuid.UUID) - itemfieldMixin := schema.ItemField{}.Mixin() - itemfieldMixinFields0 := itemfieldMixin[0].Fields() - _ = itemfieldMixinFields0 - itemfieldMixinFields1 := itemfieldMixin[1].Fields() - _ = itemfieldMixinFields1 - itemfieldFields := schema.ItemField{}.Fields() - _ = itemfieldFields - // itemfieldDescCreatedAt is the schema descriptor for created_at field. - itemfieldDescCreatedAt := itemfieldMixinFields0[1].Descriptor() - // itemfield.DefaultCreatedAt holds the default value on creation for the created_at field. - itemfield.DefaultCreatedAt = itemfieldDescCreatedAt.Default.(func() time.Time) - // itemfieldDescUpdatedAt is the schema descriptor for updated_at field. - itemfieldDescUpdatedAt := itemfieldMixinFields0[2].Descriptor() - // itemfield.DefaultUpdatedAt holds the default value on creation for the updated_at field. - itemfield.DefaultUpdatedAt = itemfieldDescUpdatedAt.Default.(func() time.Time) - // itemfield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. - itemfield.UpdateDefaultUpdatedAt = itemfieldDescUpdatedAt.UpdateDefault.(func() time.Time) - // itemfieldDescName is the schema descriptor for name field. - itemfieldDescName := itemfieldMixinFields1[0].Descriptor() - // itemfield.NameValidator is a validator for the "name" field. It is called by the builders before save. - itemfield.NameValidator = func() func(string) error { - validators := itemfieldDescName.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 - } - }() - // itemfieldDescDescription is the schema descriptor for description field. - itemfieldDescDescription := itemfieldMixinFields1[1].Descriptor() - // itemfield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - itemfield.DescriptionValidator = itemfieldDescDescription.Validators[0].(func(string) error) - // itemfieldDescTextValue is the schema descriptor for text_value field. - itemfieldDescTextValue := itemfieldFields[1].Descriptor() - // itemfield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save. - itemfield.TextValueValidator = itemfieldDescTextValue.Validators[0].(func(string) error) - // itemfieldDescBooleanValue is the schema descriptor for boolean_value field. - itemfieldDescBooleanValue := itemfieldFields[3].Descriptor() - // itemfield.DefaultBooleanValue holds the default value on creation for the boolean_value field. - itemfield.DefaultBooleanValue = itemfieldDescBooleanValue.Default.(bool) - // itemfieldDescTimeValue is the schema descriptor for time_value field. - itemfieldDescTimeValue := itemfieldFields[4].Descriptor() - // itemfield.DefaultTimeValue holds the default value on creation for the time_value field. - itemfield.DefaultTimeValue = itemfieldDescTimeValue.Default.(func() time.Time) - // itemfieldDescID is the schema descriptor for id field. - 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 @@ -450,49 +505,6 @@ func init() { labelDescID := labelMixinFields0[0].Descriptor() // label.DefaultID holds the default value on creation for the id field. label.DefaultID = labelDescID.Default.(func() uuid.UUID) - locationMixin := schema.Location{}.Mixin() - locationMixinFields0 := locationMixin[0].Fields() - _ = locationMixinFields0 - locationMixinFields1 := locationMixin[1].Fields() - _ = locationMixinFields1 - locationFields := schema.Location{}.Fields() - _ = locationFields - // locationDescCreatedAt is the schema descriptor for created_at field. - locationDescCreatedAt := locationMixinFields0[1].Descriptor() - // location.DefaultCreatedAt holds the default value on creation for the created_at field. - location.DefaultCreatedAt = locationDescCreatedAt.Default.(func() time.Time) - // locationDescUpdatedAt is the schema descriptor for updated_at field. - locationDescUpdatedAt := locationMixinFields0[2].Descriptor() - // location.DefaultUpdatedAt holds the default value on creation for the updated_at field. - location.DefaultUpdatedAt = locationDescUpdatedAt.Default.(func() time.Time) - // location.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. - location.UpdateDefaultUpdatedAt = locationDescUpdatedAt.UpdateDefault.(func() time.Time) - // locationDescName is the schema descriptor for name field. - locationDescName := locationMixinFields1[0].Descriptor() - // location.NameValidator is a validator for the "name" field. It is called by the builders before save. - location.NameValidator = func() func(string) error { - validators := locationDescName.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 - } - }() - // locationDescDescription is the schema descriptor for description field. - locationDescDescription := locationMixinFields1[1].Descriptor() - // location.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - location.DescriptionValidator = locationDescDescription.Validators[0].(func(string) error) - // locationDescID is the schema descriptor for id field. - locationDescID := locationMixinFields0[0].Descriptor() - // location.DefaultID holds the default value on creation for the id field. - location.DefaultID = locationDescID.Default.(func() uuid.UUID) maintenanceentryMixin := schema.MaintenanceEntry{}.Mixin() maintenanceentryMixinFields0 := maintenanceentryMixin[0].Fields() _ = maintenanceentryMixinFields0 diff --git a/backend/internal/data/ent/schema/group.go b/backend/internal/data/ent/schema/group.go index 2ba5ba7a..a35addce 100644 --- a/backend/internal/data/ent/schema/group.go +++ b/backend/internal/data/ent/schema/group.go @@ -43,8 +43,7 @@ func (Group) Edges() []ent.Edge { return []ent.Edge{ owned("users", User.Type), - owned("locations", Location.Type), - owned("items", Item.Type), + owned("entities", Entity.Type), owned("labels", Label.Type), owned("invitation_tokens", GroupInvitationToken.Type), owned("notifiers", Notifier.Type), diff --git a/backend/internal/data/ent/schema/item_template.go b/backend/internal/data/ent/schema/item_template.go index bb86170a..8e539ad6 100644 --- a/backend/internal/data/ent/schema/item_template.go +++ b/backend/internal/data/ent/schema/item_template.go @@ -105,7 +105,7 @@ func (ItemTemplate) Edges() []ent.Edge { return []ent.Edge{ owned("fields", TemplateField.Type), // Default location for items created from this template - edge.To("location", Location.Type). + edge.To("location", Entity.Type). Unique(), } } diff --git a/backend/internal/data/ent/tx.go b/backend/internal/data/ent/tx.go index f8561a0b..c1a2c1af 100644 --- a/backend/internal/data/ent/tx.go +++ b/backend/internal/data/ent/tx.go @@ -18,20 +18,20 @@ type Tx struct { AuthRoles *AuthRolesClient // AuthTokens is the client for interacting with the AuthTokens builders. AuthTokens *AuthTokensClient + // Entity is the client for interacting with the Entity builders. + Entity *EntityClient + // EntityField is the client for interacting with the EntityField builders. + EntityField *EntityFieldClient + // EntityType is the client for interacting with the EntityType builders. + EntityType *EntityTypeClient // Group is the client for interacting with the Group builders. Group *GroupClient // GroupInvitationToken is the client for interacting with the GroupInvitationToken builders. GroupInvitationToken *GroupInvitationTokenClient - // Item is the client for interacting with the Item builders. - 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. - Location *LocationClient // MaintenanceEntry is the client for interacting with the MaintenanceEntry builders. MaintenanceEntry *MaintenanceEntryClient // Notifier is the client for interacting with the Notifier builders. @@ -174,13 +174,13 @@ func (tx *Tx) init() { tx.Attachment = NewAttachmentClient(tx.config) tx.AuthRoles = NewAuthRolesClient(tx.config) tx.AuthTokens = NewAuthTokensClient(tx.config) + tx.Entity = NewEntityClient(tx.config) + tx.EntityField = NewEntityFieldClient(tx.config) + tx.EntityType = NewEntityTypeClient(tx.config) tx.Group = NewGroupClient(tx.config) 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) diff --git a/docs/en/api/openapi-3.0.json b/docs/en/api/openapi-3.0.json index a80a6124..de365553 100644 --- a/docs/en/api/openapi-3.0.json +++ b/docs/en/api/openapi-3.0.json @@ -196,6 +196,456 @@ } } }, + "/v1/entities/{id}/attachments": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Create Item Attachment", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/postV1Entities_id_attachments" + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemOut" + } + } + } + }, + "422": { + "description": "Unprocessable Entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/validate.ErrorResponse" + } + } + } + } + } + } + }, + "/v1/entities/{id}/attachments/{attachment_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Get Item Attachment", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/v1.ItemAttachmentToken" + } + } + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Update Item Attachment", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/repo.EntityAttachmentUpdate" + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/repo.ItemOut" + } + } + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Delete Item Attachment", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/entities/{id}/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Get Maintenance Log", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query", + "schema": { + "type": "string", + "enum": [ + "scheduled", + "completed", + "both" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.MaintenanceEntryWithDetails" + } + } + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Create Maintenance Entry", + "parameters": [ + { + "description": "Item ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/repo.MaintenanceEntryCreate" + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.MaintenanceEntry" + } + } + } + } + } + } + }, + "/v1/entitytype": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Query All Entity Types", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.EntityType" + } + } + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Create Entity Type", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityTypeCreate" + } + } + }, + "description": "Entity Type Data", + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityType" + } + } + } + } + } + } + }, + "/v1/entitytype/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Get One Entity Type", + "parameters": [ + { + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityType" + } + } + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Update Entity Type", + "parameters": [ + { + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityTypeUpdate" + } + } + }, + "description": "Entity Type Data", + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityType" + } + } + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Delete Entity Type", + "parameters": [ + { + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityTypeDelete" + } + } + }, + "description": "Entity Type Delete Options", + "required": true + }, + "responses": { + "204": { + "description": "No Content" + } + } + } + }, "/v1/groups": { "get": { "security": [ @@ -425,7 +875,8 @@ "tags": [ "Items" ], - "summary": "Query All Items", + "summary": "(Deprecated) Query All Items", + "deprecated": true, "parameters": [ { "description": "search string", @@ -511,6 +962,7 @@ "Items" ], "summary": "Create Item", + "deprecated": true, "requestBody": { "content": { "application/json": { @@ -546,7 +998,8 @@ "tags": [ "Items" ], - "summary": "Export Items", + "summary": "(Deprecated) Export Items", + "deprecated": true, "responses": { "200": { "description": "text/csv", @@ -571,7 +1024,8 @@ "tags": [ "Items" ], - "summary": "Get All Custom Field Names", + "summary": "(Deprecated) Get All Custom Field Names", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -599,7 +1053,8 @@ "tags": [ "Items" ], - "summary": "Get All Custom Field Values", + "summary": "(Deprecated) Get All Custom Field Values", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -627,7 +1082,8 @@ "tags": [ "Items" ], - "summary": "Import Items", + "summary": "(Deprecated) Import Items", + "deprecated": true, "requestBody": { "content": { "multipart/form-data": { @@ -665,7 +1121,8 @@ "tags": [ "Items" ], - "summary": "Get Item", + "summary": "(Deprecated) Get Item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -699,7 +1156,8 @@ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -744,7 +1202,8 @@ "tags": [ "Items" ], - "summary": "Delete Item", + "summary": "(Deprecated) Delete Item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -771,7 +1230,8 @@ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -819,6 +1279,7 @@ "Items Attachments" ], "summary": "Create Item Attachment", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -831,37 +1292,7 @@ } ], "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "file": { - "description": "File attachment", - "type": "string", - "format": "binary" - }, - "type": { - "description": "Type of file", - "type": "string" - }, - "primary": { - "description": "Is this the primary attachment", - "type": "boolean" - }, - "name": { - "description": "name of the file including extension", - "type": "string" - } - }, - "required": [ - "file", - "name" - ] - } - } - }, - "required": true + "$ref": "#/components/requestBodies/postV1Entities_id_attachments" }, "responses": { "200": { @@ -898,6 +1329,7 @@ "Items Attachments" ], "summary": "Get Item Attachment", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -941,6 +1373,7 @@ "Items Attachments" ], "summary": "Update Item Attachment", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -962,15 +1395,7 @@ } ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.ItemAttachmentUpdate" - } - } - }, - "description": "Attachment Update", - "required": true + "$ref": "#/components/requestBodies/repo.EntityAttachmentUpdate" }, "responses": { "200": { @@ -995,6 +1420,7 @@ "Items Attachments" ], "summary": "Delete Item Attachment", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1080,6 +1506,7 @@ "Item Maintenance" ], "summary": "Get Maintenance Log", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1134,6 +1561,7 @@ "Item Maintenance" ], "summary": "Create Maintenance Entry", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1146,15 +1574,7 @@ } ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.MaintenanceEntryCreate" - } - } - }, - "description": "Entry Data", - "required": true + "$ref": "#/components/requestBodies/repo.MaintenanceEntryCreate" }, "responses": { "201": { @@ -1180,7 +1600,8 @@ "tags": [ "Items" ], - "summary": "Get the full path of an item", + "summary": "(Deprecated) Get the full path of an item", + "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1510,7 +1931,8 @@ "tags": [ "Locations" ], - "summary": "Get All Locations", + "summary": "(Deprecated) Get All Locations", + "deprecated": true, "parameters": [ { "description": "Filter locations with parents", @@ -1546,7 +1968,8 @@ "tags": [ "Locations" ], - "summary": "Create Location", + "summary": "(Deprecated) Create Location", + "deprecated": true, "requestBody": { "content": { "application/json": { @@ -1582,7 +2005,8 @@ "tags": [ "Locations" ], - "summary": "Get Locations Tree", + "summary": "(Deprecated) Get Locations Tree", + "deprecated": true, "parameters": [ { "description": "include items in response tree", @@ -1620,7 +2044,8 @@ "tags": [ "Locations" ], - "summary": "Get Location", + "summary": "(Deprecated) Get Location", + "deprecated": true, "parameters": [ { "description": "Location ID", @@ -1654,7 +2079,8 @@ "tags": [ "Locations" ], - "summary": "Update Location", + "summary": "(Deprecated) Update Location", + "deprecated": true, "parameters": [ { "description": "Location ID", @@ -1699,7 +2125,8 @@ "tags": [ "Locations" ], - "summary": "Delete Location", + "summary": "(Deprecated) Delete Location", + "deprecated": true, "parameters": [ { "description": "Location ID", @@ -2640,6 +3067,63 @@ } ], "components": { + "requestBodies": { + "postV1Entities_id_attachments": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "description": "File attachment", + "type": "string", + "format": "binary" + }, + "type": { + "description": "Type of file", + "type": "string" + }, + "primary": { + "description": "Is this the primary attachment", + "type": "boolean" + }, + "name": { + "description": "name of the file including extension", + "type": "string" + } + }, + "required": [ + "file", + "name" + ] + } + } + }, + "required": true + }, + "repo.MaintenanceEntryCreate": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.MaintenanceEntryCreate" + } + } + }, + "description": "Entry Data", + "required": true + }, + "repo.EntityAttachmentUpdate": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.EntityAttachmentUpdate" + } + } + }, + "description": "Attachment Update", + "required": true + } + }, "securitySchemes": { "Bearer": { "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"", @@ -2757,11 +3241,11 @@ "ent.AttachmentEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" } ] }, @@ -2870,147 +3354,7 @@ } } }, - "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": "#/components/schemas/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": "#/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", - "items": { - "$ref": "#/components/schemas/ent.Item" - } - }, - "labels": { - "description": "Labels holds the value of the labels edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Label" - } - }, - "locations": { - "description": "Locations holds the value of the locations edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Location" - } - }, - "notifiers": { - "description": "Notifiers holds the value of the notifiers edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Notifier" - } - }, - "users": { - "description": "Users holds the value of the users edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/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": "#/components/schemas/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": "#/components/schemas/ent.Group" - } - ] - } - } - }, - "ent.Item": { + "ent.Entity": { "type": "object", "properties": { "archived": { @@ -3030,10 +3374,10 @@ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/components/schemas/ent.ItemEdges" + "$ref": "#/components/schemas/ent.EntityEdges" } ] }, @@ -3105,8 +3449,8 @@ "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.", + "sync_child_entities_locations": { + "description": "SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.", "type": "boolean" }, "updated_at": { @@ -3123,7 +3467,7 @@ } } }, - "ent.ItemEdges": { + "ent.EntityEdges": { "type": "object", "properties": { "attachments": { @@ -3137,14 +3481,21 @@ "description": "Children holds the value of the children edge.", "type": "array", "items": { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" + } + }, + "entity": { + "description": "Entity holds the value of the entity edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Entity" } }, "fields": { "description": "Fields holds the value of the fields edge.", "type": "array", "items": { - "$ref": "#/components/schemas/ent.ItemField" + "$ref": "#/components/schemas/ent.EntityField" } }, "group": { @@ -3166,7 +3517,7 @@ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Location" + "$ref": "#/components/schemas/ent.Entity" } ] }, @@ -3181,13 +3532,21 @@ "description": "Parent holds the value of the parent edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" + } + ] + }, + "type": { + "description": "Type holds the value of the type edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.EntityType" } ] } } }, - "ent.ItemField": { + "ent.EntityField": { "type": "object", "properties": { "boolean_value": { @@ -3203,10 +3562,10 @@ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/components/schemas/ent.ItemFieldEdges" + "$ref": "#/components/schemas/ent.EntityFieldEdges" } ] }, @@ -3234,7 +3593,7 @@ "description": "Type holds the value of the \"type\" field.", "allOf": [ { - "$ref": "#/components/schemas/itemfield.Type" + "$ref": "#/components/schemas/entityfield.Type" } ] }, @@ -3244,14 +3603,219 @@ } } }, - "ent.ItemFieldEdges": { + "ent.EntityFieldEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" + } + ] + } + } + }, + "ent.EntityType": { + "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 EntityTypeQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.EntityTypeEdges" + } + ] + }, + "icon": { + "description": "Icon holds the value of the \"icon\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_location": { + "description": "IsLocation holds the value of the \"is_location\" 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" + } + } + }, + "ent.EntityTypeEdges": { + "type": "object", + "properties": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Entity" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Group" + } + ] + } + } + }, + "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": "#/components/schemas/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": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Entity" + } + }, + "entity_types": { + "description": "EntityTypes holds the value of the entity_types edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.EntityType" + } + }, + "invitation_tokens": { + "description": "InvitationTokens holds the value of the invitation_tokens edge.", + "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" + } + }, + "labels": { + "description": "Labels holds the value of the labels edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Label" + } + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Notifier" + } + }, + "users": { + "description": "Users holds the value of the users edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/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": "#/components/schemas/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": "#/components/schemas/ent.Group" } ] } @@ -3367,7 +3931,7 @@ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Location" + "$ref": "#/components/schemas/ent.Entity" } ] } @@ -3413,64 +3977,11 @@ "ent.LabelEdges": { "type": "object", "properties": { - "group": { - "description": "Group holds the value of the group edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Group" - } - ] - }, - "items": { - "description": "Items holds the value of the items edge.", + "entities": { + "description": "Entities holds the value of the entities edge.", "type": "array", "items": { - "$ref": "#/components/schemas/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": "#/components/schemas/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": "#/components/schemas/ent.Location" + "$ref": "#/components/schemas/ent.Entity" } }, "group": { @@ -3480,21 +3991,6 @@ "$ref": "#/components/schemas/ent.Group" } ] - }, - "items": { - "description": "Items holds the value of the items edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Item" - } - }, - "parent": { - "description": "Parent holds the value of the parent edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Location" - } - ] } } }, @@ -3525,12 +4021,12 @@ } ] }, - "id": { - "description": "ID of the ent.", + "entity_id": { + "description": "EntityID holds the value of the \"entity_id\" field.", "type": "string" }, - "item_id": { - "description": "ItemID holds the value of the \"item_id\" field.", + "id": { + "description": "ID of the ent.", "type": "string" }, "name": { @@ -3550,11 +4046,11 @@ "ent.MaintenanceEntryEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Item" + "$ref": "#/components/schemas/ent.Entity" } ] } @@ -3768,7 +4264,7 @@ } } }, - "itemfield.Type": { + "entityfield.Type": { "type": "string", "enum": [ "text", @@ -3831,6 +4327,122 @@ } } }, + "repo.EntityAttachment": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "path": { + "type": "string" + }, + "primary": { + "type": "boolean" + }, + "thumbnail": { + "$ref": "#/components/schemas/ent.Attachment" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.EntityAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.EntityType": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeCreate": { + "type": "object", + "required": [ + "isLocation", + "name" + ], + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeDelete": { + "type": "object", + "properties": { + "replacementId": { + "$ref": "#/components/schemas/uuid.NullUUID" + } + } + }, + "repo.EntityTypeUpdate": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + } + } + }, "repo.Group": { "type": "object", "properties": { @@ -3885,55 +4497,10 @@ } } }, - "repo.ItemAttachment": { - "type": "object", - "properties": { - "createdAt": { - "type": "string" - }, - "id": { - "type": "string" - }, - "mimeType": { - "type": "string" - }, - "path": { - "type": "string" - }, - "primary": { - "type": "boolean" - }, - "thumbnail": { - "$ref": "#/components/schemas/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": [ + "entityType", "name" ], "properties": { @@ -3941,6 +4508,9 @@ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "labelIds": { "type": "array", "items": { @@ -4001,7 +4571,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/components/schemas/repo.ItemAttachment" + "$ref": "#/components/schemas/repo.EntityAttachment" } }, "createdAt": { @@ -4010,6 +4580,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -4173,6 +4746,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4500,17 +5076,22 @@ "repo.ItemType": { "type": "string", "enum": [ + "location", + "item", "location", "item" ], "x-enum-varnames": [ "ItemTypeLocation", - "ItemTypeItem" + "ItemTypeItem", + "EntityTypeLocation", + "EntityTypeItem" ] }, "repo.ItemUpdate": { "type": "object", "required": [ + "entityType", "name" ], "properties": { @@ -4524,6 +5105,9 @@ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -4685,10 +5269,16 @@ }, "repo.LocationCreate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "name": { "type": "string" }, @@ -4713,6 +5303,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4739,6 +5332,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4762,6 +5358,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4775,10 +5374,16 @@ }, "repo.LocationUpdate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -5195,6 +5800,18 @@ "RoleOwner" ] }, + "uuid.NullUUID": { + "type": "object", + "properties": { + "uuid": { + "type": "string" + }, + "valid": { + "description": "Valid is true if UUID is not NULL", + "type": "boolean" + } + } + }, "v1.APISummary": { "type": "object", "properties": { diff --git a/docs/en/api/openapi-3.0.yaml b/docs/en/api/openapi-3.0.yaml index 0a6d2042..27e5caf7 100644 --- a/docs/en/api/openapi-3.0.yaml +++ b/docs/en/api/openapi-3.0.yaml @@ -115,6 +115,276 @@ paths: application/json: schema: $ref: "#/components/schemas/currencies.Currency" + "/v1/entities/{id}/attachments": + post: + security: + - Bearer: [] + tags: + - Items Attachments + summary: Create Item Attachment + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + requestBody: + $ref: "#/components/requestBodies/postV1Entities_id_attachments" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemOut" + "422": + description: Unprocessable Entity + content: + application/json: + schema: + $ref: "#/components/schemas/validate.ErrorResponse" + "/v1/entities/{id}/attachments/{attachment_id}": + get: + security: + - Bearer: [] + tags: + - Items Attachments + summary: Get Item Attachment + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + - description: Attachment ID + name: attachment_id + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/octet-stream: + schema: + $ref: "#/components/schemas/v1.ItemAttachmentToken" + put: + security: + - Bearer: [] + tags: + - Items Attachments + summary: Update Item Attachment + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + - description: Attachment ID + name: attachment_id + in: path + required: true + schema: + type: string + requestBody: + $ref: "#/components/requestBodies/repo.EntityAttachmentUpdate" + responses: + "200": + description: OK + content: + "*/*": + schema: + $ref: "#/components/schemas/repo.ItemOut" + delete: + security: + - Bearer: [] + tags: + - Items Attachments + summary: Delete Item Attachment + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + - description: Attachment ID + name: attachment_id + in: path + required: true + schema: + type: string + responses: + "204": + description: No Content + "/v1/entities/{id}/maintenance": + get: + security: + - Bearer: [] + tags: + - Item Maintenance + summary: Get Maintenance Log + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + - x-enum-varnames: + - MaintenanceFilterStatusScheduled + - MaintenanceFilterStatusCompleted + - MaintenanceFilterStatusBoth + name: status + in: query + schema: + type: string + enum: + - scheduled + - completed + - both + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/repo.MaintenanceEntryWithDetails" + post: + security: + - Bearer: [] + tags: + - Item Maintenance + summary: Create Maintenance Entry + parameters: + - description: Item ID + name: id + in: path + required: true + schema: + type: string + requestBody: + $ref: "#/components/requestBodies/repo.MaintenanceEntryCreate" + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: "#/components/schemas/repo.MaintenanceEntry" + /v1/entitytype: + get: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Query All Entity Types + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/repo.EntityType" + post: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Create Entity Type + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityTypeCreate" + description: Entity Type Data + required: true + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityType" + "/v1/entitytype/{id}": + get: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Get One Entity Type + parameters: + - description: Entity Type ID + name: id + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityType" + put: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Update Entity Type + parameters: + - description: Entity Type ID + name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityTypeUpdate" + description: Entity Type Data + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityType" + delete: + security: + - Bearer: [] + tags: + - EntityTypes + summary: Delete Entity Type + parameters: + - description: Entity Type ID + name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityTypeDelete" + description: Entity Type Delete Options + required: true + responses: + "204": + description: No Content /v1/groups: get: security: @@ -247,7 +517,8 @@ paths: - Bearer: [] tags: - Items - summary: Query All Items + summary: (Deprecated) Query All Items + deprecated: true parameters: - description: search string name: q @@ -301,6 +572,7 @@ paths: tags: - Items summary: Create Item + deprecated: true requestBody: content: application/json: @@ -321,7 +593,8 @@ paths: - Bearer: [] tags: - Items - summary: Export Items + summary: (Deprecated) Export Items + deprecated: true responses: "200": description: text/csv @@ -335,7 +608,8 @@ paths: - Bearer: [] tags: - Items - summary: Get All Custom Field Names + summary: (Deprecated) Get All Custom Field Names + deprecated: true responses: "200": description: OK @@ -351,7 +625,8 @@ paths: - Bearer: [] tags: - Items - summary: Get All Custom Field Values + summary: (Deprecated) Get All Custom Field Values + deprecated: true responses: "200": description: OK @@ -367,7 +642,8 @@ paths: - Bearer: [] tags: - Items - summary: Import Items + summary: (Deprecated) Import Items + deprecated: true requestBody: content: multipart/form-data: @@ -390,7 +666,8 @@ paths: - Bearer: [] tags: - Items - summary: Get Item + summary: (Deprecated) Get Item + deprecated: true parameters: - description: Item ID name: id @@ -410,7 +687,8 @@ paths: - Bearer: [] tags: - Items - summary: Update Item + summary: (Deprecated) Update Item + deprecated: true parameters: - description: Item ID name: id @@ -437,7 +715,8 @@ paths: - Bearer: [] tags: - Items - summary: Delete Item + summary: (Deprecated) Delete Item + deprecated: true parameters: - description: Item ID name: id @@ -453,7 +732,8 @@ paths: - Bearer: [] tags: - Items - summary: Update Item + summary: (Deprecated) Update Item + deprecated: true parameters: - description: Item ID name: id @@ -482,6 +762,7 @@ paths: tags: - Items Attachments summary: Create Item Attachment + deprecated: true parameters: - description: Item ID name: id @@ -490,28 +771,7 @@ paths: schema: type: string requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - file: - description: File attachment - type: string - format: binary - type: - description: Type of file - type: string - primary: - description: Is this the primary attachment - type: boolean - name: - description: name of the file including extension - type: string - required: - - file - - name - required: true + $ref: "#/components/requestBodies/postV1Entities_id_attachments" responses: "200": description: OK @@ -532,6 +792,7 @@ paths: tags: - Items Attachments summary: Get Item Attachment + deprecated: true parameters: - description: Item ID name: id @@ -558,6 +819,7 @@ paths: tags: - Items Attachments summary: Update Item Attachment + deprecated: true parameters: - description: Item ID name: id @@ -572,12 +834,7 @@ paths: schema: type: string requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.ItemAttachmentUpdate" - description: Attachment Update - required: true + $ref: "#/components/requestBodies/repo.EntityAttachmentUpdate" responses: "200": description: OK @@ -591,6 +848,7 @@ paths: tags: - Items Attachments summary: Delete Item Attachment + deprecated: true parameters: - description: Item ID name: id @@ -642,6 +900,7 @@ paths: tags: - Item Maintenance summary: Get Maintenance Log + deprecated: true parameters: - description: Item ID name: id @@ -676,6 +935,7 @@ paths: tags: - Item Maintenance summary: Create Maintenance Entry + deprecated: true parameters: - description: Item ID name: id @@ -684,12 +944,7 @@ paths: schema: type: string requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.MaintenanceEntryCreate" - description: Entry Data - required: true + $ref: "#/components/requestBodies/repo.MaintenanceEntryCreate" responses: "201": description: Created @@ -703,7 +958,8 @@ paths: - Bearer: [] tags: - Items - summary: Get the full path of an item + summary: (Deprecated) Get the full path of an item + deprecated: true parameters: - description: Item ID name: id @@ -897,7 +1153,8 @@ paths: - Bearer: [] tags: - Locations - summary: Get All Locations + summary: (Deprecated) Get All Locations + deprecated: true parameters: - description: Filter locations with parents name: filterChildren @@ -918,7 +1175,8 @@ paths: - Bearer: [] tags: - Locations - summary: Create Location + summary: (Deprecated) Create Location + deprecated: true requestBody: content: application/json: @@ -939,7 +1197,8 @@ paths: - Bearer: [] tags: - Locations - summary: Get Locations Tree + summary: (Deprecated) Get Locations Tree + deprecated: true parameters: - description: include items in response tree name: withItems @@ -961,7 +1220,8 @@ paths: - Bearer: [] tags: - Locations - summary: Get Location + summary: (Deprecated) Get Location + deprecated: true parameters: - description: Location ID name: id @@ -981,7 +1241,8 @@ paths: - Bearer: [] tags: - Locations - summary: Update Location + summary: (Deprecated) Update Location + deprecated: true parameters: - description: Location ID name: id @@ -1008,7 +1269,8 @@ paths: - Bearer: [] tags: - Locations - summary: Delete Location + summary: (Deprecated) Delete Location + deprecated: true parameters: - description: Location ID name: id @@ -1562,6 +1824,44 @@ servers: - url: https://demo.homebox.software/api - url: http://demo.homebox.software/api components: + requestBodies: + postV1Entities_id_attachments: + content: + multipart/form-data: + schema: + type: object + properties: + file: + description: File attachment + type: string + format: binary + type: + description: Type of file + type: string + primary: + description: Is this the primary attachment + type: boolean + name: + description: name of the file including extension + type: string + required: + - file + - name + required: true + repo.MaintenanceEntryCreate: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.MaintenanceEntryCreate" + description: Entry Data + required: true + repo.EntityAttachmentUpdate: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.EntityAttachmentUpdate" + description: Attachment Update + required: true securitySchemes: Bearer: description: "\"Type 'Bearer TOKEN' to correctly set the API Key\"" @@ -1650,10 +1950,10 @@ components: ent.AttachmentEdges: type: object properties: - item: - description: Item holds the value of the item edge. + entity: + description: Entity holds the value of the entity edge. allOf: - - $ref: "#/components/schemas/ent.Item" + - $ref: "#/components/schemas/ent.Entity" thumbnail: description: Thumbnail holds the value of the thumbnail edge. allOf: @@ -1720,107 +2020,7 @@ components: description: User holds the value of the user edge. allOf: - $ref: "#/components/schemas/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. - - The values are being populated by the GroupQuery when eager-loading is set. - allOf: - - $ref: "#/components/schemas/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: "#/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 - items: - $ref: "#/components/schemas/ent.Item" - labels: - description: Labels holds the value of the labels edge. - type: array - items: - $ref: "#/components/schemas/ent.Label" - locations: - description: Locations holds the value of the locations edge. - type: array - items: - $ref: "#/components/schemas/ent.Location" - notifiers: - description: Notifiers holds the value of the notifiers edge. - type: array - items: - $ref: "#/components/schemas/ent.Notifier" - users: - description: Users holds the value of the users edge. - type: array - items: - $ref: "#/components/schemas/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. - - The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. - allOf: - - $ref: "#/components/schemas/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: "#/components/schemas/ent.Group" - ent.Item: + ent.Entity: type: object properties: archived: @@ -1839,9 +2039,9 @@ components: 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. + The values are being populated by the EntityQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.ItemEdges" + - $ref: "#/components/schemas/ent.EntityEdges" id: description: ID of the ent. type: string @@ -1893,9 +2093,9 @@ components: 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. + sync_child_entities_locations: + description: SyncChildEntitiesLocations holds the value of the + "sync_child_entities_locations" field. type: boolean updated_at: description: UpdatedAt holds the value of the "updated_at" field. @@ -1906,7 +2106,7 @@ components: warranty_expires: description: WarrantyExpires holds the value of the "warranty_expires" field. type: string - ent.ItemEdges: + ent.EntityEdges: type: object properties: attachments: @@ -1918,12 +2118,17 @@ components: description: Children holds the value of the children edge. type: array items: - $ref: "#/components/schemas/ent.Item" + $ref: "#/components/schemas/ent.Entity" + entity: + description: Entity holds the value of the entity edge. + type: array + items: + $ref: "#/components/schemas/ent.Entity" fields: description: Fields holds the value of the fields edge. type: array items: - $ref: "#/components/schemas/ent.ItemField" + $ref: "#/components/schemas/ent.EntityField" group: description: Group holds the value of the group edge. allOf: @@ -1936,7 +2141,7 @@ components: location: description: Location holds the value of the location edge. allOf: - - $ref: "#/components/schemas/ent.Location" + - $ref: "#/components/schemas/ent.Entity" maintenance_entries: description: MaintenanceEntries holds the value of the maintenance_entries edge. type: array @@ -1945,8 +2150,12 @@ components: parent: description: Parent holds the value of the parent edge. allOf: - - $ref: "#/components/schemas/ent.Item" - ent.ItemField: + - $ref: "#/components/schemas/ent.Entity" + type: + description: Type holds the value of the type edge. + allOf: + - $ref: "#/components/schemas/ent.EntityType" + ent.EntityField: type: object properties: boolean_value: @@ -1962,9 +2171,9 @@ components: 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. + The values are being populated by the EntityFieldQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.ItemFieldEdges" + - $ref: "#/components/schemas/ent.EntityFieldEdges" id: description: ID of the ent. type: string @@ -1983,17 +2192,163 @@ components: type: description: Type holds the value of the "type" field. allOf: - - $ref: "#/components/schemas/itemfield.Type" + - $ref: "#/components/schemas/entityfield.Type" updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string - ent.ItemFieldEdges: + ent.EntityFieldEdges: type: object properties: - item: - description: Item holds the value of the item edge. + entity: + description: Entity holds the value of the entity edge. allOf: - - $ref: "#/components/schemas/ent.Item" + - $ref: "#/components/schemas/ent.Entity" + ent.EntityType: + 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. + + The values are being populated by the EntityTypeQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.EntityTypeEdges" + icon: + description: Icon holds the value of the "icon" field. + type: string + id: + description: ID of the ent. + type: string + is_location: + description: IsLocation holds the value of the "is_location" 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 + ent.EntityTypeEdges: + type: object + properties: + entities: + description: Entities holds the value of the entities edge. + type: array + items: + $ref: "#/components/schemas/ent.Entity" + group: + description: Group holds the value of the group edge. + allOf: + - $ref: "#/components/schemas/ent.Group" + 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. + + The values are being populated by the GroupQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/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: + entities: + description: Entities holds the value of the entities edge. + type: array + items: + $ref: "#/components/schemas/ent.Entity" + entity_types: + description: EntityTypes holds the value of the entity_types edge. + type: array + items: + $ref: "#/components/schemas/ent.EntityType" + invitation_tokens: + description: InvitationTokens holds the value of the invitation_tokens edge. + 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" + labels: + description: Labels holds the value of the labels edge. + type: array + items: + $ref: "#/components/schemas/ent.Label" + notifiers: + description: Notifiers holds the value of the notifiers edge. + type: array + items: + $ref: "#/components/schemas/ent.Notifier" + users: + description: Users holds the value of the users edge. + type: array + items: + $ref: "#/components/schemas/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. + + The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/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: "#/components/schemas/ent.Group" ent.ItemTemplate: type: object properties: @@ -2080,7 +2435,7 @@ components: location: description: Location holds the value of the location edge. allOf: - - $ref: "#/components/schemas/ent.Location" + - $ref: "#/components/schemas/ent.Entity" ent.Label: type: object properties: @@ -2112,61 +2467,15 @@ components: ent.LabelEdges: type: object properties: + entities: + description: Entities holds the value of the entities edge. + type: array + items: + $ref: "#/components/schemas/ent.Entity" group: description: Group holds the value of the group edge. allOf: - $ref: "#/components/schemas/ent.Group" - items: - description: Items holds the value of the items edge. - type: array - items: - $ref: "#/components/schemas/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. - - The values are being populated by the LocationQuery when eager-loading is set. - allOf: - - $ref: "#/components/schemas/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: "#/components/schemas/ent.Location" - group: - description: Group holds the value of the group edge. - allOf: - - $ref: "#/components/schemas/ent.Group" - items: - description: Items holds the value of the items edge. - type: array - items: - $ref: "#/components/schemas/ent.Item" - parent: - description: Parent holds the value of the parent edge. - allOf: - - $ref: "#/components/schemas/ent.Location" ent.MaintenanceEntry: type: object properties: @@ -2189,12 +2498,12 @@ components: The values are being populated by the MaintenanceEntryQuery when eager-loading is set. allOf: - $ref: "#/components/schemas/ent.MaintenanceEntryEdges" + entity_id: + description: EntityID holds the value of the "entity_id" field. + type: string 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 @@ -2207,10 +2516,10 @@ components: ent.MaintenanceEntryEdges: type: object properties: - item: - description: Item holds the value of the item edge. + entity: + description: Entity holds the value of the entity edge. allOf: - - $ref: "#/components/schemas/ent.Item" + - $ref: "#/components/schemas/ent.Entity" ent.Notifier: type: object properties: @@ -2353,7 +2662,7 @@ components: type: array items: $ref: "#/components/schemas/ent.Notifier" - itemfield.Type: + entityfield.Type: type: string enum: - text @@ -2397,6 +2706,82 @@ components: type: boolean copyPrefix: type: string + repo.EntityAttachment: + type: object + properties: + createdAt: + type: string + id: + type: string + mimeType: + type: string + path: + type: string + primary: + type: boolean + thumbnail: + $ref: "#/components/schemas/ent.Attachment" + title: + type: string + type: + type: string + updatedAt: + type: string + repo.EntityAttachmentUpdate: + type: object + properties: + primary: + type: boolean + title: + type: string + type: + type: string + repo.EntityType: + type: object + properties: + color: + type: string + description: + type: string + icon: + type: string + isLocation: + type: boolean + name: + type: string + repo.EntityTypeCreate: + type: object + required: + - isLocation + - name + properties: + color: + type: string + description: + type: string + icon: + type: string + isLocation: + type: boolean + name: + type: string + repo.EntityTypeDelete: + type: object + properties: + replacementId: + $ref: "#/components/schemas/uuid.NullUUID" + repo.EntityTypeUpdate: + type: object + properties: + color: + type: string + description: + type: string + icon: + type: string + name: + type: string + minLength: 1 repo.Group: type: object properties: @@ -2432,44 +2817,17 @@ components: 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: "#/components/schemas/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: + - entityType - name properties: description: type: string maxLength: 1000 + entityType: + type: string labelIds: type: array items: @@ -2512,11 +2870,13 @@ components: attachments: type: array items: - $ref: "#/components/schemas/repo.ItemAttachment" + $ref: "#/components/schemas/repo.EntityAttachment" createdAt: type: string description: type: string + entityType: + type: string fields: type: array items: @@ -2628,6 +2988,8 @@ components: type: string description: type: string + entityType: + type: string id: type: string imageId: @@ -2861,12 +3223,17 @@ components: enum: - location - item + - location + - item x-enum-varnames: - ItemTypeLocation - ItemTypeItem + - EntityTypeLocation + - EntityTypeItem repo.ItemUpdate: type: object required: + - entityType - name properties: archived: @@ -2876,6 +3243,8 @@ components: description: type: string maxLength: 1000 + entityType: + type: string fields: type: array items: @@ -2988,9 +3357,13 @@ components: type: string repo.LocationCreate: type: object + required: + - entityType properties: description: type: string + entityType: + type: string name: type: string parentId: @@ -3007,6 +3380,8 @@ components: type: string description: type: string + entityType: + type: string id: type: string name: @@ -3024,6 +3399,8 @@ components: type: string description: type: string + entityType: + type: string id: type: string itemCount: @@ -3039,6 +3416,8 @@ components: type: string description: type: string + entityType: + type: string id: type: string name: @@ -3047,9 +3426,13 @@ components: type: string repo.LocationUpdate: type: object + required: + - entityType properties: description: type: string + entityType: + type: string id: type: string name: @@ -3326,6 +3709,14 @@ components: - DefaultRole - RoleUser - RoleOwner + uuid.NullUUID: + type: object + properties: + uuid: + type: string + valid: + description: Valid is true if UUID is not NULL + type: boolean v1.APISummary: type: object properties: diff --git a/docs/en/api/swagger-2.0.json b/docs/en/api/swagger-2.0.json index 61b8612a..c0ef4e99 100644 --- a/docs/en/api/swagger-2.0.json +++ b/docs/en/api/swagger-2.0.json @@ -193,6 +193,454 @@ } } }, + "/v1/entities/{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/entities/{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.EntityAttachmentUpdate" + } + } + ], + "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/entities/{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/entitytype": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Query All Entity Types", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Create Entity Type", + "parameters": [ + { + "description": "Entity Type Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.EntityTypeCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + } + }, + "/v1/entitytype/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Get One Entity Type", + "parameters": [ + { + "type": "string", + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "EntityTypes" + ], + "summary": "Update Entity Type", + "parameters": [ + { + "type": "string", + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entity Type Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.EntityTypeUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.EntityType" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "EntityTypes" + ], + "summary": "Delete Entity Type", + "parameters": [ + { + "type": "string", + "description": "Entity Type ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entity Type Delete Options", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.EntityTypeDelete" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, "/v1/groups": { "get": { "security": [ @@ -414,7 +862,8 @@ "tags": [ "Items" ], - "summary": "Query All Items", + "summary": "(Deprecated) Query All Items", + "deprecated": true, "parameters": [ { "type": "string", @@ -480,6 +929,9 @@ "Bearer": [] } ], + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], @@ -487,6 +939,7 @@ "Items" ], "summary": "Create Item", + "deprecated": true, "parameters": [ { "description": "Item Data", @@ -518,7 +971,8 @@ "tags": [ "Items" ], - "summary": "Export Items", + "summary": "(Deprecated) Export Items", + "deprecated": true, "responses": { "200": { "description": "text/csv", @@ -542,7 +996,8 @@ "tags": [ "Items" ], - "summary": "Get All Custom Field Names", + "summary": "(Deprecated) Get All Custom Field Names", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -569,7 +1024,8 @@ "tags": [ "Items" ], - "summary": "Get All Custom Field Values", + "summary": "(Deprecated) Get All Custom Field Values", + "deprecated": true, "responses": { "200": { "description": "OK", @@ -599,7 +1055,8 @@ "tags": [ "Items" ], - "summary": "Import Items", + "summary": "(Deprecated) Import Items", + "deprecated": true, "parameters": [ { "type": "file", @@ -629,7 +1086,8 @@ "tags": [ "Items" ], - "summary": "Get Item", + "summary": "(Deprecated) Get Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -660,7 +1118,8 @@ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -700,7 +1159,8 @@ "tags": [ "Items" ], - "summary": "Delete Item", + "summary": "(Deprecated) Delete Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -728,7 +1188,8 @@ "tags": [ "Items" ], - "summary": "Update Item", + "summary": "(Deprecated) Update Item", + "deprecated": true, "parameters": [ { "type": "string", @@ -774,6 +1235,7 @@ "Items Attachments" ], "summary": "Create Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -839,6 +1301,7 @@ "Items Attachments" ], "summary": "Get Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -874,6 +1337,7 @@ "Items Attachments" ], "summary": "Update Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -895,7 +1359,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/repo.ItemAttachmentUpdate" + "$ref": "#/definitions/repo.EntityAttachmentUpdate" } } ], @@ -918,6 +1382,7 @@ "Items Attachments" ], "summary": "Delete Item Attachment", + "deprecated": true, "parameters": [ { "type": "string", @@ -997,6 +1462,7 @@ "Item Maintenance" ], "summary": "Get Maintenance Log", + "deprecated": true, "parameters": [ { "type": "string", @@ -1046,6 +1512,7 @@ "Item Maintenance" ], "summary": "Create Maintenance Entry", + "deprecated": true, "parameters": [ { "type": "string", @@ -1087,7 +1554,8 @@ "tags": [ "Items" ], - "summary": "Get the full path of an item", + "summary": "(Deprecated) Get the full path of an item", + "deprecated": true, "parameters": [ { "type": "string", @@ -1392,7 +1860,8 @@ "tags": [ "Locations" ], - "summary": "Get All Locations", + "summary": "(Deprecated) Get All Locations", + "deprecated": true, "parameters": [ { "type": "boolean", @@ -1425,7 +1894,8 @@ "tags": [ "Locations" ], - "summary": "Create Location", + "summary": "(Deprecated) Create Location", + "deprecated": true, "parameters": [ { "description": "Location Data", @@ -1460,7 +1930,8 @@ "tags": [ "Locations" ], - "summary": "Get Locations Tree", + "summary": "(Deprecated) Get Locations Tree", + "deprecated": true, "parameters": [ { "type": "boolean", @@ -1495,7 +1966,8 @@ "tags": [ "Locations" ], - "summary": "Get Location", + "summary": "(Deprecated) Get Location", + "deprecated": true, "parameters": [ { "type": "string", @@ -1526,7 +1998,8 @@ "tags": [ "Locations" ], - "summary": "Update Location", + "summary": "(Deprecated) Update Location", + "deprecated": true, "parameters": [ { "type": "string", @@ -1566,7 +2039,8 @@ "tags": [ "Locations" ], - "summary": "Delete Location", + "summary": "(Deprecated) Delete Location", + "deprecated": true, "parameters": [ { "type": "string", @@ -2558,11 +3032,11 @@ "ent.AttachmentEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" } ] }, @@ -2671,147 +3145,7 @@ } } }, - "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": { + "ent.Entity": { "type": "object", "properties": { "archived": { @@ -2831,10 +3165,10 @@ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/definitions/ent.ItemEdges" + "$ref": "#/definitions/ent.EntityEdges" } ] }, @@ -2906,8 +3240,8 @@ "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.", + "sync_child_entities_locations": { + "description": "SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.", "type": "boolean" }, "updated_at": { @@ -2924,7 +3258,7 @@ } } }, - "ent.ItemEdges": { + "ent.EntityEdges": { "type": "object", "properties": { "attachments": { @@ -2938,14 +3272,21 @@ "description": "Children holds the value of the children edge.", "type": "array", "items": { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" + } + }, + "entity": { + "description": "Entity holds the value of the entity edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Entity" } }, "fields": { "description": "Fields holds the value of the fields edge.", "type": "array", "items": { - "$ref": "#/definitions/ent.ItemField" + "$ref": "#/definitions/ent.EntityField" } }, "group": { @@ -2967,7 +3308,7 @@ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/definitions/ent.Location" + "$ref": "#/definitions/ent.Entity" } ] }, @@ -2982,13 +3323,21 @@ "description": "Parent holds the value of the parent edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" + } + ] + }, + "type": { + "description": "Type holds the value of the type edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.EntityType" } ] } } }, - "ent.ItemField": { + "ent.EntityField": { "type": "object", "properties": { "boolean_value": { @@ -3004,10 +3353,10 @@ "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.", + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.", "allOf": [ { - "$ref": "#/definitions/ent.ItemFieldEdges" + "$ref": "#/definitions/ent.EntityFieldEdges" } ] }, @@ -3035,7 +3384,7 @@ "description": "Type holds the value of the \"type\" field.", "allOf": [ { - "$ref": "#/definitions/itemfield.Type" + "$ref": "#/definitions/entityfield.Type" } ] }, @@ -3045,14 +3394,219 @@ } } }, - "ent.ItemFieldEdges": { + "ent.EntityFieldEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" + } + ] + } + } + }, + "ent.EntityType": { + "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 EntityTypeQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.EntityTypeEdges" + } + ] + }, + "icon": { + "description": "Icon holds the value of the \"icon\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_location": { + "description": "IsLocation holds the value of the \"is_location\" 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" + } + } + }, + "ent.EntityTypeEdges": { + "type": "object", + "properties": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Entity" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + } + } + }, + "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": { + "entities": { + "description": "Entities holds the value of the entities edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Entity" + } + }, + "entity_types": { + "description": "EntityTypes holds the value of the entity_types edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.EntityType" + } + }, + "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" + } + }, + "labels": { + "description": "Labels holds the value of the labels edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "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" } ] } @@ -3168,7 +3722,7 @@ "description": "Location holds the value of the location edge.", "allOf": [ { - "$ref": "#/definitions/ent.Location" + "$ref": "#/definitions/ent.Entity" } ] } @@ -3214,64 +3768,11 @@ "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.", + "entities": { + "description": "Entities holds the value of the entities 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" + "$ref": "#/definitions/ent.Entity" } }, "group": { @@ -3281,21 +3782,6 @@ "$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" - } - ] } } }, @@ -3326,12 +3812,12 @@ } ] }, - "id": { - "description": "ID of the ent.", + "entity_id": { + "description": "EntityID holds the value of the \"entity_id\" field.", "type": "string" }, - "item_id": { - "description": "ItemID holds the value of the \"item_id\" field.", + "id": { + "description": "ID of the ent.", "type": "string" }, "name": { @@ -3351,11 +3837,11 @@ "ent.MaintenanceEntryEdges": { "type": "object", "properties": { - "item": { - "description": "Item holds the value of the item edge.", + "entity": { + "description": "Entity holds the value of the entity edge.", "allOf": [ { - "$ref": "#/definitions/ent.Item" + "$ref": "#/definitions/ent.Entity" } ] } @@ -3569,7 +4055,7 @@ } } }, - "itemfield.Type": { + "entityfield.Type": { "type": "string", "enum": [ "text", @@ -3632,6 +4118,122 @@ } } }, + "repo.EntityAttachment": { + "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.EntityAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.EntityType": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeCreate": { + "type": "object", + "required": [ + "isLocation", + "name" + ], + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "isLocation": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "repo.EntityTypeDelete": { + "type": "object", + "properties": { + "replacementId": { + "$ref": "#/definitions/uuid.NullUUID" + } + } + }, + "repo.EntityTypeUpdate": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 1 + } + } + }, "repo.Group": { "type": "object", "properties": { @@ -3686,55 +4288,10 @@ } } }, - "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": [ + "entityType", "name" ], "properties": { @@ -3742,6 +4299,9 @@ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "labelIds": { "type": "array", "items": { @@ -3802,7 +4362,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/definitions/repo.ItemAttachment" + "$ref": "#/definitions/repo.EntityAttachment" } }, "createdAt": { @@ -3811,6 +4371,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -3974,6 +4537,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4301,17 +4867,22 @@ "repo.ItemType": { "type": "string", "enum": [ + "location", + "item", "location", "item" ], "x-enum-varnames": [ "ItemTypeLocation", - "ItemTypeItem" + "ItemTypeItem", + "EntityTypeLocation", + "EntityTypeItem" ] }, "repo.ItemUpdate": { "type": "object", "required": [ + "entityType", "name" ], "properties": { @@ -4325,6 +4896,9 @@ "type": "string", "maxLength": 1000 }, + "entityType": { + "type": "string" + }, "fields": { "type": "array", "items": { @@ -4486,10 +5060,16 @@ }, "repo.LocationCreate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "name": { "type": "string" }, @@ -4514,6 +5094,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4540,6 +5123,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4563,6 +5149,9 @@ "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4576,10 +5165,16 @@ }, "repo.LocationUpdate": { "type": "object", + "required": [ + "entityType" + ], "properties": { "description": { "type": "string" }, + "entityType": { + "type": "string" + }, "id": { "type": "string" }, @@ -4996,6 +5591,18 @@ "RoleOwner" ] }, + "uuid.NullUUID": { + "type": "object", + "properties": { + "uuid": { + "type": "string" + }, + "valid": { + "description": "Valid is true if UUID is not NULL", + "type": "boolean" + } + } + }, "v1.APISummary": { "type": "object", "properties": { diff --git a/docs/en/api/swagger-2.0.yaml b/docs/en/api/swagger-2.0.yaml index d18a8f45..e70a8f87 100644 --- a/docs/en/api/swagger-2.0.yaml +++ b/docs/en/api/swagger-2.0.yaml @@ -79,10 +79,10 @@ definitions: type: object ent.AttachmentEdges: properties: - item: + entity: allOf: - - $ref: '#/definitions/ent.Item' - description: Item holds the value of the item edge. + - $ref: '#/definitions/ent.Entity' + description: Entity holds the value of the entity edge. thumbnail: allOf: - $ref: '#/definitions/ent.Attachment' @@ -148,105 +148,7 @@ definitions: - $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: + ent.Entity: properties: archived: description: Archived holds the value of the "archived" field. @@ -262,10 +164,10 @@ definitions: type: string edges: allOf: - - $ref: '#/definitions/ent.ItemEdges' + - $ref: '#/definitions/ent.EntityEdges' 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. + The values are being populated by the EntityQuery when eager-loading is set. id: description: ID of the ent. type: string @@ -317,8 +219,8 @@ definitions: 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" + sync_child_entities_locations: + description: SyncChildEntitiesLocations holds the value of the "sync_child_entities_locations" field. type: boolean updated_at: @@ -331,7 +233,7 @@ definitions: description: WarrantyExpires holds the value of the "warranty_expires" field. type: string type: object - ent.ItemEdges: + ent.EntityEdges: properties: attachments: description: Attachments holds the value of the attachments edge. @@ -341,12 +243,17 @@ definitions: children: description: Children holds the value of the children edge. items: - $ref: '#/definitions/ent.Item' + $ref: '#/definitions/ent.Entity' + type: array + entity: + description: Entity holds the value of the entity edge. + items: + $ref: '#/definitions/ent.Entity' type: array fields: description: Fields holds the value of the fields edge. items: - $ref: '#/definitions/ent.ItemField' + $ref: '#/definitions/ent.EntityField' type: array group: allOf: @@ -359,7 +266,7 @@ definitions: type: array location: allOf: - - $ref: '#/definitions/ent.Location' + - $ref: '#/definitions/ent.Entity' description: Location holds the value of the location edge. maintenance_entries: description: MaintenanceEntries holds the value of the maintenance_entries @@ -369,10 +276,14 @@ definitions: type: array parent: allOf: - - $ref: '#/definitions/ent.Item' + - $ref: '#/definitions/ent.Entity' description: Parent holds the value of the parent edge. + type: + allOf: + - $ref: '#/definitions/ent.EntityType' + description: Type holds the value of the type edge. type: object - ent.ItemField: + ent.EntityField: properties: boolean_value: description: BooleanValue holds the value of the "boolean_value" field. @@ -385,10 +296,10 @@ definitions: type: string edges: allOf: - - $ref: '#/definitions/ent.ItemFieldEdges' + - $ref: '#/definitions/ent.EntityFieldEdges' 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. + The values are being populated by the EntityFieldQuery when eager-loading is set. id: description: ID of the ent. type: string @@ -406,18 +317,161 @@ definitions: type: string type: allOf: - - $ref: '#/definitions/itemfield.Type' + - $ref: '#/definitions/entityfield.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: + ent.EntityFieldEdges: properties: - item: + entity: allOf: - - $ref: '#/definitions/ent.Item' - description: Item holds the value of the item edge. + - $ref: '#/definitions/ent.Entity' + description: Entity holds the value of the entity edge. + type: object + ent.EntityType: + 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.EntityTypeEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the EntityTypeQuery when eager-loading is set. + icon: + description: Icon holds the value of the "icon" field. + type: string + id: + description: ID of the ent. + type: string + is_location: + description: IsLocation holds the value of the "is_location" 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 + type: object + ent.EntityTypeEdges: + properties: + entities: + description: Entities holds the value of the entities edge. + items: + $ref: '#/definitions/ent.Entity' + type: array + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group 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: + entities: + description: Entities holds the value of the entities edge. + items: + $ref: '#/definitions/ent.Entity' + type: array + entity_types: + description: EntityTypes holds the value of the entity_types edge. + items: + $ref: '#/definitions/ent.EntityType' + type: array + 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 + labels: + description: Labels holds the value of the labels edge. + items: + $ref: '#/definitions/ent.Label' + 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.ItemTemplate: properties: @@ -502,7 +556,7 @@ definitions: description: Group holds the value of the group edge. location: allOf: - - $ref: '#/definitions/ent.Location' + - $ref: '#/definitions/ent.Entity' description: Location holds the value of the location edge. type: object ent.Label: @@ -534,60 +588,15 @@ definitions: 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. + entities: + description: Entities holds the value of the entities 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' + $ref: '#/definitions/ent.Entity' 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: @@ -609,12 +618,12 @@ definitions: 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. + entity_id: + description: EntityID holds the value of the "entity_id" field. + type: string 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 @@ -627,10 +636,10 @@ definitions: type: object ent.MaintenanceEntryEdges: properties: - item: + entity: allOf: - - $ref: '#/definitions/ent.Item' - description: Item holds the value of the item edge. + - $ref: '#/definitions/ent.Entity' + description: Entity holds the value of the entity edge. type: object ent.Notifier: properties: @@ -771,7 +780,7 @@ definitions: $ref: '#/definitions/ent.Notifier' type: array type: object - itemfield.Type: + entityfield.Type: enum: - text - number @@ -815,6 +824,82 @@ definitions: copyPrefix: type: string type: object + repo.EntityAttachment: + 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.EntityAttachmentUpdate: + properties: + primary: + type: boolean + title: + type: string + type: + type: string + type: object + repo.EntityType: + properties: + color: + type: string + description: + type: string + icon: + type: string + isLocation: + type: boolean + name: + type: string + type: object + repo.EntityTypeCreate: + properties: + color: + type: string + description: + type: string + icon: + type: string + isLocation: + type: boolean + name: + type: string + required: + - isLocation + - name + type: object + repo.EntityTypeDelete: + properties: + replacementId: + $ref: '#/definitions/uuid.NullUUID' + type: object + repo.EntityTypeUpdate: + properties: + color: + type: string + description: + type: string + icon: + type: string + name: + minLength: 1 + type: string + type: object repo.Group: properties: createdAt: @@ -850,41 +935,13 @@ definitions: 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 + entityType: + type: string labelIds: items: type: string @@ -902,6 +959,7 @@ definitions: quantity: type: integer required: + - entityType - name type: object repo.ItemField: @@ -928,12 +986,14 @@ definitions: type: string attachments: items: - $ref: '#/definitions/repo.ItemAttachment' + $ref: '#/definitions/repo.EntityAttachment' type: array createdAt: type: string description: type: string + entityType: + type: string fields: items: $ref: '#/definitions/repo.ItemField' @@ -1045,6 +1105,8 @@ definitions: type: string description: type: string + entityType: + type: string id: type: string imageId: @@ -1278,10 +1340,14 @@ definitions: enum: - location - item + - location + - item type: string x-enum-varnames: - ItemTypeLocation - ItemTypeItem + - EntityTypeLocation + - EntityTypeItem repo.ItemUpdate: properties: archived: @@ -1291,6 +1357,8 @@ definitions: description: maxLength: 1000 type: string + entityType: + type: string fields: items: $ref: '#/definitions/repo.ItemField' @@ -1358,6 +1426,7 @@ definitions: warrantyExpires: type: string required: + - entityType - name type: object repo.LabelCreate: @@ -1408,11 +1477,15 @@ definitions: properties: description: type: string + entityType: + type: string name: type: string parentId: type: string x-nullable: true + required: + - entityType type: object repo.LocationOut: properties: @@ -1424,6 +1497,8 @@ definitions: type: string description: type: string + entityType: + type: string id: type: string name: @@ -1441,6 +1516,8 @@ definitions: type: string description: type: string + entityType: + type: string id: type: string itemCount: @@ -1456,6 +1533,8 @@ definitions: type: string description: type: string + entityType: + type: string id: type: string name: @@ -1467,6 +1546,8 @@ definitions: properties: description: type: string + entityType: + type: string id: type: string name: @@ -1474,6 +1555,8 @@ definitions: parentId: type: string x-nullable: true + required: + - entityType type: object repo.MaintenanceEntry: properties: @@ -1744,6 +1827,14 @@ definitions: - DefaultRole - RoleUser - RoleOwner + uuid.NullUUID: + properties: + uuid: + type: string + valid: + description: Valid is true if UUID is not NULL + type: boolean + type: object v1.APISummary: properties: allowRegistration: @@ -1994,6 +2085,287 @@ paths: summary: Currency tags: - Base + /v1/entities/{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/entities/{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.EntityAttachmentUpdate' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Update Item Attachment + tags: + - Items Attachments + /v1/entities/{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/entitytype: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.EntityType' + type: array + security: + - Bearer: [] + summary: Query All Entity Types + tags: + - EntityTypes + post: + consumes: + - application/json + parameters: + - description: Entity Type Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.EntityTypeCreate' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.EntityType' + security: + - Bearer: [] + summary: Create Entity Type + tags: + - EntityTypes + /v1/entitytype/{id}: + delete: + parameters: + - description: Entity Type ID + in: path + name: id + required: true + type: string + - description: Entity Type Delete Options + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.EntityTypeDelete' + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Entity Type + tags: + - EntityTypes + get: + parameters: + - description: Entity Type ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.EntityType' + security: + - Bearer: [] + summary: Get One Entity Type + tags: + - EntityTypes + put: + consumes: + - application/json + parameters: + - description: Entity Type ID + in: path + name: id + required: true + type: string + - description: Entity Type Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.EntityTypeUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.EntityType' + security: + - Bearer: [] + summary: Update Entity Type + tags: + - EntityTypes /v1/groups: get: produces: @@ -2120,6 +2492,7 @@ paths: - Statistics /v1/items: get: + deprecated: true parameters: - description: search string in: query @@ -2163,10 +2536,13 @@ paths: $ref: '#/definitions/repo.PaginationResult-repo_ItemSummary' security: - Bearer: [] - summary: Query All Items + summary: (Deprecated) Query All Items tags: - Items post: + consumes: + - application/json + deprecated: true parameters: - description: Item Data in: body @@ -2188,6 +2564,7 @@ paths: - Items /v1/items/{id}: delete: + deprecated: true parameters: - description: Item ID in: path @@ -2201,10 +2578,11 @@ paths: description: No Content security: - Bearer: [] - summary: Delete Item + summary: (Deprecated) Delete Item tags: - Items get: + deprecated: true parameters: - description: Item ID in: path @@ -2220,10 +2598,11 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: Get Item + summary: (Deprecated) Get Item tags: - Items patch: + deprecated: true parameters: - description: Item ID in: path @@ -2245,10 +2624,11 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: Update Item + summary: (Deprecated) Update Item tags: - Items put: + deprecated: true parameters: - description: Item ID in: path @@ -2270,13 +2650,14 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: Update Item + summary: (Deprecated) Update Item tags: - Items /v1/items/{id}/attachments: post: consumes: - multipart/form-data + deprecated: true parameters: - description: Item ID in: path @@ -2319,6 +2700,7 @@ paths: - Items Attachments /v1/items/{id}/attachments/{attachment_id}: delete: + deprecated: true parameters: - description: Item ID in: path @@ -2339,6 +2721,7 @@ paths: tags: - Items Attachments get: + deprecated: true parameters: - description: Item ID in: path @@ -2363,6 +2746,7 @@ paths: tags: - Items Attachments put: + deprecated: true parameters: - description: Item ID in: path @@ -2379,7 +2763,7 @@ paths: name: payload required: true schema: - $ref: '#/definitions/repo.ItemAttachmentUpdate' + $ref: '#/definitions/repo.EntityAttachmentUpdate' responses: "200": description: OK @@ -2418,6 +2802,7 @@ paths: - Items /v1/items/{id}/maintenance: get: + deprecated: true parameters: - description: Item ID in: path @@ -2450,6 +2835,7 @@ paths: tags: - Item Maintenance post: + deprecated: true parameters: - description: Item ID in: path @@ -2476,6 +2862,7 @@ paths: - Item Maintenance /v1/items/{id}/path: get: + deprecated: true parameters: - description: Item ID in: path @@ -2493,11 +2880,12 @@ paths: type: array security: - Bearer: [] - summary: Get the full path of an item + summary: (Deprecated) Get the full path of an item tags: - Items /v1/items/export: get: + deprecated: true responses: "200": description: text/csv @@ -2505,11 +2893,12 @@ paths: type: string security: - Bearer: [] - summary: Export Items + summary: (Deprecated) Export Items tags: - Items /v1/items/fields: get: + deprecated: true produces: - application/json responses: @@ -2521,11 +2910,12 @@ paths: type: array security: - Bearer: [] - summary: Get All Custom Field Names + summary: (Deprecated) Get All Custom Field Names tags: - Items /v1/items/fields/values: get: + deprecated: true produces: - application/json responses: @@ -2537,13 +2927,14 @@ paths: type: array security: - Bearer: [] - summary: Get All Custom Field Values + summary: (Deprecated) Get All Custom Field Values tags: - Items /v1/items/import: post: consumes: - multipart/form-data + deprecated: true parameters: - description: Image to upload in: formData @@ -2557,7 +2948,7 @@ paths: description: No Content security: - Bearer: [] - summary: Import Items + summary: (Deprecated) Import Items tags: - Items /v1/labelmaker/assets/{id}: @@ -2726,6 +3117,7 @@ paths: - Labels /v1/locations: get: + deprecated: true parameters: - description: Filter locations with parents in: query @@ -2742,10 +3134,11 @@ paths: type: array security: - Bearer: [] - summary: Get All Locations + summary: (Deprecated) Get All Locations tags: - Locations post: + deprecated: true parameters: - description: Location Data in: body @@ -2762,11 +3155,12 @@ paths: $ref: '#/definitions/repo.LocationSummary' security: - Bearer: [] - summary: Create Location + summary: (Deprecated) Create Location tags: - Locations /v1/locations/{id}: delete: + deprecated: true parameters: - description: Location ID in: path @@ -2780,10 +3174,11 @@ paths: description: No Content security: - Bearer: [] - summary: Delete Location + summary: (Deprecated) Delete Location tags: - Locations get: + deprecated: true parameters: - description: Location ID in: path @@ -2799,10 +3194,11 @@ paths: $ref: '#/definitions/repo.LocationOut' security: - Bearer: [] - summary: Get Location + summary: (Deprecated) Get Location tags: - Locations put: + deprecated: true parameters: - description: Location ID in: path @@ -2824,11 +3220,12 @@ paths: $ref: '#/definitions/repo.LocationOut' security: - Bearer: [] - summary: Update Location + summary: (Deprecated) Update Location tags: - Locations /v1/locations/tree: get: + deprecated: true parameters: - description: include items in response tree in: query @@ -2845,7 +3242,7 @@ paths: type: array security: - Bearer: [] - summary: Get Locations Tree + summary: (Deprecated) Get Locations Tree tags: - Locations /v1/maintenance: diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.ts index 10414206..55e6d8d1 100644 --- a/frontend/lib/api/types/data-contracts.ts +++ b/frontend/lib/api/types/data-contracts.ts @@ -30,9 +30,11 @@ export enum MaintenanceFilterStatus { export enum ItemType { ItemTypeLocation = "location", ItemTypeItem = "item", + EntityTypeLocation = "location", + EntityTypeItem = "item", } -export enum ItemfieldType { +export enum EntityfieldType { TypeText = "text", TypeNumber = "number", TypeBoolean = "boolean", @@ -89,8 +91,8 @@ export interface EntAttachment { } export interface EntAttachmentEdges { - /** Item holds the value of the item edge. */ - item: EntItem; + /** Entity holds the value of the entity edge. */ + entity: EntEntity; /** Thumbnail holds the value of the thumbnail edge. */ thumbnail: EntAttachment; } @@ -137,67 +139,7 @@ export interface EntAuthTokensEdges { user: EntUser; } -export interface EntGroup { - /** CreatedAt holds the value of the "created_at" field. */ - created_at: string; - /** Currency holds the value of the "currency" field. */ - currency: string; - /** - * Edges holds the relations/edges for other nodes in the graph. - * The values are being populated by the GroupQuery when eager-loading is set. - */ - edges: EntGroupEdges; - /** ID of the ent. */ - id: string; - /** Name holds the value of the "name" field. */ - name: string; - /** UpdatedAt holds the value of the "updated_at" field. */ - updated_at: string; -} - -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. */ - labels: EntLabel[]; - /** Locations holds the value of the locations edge. */ - locations: EntLocation[]; - /** Notifiers holds the value of the notifiers edge. */ - notifiers: EntNotifier[]; - /** Users holds the value of the users edge. */ - users: EntUser[]; -} - -export interface EntGroupInvitationToken { - /** CreatedAt holds the value of the "created_at" field. */ - created_at: string; - /** - * Edges holds the relations/edges for other nodes in the graph. - * The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. - */ - edges: EntGroupInvitationTokenEdges; - /** ExpiresAt holds the value of the "expires_at" field. */ - expires_at: string; - /** ID of the ent. */ - id: string; - /** Token holds the value of the "token" field. */ - token: number[]; - /** UpdatedAt holds the value of the "updated_at" field. */ - updated_at: string; - /** Uses holds the value of the "uses" field. */ - uses: number; -} - -export interface EntGroupInvitationTokenEdges { - /** Group holds the value of the group edge. */ - group: EntGroup; -} - -export interface EntItem { +export interface EntEntity { /** Archived holds the value of the "archived" field. */ archived: boolean; /** AssetID holds the value of the "asset_id" field. */ @@ -208,9 +150,9 @@ export interface EntItem { description: string; /** * Edges holds the relations/edges for other nodes in the graph. - * The values are being populated by the ItemQuery when eager-loading is set. + * The values are being populated by the EntityQuery when eager-loading is set. */ - edges: EntItemEdges; + edges: EntEntityEdges; /** ID of the ent. */ id: string; /** ImportRef holds the value of the "import_ref" field. */ @@ -245,8 +187,8 @@ export interface EntItem { sold_time: string; /** SoldTo holds the value of the "sold_to" field. */ sold_to: string; - /** SyncChildItemsLocations holds the value of the "sync_child_items_locations" field. */ - sync_child_items_locations: boolean; + /** SyncChildEntitiesLocations holds the value of the "sync_child_entities_locations" field. */ + sync_child_entities_locations: boolean; /** UpdatedAt holds the value of the "updated_at" field. */ updated_at: string; /** WarrantyDetails holds the value of the "warranty_details" field. */ @@ -255,26 +197,30 @@ export interface EntItem { warranty_expires: string; } -export interface EntItemEdges { +export interface EntEntityEdges { /** Attachments holds the value of the attachments edge. */ attachments: EntAttachment[]; /** Children holds the value of the children edge. */ - children: EntItem[]; + children: EntEntity[]; + /** Entity holds the value of the entity edge. */ + entity: EntEntity[]; /** Fields holds the value of the fields edge. */ - fields: EntItemField[]; + fields: EntEntityField[]; /** Group holds the value of the group edge. */ group: EntGroup; /** Label holds the value of the label edge. */ label: EntLabel[]; /** Location holds the value of the location edge. */ - location: EntLocation; + location: EntEntity; /** MaintenanceEntries holds the value of the maintenance_entries edge. */ maintenance_entries: EntMaintenanceEntry[]; /** Parent holds the value of the parent edge. */ - parent: EntItem; + parent: EntEntity; + /** Type holds the value of the type edge. */ + type: EntEntityType; } -export interface EntItemField { +export interface EntEntityField { /** BooleanValue holds the value of the "boolean_value" field. */ boolean_value: boolean; /** CreatedAt holds the value of the "created_at" field. */ @@ -283,9 +229,9 @@ export interface EntItemField { description: string; /** * Edges holds the relations/edges for other nodes in the graph. - * The values are being populated by the ItemFieldQuery when eager-loading is set. + * The values are being populated by the EntityFieldQuery when eager-loading is set. */ - edges: EntItemFieldEdges; + edges: EntEntityFieldEdges; /** ID of the ent. */ id: string; /** Name holds the value of the "name" field. */ @@ -297,14 +243,105 @@ export interface EntItemField { /** TimeValue holds the value of the "time_value" field. */ time_value: string; /** Type holds the value of the "type" field. */ - type: ItemfieldType; + type: EntityfieldType; /** UpdatedAt holds the value of the "updated_at" field. */ updated_at: string; } -export interface EntItemFieldEdges { - /** Item holds the value of the item edge. */ - item: EntItem; +export interface EntEntityFieldEdges { + /** Entity holds the value of the entity edge. */ + entity: EntEntity; +} + +export interface EntEntityType { + /** Color holds the value of the "color" field. */ + color: string; + /** 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 EntityTypeQuery when eager-loading is set. + */ + edges: EntEntityTypeEdges; + /** Icon holds the value of the "icon" field. */ + icon: string; + /** ID of the ent. */ + id: string; + /** IsLocation holds the value of the "is_location" field. */ + is_location: boolean; + /** Name holds the value of the "name" field. */ + name: string; + /** UpdatedAt holds the value of the "updated_at" field. */ + updated_at: string; +} + +export interface EntEntityTypeEdges { + /** Entities holds the value of the entities edge. */ + entities: EntEntity[]; + /** Group holds the value of the group edge. */ + group: EntGroup; +} + +export interface EntGroup { + /** CreatedAt holds the value of the "created_at" field. */ + created_at: string; + /** Currency holds the value of the "currency" field. */ + currency: string; + /** + * Edges holds the relations/edges for other nodes in the graph. + * The values are being populated by the GroupQuery when eager-loading is set. + */ + edges: EntGroupEdges; + /** ID of the ent. */ + id: string; + /** Name holds the value of the "name" field. */ + name: string; + /** UpdatedAt holds the value of the "updated_at" field. */ + updated_at: string; +} + +export interface EntGroupEdges { + /** Entities holds the value of the entities edge. */ + entities: EntEntity[]; + /** EntityTypes holds the value of the entity_types edge. */ + entity_types: EntEntityType[]; + /** InvitationTokens holds the value of the invitation_tokens edge. */ + invitation_tokens: EntGroupInvitationToken[]; + /** ItemTemplates holds the value of the item_templates edge. */ + item_templates: EntItemTemplate[]; + /** Labels holds the value of the labels edge. */ + labels: EntLabel[]; + /** Notifiers holds the value of the notifiers edge. */ + notifiers: EntNotifier[]; + /** Users holds the value of the users edge. */ + users: EntUser[]; +} + +export interface EntGroupInvitationToken { + /** CreatedAt holds the value of the "created_at" field. */ + created_at: string; + /** + * Edges holds the relations/edges for other nodes in the graph. + * The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. + */ + edges: EntGroupInvitationTokenEdges; + /** ExpiresAt holds the value of the "expires_at" field. */ + expires_at: string; + /** ID of the ent. */ + id: string; + /** Token holds the value of the "token" field. */ + token: number[]; + /** UpdatedAt holds the value of the "updated_at" field. */ + updated_at: string; + /** Uses holds the value of the "uses" field. */ + uses: number; +} + +export interface EntGroupInvitationTokenEdges { + /** Group holds the value of the group edge. */ + group: EntGroup; } export interface EntItemTemplate { @@ -357,7 +394,7 @@ export interface EntItemTemplateEdges { /** Group holds the value of the group edge. */ group: EntGroup; /** Location holds the value of the location edge. */ - location: EntLocation; + location: EntEntity; } export interface EntLabel { @@ -381,39 +418,10 @@ export interface EntLabel { } export interface EntLabelEdges { + /** Entities holds the value of the entities edge. */ + entities: EntEntity[]; /** Group holds the value of the group edge. */ group: EntGroup; - /** Items holds the value of the items edge. */ - items: EntItem[]; -} - -export interface EntLocation { - /** 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 LocationQuery when eager-loading is set. - */ - edges: EntLocationEdges; - /** ID of the ent. */ - id: string; - /** Name holds the value of the "name" field. */ - name: string; - /** UpdatedAt holds the value of the "updated_at" field. */ - updated_at: string; -} - -export interface EntLocationEdges { - /** Children holds the value of the children edge. */ - children: EntLocation[]; - /** Group holds the value of the group edge. */ - group: EntGroup; - /** Items holds the value of the items edge. */ - items: EntItem[]; - /** Parent holds the value of the parent edge. */ - parent: EntLocation; } export interface EntMaintenanceEntry { @@ -430,10 +438,10 @@ export interface EntMaintenanceEntry { * The values are being populated by the MaintenanceEntryQuery when eager-loading is set. */ edges: EntMaintenanceEntryEdges; + /** EntityID holds the value of the "entity_id" field. */ + entity_id: string; /** ID of the ent. */ id: string; - /** ItemID holds the value of the "item_id" field. */ - item_id: string; /** Name holds the value of the "name" field. */ name: string; /** ScheduledDate holds the value of the "scheduled_date" field. */ @@ -443,8 +451,8 @@ export interface EntMaintenanceEntry { } export interface EntMaintenanceEntryEdges { - /** Item holds the value of the item edge. */ - item: EntItem; + /** Entity holds the value of the entity edge. */ + entity: EntEntity; } export interface EntNotifier { @@ -562,6 +570,52 @@ export interface DuplicateOptions { copyPrefix: string; } +export interface EntityAttachment { + createdAt: Date | string; + id: string; + mimeType: string; + path: string; + primary: boolean; + thumbnail: EntAttachment; + title: string; + type: string; + updatedAt: Date | string; +} + +export interface EntityAttachmentUpdate { + primary: boolean; + title: string; + type: string; +} + +export interface EntityType { + color: string; + description: string; + icon: string; + isLocation: boolean; + name: string; +} + +export interface EntityTypeCreate { + color: string; + description: string; + icon: string; + isLocation: boolean; + name: string; +} + +export interface EntityTypeDelete { + replacementId: UuidNullUUID; +} + +export interface EntityTypeUpdate { + color: string; + description: string; + icon: string; + /** @minLength 1 */ + name: string; +} + export interface Group { createdAt: Date | string; currency: string; @@ -584,27 +638,10 @@ export interface GroupUpdate { name: string; } -export interface ItemAttachment { - createdAt: Date | string; - id: string; - mimeType: string; - path: string; - primary: boolean; - thumbnail: EntAttachment; - title: string; - type: string; - updatedAt: Date | string; -} - -export interface ItemAttachmentUpdate { - primary: boolean; - title: string; - type: string; -} - export interface ItemCreate { /** @maxLength 1000 */ description: string; + entityType: string; labelIds: string[]; /** Edges */ locationId: string; @@ -630,9 +667,10 @@ export interface ItemOut { archived: boolean; /** @example "0" */ assetId: string; - attachments: ItemAttachment[]; + attachments: EntityAttachment[]; createdAt: Date | string; description: string; + entityType: string; fields: ItemField[]; id: string; imageId?: string | null; @@ -685,6 +723,7 @@ export interface ItemSummary { assetId: string; createdAt: Date | string; description: string; + entityType: string; id: string; imageId?: string | null; insured: boolean; @@ -811,6 +850,7 @@ export interface ItemUpdate { assetId: string; /** @maxLength 1000 */ description: string; + entityType: string; fields: ItemField[]; id: string; insured: boolean; @@ -879,6 +919,7 @@ export interface LabelSummary { export interface LocationCreate { description: string; + entityType: string; name: string; parentId?: string | null; } @@ -887,6 +928,7 @@ export interface LocationOut { children: LocationSummary[]; createdAt: Date | string; description: string; + entityType: string; id: string; name: string; parent: LocationSummary; @@ -897,6 +939,7 @@ export interface LocationOut { export interface LocationOutCount { createdAt: Date | string; description: string; + entityType: string; id: string; itemCount: number; name: string; @@ -906,6 +949,7 @@ export interface LocationOutCount { export interface LocationSummary { createdAt: Date | string; description: string; + entityType: string; id: string; name: string; updatedAt: Date | string; @@ -913,6 +957,7 @@ export interface LocationSummary { export interface LocationUpdate { description: string; + entityType: string; id: string; name: string; parentId?: string | null; @@ -1069,6 +1114,12 @@ export interface UserRegistration { token: string; } +export interface UuidNullUUID { + uuid: string; + /** Valid is true if UUID is not NULL */ + valid: boolean; +} + export interface APISummary { allowRegistration: boolean; build: Build;