From 62af96a6d9dc95ca9e281a992c2d8e2272468fb8 Mon Sep 17 00:00:00 2001 From: James Kwon <96548424+hongil0316@users.noreply.github.com> Date: Wed, 25 Dec 2024 21:37:38 -0500 Subject: [PATCH] add comfy node --- .env | 2 + drip/api.gen.go | 497 +++++-- ent/client.go | 195 ++- ent/comfynode.go | 268 ++++ ent/comfynode/comfynode.go | 165 +++ ent/comfynode/where.go | 560 ++++++++ ent/comfynode_create.go | 1209 +++++++++++++++++ ent/comfynode_delete.go | 88 ++ ent/comfynode_query.go | 655 +++++++++ ent/comfynode_update.go | 751 ++++++++++ ent/ent.go | 2 + ent/hook/hook.go | 12 + ent/migrate/schema.go | 39 + ent/mutation.go | 1194 +++++++++++++++- ent/nodeversion.go | 18 +- ent/nodeversion/nodeversion.go | 30 + ent/nodeversion/where.go | 23 + ent/nodeversion_create.go | 32 + ent/nodeversion_query.go | 77 +- ent/nodeversion_update.go | 163 +++ ent/predicate/predicate.go | 3 + ent/runtime.go | 36 + ent/schema/comfy_node.go | 59 + ent/schema/node_version.go | 1 + ent/tx.go | 3 + .../registry_integration_test.go | 191 ++- mapper/node_version.go | 29 + openapi.yml | 167 ++- server/implementation/registry.go | 48 +- .../authentication/firebase_auth.go | 46 +- .../authentication/firebase_auth_test.go | 7 +- .../authentication/service_account_auth.go | 35 +- .../service_account_auth_test.go | 2 + services/registry/registry_svc.go | 109 +- 34 files changed, 6477 insertions(+), 239 deletions(-) create mode 100755 .env create mode 100644 ent/comfynode.go create mode 100644 ent/comfynode/comfynode.go create mode 100644 ent/comfynode/where.go create mode 100644 ent/comfynode_create.go create mode 100644 ent/comfynode_delete.go create mode 100644 ent/comfynode_query.go create mode 100644 ent/comfynode_update.go create mode 100644 ent/schema/comfy_node.go diff --git a/.env b/.env new file mode 100755 index 0000000..e8504fe --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +ALGOLIA_APP_ID=683E7V7Y2D +ALGOLIA_API_KEY=e87344d5f7d365be084a520e23d22435 \ No newline at end of file diff --git a/drip/api.gen.go b/drip/api.gen.go index 99cf2a5..caa1648 100644 --- a/drip/api.gen.go +++ b/drip/api.gen.go @@ -128,6 +128,39 @@ type ActionJobResult struct { WorkflowName *string `json:"workflow_name,omitempty"` } +// ComfyNode defines model for ComfyNode. +type ComfyNode struct { + // Category UI category where the node is listed, used for grouping nodes. + Category *string `json:"category,omitempty"` + + // ComfyNodeId Unique identifier for the node + ComfyNodeId *string `json:"comfy_node_id,omitempty"` + + // Deprecated Indicates if the node is deprecated. Deprecated nodes are hidden in the UI. + Deprecated *bool `json:"deprecated,omitempty"` + + // Description Brief description of the node's functionality or purpose. + Description *string `json:"description,omitempty"` + + // Experimental Indicates if the node is experimental, subject to changes or removal. + Experimental *bool `json:"experimental,omitempty"` + + // Function Name of the entry-point function to execute the node. + Function *string `json:"function,omitempty"` + + // InputTypes Defines input parameters + InputTypes *string `json:"input_types,omitempty"` + + // OutputIsList Boolean values indicating if each output is a list. + OutputIsList *[]bool `json:"output_is_list,omitempty"` + + // ReturnNames Names of the outputs for clarity in workflows. + ReturnNames *[]string `json:"return_names,omitempty"` + + // ReturnTypes Specifies the types of outputs produced by the node. + ReturnTypes *[]string `json:"return_types,omitempty"` +} + // Error defines model for Error. type Error struct { // Details Optional detailed information about the error or hints for resolving it. @@ -243,7 +276,8 @@ type NodeStatus string // NodeVersion defines model for NodeVersion. type NodeVersion struct { // Changelog Summary of changes made in this version - Changelog *string `json:"changelog,omitempty"` + Changelog *string `json:"changelog,omitempty"` + ComfyNodes *map[string]ComfyNode `json:"comfy_nodes,omitempty"` // CreatedAt The date and time the version was created. CreatedAt *time.Time `json:"createdAt,omitempty"` @@ -469,10 +503,12 @@ type PostNodeReviewParams struct { // ListNodeVersionsParams defines parameters for ListNodeVersions. type ListNodeVersionsParams struct { - Statuses *[]NodeVersionStatus `form:"statuses,omitempty" json:"statuses,omitempty"` - IncludeStatusReason *bool `form:"include_status_reason,omitempty" json:"include_status_reason,omitempty"` + Statuses *[]NodeVersionStatus `form:"statuses,omitempty" json:"statuses,omitempty"` } +// CreateComfyNodesJSONBody defines parameters for CreateComfyNodes. +type CreateComfyNodesJSONBody map[string]ComfyNode + // ValidatePublisherParams defines parameters for ValidatePublisher. type ValidatePublisherParams struct { // Username The publisher username to validate. @@ -570,9 +606,8 @@ type PostUploadArtifactJSONBody struct { // ListAllNodeVersionsParams defines parameters for ListAllNodeVersions. type ListAllNodeVersionsParams struct { - NodeId *string `form:"nodeId,omitempty" json:"nodeId,omitempty"` - Statuses *[]NodeVersionStatus `form:"statuses,omitempty" json:"statuses,omitempty"` - IncludeStatusReason *bool `form:"include_status_reason,omitempty" json:"include_status_reason,omitempty"` + NodeId *string `form:"nodeId,omitempty" json:"nodeId,omitempty"` + Statuses *[]NodeVersionStatus `form:"statuses,omitempty" json:"statuses,omitempty"` // Page The page number to retrieve. Page *int `form:"page,omitempty" json:"page,omitempty"` @@ -584,6 +619,9 @@ type ListAllNodeVersionsParams struct { // AdminUpdateNodeVersionJSONRequestBody defines body for AdminUpdateNodeVersion for application/json ContentType. type AdminUpdateNodeVersionJSONRequestBody AdminUpdateNodeVersionJSONBody +// CreateComfyNodesJSONRequestBody defines body for CreateComfyNodes for application/json ContentType. +type CreateComfyNodesJSONRequestBody CreateComfyNodesJSONBody + // CreatePublisherJSONRequestBody defines body for CreatePublisher for application/json ContentType. type CreatePublisherJSONRequestBody = Publisher @@ -646,6 +684,12 @@ type ServerInterface interface { // Retrieve a specific version of a node // (GET /nodes/{nodeId}/versions/{versionId}) GetNodeVersion(ctx echo.Context, nodeId string, versionId string) error + // create comfy-nodes for certain node + // (POST /nodes/{nodeId}/versions/{versionId}/comfy-nodes) + CreateComfyNodes(ctx echo.Context, nodeId string, versionId string) error + // get specify comfy-node based on its id + // (GET /nodes/{nodeId}/versions/{versionId}/comfy-nodes/{comfyNodeId}) + GetComfyNode(ctx echo.Context, nodeId string, versionId string, comfyNodeId string) error // Retrieve all publishers // (GET /publishers) ListPublishers(ctx echo.Context) error @@ -1040,13 +1084,6 @@ func (w *ServerInterfaceWrapper) ListNodeVersions(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter statuses: %s", err)) } - // ------------- Optional query parameter "include_status_reason" ------------- - - err = runtime.BindQueryParameter("form", true, false, "include_status_reason", ctx.QueryParams(), ¶ms.IncludeStatusReason) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter include_status_reason: %s", err)) - } - // Invoke the callback with all the unmarshaled arguments err = w.Handler.ListNodeVersions(ctx, nodeId, params) return err @@ -1076,6 +1113,62 @@ func (w *ServerInterfaceWrapper) GetNodeVersion(ctx echo.Context) error { return err } +// CreateComfyNodes converts echo context to params. +func (w *ServerInterfaceWrapper) CreateComfyNodes(ctx echo.Context) error { + var err error + // ------------- Path parameter "nodeId" ------------- + var nodeId string + + err = runtime.BindStyledParameterWithOptions("simple", "nodeId", ctx.Param("nodeId"), &nodeId, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter nodeId: %s", err)) + } + + // ------------- Path parameter "versionId" ------------- + var versionId string + + err = runtime.BindStyledParameterWithOptions("simple", "versionId", ctx.Param("versionId"), &versionId, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter versionId: %s", err)) + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.CreateComfyNodes(ctx, nodeId, versionId) + return err +} + +// GetComfyNode converts echo context to params. +func (w *ServerInterfaceWrapper) GetComfyNode(ctx echo.Context) error { + var err error + // ------------- Path parameter "nodeId" ------------- + var nodeId string + + err = runtime.BindStyledParameterWithOptions("simple", "nodeId", ctx.Param("nodeId"), &nodeId, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter nodeId: %s", err)) + } + + // ------------- Path parameter "versionId" ------------- + var versionId string + + err = runtime.BindStyledParameterWithOptions("simple", "versionId", ctx.Param("versionId"), &versionId, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter versionId: %s", err)) + } + + // ------------- Path parameter "comfyNodeId" ------------- + var comfyNodeId string + + err = runtime.BindStyledParameterWithOptions("simple", "comfyNodeId", ctx.Param("comfyNodeId"), &comfyNodeId, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter comfyNodeId: %s", err)) + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.GetComfyNode(ctx, nodeId, versionId, comfyNodeId) + return err +} + // ListPublishers converts echo context to params. func (w *ServerInterfaceWrapper) ListPublishers(ctx echo.Context) error { var err error @@ -1573,13 +1666,6 @@ func (w *ServerInterfaceWrapper) ListAllNodeVersions(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter statuses: %s", err)) } - // ------------- Optional query parameter "include_status_reason" ------------- - - err = runtime.BindQueryParameter("form", true, false, "include_status_reason", ctx.QueryParams(), ¶ms.IncludeStatusReason) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter include_status_reason: %s", err)) - } - // ------------- Optional query parameter "page" ------------- err = runtime.BindQueryParameter("form", true, false, "page", ctx.QueryParams(), ¶ms.Page) @@ -1655,6 +1741,8 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.POST(baseURL+"/nodes/:nodeId/reviews", wrapper.PostNodeReview) router.GET(baseURL+"/nodes/:nodeId/versions", wrapper.ListNodeVersions) router.GET(baseURL+"/nodes/:nodeId/versions/:versionId", wrapper.GetNodeVersion) + router.POST(baseURL+"/nodes/:nodeId/versions/:versionId/comfy-nodes", wrapper.CreateComfyNodes) + router.GET(baseURL+"/nodes/:nodeId/versions/:versionId/comfy-nodes/:comfyNodeId", wrapper.GetComfyNode) router.GET(baseURL+"/publishers", wrapper.ListPublishers) router.POST(baseURL+"/publishers", wrapper.CreatePublisher) router.GET(baseURL+"/publishers/validate", wrapper.ValidatePublisher) @@ -2215,6 +2303,113 @@ func (response GetNodeVersion500JSONResponse) VisitGetNodeVersionResponse(w http return json.NewEncoder(w).Encode(response) } +type CreateComfyNodesRequestObject struct { + NodeId string `json:"nodeId"` + VersionId string `json:"versionId"` + Body *CreateComfyNodesJSONRequestBody +} + +type CreateComfyNodesResponseObject interface { + VisitCreateComfyNodesResponse(w http.ResponseWriter) error +} + +type CreateComfyNodes204Response struct { +} + +func (response CreateComfyNodes204Response) VisitCreateComfyNodesResponse(w http.ResponseWriter) error { + w.WriteHeader(204) + return nil +} + +type CreateComfyNodes401Response struct { +} + +func (response CreateComfyNodes401Response) VisitCreateComfyNodesResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil +} + +type CreateComfyNodes403JSONResponse ErrorResponse + +func (response CreateComfyNodes403JSONResponse) VisitCreateComfyNodesResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(403) + + return json.NewEncoder(w).Encode(response) +} + +type CreateComfyNodes404JSONResponse ErrorResponse + +func (response CreateComfyNodes404JSONResponse) VisitCreateComfyNodesResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + + return json.NewEncoder(w).Encode(response) +} + +type CreateComfyNodes500JSONResponse ErrorResponse + +func (response CreateComfyNodes500JSONResponse) VisitCreateComfyNodesResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + + return json.NewEncoder(w).Encode(response) +} + +type GetComfyNodeRequestObject struct { + NodeId string `json:"nodeId"` + VersionId string `json:"versionId"` + ComfyNodeId string `json:"comfyNodeId"` +} + +type GetComfyNodeResponseObject interface { + VisitGetComfyNodeResponse(w http.ResponseWriter) error +} + +type GetComfyNode200JSONResponse ComfyNode + +func (response GetComfyNode200JSONResponse) VisitGetComfyNodeResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type GetComfyNode401Response struct { +} + +func (response GetComfyNode401Response) VisitGetComfyNodeResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil +} + +type GetComfyNode403JSONResponse ErrorResponse + +func (response GetComfyNode403JSONResponse) VisitGetComfyNodeResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(403) + + return json.NewEncoder(w).Encode(response) +} + +type GetComfyNode404JSONResponse ErrorResponse + +func (response GetComfyNode404JSONResponse) VisitGetComfyNodeResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(404) + + return json.NewEncoder(w).Encode(response) +} + +type GetComfyNode500JSONResponse ErrorResponse + +func (response GetComfyNode500JSONResponse) VisitGetComfyNodeResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + + return json.NewEncoder(w).Encode(response) +} + type ListPublishersRequestObject struct { } @@ -3395,6 +3590,12 @@ type StrictServerInterface interface { // Retrieve a specific version of a node // (GET /nodes/{nodeId}/versions/{versionId}) GetNodeVersion(ctx context.Context, request GetNodeVersionRequestObject) (GetNodeVersionResponseObject, error) + // create comfy-nodes for certain node + // (POST /nodes/{nodeId}/versions/{versionId}/comfy-nodes) + CreateComfyNodes(ctx context.Context, request CreateComfyNodesRequestObject) (CreateComfyNodesResponseObject, error) + // get specify comfy-node based on its id + // (GET /nodes/{nodeId}/versions/{versionId}/comfy-nodes/{comfyNodeId}) + GetComfyNode(ctx context.Context, request GetComfyNodeRequestObject) (GetComfyNodeResponseObject, error) // Retrieve all publishers // (GET /publishers) ListPublishers(ctx context.Context, request ListPublishersRequestObject) (ListPublishersResponseObject, error) @@ -3796,6 +3997,65 @@ func (sh *strictHandler) GetNodeVersion(ctx echo.Context, nodeId string, version return nil } +// CreateComfyNodes operation middleware +func (sh *strictHandler) CreateComfyNodes(ctx echo.Context, nodeId string, versionId string) error { + var request CreateComfyNodesRequestObject + + request.NodeId = nodeId + request.VersionId = versionId + + var body CreateComfyNodesJSONRequestBody + if err := ctx.Bind(&body); err != nil { + return err + } + request.Body = &body + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.CreateComfyNodes(ctx.Request().Context(), request.(CreateComfyNodesRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "CreateComfyNodes") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(CreateComfyNodesResponseObject); ok { + return validResponse.VisitCreateComfyNodesResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// GetComfyNode operation middleware +func (sh *strictHandler) GetComfyNode(ctx echo.Context, nodeId string, versionId string, comfyNodeId string) error { + var request GetComfyNodeRequestObject + + request.NodeId = nodeId + request.VersionId = versionId + request.ComfyNodeId = comfyNodeId + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.GetComfyNode(ctx.Request().Context(), request.(GetComfyNodeRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "GetComfyNode") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(GetComfyNodeResponseObject); ok { + return validResponse.VisitGetComfyNodeResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + // ListPublishers operation middleware func (sh *strictHandler) ListPublishers(ctx echo.Context) error { var request ListPublishersRequestObject @@ -4498,101 +4758,108 @@ func (sh *strictHandler) GetWorkflowResult(ctx echo.Context, workflowResultId st // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+w9f2/btrZfhdC7wFY8x053e4eH/Jema5dtSYOk6bC75vnSEi2zlUiNpJJ6Rb77BX/J", - "lETKspO49mbg4jYzqcND8vzmIc+XKKZ5QQkigkdHXyIez1AO1Z/HscCU/EQnl4iXmZA/FYwWiAmMVAeo", - "Oow/0skYJ/KHBPGY4UL+Gh1FpwkiAk8xYoBOgZgh8JFOgJhhDpiCCCYooyTlQNBoEIl5gaKjiAuGSRrd", - "Dyx4VpKe4FlJVgFfihllbbjvZgjoNgs3pnmOhRfGbTq+ZTAPQLlFDKYIvL88PgMlRwmYzO06LKBhIlCK", - "mAQ3YZDEszGBOWpDPIc5qmaKMnQLiQApFkB/5UMvpvl0rhZwmsGU+7FUndTaqU5D8MMwHYL/HBxk9O5A", - "Tu4/AdA5FuMZ5DM/WNmyfAENGN/+SiCnr3qDyBHnMEV+OKaxNzCB8wCka4I/A9nMBcwLcDdDxAEJ7iAH", - "OUxQNIimlOVQ6A3+/oV3v+MygeNbxLiC3xzu5PrVMTCtinx8CCOSdGCLSKKQdRkQcgAb0xj2QzfFYsxQ", - "Qf1jyRaOBWVzoAjYg6xvm68J/qNEAC+4eUpZhazmZBe9ssTehZBSSDCcpoiNS44CjC1bwN2MAtMVJXao", - "oQ9oDuMZJmjMBdTi8R8MTaOj6H9GC6k5MiJzdKY7X6m+94NIikooMEnHfM4F8giJt7YH0D2Cu1wg+KlD", - "0Mjm/lKmYGNS5pPQEhVllgGG/igRF8B09KE0FzNKwtR7MX9HWTxbSsDFXMh+DwfEBWRdnKvaH5EbJE2U", - "S4niV8o+TTN6d1mSK/2B+pRKxTCe4gwtA3Cl+76WXe8H0Z2B10NJ2K7txbqvfqGTjygWEvAPjGltWNfx", - "CRIQZ9xHu/IPmAHdAyUAE71qcpPghJZCYYEkXEAZmGEiuGJuhjjNbiXZYyEXGwuUqxFae2p+gIzBueLH", - "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EXuU1THnpJRU2ajGRInenM16JvmSJykbWEcknr7Ah9cIikT9I9gv2Nek313ebFcQs0O9Z", + "47MMHBYLA2xPzMHLw8PhpoU3ndjkExbgHAQubz5AIZcexsbWlnbZ3horVQLRQpfTFEl7SJiaxy25SNbk", + "1Y9mjr7af1+pfy95Xv63Sudex0p1+FvzFJ+2DX+mEzMZ/8vuKa6Zuk94ymOG373iJia6pl/gu9dWqQSg", + "iSRnSXAUzITI+NFoBDM8VNHDIWVxcH97/38BAAD//9j1hCsivgAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/ent/client.go b/ent/client.go index 04dbce9..c5c323e 100644 --- a/ent/client.go +++ b/ent/client.go @@ -12,6 +12,7 @@ import ( "registry-backend/ent/migrate" "registry-backend/ent/ciworkflowresult" + "registry-backend/ent/comfynode" "registry-backend/ent/gitcommit" "registry-backend/ent/node" "registry-backend/ent/nodereview" @@ -36,6 +37,8 @@ type Client struct { Schema *migrate.Schema // CIWorkflowResult is the client for interacting with the CIWorkflowResult builders. CIWorkflowResult *CIWorkflowResultClient + // ComfyNode is the client for interacting with the ComfyNode builders. + ComfyNode *ComfyNodeClient // GitCommit is the client for interacting with the GitCommit builders. GitCommit *GitCommitClient // Node is the client for interacting with the Node builders. @@ -66,6 +69,7 @@ func NewClient(opts ...Option) *Client { func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.CIWorkflowResult = NewCIWorkflowResultClient(c.config) + c.ComfyNode = NewComfyNodeClient(c.config) c.GitCommit = NewGitCommitClient(c.config) c.Node = NewNodeClient(c.config) c.NodeReview = NewNodeReviewClient(c.config) @@ -168,6 +172,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { ctx: ctx, config: cfg, CIWorkflowResult: NewCIWorkflowResultClient(cfg), + ComfyNode: NewComfyNodeClient(cfg), GitCommit: NewGitCommitClient(cfg), Node: NewNodeClient(cfg), NodeReview: NewNodeReviewClient(cfg), @@ -197,6 +202,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) ctx: ctx, config: cfg, CIWorkflowResult: NewCIWorkflowResultClient(cfg), + ComfyNode: NewComfyNodeClient(cfg), GitCommit: NewGitCommitClient(cfg), Node: NewNodeClient(cfg), NodeReview: NewNodeReviewClient(cfg), @@ -235,9 +241,9 @@ 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.CIWorkflowResult, c.GitCommit, c.Node, c.NodeReview, c.NodeVersion, - c.PersonalAccessToken, c.Publisher, c.PublisherPermission, c.StorageFile, - c.User, + c.CIWorkflowResult, c.ComfyNode, c.GitCommit, c.Node, c.NodeReview, + c.NodeVersion, c.PersonalAccessToken, c.Publisher, c.PublisherPermission, + c.StorageFile, c.User, } { n.Use(hooks...) } @@ -247,9 +253,9 @@ 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.CIWorkflowResult, c.GitCommit, c.Node, c.NodeReview, c.NodeVersion, - c.PersonalAccessToken, c.Publisher, c.PublisherPermission, c.StorageFile, - c.User, + c.CIWorkflowResult, c.ComfyNode, c.GitCommit, c.Node, c.NodeReview, + c.NodeVersion, c.PersonalAccessToken, c.Publisher, c.PublisherPermission, + c.StorageFile, c.User, } { n.Intercept(interceptors...) } @@ -260,6 +266,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { switch m := m.(type) { case *CIWorkflowResultMutation: return c.CIWorkflowResult.mutate(ctx, m) + case *ComfyNodeMutation: + return c.ComfyNode.mutate(ctx, m) case *GitCommitMutation: return c.GitCommit.mutate(ctx, m) case *NodeMutation: @@ -448,6 +456,155 @@ func (c *CIWorkflowResultClient) mutate(ctx context.Context, m *CIWorkflowResult } } +// ComfyNodeClient is a client for the ComfyNode schema. +type ComfyNodeClient struct { + config +} + +// NewComfyNodeClient returns a client for the ComfyNode from the given config. +func NewComfyNodeClient(c config) *ComfyNodeClient { + return &ComfyNodeClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `comfynode.Hooks(f(g(h())))`. +func (c *ComfyNodeClient) Use(hooks ...Hook) { + c.hooks.ComfyNode = append(c.hooks.ComfyNode, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `comfynode.Intercept(f(g(h())))`. +func (c *ComfyNodeClient) Intercept(interceptors ...Interceptor) { + c.inters.ComfyNode = append(c.inters.ComfyNode, interceptors...) +} + +// Create returns a builder for creating a ComfyNode entity. +func (c *ComfyNodeClient) Create() *ComfyNodeCreate { + mutation := newComfyNodeMutation(c.config, OpCreate) + return &ComfyNodeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ComfyNode entities. +func (c *ComfyNodeClient) CreateBulk(builders ...*ComfyNodeCreate) *ComfyNodeCreateBulk { + return &ComfyNodeCreateBulk{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 *ComfyNodeClient) MapCreateBulk(slice any, setFunc func(*ComfyNodeCreate, int)) *ComfyNodeCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ComfyNodeCreateBulk{err: fmt.Errorf("calling to ComfyNodeClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ComfyNodeCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ComfyNodeCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ComfyNode. +func (c *ComfyNodeClient) Update() *ComfyNodeUpdate { + mutation := newComfyNodeMutation(c.config, OpUpdate) + return &ComfyNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ComfyNodeClient) UpdateOne(cn *ComfyNode) *ComfyNodeUpdateOne { + mutation := newComfyNodeMutation(c.config, OpUpdateOne, withComfyNode(cn)) + return &ComfyNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ComfyNodeClient) UpdateOneID(id string) *ComfyNodeUpdateOne { + mutation := newComfyNodeMutation(c.config, OpUpdateOne, withComfyNodeID(id)) + return &ComfyNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ComfyNode. +func (c *ComfyNodeClient) Delete() *ComfyNodeDelete { + mutation := newComfyNodeMutation(c.config, OpDelete) + return &ComfyNodeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ComfyNodeClient) DeleteOne(cn *ComfyNode) *ComfyNodeDeleteOne { + return c.DeleteOneID(cn.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ComfyNodeClient) DeleteOneID(id string) *ComfyNodeDeleteOne { + builder := c.Delete().Where(comfynode.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ComfyNodeDeleteOne{builder} +} + +// Query returns a query builder for ComfyNode. +func (c *ComfyNodeClient) Query() *ComfyNodeQuery { + return &ComfyNodeQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeComfyNode}, + inters: c.Interceptors(), + } +} + +// Get returns a ComfyNode entity by its id. +func (c *ComfyNodeClient) Get(ctx context.Context, id string) (*ComfyNode, error) { + return c.Query().Where(comfynode.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ComfyNodeClient) GetX(ctx context.Context, id string) *ComfyNode { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryVersions queries the versions edge of a ComfyNode. +func (c *ComfyNodeClient) QueryVersions(cn *ComfyNode) *NodeVersionQuery { + query := (&NodeVersionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := cn.ID + step := sqlgraph.NewStep( + sqlgraph.From(comfynode.Table, comfynode.FieldID, id), + sqlgraph.To(nodeversion.Table, nodeversion.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, comfynode.VersionsTable, comfynode.VersionsColumn), + ) + fromV = sqlgraph.Neighbors(cn.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ComfyNodeClient) Hooks() []Hook { + return c.hooks.ComfyNode +} + +// Interceptors returns the client interceptors. +func (c *ComfyNodeClient) Interceptors() []Interceptor { + return c.inters.ComfyNode +} + +func (c *ComfyNodeClient) mutate(ctx context.Context, m *ComfyNodeMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ComfyNodeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ComfyNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ComfyNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ComfyNodeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ComfyNode mutation op: %q", m.Op()) + } +} + // GitCommitClient is a client for the GitCommit schema. type GitCommitClient struct { config @@ -1083,6 +1240,22 @@ func (c *NodeVersionClient) QueryStorageFile(nv *NodeVersion) *StorageFileQuery return query } +// QueryComfyNodes queries the comfy_nodes edge of a NodeVersion. +func (c *NodeVersionClient) QueryComfyNodes(nv *NodeVersion) *ComfyNodeQuery { + query := (&ComfyNodeClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := nv.ID + step := sqlgraph.NewStep( + sqlgraph.From(nodeversion.Table, nodeversion.FieldID, id), + sqlgraph.To(comfynode.Table, comfynode.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, nodeversion.ComfyNodesTable, nodeversion.ComfyNodesColumn), + ) + fromV = sqlgraph.Neighbors(nv.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *NodeVersionClient) Hooks() []Hook { return c.hooks.NodeVersion @@ -1904,11 +2077,13 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - CIWorkflowResult, GitCommit, Node, NodeReview, NodeVersion, PersonalAccessToken, - Publisher, PublisherPermission, StorageFile, User []ent.Hook + CIWorkflowResult, ComfyNode, GitCommit, Node, NodeReview, NodeVersion, + PersonalAccessToken, Publisher, PublisherPermission, StorageFile, + User []ent.Hook } inters struct { - CIWorkflowResult, GitCommit, Node, NodeReview, NodeVersion, PersonalAccessToken, - Publisher, PublisherPermission, StorageFile, User []ent.Interceptor + CIWorkflowResult, ComfyNode, GitCommit, Node, NodeReview, NodeVersion, + PersonalAccessToken, Publisher, PublisherPermission, StorageFile, + User []ent.Interceptor } ) diff --git a/ent/comfynode.go b/ent/comfynode.go new file mode 100644 index 0000000..654b512 --- /dev/null +++ b/ent/comfynode.go @@ -0,0 +1,268 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "registry-backend/ent/comfynode" + "registry-backend/ent/nodeversion" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/google/uuid" +) + +// ComfyNode is the model entity for the ComfyNode schema. +type ComfyNode struct { + config `json:"-"` + // ID of the ent. + ID string `json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime time.Time `json:"update_time,omitempty"` + // NodeVersionID holds the value of the "node_version_id" field. + NodeVersionID uuid.UUID `json:"node_version_id,omitempty"` + // Category holds the value of the "category" field. + Category string `json:"category,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // InputTypes holds the value of the "input_types" field. + InputTypes string `json:"input_types,omitempty"` + // Deprecated holds the value of the "deprecated" field. + Deprecated bool `json:"deprecated,omitempty"` + // Experimental holds the value of the "experimental" field. + Experimental bool `json:"experimental,omitempty"` + // OutputIsList holds the value of the "output_is_list" field. + OutputIsList []bool `json:"output_is_list,omitempty"` + // ReturnNames holds the value of the "return_names" field. + ReturnNames []string `json:"return_names,omitempty"` + // ReturnTypes holds the value of the "return_types" field. + ReturnTypes []string `json:"return_types,omitempty"` + // Function holds the value of the "function" field. + Function string `json:"function,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ComfyNodeQuery when eager-loading is set. + Edges ComfyNodeEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ComfyNodeEdges holds the relations/edges for other nodes in the graph. +type ComfyNodeEdges struct { + // Versions holds the value of the versions edge. + Versions *NodeVersion `json:"versions,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// VersionsOrErr returns the Versions value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ComfyNodeEdges) VersionsOrErr() (*NodeVersion, error) { + if e.Versions != nil { + return e.Versions, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: nodeversion.Label} + } + return nil, &NotLoadedError{edge: "versions"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ComfyNode) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case comfynode.FieldOutputIsList, comfynode.FieldReturnNames, comfynode.FieldReturnTypes: + values[i] = new([]byte) + case comfynode.FieldDeprecated, comfynode.FieldExperimental: + values[i] = new(sql.NullBool) + case comfynode.FieldID, comfynode.FieldCategory, comfynode.FieldDescription, comfynode.FieldInputTypes, comfynode.FieldFunction: + values[i] = new(sql.NullString) + case comfynode.FieldCreateTime, comfynode.FieldUpdateTime: + values[i] = new(sql.NullTime) + case comfynode.FieldNodeVersionID: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ComfyNode fields. +func (cn *ComfyNode) 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 comfynode.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + cn.ID = value.String + } + case comfynode.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + cn.CreateTime = value.Time + } + case comfynode.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + cn.UpdateTime = value.Time + } + case comfynode.FieldNodeVersionID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field node_version_id", values[i]) + } else if value != nil { + cn.NodeVersionID = *value + } + case comfynode.FieldCategory: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field category", values[i]) + } else if value.Valid { + cn.Category = value.String + } + case comfynode.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + cn.Description = value.String + } + case comfynode.FieldInputTypes: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field input_types", values[i]) + } else if value.Valid { + cn.InputTypes = value.String + } + case comfynode.FieldDeprecated: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deprecated", values[i]) + } else if value.Valid { + cn.Deprecated = value.Bool + } + case comfynode.FieldExperimental: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field experimental", values[i]) + } else if value.Valid { + cn.Experimental = value.Bool + } + case comfynode.FieldOutputIsList: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field output_is_list", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &cn.OutputIsList); err != nil { + return fmt.Errorf("unmarshal field output_is_list: %w", err) + } + } + case comfynode.FieldReturnNames: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field return_names", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &cn.ReturnNames); err != nil { + return fmt.Errorf("unmarshal field return_names: %w", err) + } + } + case comfynode.FieldReturnTypes: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field return_types", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &cn.ReturnTypes); err != nil { + return fmt.Errorf("unmarshal field return_types: %w", err) + } + } + case comfynode.FieldFunction: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field function", values[i]) + } else if value.Valid { + cn.Function = value.String + } + default: + cn.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ComfyNode. +// This includes values selected through modifiers, order, etc. +func (cn *ComfyNode) Value(name string) (ent.Value, error) { + return cn.selectValues.Get(name) +} + +// QueryVersions queries the "versions" edge of the ComfyNode entity. +func (cn *ComfyNode) QueryVersions() *NodeVersionQuery { + return NewComfyNodeClient(cn.config).QueryVersions(cn) +} + +// Update returns a builder for updating this ComfyNode. +// Note that you need to call ComfyNode.Unwrap() before calling this method if this ComfyNode +// was returned from a transaction, and the transaction was committed or rolled back. +func (cn *ComfyNode) Update() *ComfyNodeUpdateOne { + return NewComfyNodeClient(cn.config).UpdateOne(cn) +} + +// Unwrap unwraps the ComfyNode 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 (cn *ComfyNode) Unwrap() *ComfyNode { + _tx, ok := cn.config.driver.(*txDriver) + if !ok { + panic("ent: ComfyNode is not a transactional entity") + } + cn.config.driver = _tx.drv + return cn +} + +// String implements the fmt.Stringer. +func (cn *ComfyNode) String() string { + var builder strings.Builder + builder.WriteString("ComfyNode(") + builder.WriteString(fmt.Sprintf("id=%v, ", cn.ID)) + builder.WriteString("create_time=") + builder.WriteString(cn.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(cn.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("node_version_id=") + builder.WriteString(fmt.Sprintf("%v", cn.NodeVersionID)) + builder.WriteString(", ") + builder.WriteString("category=") + builder.WriteString(cn.Category) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(cn.Description) + builder.WriteString(", ") + builder.WriteString("input_types=") + builder.WriteString(cn.InputTypes) + builder.WriteString(", ") + builder.WriteString("deprecated=") + builder.WriteString(fmt.Sprintf("%v", cn.Deprecated)) + builder.WriteString(", ") + builder.WriteString("experimental=") + builder.WriteString(fmt.Sprintf("%v", cn.Experimental)) + builder.WriteString(", ") + builder.WriteString("output_is_list=") + builder.WriteString(fmt.Sprintf("%v", cn.OutputIsList)) + builder.WriteString(", ") + builder.WriteString("return_names=") + builder.WriteString(fmt.Sprintf("%v", cn.ReturnNames)) + builder.WriteString(", ") + builder.WriteString("return_types=") + builder.WriteString(fmt.Sprintf("%v", cn.ReturnTypes)) + builder.WriteString(", ") + builder.WriteString("function=") + builder.WriteString(cn.Function) + builder.WriteByte(')') + return builder.String() +} + +// ComfyNodes is a parsable slice of ComfyNode. +type ComfyNodes []*ComfyNode diff --git a/ent/comfynode/comfynode.go b/ent/comfynode/comfynode.go new file mode 100644 index 0000000..82ba90f --- /dev/null +++ b/ent/comfynode/comfynode.go @@ -0,0 +1,165 @@ +// Code generated by ent, DO NOT EDIT. + +package comfynode + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the comfynode type in the database. + Label = "comfy_node" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldNodeVersionID holds the string denoting the node_version_id field in the database. + FieldNodeVersionID = "node_version_id" + // FieldCategory holds the string denoting the category field in the database. + FieldCategory = "category" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldInputTypes holds the string denoting the input_types field in the database. + FieldInputTypes = "input_types" + // FieldDeprecated holds the string denoting the deprecated field in the database. + FieldDeprecated = "deprecated" + // FieldExperimental holds the string denoting the experimental field in the database. + FieldExperimental = "experimental" + // FieldOutputIsList holds the string denoting the output_is_list field in the database. + FieldOutputIsList = "output_is_list" + // FieldReturnNames holds the string denoting the return_names field in the database. + FieldReturnNames = "return_names" + // FieldReturnTypes holds the string denoting the return_types field in the database. + FieldReturnTypes = "return_types" + // FieldFunction holds the string denoting the function field in the database. + FieldFunction = "function" + // EdgeVersions holds the string denoting the versions edge name in mutations. + EdgeVersions = "versions" + // Table holds the table name of the comfynode in the database. + Table = "comfy_nodes" + // VersionsTable is the table that holds the versions relation/edge. + VersionsTable = "comfy_nodes" + // VersionsInverseTable is the table name for the NodeVersion entity. + // It exists in this package in order to avoid circular dependency with the "nodeversion" package. + VersionsInverseTable = "node_versions" + // VersionsColumn is the table column denoting the versions relation/edge. + VersionsColumn = "node_version_id" +) + +// Columns holds all SQL columns for comfynode fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldNodeVersionID, + FieldCategory, + FieldDescription, + FieldInputTypes, + FieldDeprecated, + FieldExperimental, + FieldOutputIsList, + FieldReturnNames, + FieldReturnTypes, + FieldFunction, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // DefaultDeprecated holds the default value on creation for the "deprecated" field. + DefaultDeprecated bool + // DefaultExperimental holds the default value on creation for the "experimental" field. + DefaultExperimental bool + // DefaultOutputIsList holds the default value on creation for the "output_is_list" field. + DefaultOutputIsList []bool + // DefaultReturnNames holds the default value on creation for the "return_names" field. + DefaultReturnNames []string + // DefaultReturnTypes holds the default value on creation for the "return_types" field. + DefaultReturnTypes []string +) + +// OrderOption defines the ordering options for the ComfyNode queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByNodeVersionID orders the results by the node_version_id field. +func ByNodeVersionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNodeVersionID, opts...).ToFunc() +} + +// ByCategory orders the results by the category field. +func ByCategory(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCategory, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByInputTypes orders the results by the input_types field. +func ByInputTypes(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldInputTypes, opts...).ToFunc() +} + +// ByDeprecated orders the results by the deprecated field. +func ByDeprecated(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeprecated, opts...).ToFunc() +} + +// ByExperimental orders the results by the experimental field. +func ByExperimental(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExperimental, opts...).ToFunc() +} + +// ByFunction orders the results by the function field. +func ByFunction(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFunction, opts...).ToFunc() +} + +// ByVersionsField orders the results by versions field. +func ByVersionsField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newVersionsStep(), sql.OrderByField(field, opts...)) + } +} +func newVersionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(VersionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, VersionsTable, VersionsColumn), + ) +} diff --git a/ent/comfynode/where.go b/ent/comfynode/where.go new file mode 100644 index 0000000..a5315f2 --- /dev/null +++ b/ent/comfynode/where.go @@ -0,0 +1,560 @@ +// Code generated by ent, DO NOT EDIT. + +package comfynode + +import ( + "registry-backend/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldContainsFold(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldUpdateTime, v)) +} + +// NodeVersionID applies equality check predicate on the "node_version_id" field. It's identical to NodeVersionIDEQ. +func NodeVersionID(v uuid.UUID) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldNodeVersionID, v)) +} + +// Category applies equality check predicate on the "category" field. It's identical to CategoryEQ. +func Category(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldCategory, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldDescription, v)) +} + +// InputTypes applies equality check predicate on the "input_types" field. It's identical to InputTypesEQ. +func InputTypes(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldInputTypes, v)) +} + +// Deprecated applies equality check predicate on the "deprecated" field. It's identical to DeprecatedEQ. +func Deprecated(v bool) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldDeprecated, v)) +} + +// Experimental applies equality check predicate on the "experimental" field. It's identical to ExperimentalEQ. +func Experimental(v bool) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldExperimental, v)) +} + +// Function applies equality check predicate on the "function" field. It's identical to FunctionEQ. +func Function(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldFunction, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLTE(FieldUpdateTime, v)) +} + +// NodeVersionIDEQ applies the EQ predicate on the "node_version_id" field. +func NodeVersionIDEQ(v uuid.UUID) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldNodeVersionID, v)) +} + +// NodeVersionIDNEQ applies the NEQ predicate on the "node_version_id" field. +func NodeVersionIDNEQ(v uuid.UUID) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldNodeVersionID, v)) +} + +// NodeVersionIDIn applies the In predicate on the "node_version_id" field. +func NodeVersionIDIn(vs ...uuid.UUID) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIn(FieldNodeVersionID, vs...)) +} + +// NodeVersionIDNotIn applies the NotIn predicate on the "node_version_id" field. +func NodeVersionIDNotIn(vs ...uuid.UUID) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotIn(FieldNodeVersionID, vs...)) +} + +// CategoryEQ applies the EQ predicate on the "category" field. +func CategoryEQ(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldCategory, v)) +} + +// CategoryNEQ applies the NEQ predicate on the "category" field. +func CategoryNEQ(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldCategory, v)) +} + +// CategoryIn applies the In predicate on the "category" field. +func CategoryIn(vs ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIn(FieldCategory, vs...)) +} + +// CategoryNotIn applies the NotIn predicate on the "category" field. +func CategoryNotIn(vs ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotIn(FieldCategory, vs...)) +} + +// CategoryGT applies the GT predicate on the "category" field. +func CategoryGT(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGT(FieldCategory, v)) +} + +// CategoryGTE applies the GTE predicate on the "category" field. +func CategoryGTE(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGTE(FieldCategory, v)) +} + +// CategoryLT applies the LT predicate on the "category" field. +func CategoryLT(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLT(FieldCategory, v)) +} + +// CategoryLTE applies the LTE predicate on the "category" field. +func CategoryLTE(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLTE(FieldCategory, v)) +} + +// CategoryContains applies the Contains predicate on the "category" field. +func CategoryContains(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldContains(FieldCategory, v)) +} + +// CategoryHasPrefix applies the HasPrefix predicate on the "category" field. +func CategoryHasPrefix(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldHasPrefix(FieldCategory, v)) +} + +// CategoryHasSuffix applies the HasSuffix predicate on the "category" field. +func CategoryHasSuffix(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldHasSuffix(FieldCategory, v)) +} + +// CategoryIsNil applies the IsNil predicate on the "category" field. +func CategoryIsNil() predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIsNull(FieldCategory)) +} + +// CategoryNotNil applies the NotNil predicate on the "category" field. +func CategoryNotNil() predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotNull(FieldCategory)) +} + +// CategoryEqualFold applies the EqualFold predicate on the "category" field. +func CategoryEqualFold(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEqualFold(FieldCategory, v)) +} + +// CategoryContainsFold applies the ContainsFold predicate on the "category" field. +func CategoryContainsFold(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldContainsFold(FieldCategory, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldContainsFold(FieldDescription, v)) +} + +// InputTypesEQ applies the EQ predicate on the "input_types" field. +func InputTypesEQ(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldInputTypes, v)) +} + +// InputTypesNEQ applies the NEQ predicate on the "input_types" field. +func InputTypesNEQ(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldInputTypes, v)) +} + +// InputTypesIn applies the In predicate on the "input_types" field. +func InputTypesIn(vs ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIn(FieldInputTypes, vs...)) +} + +// InputTypesNotIn applies the NotIn predicate on the "input_types" field. +func InputTypesNotIn(vs ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotIn(FieldInputTypes, vs...)) +} + +// InputTypesGT applies the GT predicate on the "input_types" field. +func InputTypesGT(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGT(FieldInputTypes, v)) +} + +// InputTypesGTE applies the GTE predicate on the "input_types" field. +func InputTypesGTE(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGTE(FieldInputTypes, v)) +} + +// InputTypesLT applies the LT predicate on the "input_types" field. +func InputTypesLT(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLT(FieldInputTypes, v)) +} + +// InputTypesLTE applies the LTE predicate on the "input_types" field. +func InputTypesLTE(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLTE(FieldInputTypes, v)) +} + +// InputTypesContains applies the Contains predicate on the "input_types" field. +func InputTypesContains(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldContains(FieldInputTypes, v)) +} + +// InputTypesHasPrefix applies the HasPrefix predicate on the "input_types" field. +func InputTypesHasPrefix(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldHasPrefix(FieldInputTypes, v)) +} + +// InputTypesHasSuffix applies the HasSuffix predicate on the "input_types" field. +func InputTypesHasSuffix(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldHasSuffix(FieldInputTypes, v)) +} + +// InputTypesIsNil applies the IsNil predicate on the "input_types" field. +func InputTypesIsNil() predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIsNull(FieldInputTypes)) +} + +// InputTypesNotNil applies the NotNil predicate on the "input_types" field. +func InputTypesNotNil() predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotNull(FieldInputTypes)) +} + +// InputTypesEqualFold applies the EqualFold predicate on the "input_types" field. +func InputTypesEqualFold(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEqualFold(FieldInputTypes, v)) +} + +// InputTypesContainsFold applies the ContainsFold predicate on the "input_types" field. +func InputTypesContainsFold(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldContainsFold(FieldInputTypes, v)) +} + +// DeprecatedEQ applies the EQ predicate on the "deprecated" field. +func DeprecatedEQ(v bool) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldDeprecated, v)) +} + +// DeprecatedNEQ applies the NEQ predicate on the "deprecated" field. +func DeprecatedNEQ(v bool) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldDeprecated, v)) +} + +// ExperimentalEQ applies the EQ predicate on the "experimental" field. +func ExperimentalEQ(v bool) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldExperimental, v)) +} + +// ExperimentalNEQ applies the NEQ predicate on the "experimental" field. +func ExperimentalNEQ(v bool) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldExperimental, v)) +} + +// FunctionEQ applies the EQ predicate on the "function" field. +func FunctionEQ(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEQ(FieldFunction, v)) +} + +// FunctionNEQ applies the NEQ predicate on the "function" field. +func FunctionNEQ(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNEQ(FieldFunction, v)) +} + +// FunctionIn applies the In predicate on the "function" field. +func FunctionIn(vs ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldIn(FieldFunction, vs...)) +} + +// FunctionNotIn applies the NotIn predicate on the "function" field. +func FunctionNotIn(vs ...string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldNotIn(FieldFunction, vs...)) +} + +// FunctionGT applies the GT predicate on the "function" field. +func FunctionGT(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGT(FieldFunction, v)) +} + +// FunctionGTE applies the GTE predicate on the "function" field. +func FunctionGTE(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldGTE(FieldFunction, v)) +} + +// FunctionLT applies the LT predicate on the "function" field. +func FunctionLT(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLT(FieldFunction, v)) +} + +// FunctionLTE applies the LTE predicate on the "function" field. +func FunctionLTE(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldLTE(FieldFunction, v)) +} + +// FunctionContains applies the Contains predicate on the "function" field. +func FunctionContains(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldContains(FieldFunction, v)) +} + +// FunctionHasPrefix applies the HasPrefix predicate on the "function" field. +func FunctionHasPrefix(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldHasPrefix(FieldFunction, v)) +} + +// FunctionHasSuffix applies the HasSuffix predicate on the "function" field. +func FunctionHasSuffix(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldHasSuffix(FieldFunction, v)) +} + +// FunctionEqualFold applies the EqualFold predicate on the "function" field. +func FunctionEqualFold(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldEqualFold(FieldFunction, v)) +} + +// FunctionContainsFold applies the ContainsFold predicate on the "function" field. +func FunctionContainsFold(v string) predicate.ComfyNode { + return predicate.ComfyNode(sql.FieldContainsFold(FieldFunction, v)) +} + +// HasVersions applies the HasEdge predicate on the "versions" edge. +func HasVersions() predicate.ComfyNode { + return predicate.ComfyNode(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, VersionsTable, VersionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasVersionsWith applies the HasEdge predicate on the "versions" edge with a given conditions (other predicates). +func HasVersionsWith(preds ...predicate.NodeVersion) predicate.ComfyNode { + return predicate.ComfyNode(func(s *sql.Selector) { + step := newVersionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ComfyNode) predicate.ComfyNode { + return predicate.ComfyNode(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ComfyNode) predicate.ComfyNode { + return predicate.ComfyNode(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ComfyNode) predicate.ComfyNode { + return predicate.ComfyNode(sql.NotPredicates(p)) +} diff --git a/ent/comfynode_create.go b/ent/comfynode_create.go new file mode 100644 index 0000000..913ea68 --- /dev/null +++ b/ent/comfynode_create.go @@ -0,0 +1,1209 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "registry-backend/ent/comfynode" + "registry-backend/ent/nodeversion" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" +) + +// ComfyNodeCreate is the builder for creating a ComfyNode entity. +type ComfyNodeCreate struct { + config + mutation *ComfyNodeMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreateTime sets the "create_time" field. +func (cnc *ComfyNodeCreate) SetCreateTime(t time.Time) *ComfyNodeCreate { + cnc.mutation.SetCreateTime(t) + return cnc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (cnc *ComfyNodeCreate) SetNillableCreateTime(t *time.Time) *ComfyNodeCreate { + if t != nil { + cnc.SetCreateTime(*t) + } + return cnc +} + +// SetUpdateTime sets the "update_time" field. +func (cnc *ComfyNodeCreate) SetUpdateTime(t time.Time) *ComfyNodeCreate { + cnc.mutation.SetUpdateTime(t) + return cnc +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (cnc *ComfyNodeCreate) SetNillableUpdateTime(t *time.Time) *ComfyNodeCreate { + if t != nil { + cnc.SetUpdateTime(*t) + } + return cnc +} + +// SetNodeVersionID sets the "node_version_id" field. +func (cnc *ComfyNodeCreate) SetNodeVersionID(u uuid.UUID) *ComfyNodeCreate { + cnc.mutation.SetNodeVersionID(u) + return cnc +} + +// SetCategory sets the "category" field. +func (cnc *ComfyNodeCreate) SetCategory(s string) *ComfyNodeCreate { + cnc.mutation.SetCategory(s) + return cnc +} + +// SetNillableCategory sets the "category" field if the given value is not nil. +func (cnc *ComfyNodeCreate) SetNillableCategory(s *string) *ComfyNodeCreate { + if s != nil { + cnc.SetCategory(*s) + } + return cnc +} + +// SetDescription sets the "description" field. +func (cnc *ComfyNodeCreate) SetDescription(s string) *ComfyNodeCreate { + cnc.mutation.SetDescription(s) + return cnc +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (cnc *ComfyNodeCreate) SetNillableDescription(s *string) *ComfyNodeCreate { + if s != nil { + cnc.SetDescription(*s) + } + return cnc +} + +// SetInputTypes sets the "input_types" field. +func (cnc *ComfyNodeCreate) SetInputTypes(s string) *ComfyNodeCreate { + cnc.mutation.SetInputTypes(s) + return cnc +} + +// SetNillableInputTypes sets the "input_types" field if the given value is not nil. +func (cnc *ComfyNodeCreate) SetNillableInputTypes(s *string) *ComfyNodeCreate { + if s != nil { + cnc.SetInputTypes(*s) + } + return cnc +} + +// SetDeprecated sets the "deprecated" field. +func (cnc *ComfyNodeCreate) SetDeprecated(b bool) *ComfyNodeCreate { + cnc.mutation.SetDeprecated(b) + return cnc +} + +// SetNillableDeprecated sets the "deprecated" field if the given value is not nil. +func (cnc *ComfyNodeCreate) SetNillableDeprecated(b *bool) *ComfyNodeCreate { + if b != nil { + cnc.SetDeprecated(*b) + } + return cnc +} + +// SetExperimental sets the "experimental" field. +func (cnc *ComfyNodeCreate) SetExperimental(b bool) *ComfyNodeCreate { + cnc.mutation.SetExperimental(b) + return cnc +} + +// SetNillableExperimental sets the "experimental" field if the given value is not nil. +func (cnc *ComfyNodeCreate) SetNillableExperimental(b *bool) *ComfyNodeCreate { + if b != nil { + cnc.SetExperimental(*b) + } + return cnc +} + +// SetOutputIsList sets the "output_is_list" field. +func (cnc *ComfyNodeCreate) SetOutputIsList(b []bool) *ComfyNodeCreate { + cnc.mutation.SetOutputIsList(b) + return cnc +} + +// SetReturnNames sets the "return_names" field. +func (cnc *ComfyNodeCreate) SetReturnNames(s []string) *ComfyNodeCreate { + cnc.mutation.SetReturnNames(s) + return cnc +} + +// SetReturnTypes sets the "return_types" field. +func (cnc *ComfyNodeCreate) SetReturnTypes(s []string) *ComfyNodeCreate { + cnc.mutation.SetReturnTypes(s) + return cnc +} + +// SetFunction sets the "function" field. +func (cnc *ComfyNodeCreate) SetFunction(s string) *ComfyNodeCreate { + cnc.mutation.SetFunction(s) + return cnc +} + +// SetID sets the "id" field. +func (cnc *ComfyNodeCreate) SetID(s string) *ComfyNodeCreate { + cnc.mutation.SetID(s) + return cnc +} + +// SetVersionsID sets the "versions" edge to the NodeVersion entity by ID. +func (cnc *ComfyNodeCreate) SetVersionsID(id uuid.UUID) *ComfyNodeCreate { + cnc.mutation.SetVersionsID(id) + return cnc +} + +// SetVersions sets the "versions" edge to the NodeVersion entity. +func (cnc *ComfyNodeCreate) SetVersions(n *NodeVersion) *ComfyNodeCreate { + return cnc.SetVersionsID(n.ID) +} + +// Mutation returns the ComfyNodeMutation object of the builder. +func (cnc *ComfyNodeCreate) Mutation() *ComfyNodeMutation { + return cnc.mutation +} + +// Save creates the ComfyNode in the database. +func (cnc *ComfyNodeCreate) Save(ctx context.Context) (*ComfyNode, error) { + cnc.defaults() + return withHooks(ctx, cnc.sqlSave, cnc.mutation, cnc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (cnc *ComfyNodeCreate) SaveX(ctx context.Context) *ComfyNode { + v, err := cnc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (cnc *ComfyNodeCreate) Exec(ctx context.Context) error { + _, err := cnc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (cnc *ComfyNodeCreate) ExecX(ctx context.Context) { + if err := cnc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (cnc *ComfyNodeCreate) defaults() { + if _, ok := cnc.mutation.CreateTime(); !ok { + v := comfynode.DefaultCreateTime() + cnc.mutation.SetCreateTime(v) + } + if _, ok := cnc.mutation.UpdateTime(); !ok { + v := comfynode.DefaultUpdateTime() + cnc.mutation.SetUpdateTime(v) + } + if _, ok := cnc.mutation.Deprecated(); !ok { + v := comfynode.DefaultDeprecated + cnc.mutation.SetDeprecated(v) + } + if _, ok := cnc.mutation.Experimental(); !ok { + v := comfynode.DefaultExperimental + cnc.mutation.SetExperimental(v) + } + if _, ok := cnc.mutation.OutputIsList(); !ok { + v := comfynode.DefaultOutputIsList + cnc.mutation.SetOutputIsList(v) + } + if _, ok := cnc.mutation.ReturnNames(); !ok { + v := comfynode.DefaultReturnNames + cnc.mutation.SetReturnNames(v) + } + if _, ok := cnc.mutation.ReturnTypes(); !ok { + v := comfynode.DefaultReturnTypes + cnc.mutation.SetReturnTypes(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (cnc *ComfyNodeCreate) check() error { + if _, ok := cnc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "ComfyNode.create_time"`)} + } + if _, ok := cnc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "ComfyNode.update_time"`)} + } + if _, ok := cnc.mutation.NodeVersionID(); !ok { + return &ValidationError{Name: "node_version_id", err: errors.New(`ent: missing required field "ComfyNode.node_version_id"`)} + } + if _, ok := cnc.mutation.Deprecated(); !ok { + return &ValidationError{Name: "deprecated", err: errors.New(`ent: missing required field "ComfyNode.deprecated"`)} + } + if _, ok := cnc.mutation.Experimental(); !ok { + return &ValidationError{Name: "experimental", err: errors.New(`ent: missing required field "ComfyNode.experimental"`)} + } + if _, ok := cnc.mutation.OutputIsList(); !ok { + return &ValidationError{Name: "output_is_list", err: errors.New(`ent: missing required field "ComfyNode.output_is_list"`)} + } + if _, ok := cnc.mutation.ReturnNames(); !ok { + return &ValidationError{Name: "return_names", err: errors.New(`ent: missing required field "ComfyNode.return_names"`)} + } + if _, ok := cnc.mutation.ReturnTypes(); !ok { + return &ValidationError{Name: "return_types", err: errors.New(`ent: missing required field "ComfyNode.return_types"`)} + } + if _, ok := cnc.mutation.Function(); !ok { + return &ValidationError{Name: "function", err: errors.New(`ent: missing required field "ComfyNode.function"`)} + } + if _, ok := cnc.mutation.VersionsID(); !ok { + return &ValidationError{Name: "versions", err: errors.New(`ent: missing required edge "ComfyNode.versions"`)} + } + return nil +} + +func (cnc *ComfyNodeCreate) sqlSave(ctx context.Context) (*ComfyNode, error) { + if err := cnc.check(); err != nil { + return nil, err + } + _node, _spec := cnc.createSpec() + if err := sqlgraph.CreateNode(ctx, cnc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(string); ok { + _node.ID = id + } else { + return nil, fmt.Errorf("unexpected ComfyNode.ID type: %T", _spec.ID.Value) + } + } + cnc.mutation.id = &_node.ID + cnc.mutation.done = true + return _node, nil +} + +func (cnc *ComfyNodeCreate) createSpec() (*ComfyNode, *sqlgraph.CreateSpec) { + var ( + _node = &ComfyNode{config: cnc.config} + _spec = sqlgraph.NewCreateSpec(comfynode.Table, sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString)) + ) + _spec.OnConflict = cnc.conflict + if id, ok := cnc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := cnc.mutation.CreateTime(); ok { + _spec.SetField(comfynode.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := cnc.mutation.UpdateTime(); ok { + _spec.SetField(comfynode.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if value, ok := cnc.mutation.Category(); ok { + _spec.SetField(comfynode.FieldCategory, field.TypeString, value) + _node.Category = value + } + if value, ok := cnc.mutation.Description(); ok { + _spec.SetField(comfynode.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := cnc.mutation.InputTypes(); ok { + _spec.SetField(comfynode.FieldInputTypes, field.TypeString, value) + _node.InputTypes = value + } + if value, ok := cnc.mutation.Deprecated(); ok { + _spec.SetField(comfynode.FieldDeprecated, field.TypeBool, value) + _node.Deprecated = value + } + if value, ok := cnc.mutation.Experimental(); ok { + _spec.SetField(comfynode.FieldExperimental, field.TypeBool, value) + _node.Experimental = value + } + if value, ok := cnc.mutation.OutputIsList(); ok { + _spec.SetField(comfynode.FieldOutputIsList, field.TypeJSON, value) + _node.OutputIsList = value + } + if value, ok := cnc.mutation.ReturnNames(); ok { + _spec.SetField(comfynode.FieldReturnNames, field.TypeJSON, value) + _node.ReturnNames = value + } + if value, ok := cnc.mutation.ReturnTypes(); ok { + _spec.SetField(comfynode.FieldReturnTypes, field.TypeJSON, value) + _node.ReturnTypes = value + } + if value, ok := cnc.mutation.Function(); ok { + _spec.SetField(comfynode.FieldFunction, field.TypeString, value) + _node.Function = value + } + if nodes := cnc.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: comfynode.VersionsTable, + Columns: []string{comfynode.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(nodeversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.NodeVersionID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ComfyNode.Create(). +// SetCreateTime(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ComfyNodeUpsert) { +// SetCreateTime(v+v). +// }). +// Exec(ctx) +func (cnc *ComfyNodeCreate) OnConflict(opts ...sql.ConflictOption) *ComfyNodeUpsertOne { + cnc.conflict = opts + return &ComfyNodeUpsertOne{ + create: cnc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ComfyNode.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (cnc *ComfyNodeCreate) OnConflictColumns(columns ...string) *ComfyNodeUpsertOne { + cnc.conflict = append(cnc.conflict, sql.ConflictColumns(columns...)) + return &ComfyNodeUpsertOne{ + create: cnc, + } +} + +type ( + // ComfyNodeUpsertOne is the builder for "upsert"-ing + // one ComfyNode node. + ComfyNodeUpsertOne struct { + create *ComfyNodeCreate + } + + // ComfyNodeUpsert is the "OnConflict" setter. + ComfyNodeUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdateTime sets the "update_time" field. +func (u *ComfyNodeUpsert) SetUpdateTime(v time.Time) *ComfyNodeUpsert { + u.Set(comfynode.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateUpdateTime() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldUpdateTime) + return u +} + +// SetNodeVersionID sets the "node_version_id" field. +func (u *ComfyNodeUpsert) SetNodeVersionID(v uuid.UUID) *ComfyNodeUpsert { + u.Set(comfynode.FieldNodeVersionID, v) + return u +} + +// UpdateNodeVersionID sets the "node_version_id" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateNodeVersionID() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldNodeVersionID) + return u +} + +// SetCategory sets the "category" field. +func (u *ComfyNodeUpsert) SetCategory(v string) *ComfyNodeUpsert { + u.Set(comfynode.FieldCategory, v) + return u +} + +// UpdateCategory sets the "category" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateCategory() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldCategory) + return u +} + +// ClearCategory clears the value of the "category" field. +func (u *ComfyNodeUpsert) ClearCategory() *ComfyNodeUpsert { + u.SetNull(comfynode.FieldCategory) + return u +} + +// SetDescription sets the "description" field. +func (u *ComfyNodeUpsert) SetDescription(v string) *ComfyNodeUpsert { + u.Set(comfynode.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateDescription() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldDescription) + return u +} + +// ClearDescription clears the value of the "description" field. +func (u *ComfyNodeUpsert) ClearDescription() *ComfyNodeUpsert { + u.SetNull(comfynode.FieldDescription) + return u +} + +// SetInputTypes sets the "input_types" field. +func (u *ComfyNodeUpsert) SetInputTypes(v string) *ComfyNodeUpsert { + u.Set(comfynode.FieldInputTypes, v) + return u +} + +// UpdateInputTypes sets the "input_types" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateInputTypes() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldInputTypes) + return u +} + +// ClearInputTypes clears the value of the "input_types" field. +func (u *ComfyNodeUpsert) ClearInputTypes() *ComfyNodeUpsert { + u.SetNull(comfynode.FieldInputTypes) + return u +} + +// SetDeprecated sets the "deprecated" field. +func (u *ComfyNodeUpsert) SetDeprecated(v bool) *ComfyNodeUpsert { + u.Set(comfynode.FieldDeprecated, v) + return u +} + +// UpdateDeprecated sets the "deprecated" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateDeprecated() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldDeprecated) + return u +} + +// SetExperimental sets the "experimental" field. +func (u *ComfyNodeUpsert) SetExperimental(v bool) *ComfyNodeUpsert { + u.Set(comfynode.FieldExperimental, v) + return u +} + +// UpdateExperimental sets the "experimental" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateExperimental() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldExperimental) + return u +} + +// SetOutputIsList sets the "output_is_list" field. +func (u *ComfyNodeUpsert) SetOutputIsList(v []bool) *ComfyNodeUpsert { + u.Set(comfynode.FieldOutputIsList, v) + return u +} + +// UpdateOutputIsList sets the "output_is_list" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateOutputIsList() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldOutputIsList) + return u +} + +// SetReturnNames sets the "return_names" field. +func (u *ComfyNodeUpsert) SetReturnNames(v []string) *ComfyNodeUpsert { + u.Set(comfynode.FieldReturnNames, v) + return u +} + +// UpdateReturnNames sets the "return_names" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateReturnNames() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldReturnNames) + return u +} + +// SetReturnTypes sets the "return_types" field. +func (u *ComfyNodeUpsert) SetReturnTypes(v []string) *ComfyNodeUpsert { + u.Set(comfynode.FieldReturnTypes, v) + return u +} + +// UpdateReturnTypes sets the "return_types" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateReturnTypes() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldReturnTypes) + return u +} + +// SetFunction sets the "function" field. +func (u *ComfyNodeUpsert) SetFunction(v string) *ComfyNodeUpsert { + u.Set(comfynode.FieldFunction, v) + return u +} + +// UpdateFunction sets the "function" field to the value that was provided on create. +func (u *ComfyNodeUpsert) UpdateFunction() *ComfyNodeUpsert { + u.SetExcluded(comfynode.FieldFunction) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.ComfyNode.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(comfynode.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ComfyNodeUpsertOne) UpdateNewValues() *ComfyNodeUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(comfynode.FieldID) + } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(comfynode.FieldCreateTime) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ComfyNode.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ComfyNodeUpsertOne) Ignore() *ComfyNodeUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ComfyNodeUpsertOne) DoNothing() *ComfyNodeUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ComfyNodeCreate.OnConflict +// documentation for more info. +func (u *ComfyNodeUpsertOne) Update(set func(*ComfyNodeUpsert)) *ComfyNodeUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ComfyNodeUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdateTime sets the "update_time" field. +func (u *ComfyNodeUpsertOne) SetUpdateTime(v time.Time) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateUpdateTime() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateUpdateTime() + }) +} + +// SetNodeVersionID sets the "node_version_id" field. +func (u *ComfyNodeUpsertOne) SetNodeVersionID(v uuid.UUID) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetNodeVersionID(v) + }) +} + +// UpdateNodeVersionID sets the "node_version_id" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateNodeVersionID() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateNodeVersionID() + }) +} + +// SetCategory sets the "category" field. +func (u *ComfyNodeUpsertOne) SetCategory(v string) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetCategory(v) + }) +} + +// UpdateCategory sets the "category" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateCategory() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateCategory() + }) +} + +// ClearCategory clears the value of the "category" field. +func (u *ComfyNodeUpsertOne) ClearCategory() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.ClearCategory() + }) +} + +// SetDescription sets the "description" field. +func (u *ComfyNodeUpsertOne) SetDescription(v string) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateDescription() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *ComfyNodeUpsertOne) ClearDescription() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.ClearDescription() + }) +} + +// SetInputTypes sets the "input_types" field. +func (u *ComfyNodeUpsertOne) SetInputTypes(v string) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetInputTypes(v) + }) +} + +// UpdateInputTypes sets the "input_types" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateInputTypes() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateInputTypes() + }) +} + +// ClearInputTypes clears the value of the "input_types" field. +func (u *ComfyNodeUpsertOne) ClearInputTypes() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.ClearInputTypes() + }) +} + +// SetDeprecated sets the "deprecated" field. +func (u *ComfyNodeUpsertOne) SetDeprecated(v bool) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetDeprecated(v) + }) +} + +// UpdateDeprecated sets the "deprecated" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateDeprecated() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateDeprecated() + }) +} + +// SetExperimental sets the "experimental" field. +func (u *ComfyNodeUpsertOne) SetExperimental(v bool) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetExperimental(v) + }) +} + +// UpdateExperimental sets the "experimental" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateExperimental() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateExperimental() + }) +} + +// SetOutputIsList sets the "output_is_list" field. +func (u *ComfyNodeUpsertOne) SetOutputIsList(v []bool) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetOutputIsList(v) + }) +} + +// UpdateOutputIsList sets the "output_is_list" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateOutputIsList() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateOutputIsList() + }) +} + +// SetReturnNames sets the "return_names" field. +func (u *ComfyNodeUpsertOne) SetReturnNames(v []string) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetReturnNames(v) + }) +} + +// UpdateReturnNames sets the "return_names" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateReturnNames() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateReturnNames() + }) +} + +// SetReturnTypes sets the "return_types" field. +func (u *ComfyNodeUpsertOne) SetReturnTypes(v []string) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetReturnTypes(v) + }) +} + +// UpdateReturnTypes sets the "return_types" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateReturnTypes() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateReturnTypes() + }) +} + +// SetFunction sets the "function" field. +func (u *ComfyNodeUpsertOne) SetFunction(v string) *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetFunction(v) + }) +} + +// UpdateFunction sets the "function" field to the value that was provided on create. +func (u *ComfyNodeUpsertOne) UpdateFunction() *ComfyNodeUpsertOne { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateFunction() + }) +} + +// Exec executes the query. +func (u *ComfyNodeUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ComfyNodeCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ComfyNodeUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *ComfyNodeUpsertOne) ID(ctx context.Context) (id string, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("ent: ComfyNodeUpsertOne.ID is not supported by MySQL driver. Use ComfyNodeUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *ComfyNodeUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// ComfyNodeCreateBulk is the builder for creating many ComfyNode entities in bulk. +type ComfyNodeCreateBulk struct { + config + err error + builders []*ComfyNodeCreate + conflict []sql.ConflictOption +} + +// Save creates the ComfyNode entities in the database. +func (cncb *ComfyNodeCreateBulk) Save(ctx context.Context) ([]*ComfyNode, error) { + if cncb.err != nil { + return nil, cncb.err + } + specs := make([]*sqlgraph.CreateSpec, len(cncb.builders)) + nodes := make([]*ComfyNode, len(cncb.builders)) + mutators := make([]Mutator, len(cncb.builders)) + for i := range cncb.builders { + func(i int, root context.Context) { + builder := cncb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ComfyNodeMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, cncb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = cncb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, cncb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, cncb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (cncb *ComfyNodeCreateBulk) SaveX(ctx context.Context) []*ComfyNode { + v, err := cncb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (cncb *ComfyNodeCreateBulk) Exec(ctx context.Context) error { + _, err := cncb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (cncb *ComfyNodeCreateBulk) ExecX(ctx context.Context) { + if err := cncb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ComfyNode.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ComfyNodeUpsert) { +// SetCreateTime(v+v). +// }). +// Exec(ctx) +func (cncb *ComfyNodeCreateBulk) OnConflict(opts ...sql.ConflictOption) *ComfyNodeUpsertBulk { + cncb.conflict = opts + return &ComfyNodeUpsertBulk{ + create: cncb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ComfyNode.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (cncb *ComfyNodeCreateBulk) OnConflictColumns(columns ...string) *ComfyNodeUpsertBulk { + cncb.conflict = append(cncb.conflict, sql.ConflictColumns(columns...)) + return &ComfyNodeUpsertBulk{ + create: cncb, + } +} + +// ComfyNodeUpsertBulk is the builder for "upsert"-ing +// a bulk of ComfyNode nodes. +type ComfyNodeUpsertBulk struct { + create *ComfyNodeCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.ComfyNode.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(comfynode.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ComfyNodeUpsertBulk) UpdateNewValues() *ComfyNodeUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(comfynode.FieldID) + } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(comfynode.FieldCreateTime) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ComfyNode.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ComfyNodeUpsertBulk) Ignore() *ComfyNodeUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ComfyNodeUpsertBulk) DoNothing() *ComfyNodeUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ComfyNodeCreateBulk.OnConflict +// documentation for more info. +func (u *ComfyNodeUpsertBulk) Update(set func(*ComfyNodeUpsert)) *ComfyNodeUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ComfyNodeUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdateTime sets the "update_time" field. +func (u *ComfyNodeUpsertBulk) SetUpdateTime(v time.Time) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateUpdateTime() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateUpdateTime() + }) +} + +// SetNodeVersionID sets the "node_version_id" field. +func (u *ComfyNodeUpsertBulk) SetNodeVersionID(v uuid.UUID) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetNodeVersionID(v) + }) +} + +// UpdateNodeVersionID sets the "node_version_id" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateNodeVersionID() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateNodeVersionID() + }) +} + +// SetCategory sets the "category" field. +func (u *ComfyNodeUpsertBulk) SetCategory(v string) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetCategory(v) + }) +} + +// UpdateCategory sets the "category" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateCategory() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateCategory() + }) +} + +// ClearCategory clears the value of the "category" field. +func (u *ComfyNodeUpsertBulk) ClearCategory() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.ClearCategory() + }) +} + +// SetDescription sets the "description" field. +func (u *ComfyNodeUpsertBulk) SetDescription(v string) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateDescription() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *ComfyNodeUpsertBulk) ClearDescription() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.ClearDescription() + }) +} + +// SetInputTypes sets the "input_types" field. +func (u *ComfyNodeUpsertBulk) SetInputTypes(v string) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetInputTypes(v) + }) +} + +// UpdateInputTypes sets the "input_types" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateInputTypes() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateInputTypes() + }) +} + +// ClearInputTypes clears the value of the "input_types" field. +func (u *ComfyNodeUpsertBulk) ClearInputTypes() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.ClearInputTypes() + }) +} + +// SetDeprecated sets the "deprecated" field. +func (u *ComfyNodeUpsertBulk) SetDeprecated(v bool) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetDeprecated(v) + }) +} + +// UpdateDeprecated sets the "deprecated" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateDeprecated() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateDeprecated() + }) +} + +// SetExperimental sets the "experimental" field. +func (u *ComfyNodeUpsertBulk) SetExperimental(v bool) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetExperimental(v) + }) +} + +// UpdateExperimental sets the "experimental" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateExperimental() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateExperimental() + }) +} + +// SetOutputIsList sets the "output_is_list" field. +func (u *ComfyNodeUpsertBulk) SetOutputIsList(v []bool) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetOutputIsList(v) + }) +} + +// UpdateOutputIsList sets the "output_is_list" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateOutputIsList() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateOutputIsList() + }) +} + +// SetReturnNames sets the "return_names" field. +func (u *ComfyNodeUpsertBulk) SetReturnNames(v []string) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetReturnNames(v) + }) +} + +// UpdateReturnNames sets the "return_names" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateReturnNames() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateReturnNames() + }) +} + +// SetReturnTypes sets the "return_types" field. +func (u *ComfyNodeUpsertBulk) SetReturnTypes(v []string) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetReturnTypes(v) + }) +} + +// UpdateReturnTypes sets the "return_types" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateReturnTypes() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateReturnTypes() + }) +} + +// SetFunction sets the "function" field. +func (u *ComfyNodeUpsertBulk) SetFunction(v string) *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.SetFunction(v) + }) +} + +// UpdateFunction sets the "function" field to the value that was provided on create. +func (u *ComfyNodeUpsertBulk) UpdateFunction() *ComfyNodeUpsertBulk { + return u.Update(func(s *ComfyNodeUpsert) { + s.UpdateFunction() + }) +} + +// Exec executes the query. +func (u *ComfyNodeUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ComfyNodeCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ComfyNodeCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ComfyNodeUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/comfynode_delete.go b/ent/comfynode_delete.go new file mode 100644 index 0000000..0d646c7 --- /dev/null +++ b/ent/comfynode_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "registry-backend/ent/comfynode" + "registry-backend/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ComfyNodeDelete is the builder for deleting a ComfyNode entity. +type ComfyNodeDelete struct { + config + hooks []Hook + mutation *ComfyNodeMutation +} + +// Where appends a list predicates to the ComfyNodeDelete builder. +func (cnd *ComfyNodeDelete) Where(ps ...predicate.ComfyNode) *ComfyNodeDelete { + cnd.mutation.Where(ps...) + return cnd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (cnd *ComfyNodeDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, cnd.sqlExec, cnd.mutation, cnd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (cnd *ComfyNodeDelete) ExecX(ctx context.Context) int { + n, err := cnd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (cnd *ComfyNodeDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(comfynode.Table, sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString)) + if ps := cnd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, cnd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + cnd.mutation.done = true + return affected, err +} + +// ComfyNodeDeleteOne is the builder for deleting a single ComfyNode entity. +type ComfyNodeDeleteOne struct { + cnd *ComfyNodeDelete +} + +// Where appends a list predicates to the ComfyNodeDelete builder. +func (cndo *ComfyNodeDeleteOne) Where(ps ...predicate.ComfyNode) *ComfyNodeDeleteOne { + cndo.cnd.mutation.Where(ps...) + return cndo +} + +// Exec executes the deletion query. +func (cndo *ComfyNodeDeleteOne) Exec(ctx context.Context) error { + n, err := cndo.cnd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{comfynode.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (cndo *ComfyNodeDeleteOne) ExecX(ctx context.Context) { + if err := cndo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/comfynode_query.go b/ent/comfynode_query.go new file mode 100644 index 0000000..1f0f0d3 --- /dev/null +++ b/ent/comfynode_query.go @@ -0,0 +1,655 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "registry-backend/ent/comfynode" + "registry-backend/ent/nodeversion" + "registry-backend/ent/predicate" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" +) + +// ComfyNodeQuery is the builder for querying ComfyNode entities. +type ComfyNodeQuery struct { + config + ctx *QueryContext + order []comfynode.OrderOption + inters []Interceptor + predicates []predicate.ComfyNode + withVersions *NodeVersionQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ComfyNodeQuery builder. +func (cnq *ComfyNodeQuery) Where(ps ...predicate.ComfyNode) *ComfyNodeQuery { + cnq.predicates = append(cnq.predicates, ps...) + return cnq +} + +// Limit the number of records to be returned by this query. +func (cnq *ComfyNodeQuery) Limit(limit int) *ComfyNodeQuery { + cnq.ctx.Limit = &limit + return cnq +} + +// Offset to start from. +func (cnq *ComfyNodeQuery) Offset(offset int) *ComfyNodeQuery { + cnq.ctx.Offset = &offset + return cnq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (cnq *ComfyNodeQuery) Unique(unique bool) *ComfyNodeQuery { + cnq.ctx.Unique = &unique + return cnq +} + +// Order specifies how the records should be ordered. +func (cnq *ComfyNodeQuery) Order(o ...comfynode.OrderOption) *ComfyNodeQuery { + cnq.order = append(cnq.order, o...) + return cnq +} + +// QueryVersions chains the current query on the "versions" edge. +func (cnq *ComfyNodeQuery) QueryVersions() *NodeVersionQuery { + query := (&NodeVersionClient{config: cnq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := cnq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := cnq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(comfynode.Table, comfynode.FieldID, selector), + sqlgraph.To(nodeversion.Table, nodeversion.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, comfynode.VersionsTable, comfynode.VersionsColumn), + ) + fromU = sqlgraph.SetNeighbors(cnq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ComfyNode entity from the query. +// Returns a *NotFoundError when no ComfyNode was found. +func (cnq *ComfyNodeQuery) First(ctx context.Context) (*ComfyNode, error) { + nodes, err := cnq.Limit(1).All(setContextOp(ctx, cnq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{comfynode.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (cnq *ComfyNodeQuery) FirstX(ctx context.Context) *ComfyNode { + node, err := cnq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ComfyNode ID from the query. +// Returns a *NotFoundError when no ComfyNode ID was found. +func (cnq *ComfyNodeQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = cnq.Limit(1).IDs(setContextOp(ctx, cnq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{comfynode.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (cnq *ComfyNodeQuery) FirstIDX(ctx context.Context) string { + id, err := cnq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ComfyNode entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ComfyNode entity is found. +// Returns a *NotFoundError when no ComfyNode entities are found. +func (cnq *ComfyNodeQuery) Only(ctx context.Context) (*ComfyNode, error) { + nodes, err := cnq.Limit(2).All(setContextOp(ctx, cnq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{comfynode.Label} + default: + return nil, &NotSingularError{comfynode.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (cnq *ComfyNodeQuery) OnlyX(ctx context.Context) *ComfyNode { + node, err := cnq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ComfyNode ID in the query. +// Returns a *NotSingularError when more than one ComfyNode ID is found. +// Returns a *NotFoundError when no entities are found. +func (cnq *ComfyNodeQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = cnq.Limit(2).IDs(setContextOp(ctx, cnq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{comfynode.Label} + default: + err = &NotSingularError{comfynode.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (cnq *ComfyNodeQuery) OnlyIDX(ctx context.Context) string { + id, err := cnq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ComfyNodes. +func (cnq *ComfyNodeQuery) All(ctx context.Context) ([]*ComfyNode, error) { + ctx = setContextOp(ctx, cnq.ctx, "All") + if err := cnq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ComfyNode, *ComfyNodeQuery]() + return withInterceptors[[]*ComfyNode](ctx, cnq, qr, cnq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (cnq *ComfyNodeQuery) AllX(ctx context.Context) []*ComfyNode { + nodes, err := cnq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ComfyNode IDs. +func (cnq *ComfyNodeQuery) IDs(ctx context.Context) (ids []string, err error) { + if cnq.ctx.Unique == nil && cnq.path != nil { + cnq.Unique(true) + } + ctx = setContextOp(ctx, cnq.ctx, "IDs") + if err = cnq.Select(comfynode.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (cnq *ComfyNodeQuery) IDsX(ctx context.Context) []string { + ids, err := cnq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (cnq *ComfyNodeQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, cnq.ctx, "Count") + if err := cnq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, cnq, querierCount[*ComfyNodeQuery](), cnq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (cnq *ComfyNodeQuery) CountX(ctx context.Context) int { + count, err := cnq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (cnq *ComfyNodeQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, cnq.ctx, "Exist") + switch _, err := cnq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (cnq *ComfyNodeQuery) ExistX(ctx context.Context) bool { + exist, err := cnq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ComfyNodeQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (cnq *ComfyNodeQuery) Clone() *ComfyNodeQuery { + if cnq == nil { + return nil + } + return &ComfyNodeQuery{ + config: cnq.config, + ctx: cnq.ctx.Clone(), + order: append([]comfynode.OrderOption{}, cnq.order...), + inters: append([]Interceptor{}, cnq.inters...), + predicates: append([]predicate.ComfyNode{}, cnq.predicates...), + withVersions: cnq.withVersions.Clone(), + // clone intermediate query. + sql: cnq.sql.Clone(), + path: cnq.path, + } +} + +// WithVersions tells the query-builder to eager-load the nodes that are connected to +// the "versions" edge. The optional arguments are used to configure the query builder of the edge. +func (cnq *ComfyNodeQuery) WithVersions(opts ...func(*NodeVersionQuery)) *ComfyNodeQuery { + query := (&NodeVersionClient{config: cnq.config}).Query() + for _, opt := range opts { + opt(query) + } + cnq.withVersions = query + return cnq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ComfyNode.Query(). +// GroupBy(comfynode.FieldCreateTime). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (cnq *ComfyNodeQuery) GroupBy(field string, fields ...string) *ComfyNodeGroupBy { + cnq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ComfyNodeGroupBy{build: cnq} + grbuild.flds = &cnq.ctx.Fields + grbuild.label = comfynode.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// } +// +// client.ComfyNode.Query(). +// Select(comfynode.FieldCreateTime). +// Scan(ctx, &v) +func (cnq *ComfyNodeQuery) Select(fields ...string) *ComfyNodeSelect { + cnq.ctx.Fields = append(cnq.ctx.Fields, fields...) + sbuild := &ComfyNodeSelect{ComfyNodeQuery: cnq} + sbuild.label = comfynode.Label + sbuild.flds, sbuild.scan = &cnq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ComfyNodeSelect configured with the given aggregations. +func (cnq *ComfyNodeQuery) Aggregate(fns ...AggregateFunc) *ComfyNodeSelect { + return cnq.Select().Aggregate(fns...) +} + +func (cnq *ComfyNodeQuery) prepareQuery(ctx context.Context) error { + for _, inter := range cnq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, cnq); err != nil { + return err + } + } + } + for _, f := range cnq.ctx.Fields { + if !comfynode.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if cnq.path != nil { + prev, err := cnq.path(ctx) + if err != nil { + return err + } + cnq.sql = prev + } + return nil +} + +func (cnq *ComfyNodeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ComfyNode, error) { + var ( + nodes = []*ComfyNode{} + _spec = cnq.querySpec() + loadedTypes = [1]bool{ + cnq.withVersions != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ComfyNode).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ComfyNode{config: cnq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(cnq.modifiers) > 0 { + _spec.Modifiers = cnq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, cnq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := cnq.withVersions; query != nil { + if err := cnq.loadVersions(ctx, query, nodes, nil, + func(n *ComfyNode, e *NodeVersion) { n.Edges.Versions = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (cnq *ComfyNodeQuery) loadVersions(ctx context.Context, query *NodeVersionQuery, nodes []*ComfyNode, init func(*ComfyNode), assign func(*ComfyNode, *NodeVersion)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*ComfyNode) + for i := range nodes { + fk := nodes[i].NodeVersionID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(nodeversion.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "node_version_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (cnq *ComfyNodeQuery) sqlCount(ctx context.Context) (int, error) { + _spec := cnq.querySpec() + if len(cnq.modifiers) > 0 { + _spec.Modifiers = cnq.modifiers + } + _spec.Node.Columns = cnq.ctx.Fields + if len(cnq.ctx.Fields) > 0 { + _spec.Unique = cnq.ctx.Unique != nil && *cnq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, cnq.driver, _spec) +} + +func (cnq *ComfyNodeQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(comfynode.Table, comfynode.Columns, sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString)) + _spec.From = cnq.sql + if unique := cnq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if cnq.path != nil { + _spec.Unique = true + } + if fields := cnq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, comfynode.FieldID) + for i := range fields { + if fields[i] != comfynode.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if cnq.withVersions != nil { + _spec.Node.AddColumnOnce(comfynode.FieldNodeVersionID) + } + } + if ps := cnq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := cnq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := cnq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := cnq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (cnq *ComfyNodeQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(cnq.driver.Dialect()) + t1 := builder.Table(comfynode.Table) + columns := cnq.ctx.Fields + if len(columns) == 0 { + columns = comfynode.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if cnq.sql != nil { + selector = cnq.sql + selector.Select(selector.Columns(columns...)...) + } + if cnq.ctx.Unique != nil && *cnq.ctx.Unique { + selector.Distinct() + } + for _, m := range cnq.modifiers { + m(selector) + } + for _, p := range cnq.predicates { + p(selector) + } + for _, p := range cnq.order { + p(selector) + } + if offset := cnq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := cnq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (cnq *ComfyNodeQuery) ForUpdate(opts ...sql.LockOption) *ComfyNodeQuery { + if cnq.driver.Dialect() == dialect.Postgres { + cnq.Unique(false) + } + cnq.modifiers = append(cnq.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return cnq +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (cnq *ComfyNodeQuery) ForShare(opts ...sql.LockOption) *ComfyNodeQuery { + if cnq.driver.Dialect() == dialect.Postgres { + cnq.Unique(false) + } + cnq.modifiers = append(cnq.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return cnq +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (cnq *ComfyNodeQuery) Modify(modifiers ...func(s *sql.Selector)) *ComfyNodeSelect { + cnq.modifiers = append(cnq.modifiers, modifiers...) + return cnq.Select() +} + +// ComfyNodeGroupBy is the group-by builder for ComfyNode entities. +type ComfyNodeGroupBy struct { + selector + build *ComfyNodeQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (cngb *ComfyNodeGroupBy) Aggregate(fns ...AggregateFunc) *ComfyNodeGroupBy { + cngb.fns = append(cngb.fns, fns...) + return cngb +} + +// Scan applies the selector query and scans the result into the given value. +func (cngb *ComfyNodeGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, cngb.build.ctx, "GroupBy") + if err := cngb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ComfyNodeQuery, *ComfyNodeGroupBy](ctx, cngb.build, cngb, cngb.build.inters, v) +} + +func (cngb *ComfyNodeGroupBy) sqlScan(ctx context.Context, root *ComfyNodeQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(cngb.fns)) + for _, fn := range cngb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*cngb.flds)+len(cngb.fns)) + for _, f := range *cngb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*cngb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := cngb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ComfyNodeSelect is the builder for selecting fields of ComfyNode entities. +type ComfyNodeSelect struct { + *ComfyNodeQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (cns *ComfyNodeSelect) Aggregate(fns ...AggregateFunc) *ComfyNodeSelect { + cns.fns = append(cns.fns, fns...) + return cns +} + +// Scan applies the selector query and scans the result into the given value. +func (cns *ComfyNodeSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, cns.ctx, "Select") + if err := cns.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ComfyNodeQuery, *ComfyNodeSelect](ctx, cns.ComfyNodeQuery, cns, cns.inters, v) +} + +func (cns *ComfyNodeSelect) sqlScan(ctx context.Context, root *ComfyNodeQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(cns.fns)) + for _, fn := range cns.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*cns.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := cns.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (cns *ComfyNodeSelect) Modify(modifiers ...func(s *sql.Selector)) *ComfyNodeSelect { + cns.modifiers = append(cns.modifiers, modifiers...) + return cns +} diff --git a/ent/comfynode_update.go b/ent/comfynode_update.go new file mode 100644 index 0000000..716e83d --- /dev/null +++ b/ent/comfynode_update.go @@ -0,0 +1,751 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "registry-backend/ent/comfynode" + "registry-backend/ent/nodeversion" + "registry-backend/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/dialect/sql/sqljson" + "entgo.io/ent/schema/field" + "github.com/google/uuid" +) + +// ComfyNodeUpdate is the builder for updating ComfyNode entities. +type ComfyNodeUpdate struct { + config + hooks []Hook + mutation *ComfyNodeMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ComfyNodeUpdate builder. +func (cnu *ComfyNodeUpdate) Where(ps ...predicate.ComfyNode) *ComfyNodeUpdate { + cnu.mutation.Where(ps...) + return cnu +} + +// SetUpdateTime sets the "update_time" field. +func (cnu *ComfyNodeUpdate) SetUpdateTime(t time.Time) *ComfyNodeUpdate { + cnu.mutation.SetUpdateTime(t) + return cnu +} + +// SetNodeVersionID sets the "node_version_id" field. +func (cnu *ComfyNodeUpdate) SetNodeVersionID(u uuid.UUID) *ComfyNodeUpdate { + cnu.mutation.SetNodeVersionID(u) + return cnu +} + +// SetNillableNodeVersionID sets the "node_version_id" field if the given value is not nil. +func (cnu *ComfyNodeUpdate) SetNillableNodeVersionID(u *uuid.UUID) *ComfyNodeUpdate { + if u != nil { + cnu.SetNodeVersionID(*u) + } + return cnu +} + +// SetCategory sets the "category" field. +func (cnu *ComfyNodeUpdate) SetCategory(s string) *ComfyNodeUpdate { + cnu.mutation.SetCategory(s) + return cnu +} + +// SetNillableCategory sets the "category" field if the given value is not nil. +func (cnu *ComfyNodeUpdate) SetNillableCategory(s *string) *ComfyNodeUpdate { + if s != nil { + cnu.SetCategory(*s) + } + return cnu +} + +// ClearCategory clears the value of the "category" field. +func (cnu *ComfyNodeUpdate) ClearCategory() *ComfyNodeUpdate { + cnu.mutation.ClearCategory() + return cnu +} + +// SetDescription sets the "description" field. +func (cnu *ComfyNodeUpdate) SetDescription(s string) *ComfyNodeUpdate { + cnu.mutation.SetDescription(s) + return cnu +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (cnu *ComfyNodeUpdate) SetNillableDescription(s *string) *ComfyNodeUpdate { + if s != nil { + cnu.SetDescription(*s) + } + return cnu +} + +// ClearDescription clears the value of the "description" field. +func (cnu *ComfyNodeUpdate) ClearDescription() *ComfyNodeUpdate { + cnu.mutation.ClearDescription() + return cnu +} + +// SetInputTypes sets the "input_types" field. +func (cnu *ComfyNodeUpdate) SetInputTypes(s string) *ComfyNodeUpdate { + cnu.mutation.SetInputTypes(s) + return cnu +} + +// SetNillableInputTypes sets the "input_types" field if the given value is not nil. +func (cnu *ComfyNodeUpdate) SetNillableInputTypes(s *string) *ComfyNodeUpdate { + if s != nil { + cnu.SetInputTypes(*s) + } + return cnu +} + +// ClearInputTypes clears the value of the "input_types" field. +func (cnu *ComfyNodeUpdate) ClearInputTypes() *ComfyNodeUpdate { + cnu.mutation.ClearInputTypes() + return cnu +} + +// SetDeprecated sets the "deprecated" field. +func (cnu *ComfyNodeUpdate) SetDeprecated(b bool) *ComfyNodeUpdate { + cnu.mutation.SetDeprecated(b) + return cnu +} + +// SetNillableDeprecated sets the "deprecated" field if the given value is not nil. +func (cnu *ComfyNodeUpdate) SetNillableDeprecated(b *bool) *ComfyNodeUpdate { + if b != nil { + cnu.SetDeprecated(*b) + } + return cnu +} + +// SetExperimental sets the "experimental" field. +func (cnu *ComfyNodeUpdate) SetExperimental(b bool) *ComfyNodeUpdate { + cnu.mutation.SetExperimental(b) + return cnu +} + +// SetNillableExperimental sets the "experimental" field if the given value is not nil. +func (cnu *ComfyNodeUpdate) SetNillableExperimental(b *bool) *ComfyNodeUpdate { + if b != nil { + cnu.SetExperimental(*b) + } + return cnu +} + +// SetOutputIsList sets the "output_is_list" field. +func (cnu *ComfyNodeUpdate) SetOutputIsList(b []bool) *ComfyNodeUpdate { + cnu.mutation.SetOutputIsList(b) + return cnu +} + +// AppendOutputIsList appends b to the "output_is_list" field. +func (cnu *ComfyNodeUpdate) AppendOutputIsList(b []bool) *ComfyNodeUpdate { + cnu.mutation.AppendOutputIsList(b) + return cnu +} + +// SetReturnNames sets the "return_names" field. +func (cnu *ComfyNodeUpdate) SetReturnNames(s []string) *ComfyNodeUpdate { + cnu.mutation.SetReturnNames(s) + return cnu +} + +// AppendReturnNames appends s to the "return_names" field. +func (cnu *ComfyNodeUpdate) AppendReturnNames(s []string) *ComfyNodeUpdate { + cnu.mutation.AppendReturnNames(s) + return cnu +} + +// SetReturnTypes sets the "return_types" field. +func (cnu *ComfyNodeUpdate) SetReturnTypes(s []string) *ComfyNodeUpdate { + cnu.mutation.SetReturnTypes(s) + return cnu +} + +// AppendReturnTypes appends s to the "return_types" field. +func (cnu *ComfyNodeUpdate) AppendReturnTypes(s []string) *ComfyNodeUpdate { + cnu.mutation.AppendReturnTypes(s) + return cnu +} + +// SetFunction sets the "function" field. +func (cnu *ComfyNodeUpdate) SetFunction(s string) *ComfyNodeUpdate { + cnu.mutation.SetFunction(s) + return cnu +} + +// SetNillableFunction sets the "function" field if the given value is not nil. +func (cnu *ComfyNodeUpdate) SetNillableFunction(s *string) *ComfyNodeUpdate { + if s != nil { + cnu.SetFunction(*s) + } + return cnu +} + +// SetVersionsID sets the "versions" edge to the NodeVersion entity by ID. +func (cnu *ComfyNodeUpdate) SetVersionsID(id uuid.UUID) *ComfyNodeUpdate { + cnu.mutation.SetVersionsID(id) + return cnu +} + +// SetVersions sets the "versions" edge to the NodeVersion entity. +func (cnu *ComfyNodeUpdate) SetVersions(n *NodeVersion) *ComfyNodeUpdate { + return cnu.SetVersionsID(n.ID) +} + +// Mutation returns the ComfyNodeMutation object of the builder. +func (cnu *ComfyNodeUpdate) Mutation() *ComfyNodeMutation { + return cnu.mutation +} + +// ClearVersions clears the "versions" edge to the NodeVersion entity. +func (cnu *ComfyNodeUpdate) ClearVersions() *ComfyNodeUpdate { + cnu.mutation.ClearVersions() + return cnu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (cnu *ComfyNodeUpdate) Save(ctx context.Context) (int, error) { + cnu.defaults() + return withHooks(ctx, cnu.sqlSave, cnu.mutation, cnu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (cnu *ComfyNodeUpdate) SaveX(ctx context.Context) int { + affected, err := cnu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (cnu *ComfyNodeUpdate) Exec(ctx context.Context) error { + _, err := cnu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (cnu *ComfyNodeUpdate) ExecX(ctx context.Context) { + if err := cnu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (cnu *ComfyNodeUpdate) defaults() { + if _, ok := cnu.mutation.UpdateTime(); !ok { + v := comfynode.UpdateDefaultUpdateTime() + cnu.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (cnu *ComfyNodeUpdate) check() error { + if _, ok := cnu.mutation.VersionsID(); cnu.mutation.VersionsCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "ComfyNode.versions"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (cnu *ComfyNodeUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ComfyNodeUpdate { + cnu.modifiers = append(cnu.modifiers, modifiers...) + return cnu +} + +func (cnu *ComfyNodeUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := cnu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(comfynode.Table, comfynode.Columns, sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString)) + if ps := cnu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := cnu.mutation.UpdateTime(); ok { + _spec.SetField(comfynode.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := cnu.mutation.Category(); ok { + _spec.SetField(comfynode.FieldCategory, field.TypeString, value) + } + if cnu.mutation.CategoryCleared() { + _spec.ClearField(comfynode.FieldCategory, field.TypeString) + } + if value, ok := cnu.mutation.Description(); ok { + _spec.SetField(comfynode.FieldDescription, field.TypeString, value) + } + if cnu.mutation.DescriptionCleared() { + _spec.ClearField(comfynode.FieldDescription, field.TypeString) + } + if value, ok := cnu.mutation.InputTypes(); ok { + _spec.SetField(comfynode.FieldInputTypes, field.TypeString, value) + } + if cnu.mutation.InputTypesCleared() { + _spec.ClearField(comfynode.FieldInputTypes, field.TypeString) + } + if value, ok := cnu.mutation.Deprecated(); ok { + _spec.SetField(comfynode.FieldDeprecated, field.TypeBool, value) + } + if value, ok := cnu.mutation.Experimental(); ok { + _spec.SetField(comfynode.FieldExperimental, field.TypeBool, value) + } + if value, ok := cnu.mutation.OutputIsList(); ok { + _spec.SetField(comfynode.FieldOutputIsList, field.TypeJSON, value) + } + if value, ok := cnu.mutation.AppendedOutputIsList(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, comfynode.FieldOutputIsList, value) + }) + } + if value, ok := cnu.mutation.ReturnNames(); ok { + _spec.SetField(comfynode.FieldReturnNames, field.TypeJSON, value) + } + if value, ok := cnu.mutation.AppendedReturnNames(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, comfynode.FieldReturnNames, value) + }) + } + if value, ok := cnu.mutation.ReturnTypes(); ok { + _spec.SetField(comfynode.FieldReturnTypes, field.TypeJSON, value) + } + if value, ok := cnu.mutation.AppendedReturnTypes(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, comfynode.FieldReturnTypes, value) + }) + } + if value, ok := cnu.mutation.Function(); ok { + _spec.SetField(comfynode.FieldFunction, field.TypeString, value) + } + if cnu.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: comfynode.VersionsTable, + Columns: []string{comfynode.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(nodeversion.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cnu.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: comfynode.VersionsTable, + Columns: []string{comfynode.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(nodeversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(cnu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, cnu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{comfynode.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + cnu.mutation.done = true + return n, nil +} + +// ComfyNodeUpdateOne is the builder for updating a single ComfyNode entity. +type ComfyNodeUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ComfyNodeMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdateTime sets the "update_time" field. +func (cnuo *ComfyNodeUpdateOne) SetUpdateTime(t time.Time) *ComfyNodeUpdateOne { + cnuo.mutation.SetUpdateTime(t) + return cnuo +} + +// SetNodeVersionID sets the "node_version_id" field. +func (cnuo *ComfyNodeUpdateOne) SetNodeVersionID(u uuid.UUID) *ComfyNodeUpdateOne { + cnuo.mutation.SetNodeVersionID(u) + return cnuo +} + +// SetNillableNodeVersionID sets the "node_version_id" field if the given value is not nil. +func (cnuo *ComfyNodeUpdateOne) SetNillableNodeVersionID(u *uuid.UUID) *ComfyNodeUpdateOne { + if u != nil { + cnuo.SetNodeVersionID(*u) + } + return cnuo +} + +// SetCategory sets the "category" field. +func (cnuo *ComfyNodeUpdateOne) SetCategory(s string) *ComfyNodeUpdateOne { + cnuo.mutation.SetCategory(s) + return cnuo +} + +// SetNillableCategory sets the "category" field if the given value is not nil. +func (cnuo *ComfyNodeUpdateOne) SetNillableCategory(s *string) *ComfyNodeUpdateOne { + if s != nil { + cnuo.SetCategory(*s) + } + return cnuo +} + +// ClearCategory clears the value of the "category" field. +func (cnuo *ComfyNodeUpdateOne) ClearCategory() *ComfyNodeUpdateOne { + cnuo.mutation.ClearCategory() + return cnuo +} + +// SetDescription sets the "description" field. +func (cnuo *ComfyNodeUpdateOne) SetDescription(s string) *ComfyNodeUpdateOne { + cnuo.mutation.SetDescription(s) + return cnuo +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (cnuo *ComfyNodeUpdateOne) SetNillableDescription(s *string) *ComfyNodeUpdateOne { + if s != nil { + cnuo.SetDescription(*s) + } + return cnuo +} + +// ClearDescription clears the value of the "description" field. +func (cnuo *ComfyNodeUpdateOne) ClearDescription() *ComfyNodeUpdateOne { + cnuo.mutation.ClearDescription() + return cnuo +} + +// SetInputTypes sets the "input_types" field. +func (cnuo *ComfyNodeUpdateOne) SetInputTypes(s string) *ComfyNodeUpdateOne { + cnuo.mutation.SetInputTypes(s) + return cnuo +} + +// SetNillableInputTypes sets the "input_types" field if the given value is not nil. +func (cnuo *ComfyNodeUpdateOne) SetNillableInputTypes(s *string) *ComfyNodeUpdateOne { + if s != nil { + cnuo.SetInputTypes(*s) + } + return cnuo +} + +// ClearInputTypes clears the value of the "input_types" field. +func (cnuo *ComfyNodeUpdateOne) ClearInputTypes() *ComfyNodeUpdateOne { + cnuo.mutation.ClearInputTypes() + return cnuo +} + +// SetDeprecated sets the "deprecated" field. +func (cnuo *ComfyNodeUpdateOne) SetDeprecated(b bool) *ComfyNodeUpdateOne { + cnuo.mutation.SetDeprecated(b) + return cnuo +} + +// SetNillableDeprecated sets the "deprecated" field if the given value is not nil. +func (cnuo *ComfyNodeUpdateOne) SetNillableDeprecated(b *bool) *ComfyNodeUpdateOne { + if b != nil { + cnuo.SetDeprecated(*b) + } + return cnuo +} + +// SetExperimental sets the "experimental" field. +func (cnuo *ComfyNodeUpdateOne) SetExperimental(b bool) *ComfyNodeUpdateOne { + cnuo.mutation.SetExperimental(b) + return cnuo +} + +// SetNillableExperimental sets the "experimental" field if the given value is not nil. +func (cnuo *ComfyNodeUpdateOne) SetNillableExperimental(b *bool) *ComfyNodeUpdateOne { + if b != nil { + cnuo.SetExperimental(*b) + } + return cnuo +} + +// SetOutputIsList sets the "output_is_list" field. +func (cnuo *ComfyNodeUpdateOne) SetOutputIsList(b []bool) *ComfyNodeUpdateOne { + cnuo.mutation.SetOutputIsList(b) + return cnuo +} + +// AppendOutputIsList appends b to the "output_is_list" field. +func (cnuo *ComfyNodeUpdateOne) AppendOutputIsList(b []bool) *ComfyNodeUpdateOne { + cnuo.mutation.AppendOutputIsList(b) + return cnuo +} + +// SetReturnNames sets the "return_names" field. +func (cnuo *ComfyNodeUpdateOne) SetReturnNames(s []string) *ComfyNodeUpdateOne { + cnuo.mutation.SetReturnNames(s) + return cnuo +} + +// AppendReturnNames appends s to the "return_names" field. +func (cnuo *ComfyNodeUpdateOne) AppendReturnNames(s []string) *ComfyNodeUpdateOne { + cnuo.mutation.AppendReturnNames(s) + return cnuo +} + +// SetReturnTypes sets the "return_types" field. +func (cnuo *ComfyNodeUpdateOne) SetReturnTypes(s []string) *ComfyNodeUpdateOne { + cnuo.mutation.SetReturnTypes(s) + return cnuo +} + +// AppendReturnTypes appends s to the "return_types" field. +func (cnuo *ComfyNodeUpdateOne) AppendReturnTypes(s []string) *ComfyNodeUpdateOne { + cnuo.mutation.AppendReturnTypes(s) + return cnuo +} + +// SetFunction sets the "function" field. +func (cnuo *ComfyNodeUpdateOne) SetFunction(s string) *ComfyNodeUpdateOne { + cnuo.mutation.SetFunction(s) + return cnuo +} + +// SetNillableFunction sets the "function" field if the given value is not nil. +func (cnuo *ComfyNodeUpdateOne) SetNillableFunction(s *string) *ComfyNodeUpdateOne { + if s != nil { + cnuo.SetFunction(*s) + } + return cnuo +} + +// SetVersionsID sets the "versions" edge to the NodeVersion entity by ID. +func (cnuo *ComfyNodeUpdateOne) SetVersionsID(id uuid.UUID) *ComfyNodeUpdateOne { + cnuo.mutation.SetVersionsID(id) + return cnuo +} + +// SetVersions sets the "versions" edge to the NodeVersion entity. +func (cnuo *ComfyNodeUpdateOne) SetVersions(n *NodeVersion) *ComfyNodeUpdateOne { + return cnuo.SetVersionsID(n.ID) +} + +// Mutation returns the ComfyNodeMutation object of the builder. +func (cnuo *ComfyNodeUpdateOne) Mutation() *ComfyNodeMutation { + return cnuo.mutation +} + +// ClearVersions clears the "versions" edge to the NodeVersion entity. +func (cnuo *ComfyNodeUpdateOne) ClearVersions() *ComfyNodeUpdateOne { + cnuo.mutation.ClearVersions() + return cnuo +} + +// Where appends a list predicates to the ComfyNodeUpdate builder. +func (cnuo *ComfyNodeUpdateOne) Where(ps ...predicate.ComfyNode) *ComfyNodeUpdateOne { + cnuo.mutation.Where(ps...) + return cnuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (cnuo *ComfyNodeUpdateOne) Select(field string, fields ...string) *ComfyNodeUpdateOne { + cnuo.fields = append([]string{field}, fields...) + return cnuo +} + +// Save executes the query and returns the updated ComfyNode entity. +func (cnuo *ComfyNodeUpdateOne) Save(ctx context.Context) (*ComfyNode, error) { + cnuo.defaults() + return withHooks(ctx, cnuo.sqlSave, cnuo.mutation, cnuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (cnuo *ComfyNodeUpdateOne) SaveX(ctx context.Context) *ComfyNode { + node, err := cnuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (cnuo *ComfyNodeUpdateOne) Exec(ctx context.Context) error { + _, err := cnuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (cnuo *ComfyNodeUpdateOne) ExecX(ctx context.Context) { + if err := cnuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (cnuo *ComfyNodeUpdateOne) defaults() { + if _, ok := cnuo.mutation.UpdateTime(); !ok { + v := comfynode.UpdateDefaultUpdateTime() + cnuo.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (cnuo *ComfyNodeUpdateOne) check() error { + if _, ok := cnuo.mutation.VersionsID(); cnuo.mutation.VersionsCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "ComfyNode.versions"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (cnuo *ComfyNodeUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ComfyNodeUpdateOne { + cnuo.modifiers = append(cnuo.modifiers, modifiers...) + return cnuo +} + +func (cnuo *ComfyNodeUpdateOne) sqlSave(ctx context.Context) (_node *ComfyNode, err error) { + if err := cnuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(comfynode.Table, comfynode.Columns, sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString)) + id, ok := cnuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ComfyNode.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := cnuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, comfynode.FieldID) + for _, f := range fields { + if !comfynode.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != comfynode.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := cnuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := cnuo.mutation.UpdateTime(); ok { + _spec.SetField(comfynode.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := cnuo.mutation.Category(); ok { + _spec.SetField(comfynode.FieldCategory, field.TypeString, value) + } + if cnuo.mutation.CategoryCleared() { + _spec.ClearField(comfynode.FieldCategory, field.TypeString) + } + if value, ok := cnuo.mutation.Description(); ok { + _spec.SetField(comfynode.FieldDescription, field.TypeString, value) + } + if cnuo.mutation.DescriptionCleared() { + _spec.ClearField(comfynode.FieldDescription, field.TypeString) + } + if value, ok := cnuo.mutation.InputTypes(); ok { + _spec.SetField(comfynode.FieldInputTypes, field.TypeString, value) + } + if cnuo.mutation.InputTypesCleared() { + _spec.ClearField(comfynode.FieldInputTypes, field.TypeString) + } + if value, ok := cnuo.mutation.Deprecated(); ok { + _spec.SetField(comfynode.FieldDeprecated, field.TypeBool, value) + } + if value, ok := cnuo.mutation.Experimental(); ok { + _spec.SetField(comfynode.FieldExperimental, field.TypeBool, value) + } + if value, ok := cnuo.mutation.OutputIsList(); ok { + _spec.SetField(comfynode.FieldOutputIsList, field.TypeJSON, value) + } + if value, ok := cnuo.mutation.AppendedOutputIsList(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, comfynode.FieldOutputIsList, value) + }) + } + if value, ok := cnuo.mutation.ReturnNames(); ok { + _spec.SetField(comfynode.FieldReturnNames, field.TypeJSON, value) + } + if value, ok := cnuo.mutation.AppendedReturnNames(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, comfynode.FieldReturnNames, value) + }) + } + if value, ok := cnuo.mutation.ReturnTypes(); ok { + _spec.SetField(comfynode.FieldReturnTypes, field.TypeJSON, value) + } + if value, ok := cnuo.mutation.AppendedReturnTypes(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, comfynode.FieldReturnTypes, value) + }) + } + if value, ok := cnuo.mutation.Function(); ok { + _spec.SetField(comfynode.FieldFunction, field.TypeString, value) + } + if cnuo.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: comfynode.VersionsTable, + Columns: []string{comfynode.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(nodeversion.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cnuo.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: comfynode.VersionsTable, + Columns: []string{comfynode.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(nodeversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(cnuo.modifiers...) + _node = &ComfyNode{config: cnuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, cnuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{comfynode.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + cnuo.mutation.done = true + return _node, nil +} diff --git a/ent/ent.go b/ent/ent.go index aec797c..987d9fe 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -8,6 +8,7 @@ import ( "fmt" "reflect" "registry-backend/ent/ciworkflowresult" + "registry-backend/ent/comfynode" "registry-backend/ent/gitcommit" "registry-backend/ent/node" "registry-backend/ent/nodereview" @@ -83,6 +84,7 @@ func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ ciworkflowresult.Table: ciworkflowresult.ValidColumn, + comfynode.Table: comfynode.ValidColumn, gitcommit.Table: gitcommit.ValidColumn, node.Table: node.ValidColumn, nodereview.Table: nodereview.ValidColumn, diff --git a/ent/hook/hook.go b/ent/hook/hook.go index 4c792eb..f87fc70 100644 --- a/ent/hook/hook.go +++ b/ent/hook/hook.go @@ -20,6 +20,18 @@ func (f CIWorkflowResultFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.V return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CIWorkflowResultMutation", m) } +// The ComfyNodeFunc type is an adapter to allow the use of ordinary +// function as ComfyNode mutator. +type ComfyNodeFunc func(context.Context, *ent.ComfyNodeMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ComfyNodeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ComfyNodeMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ComfyNodeMutation", m) +} + // The GitCommitFunc type is an adapter to allow the use of ordinary // function as GitCommit mutator. type GitCommitFunc func(context.Context, *ent.GitCommitMutation) (ent.Value, error) diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index dea74aa..be1e9a6 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -44,6 +44,43 @@ var ( }, }, } + // ComfyNodesColumns holds the columns for the "comfy_nodes" table. + ComfyNodesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, + {Name: "category", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, + {Name: "description", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, + {Name: "input_types", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, + {Name: "deprecated", Type: field.TypeBool, Default: false}, + {Name: "experimental", Type: field.TypeBool, Default: false}, + {Name: "output_is_list", Type: field.TypeJSON}, + {Name: "return_names", Type: field.TypeJSON}, + {Name: "return_types", Type: field.TypeJSON}, + {Name: "function", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}}, + {Name: "node_version_id", Type: field.TypeUUID}, + } + // ComfyNodesTable holds the schema information for the "comfy_nodes" table. + ComfyNodesTable = &schema.Table{ + Name: "comfy_nodes", + Columns: ComfyNodesColumns, + PrimaryKey: []*schema.Column{ComfyNodesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "comfy_nodes_node_versions_comfy_nodes", + Columns: []*schema.Column{ComfyNodesColumns[12]}, + RefColumns: []*schema.Column{NodeVersionsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "comfynode_id_node_version_id", + Unique: true, + Columns: []*schema.Column{ComfyNodesColumns[0], ComfyNodesColumns[12]}, + }, + }, + } // GitCommitsColumns holds the columns for the "git_commits" table. GitCommitsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -303,6 +340,7 @@ var ( // Tables holds all the tables in the schema. Tables = []*schema.Table{ CiWorkflowResultsTable, + ComfyNodesTable, GitCommitsTable, NodesTable, NodeReviewsTable, @@ -317,6 +355,7 @@ var ( func init() { CiWorkflowResultsTable.ForeignKeys[0].RefTable = GitCommitsTable + ComfyNodesTable.ForeignKeys[0].RefTable = NodeVersionsTable NodesTable.ForeignKeys[0].RefTable = PublishersTable NodeReviewsTable.ForeignKeys[0].RefTable = NodesTable NodeReviewsTable.ForeignKeys[1].RefTable = UsersTable diff --git a/ent/mutation.go b/ent/mutation.go index fa6b9e6..eeec6e7 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "registry-backend/ent/ciworkflowresult" + "registry-backend/ent/comfynode" "registry-backend/ent/gitcommit" "registry-backend/ent/node" "registry-backend/ent/nodereview" @@ -36,6 +37,7 @@ const ( // Node types. TypeCIWorkflowResult = "CIWorkflowResult" + TypeComfyNode = "ComfyNode" TypeGitCommit = "GitCommit" TypeNode = "Node" TypeNodeReview = "NodeReview" @@ -1784,6 +1786,1107 @@ func (m *CIWorkflowResultMutation) ResetEdge(name string) error { return fmt.Errorf("unknown CIWorkflowResult edge %s", name) } +// ComfyNodeMutation represents an operation that mutates the ComfyNode nodes in the graph. +type ComfyNodeMutation struct { + config + op Op + typ string + id *string + create_time *time.Time + update_time *time.Time + category *string + description *string + input_types *string + deprecated *bool + experimental *bool + output_is_list *[]bool + appendoutput_is_list []bool + return_names *[]string + appendreturn_names []string + return_types *[]string + appendreturn_types []string + function *string + clearedFields map[string]struct{} + versions *uuid.UUID + clearedversions bool + done bool + oldValue func(context.Context) (*ComfyNode, error) + predicates []predicate.ComfyNode +} + +var _ ent.Mutation = (*ComfyNodeMutation)(nil) + +// comfynodeOption allows management of the mutation configuration using functional options. +type comfynodeOption func(*ComfyNodeMutation) + +// newComfyNodeMutation creates new mutation for the ComfyNode entity. +func newComfyNodeMutation(c config, op Op, opts ...comfynodeOption) *ComfyNodeMutation { + m := &ComfyNodeMutation{ + config: c, + op: op, + typ: TypeComfyNode, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withComfyNodeID sets the ID field of the mutation. +func withComfyNodeID(id string) comfynodeOption { + return func(m *ComfyNodeMutation) { + var ( + err error + once sync.Once + value *ComfyNode + ) + m.oldValue = func(ctx context.Context) (*ComfyNode, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ComfyNode.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withComfyNode sets the old ComfyNode of the mutation. +func withComfyNode(node *ComfyNode) comfynodeOption { + return func(m *ComfyNodeMutation) { + m.oldValue = func(context.Context) (*ComfyNode, 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 ComfyNodeMutation) 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 ComfyNodeMutation) 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 ComfyNode entities. +func (m *ComfyNodeMutation) SetID(id string) { + 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 *ComfyNodeMutation) ID() (id string, 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 *ComfyNodeMutation) IDs(ctx context.Context) ([]string, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []string{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().ComfyNode.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateTime sets the "create_time" field. +func (m *ComfyNodeMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *ComfyNodeMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *ComfyNodeMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *ComfyNodeMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *ComfyNodeMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *ComfyNodeMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetNodeVersionID sets the "node_version_id" field. +func (m *ComfyNodeMutation) SetNodeVersionID(u uuid.UUID) { + m.versions = &u +} + +// NodeVersionID returns the value of the "node_version_id" field in the mutation. +func (m *ComfyNodeMutation) NodeVersionID() (r uuid.UUID, exists bool) { + v := m.versions + if v == nil { + return + } + return *v, true +} + +// OldNodeVersionID returns the old "node_version_id" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldNodeVersionID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNodeVersionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNodeVersionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNodeVersionID: %w", err) + } + return oldValue.NodeVersionID, nil +} + +// ResetNodeVersionID resets all changes to the "node_version_id" field. +func (m *ComfyNodeMutation) ResetNodeVersionID() { + m.versions = nil +} + +// SetCategory sets the "category" field. +func (m *ComfyNodeMutation) SetCategory(s string) { + m.category = &s +} + +// Category returns the value of the "category" field in the mutation. +func (m *ComfyNodeMutation) Category() (r string, exists bool) { + v := m.category + if v == nil { + return + } + return *v, true +} + +// OldCategory returns the old "category" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldCategory(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCategory is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCategory requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCategory: %w", err) + } + return oldValue.Category, nil +} + +// ClearCategory clears the value of the "category" field. +func (m *ComfyNodeMutation) ClearCategory() { + m.category = nil + m.clearedFields[comfynode.FieldCategory] = struct{}{} +} + +// CategoryCleared returns if the "category" field was cleared in this mutation. +func (m *ComfyNodeMutation) CategoryCleared() bool { + _, ok := m.clearedFields[comfynode.FieldCategory] + return ok +} + +// ResetCategory resets all changes to the "category" field. +func (m *ComfyNodeMutation) ResetCategory() { + m.category = nil + delete(m.clearedFields, comfynode.FieldCategory) +} + +// SetDescription sets the "description" field. +func (m *ComfyNodeMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ComfyNodeMutation) 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 ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) 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 *ComfyNodeMutation) ClearDescription() { + m.description = nil + m.clearedFields[comfynode.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *ComfyNodeMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[comfynode.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *ComfyNodeMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, comfynode.FieldDescription) +} + +// SetInputTypes sets the "input_types" field. +func (m *ComfyNodeMutation) SetInputTypes(s string) { + m.input_types = &s +} + +// InputTypes returns the value of the "input_types" field in the mutation. +func (m *ComfyNodeMutation) InputTypes() (r string, exists bool) { + v := m.input_types + if v == nil { + return + } + return *v, true +} + +// OldInputTypes returns the old "input_types" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldInputTypes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInputTypes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInputTypes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInputTypes: %w", err) + } + return oldValue.InputTypes, nil +} + +// ClearInputTypes clears the value of the "input_types" field. +func (m *ComfyNodeMutation) ClearInputTypes() { + m.input_types = nil + m.clearedFields[comfynode.FieldInputTypes] = struct{}{} +} + +// InputTypesCleared returns if the "input_types" field was cleared in this mutation. +func (m *ComfyNodeMutation) InputTypesCleared() bool { + _, ok := m.clearedFields[comfynode.FieldInputTypes] + return ok +} + +// ResetInputTypes resets all changes to the "input_types" field. +func (m *ComfyNodeMutation) ResetInputTypes() { + m.input_types = nil + delete(m.clearedFields, comfynode.FieldInputTypes) +} + +// SetDeprecated sets the "deprecated" field. +func (m *ComfyNodeMutation) SetDeprecated(b bool) { + m.deprecated = &b +} + +// Deprecated returns the value of the "deprecated" field in the mutation. +func (m *ComfyNodeMutation) Deprecated() (r bool, exists bool) { + v := m.deprecated + if v == nil { + return + } + return *v, true +} + +// OldDeprecated returns the old "deprecated" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldDeprecated(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeprecated is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeprecated requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeprecated: %w", err) + } + return oldValue.Deprecated, nil +} + +// ResetDeprecated resets all changes to the "deprecated" field. +func (m *ComfyNodeMutation) ResetDeprecated() { + m.deprecated = nil +} + +// SetExperimental sets the "experimental" field. +func (m *ComfyNodeMutation) SetExperimental(b bool) { + m.experimental = &b +} + +// Experimental returns the value of the "experimental" field in the mutation. +func (m *ComfyNodeMutation) Experimental() (r bool, exists bool) { + v := m.experimental + if v == nil { + return + } + return *v, true +} + +// OldExperimental returns the old "experimental" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldExperimental(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExperimental is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExperimental requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExperimental: %w", err) + } + return oldValue.Experimental, nil +} + +// ResetExperimental resets all changes to the "experimental" field. +func (m *ComfyNodeMutation) ResetExperimental() { + m.experimental = nil +} + +// SetOutputIsList sets the "output_is_list" field. +func (m *ComfyNodeMutation) SetOutputIsList(b []bool) { + m.output_is_list = &b + m.appendoutput_is_list = nil +} + +// OutputIsList returns the value of the "output_is_list" field in the mutation. +func (m *ComfyNodeMutation) OutputIsList() (r []bool, exists bool) { + v := m.output_is_list + if v == nil { + return + } + return *v, true +} + +// OldOutputIsList returns the old "output_is_list" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldOutputIsList(ctx context.Context) (v []bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOutputIsList is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOutputIsList requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOutputIsList: %w", err) + } + return oldValue.OutputIsList, nil +} + +// AppendOutputIsList adds b to the "output_is_list" field. +func (m *ComfyNodeMutation) AppendOutputIsList(b []bool) { + m.appendoutput_is_list = append(m.appendoutput_is_list, b...) +} + +// AppendedOutputIsList returns the list of values that were appended to the "output_is_list" field in this mutation. +func (m *ComfyNodeMutation) AppendedOutputIsList() ([]bool, bool) { + if len(m.appendoutput_is_list) == 0 { + return nil, false + } + return m.appendoutput_is_list, true +} + +// ResetOutputIsList resets all changes to the "output_is_list" field. +func (m *ComfyNodeMutation) ResetOutputIsList() { + m.output_is_list = nil + m.appendoutput_is_list = nil +} + +// SetReturnNames sets the "return_names" field. +func (m *ComfyNodeMutation) SetReturnNames(s []string) { + m.return_names = &s + m.appendreturn_names = nil +} + +// ReturnNames returns the value of the "return_names" field in the mutation. +func (m *ComfyNodeMutation) ReturnNames() (r []string, exists bool) { + v := m.return_names + if v == nil { + return + } + return *v, true +} + +// OldReturnNames returns the old "return_names" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldReturnNames(ctx context.Context) (v []string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldReturnNames is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldReturnNames requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldReturnNames: %w", err) + } + return oldValue.ReturnNames, nil +} + +// AppendReturnNames adds s to the "return_names" field. +func (m *ComfyNodeMutation) AppendReturnNames(s []string) { + m.appendreturn_names = append(m.appendreturn_names, s...) +} + +// AppendedReturnNames returns the list of values that were appended to the "return_names" field in this mutation. +func (m *ComfyNodeMutation) AppendedReturnNames() ([]string, bool) { + if len(m.appendreturn_names) == 0 { + return nil, false + } + return m.appendreturn_names, true +} + +// ResetReturnNames resets all changes to the "return_names" field. +func (m *ComfyNodeMutation) ResetReturnNames() { + m.return_names = nil + m.appendreturn_names = nil +} + +// SetReturnTypes sets the "return_types" field. +func (m *ComfyNodeMutation) SetReturnTypes(s []string) { + m.return_types = &s + m.appendreturn_types = nil +} + +// ReturnTypes returns the value of the "return_types" field in the mutation. +func (m *ComfyNodeMutation) ReturnTypes() (r []string, exists bool) { + v := m.return_types + if v == nil { + return + } + return *v, true +} + +// OldReturnTypes returns the old "return_types" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldReturnTypes(ctx context.Context) (v []string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldReturnTypes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldReturnTypes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldReturnTypes: %w", err) + } + return oldValue.ReturnTypes, nil +} + +// AppendReturnTypes adds s to the "return_types" field. +func (m *ComfyNodeMutation) AppendReturnTypes(s []string) { + m.appendreturn_types = append(m.appendreturn_types, s...) +} + +// AppendedReturnTypes returns the list of values that were appended to the "return_types" field in this mutation. +func (m *ComfyNodeMutation) AppendedReturnTypes() ([]string, bool) { + if len(m.appendreturn_types) == 0 { + return nil, false + } + return m.appendreturn_types, true +} + +// ResetReturnTypes resets all changes to the "return_types" field. +func (m *ComfyNodeMutation) ResetReturnTypes() { + m.return_types = nil + m.appendreturn_types = nil +} + +// SetFunction sets the "function" field. +func (m *ComfyNodeMutation) SetFunction(s string) { + m.function = &s +} + +// Function returns the value of the "function" field in the mutation. +func (m *ComfyNodeMutation) Function() (r string, exists bool) { + v := m.function + if v == nil { + return + } + return *v, true +} + +// OldFunction returns the old "function" field's value of the ComfyNode entity. +// If the ComfyNode 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 *ComfyNodeMutation) OldFunction(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFunction is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFunction requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFunction: %w", err) + } + return oldValue.Function, nil +} + +// ResetFunction resets all changes to the "function" field. +func (m *ComfyNodeMutation) ResetFunction() { + m.function = nil +} + +// SetVersionsID sets the "versions" edge to the NodeVersion entity by id. +func (m *ComfyNodeMutation) SetVersionsID(id uuid.UUID) { + m.versions = &id +} + +// ClearVersions clears the "versions" edge to the NodeVersion entity. +func (m *ComfyNodeMutation) ClearVersions() { + m.clearedversions = true + m.clearedFields[comfynode.FieldNodeVersionID] = struct{}{} +} + +// VersionsCleared reports if the "versions" edge to the NodeVersion entity was cleared. +func (m *ComfyNodeMutation) VersionsCleared() bool { + return m.clearedversions +} + +// VersionsID returns the "versions" edge ID in the mutation. +func (m *ComfyNodeMutation) VersionsID() (id uuid.UUID, exists bool) { + if m.versions != nil { + return *m.versions, true + } + return +} + +// VersionsIDs returns the "versions" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// VersionsID instead. It exists only for internal usage by the builders. +func (m *ComfyNodeMutation) VersionsIDs() (ids []uuid.UUID) { + if id := m.versions; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetVersions resets all changes to the "versions" edge. +func (m *ComfyNodeMutation) ResetVersions() { + m.versions = nil + m.clearedversions = false +} + +// Where appends a list predicates to the ComfyNodeMutation builder. +func (m *ComfyNodeMutation) Where(ps ...predicate.ComfyNode) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ComfyNodeMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ComfyNodeMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ComfyNode, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ComfyNodeMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ComfyNodeMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ComfyNode). +func (m *ComfyNodeMutation) 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 *ComfyNodeMutation) Fields() []string { + fields := make([]string, 0, 12) + if m.create_time != nil { + fields = append(fields, comfynode.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, comfynode.FieldUpdateTime) + } + if m.versions != nil { + fields = append(fields, comfynode.FieldNodeVersionID) + } + if m.category != nil { + fields = append(fields, comfynode.FieldCategory) + } + if m.description != nil { + fields = append(fields, comfynode.FieldDescription) + } + if m.input_types != nil { + fields = append(fields, comfynode.FieldInputTypes) + } + if m.deprecated != nil { + fields = append(fields, comfynode.FieldDeprecated) + } + if m.experimental != nil { + fields = append(fields, comfynode.FieldExperimental) + } + if m.output_is_list != nil { + fields = append(fields, comfynode.FieldOutputIsList) + } + if m.return_names != nil { + fields = append(fields, comfynode.FieldReturnNames) + } + if m.return_types != nil { + fields = append(fields, comfynode.FieldReturnTypes) + } + if m.function != nil { + fields = append(fields, comfynode.FieldFunction) + } + 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 *ComfyNodeMutation) Field(name string) (ent.Value, bool) { + switch name { + case comfynode.FieldCreateTime: + return m.CreateTime() + case comfynode.FieldUpdateTime: + return m.UpdateTime() + case comfynode.FieldNodeVersionID: + return m.NodeVersionID() + case comfynode.FieldCategory: + return m.Category() + case comfynode.FieldDescription: + return m.Description() + case comfynode.FieldInputTypes: + return m.InputTypes() + case comfynode.FieldDeprecated: + return m.Deprecated() + case comfynode.FieldExperimental: + return m.Experimental() + case comfynode.FieldOutputIsList: + return m.OutputIsList() + case comfynode.FieldReturnNames: + return m.ReturnNames() + case comfynode.FieldReturnTypes: + return m.ReturnTypes() + case comfynode.FieldFunction: + return m.Function() + } + 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 *ComfyNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case comfynode.FieldCreateTime: + return m.OldCreateTime(ctx) + case comfynode.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case comfynode.FieldNodeVersionID: + return m.OldNodeVersionID(ctx) + case comfynode.FieldCategory: + return m.OldCategory(ctx) + case comfynode.FieldDescription: + return m.OldDescription(ctx) + case comfynode.FieldInputTypes: + return m.OldInputTypes(ctx) + case comfynode.FieldDeprecated: + return m.OldDeprecated(ctx) + case comfynode.FieldExperimental: + return m.OldExperimental(ctx) + case comfynode.FieldOutputIsList: + return m.OldOutputIsList(ctx) + case comfynode.FieldReturnNames: + return m.OldReturnNames(ctx) + case comfynode.FieldReturnTypes: + return m.OldReturnTypes(ctx) + case comfynode.FieldFunction: + return m.OldFunction(ctx) + } + return nil, fmt.Errorf("unknown ComfyNode 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 *ComfyNodeMutation) SetField(name string, value ent.Value) error { + switch name { + case comfynode.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case comfynode.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case comfynode.FieldNodeVersionID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNodeVersionID(v) + return nil + case comfynode.FieldCategory: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCategory(v) + return nil + case comfynode.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case comfynode.FieldInputTypes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInputTypes(v) + return nil + case comfynode.FieldDeprecated: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeprecated(v) + return nil + case comfynode.FieldExperimental: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExperimental(v) + return nil + case comfynode.FieldOutputIsList: + v, ok := value.([]bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOutputIsList(v) + return nil + case comfynode.FieldReturnNames: + v, ok := value.([]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetReturnNames(v) + return nil + case comfynode.FieldReturnTypes: + v, ok := value.([]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetReturnTypes(v) + return nil + case comfynode.FieldFunction: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFunction(v) + return nil + } + return fmt.Errorf("unknown ComfyNode field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ComfyNodeMutation) 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 *ComfyNodeMutation) 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 *ComfyNodeMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown ComfyNode numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ComfyNodeMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(comfynode.FieldCategory) { + fields = append(fields, comfynode.FieldCategory) + } + if m.FieldCleared(comfynode.FieldDescription) { + fields = append(fields, comfynode.FieldDescription) + } + if m.FieldCleared(comfynode.FieldInputTypes) { + fields = append(fields, comfynode.FieldInputTypes) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ComfyNodeMutation) 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 *ComfyNodeMutation) ClearField(name string) error { + switch name { + case comfynode.FieldCategory: + m.ClearCategory() + return nil + case comfynode.FieldDescription: + m.ClearDescription() + return nil + case comfynode.FieldInputTypes: + m.ClearInputTypes() + return nil + } + return fmt.Errorf("unknown ComfyNode 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 *ComfyNodeMutation) ResetField(name string) error { + switch name { + case comfynode.FieldCreateTime: + m.ResetCreateTime() + return nil + case comfynode.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case comfynode.FieldNodeVersionID: + m.ResetNodeVersionID() + return nil + case comfynode.FieldCategory: + m.ResetCategory() + return nil + case comfynode.FieldDescription: + m.ResetDescription() + return nil + case comfynode.FieldInputTypes: + m.ResetInputTypes() + return nil + case comfynode.FieldDeprecated: + m.ResetDeprecated() + return nil + case comfynode.FieldExperimental: + m.ResetExperimental() + return nil + case comfynode.FieldOutputIsList: + m.ResetOutputIsList() + return nil + case comfynode.FieldReturnNames: + m.ResetReturnNames() + return nil + case comfynode.FieldReturnTypes: + m.ResetReturnTypes() + return nil + case comfynode.FieldFunction: + m.ResetFunction() + return nil + } + return fmt.Errorf("unknown ComfyNode field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ComfyNodeMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.versions != nil { + edges = append(edges, comfynode.EdgeVersions) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ComfyNodeMutation) AddedIDs(name string) []ent.Value { + switch name { + case comfynode.EdgeVersions: + if id := m.versions; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ComfyNodeMutation) 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 *ComfyNodeMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ComfyNodeMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedversions { + edges = append(edges, comfynode.EdgeVersions) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ComfyNodeMutation) EdgeCleared(name string) bool { + switch name { + case comfynode.EdgeVersions: + return m.clearedversions + } + 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 *ComfyNodeMutation) ClearEdge(name string) error { + switch name { + case comfynode.EdgeVersions: + m.ClearVersions() + return nil + } + return fmt.Errorf("unknown ComfyNode 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 *ComfyNodeMutation) ResetEdge(name string) error { + switch name { + case comfynode.EdgeVersions: + m.ResetVersions() + return nil + } + return fmt.Errorf("unknown ComfyNode edge %s", name) +} + // GitCommitMutation represents an operation that mutates the GitCommit nodes in the graph. type GitCommitMutation struct { config @@ -4931,6 +6034,9 @@ type NodeVersionMutation struct { clearednode bool storage_file *uuid.UUID clearedstorage_file bool + comfy_nodes map[string]struct{} + removedcomfy_nodes map[string]struct{} + clearedcomfy_nodes bool done bool oldValue func(context.Context) (*NodeVersion, error) predicates []predicate.NodeVersion @@ -5458,6 +6564,60 @@ func (m *NodeVersionMutation) ResetStorageFile() { m.clearedstorage_file = false } +// AddComfyNodeIDs adds the "comfy_nodes" edge to the ComfyNode entity by ids. +func (m *NodeVersionMutation) AddComfyNodeIDs(ids ...string) { + if m.comfy_nodes == nil { + m.comfy_nodes = make(map[string]struct{}) + } + for i := range ids { + m.comfy_nodes[ids[i]] = struct{}{} + } +} + +// ClearComfyNodes clears the "comfy_nodes" edge to the ComfyNode entity. +func (m *NodeVersionMutation) ClearComfyNodes() { + m.clearedcomfy_nodes = true +} + +// ComfyNodesCleared reports if the "comfy_nodes" edge to the ComfyNode entity was cleared. +func (m *NodeVersionMutation) ComfyNodesCleared() bool { + return m.clearedcomfy_nodes +} + +// RemoveComfyNodeIDs removes the "comfy_nodes" edge to the ComfyNode entity by IDs. +func (m *NodeVersionMutation) RemoveComfyNodeIDs(ids ...string) { + if m.removedcomfy_nodes == nil { + m.removedcomfy_nodes = make(map[string]struct{}) + } + for i := range ids { + delete(m.comfy_nodes, ids[i]) + m.removedcomfy_nodes[ids[i]] = struct{}{} + } +} + +// RemovedComfyNodes returns the removed IDs of the "comfy_nodes" edge to the ComfyNode entity. +func (m *NodeVersionMutation) RemovedComfyNodesIDs() (ids []string) { + for id := range m.removedcomfy_nodes { + ids = append(ids, id) + } + return +} + +// ComfyNodesIDs returns the "comfy_nodes" edge IDs in the mutation. +func (m *NodeVersionMutation) ComfyNodesIDs() (ids []string) { + for id := range m.comfy_nodes { + ids = append(ids, id) + } + return +} + +// ResetComfyNodes resets all changes to the "comfy_nodes" edge. +func (m *NodeVersionMutation) ResetComfyNodes() { + m.comfy_nodes = nil + m.clearedcomfy_nodes = false + m.removedcomfy_nodes = nil +} + // Where appends a list predicates to the NodeVersionMutation builder. func (m *NodeVersionMutation) Where(ps ...predicate.NodeVersion) { m.predicates = append(m.predicates, ps...) @@ -5736,13 +6896,16 @@ func (m *NodeVersionMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *NodeVersionMutation) AddedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.node != nil { edges = append(edges, nodeversion.EdgeNode) } if m.storage_file != nil { edges = append(edges, nodeversion.EdgeStorageFile) } + if m.comfy_nodes != nil { + edges = append(edges, nodeversion.EdgeComfyNodes) + } return edges } @@ -5758,31 +6921,51 @@ func (m *NodeVersionMutation) AddedIDs(name string) []ent.Value { if id := m.storage_file; id != nil { return []ent.Value{*id} } + case nodeversion.EdgeComfyNodes: + ids := make([]ent.Value, 0, len(m.comfy_nodes)) + for id := range m.comfy_nodes { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *NodeVersionMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) + if m.removedcomfy_nodes != nil { + edges = append(edges, nodeversion.EdgeComfyNodes) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *NodeVersionMutation) RemovedIDs(name string) []ent.Value { + switch name { + case nodeversion.EdgeComfyNodes: + ids := make([]ent.Value, 0, len(m.removedcomfy_nodes)) + for id := range m.removedcomfy_nodes { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *NodeVersionMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.clearednode { edges = append(edges, nodeversion.EdgeNode) } if m.clearedstorage_file { edges = append(edges, nodeversion.EdgeStorageFile) } + if m.clearedcomfy_nodes { + edges = append(edges, nodeversion.EdgeComfyNodes) + } return edges } @@ -5794,6 +6977,8 @@ func (m *NodeVersionMutation) EdgeCleared(name string) bool { return m.clearednode case nodeversion.EdgeStorageFile: return m.clearedstorage_file + case nodeversion.EdgeComfyNodes: + return m.clearedcomfy_nodes } return false } @@ -5822,6 +7007,9 @@ func (m *NodeVersionMutation) ResetEdge(name string) error { case nodeversion.EdgeStorageFile: m.ResetStorageFile() return nil + case nodeversion.EdgeComfyNodes: + m.ResetComfyNodes() + return nil } return fmt.Errorf("unknown NodeVersion edge %s", name) } diff --git a/ent/nodeversion.go b/ent/nodeversion.go index 63d13cc..2200106 100644 --- a/ent/nodeversion.go +++ b/ent/nodeversion.go @@ -53,9 +53,11 @@ type NodeVersionEdges struct { Node *Node `json:"node,omitempty"` // StorageFile holds the value of the storage_file edge. StorageFile *StorageFile `json:"storage_file,omitempty"` + // ComfyNodes holds the value of the comfy_nodes edge. + ComfyNodes []*ComfyNode `json:"comfy_nodes,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool + loadedTypes [3]bool } // NodeOrErr returns the Node value or an error if the edge @@ -80,6 +82,15 @@ func (e NodeVersionEdges) StorageFileOrErr() (*StorageFile, error) { return nil, &NotLoadedError{edge: "storage_file"} } +// ComfyNodesOrErr returns the ComfyNodes value or an error if the edge +// was not loaded in eager-loading. +func (e NodeVersionEdges) ComfyNodesOrErr() ([]*ComfyNode, error) { + if e.loadedTypes[2] { + return e.ComfyNodes, nil + } + return nil, &NotLoadedError{edge: "comfy_nodes"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*NodeVersion) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -204,6 +215,11 @@ func (nv *NodeVersion) QueryStorageFile() *StorageFileQuery { return NewNodeVersionClient(nv.config).QueryStorageFile(nv) } +// QueryComfyNodes queries the "comfy_nodes" edge of the NodeVersion entity. +func (nv *NodeVersion) QueryComfyNodes() *ComfyNodeQuery { + return NewNodeVersionClient(nv.config).QueryComfyNodes(nv) +} + // Update returns a builder for updating this NodeVersion. // Note that you need to call NodeVersion.Unwrap() before calling this method if this NodeVersion // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/ent/nodeversion/nodeversion.go b/ent/nodeversion/nodeversion.go index bb5b59d..2b3d68c 100644 --- a/ent/nodeversion/nodeversion.go +++ b/ent/nodeversion/nodeversion.go @@ -39,6 +39,8 @@ const ( EdgeNode = "node" // EdgeStorageFile holds the string denoting the storage_file edge name in mutations. EdgeStorageFile = "storage_file" + // EdgeComfyNodes holds the string denoting the comfy_nodes edge name in mutations. + EdgeComfyNodes = "comfy_nodes" // Table holds the table name of the nodeversion in the database. Table = "node_versions" // NodeTable is the table that holds the node relation/edge. @@ -55,6 +57,13 @@ const ( StorageFileInverseTable = "storage_files" // StorageFileColumn is the table column denoting the storage_file relation/edge. StorageFileColumn = "node_version_storage_file" + // ComfyNodesTable is the table that holds the comfy_nodes relation/edge. + ComfyNodesTable = "comfy_nodes" + // ComfyNodesInverseTable is the table name for the ComfyNode entity. + // It exists in this package in order to avoid circular dependency with the "comfynode" package. + ComfyNodesInverseTable = "comfy_nodes" + // ComfyNodesColumn is the table column denoting the comfy_nodes relation/edge. + ComfyNodesColumn = "node_version_id" ) // Columns holds all SQL columns for nodeversion fields. @@ -180,6 +189,20 @@ func ByStorageFileField(field string, opts ...sql.OrderTermOption) OrderOption { sqlgraph.OrderByNeighborTerms(s, newStorageFileStep(), sql.OrderByField(field, opts...)) } } + +// ByComfyNodesCount orders the results by comfy_nodes count. +func ByComfyNodesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newComfyNodesStep(), opts...) + } +} + +// ByComfyNodes orders the results by comfy_nodes terms. +func ByComfyNodes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newComfyNodesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newNodeStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -194,3 +217,10 @@ func newStorageFileStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2O, false, StorageFileTable, StorageFileColumn), ) } +func newComfyNodesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ComfyNodesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ComfyNodesTable, ComfyNodesColumn), + ) +} diff --git a/ent/nodeversion/where.go b/ent/nodeversion/where.go index 65a2871..26dd6f1 100644 --- a/ent/nodeversion/where.go +++ b/ent/nodeversion/where.go @@ -528,6 +528,29 @@ func HasStorageFileWith(preds ...predicate.StorageFile) predicate.NodeVersion { }) } +// HasComfyNodes applies the HasEdge predicate on the "comfy_nodes" edge. +func HasComfyNodes() predicate.NodeVersion { + return predicate.NodeVersion(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ComfyNodesTable, ComfyNodesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasComfyNodesWith applies the HasEdge predicate on the "comfy_nodes" edge with a given conditions (other predicates). +func HasComfyNodesWith(preds ...predicate.ComfyNode) predicate.NodeVersion { + return predicate.NodeVersion(func(s *sql.Selector) { + step := newComfyNodesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.NodeVersion) predicate.NodeVersion { return predicate.NodeVersion(sql.AndPredicates(predicates...)) diff --git a/ent/nodeversion_create.go b/ent/nodeversion_create.go index 0b7b17d..1fac388 100644 --- a/ent/nodeversion_create.go +++ b/ent/nodeversion_create.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "registry-backend/ent/comfynode" "registry-backend/ent/node" "registry-backend/ent/nodeversion" "registry-backend/ent/schema" @@ -167,6 +168,21 @@ func (nvc *NodeVersionCreate) SetStorageFile(s *StorageFile) *NodeVersionCreate return nvc.SetStorageFileID(s.ID) } +// AddComfyNodeIDs adds the "comfy_nodes" edge to the ComfyNode entity by IDs. +func (nvc *NodeVersionCreate) AddComfyNodeIDs(ids ...string) *NodeVersionCreate { + nvc.mutation.AddComfyNodeIDs(ids...) + return nvc +} + +// AddComfyNodes adds the "comfy_nodes" edges to the ComfyNode entity. +func (nvc *NodeVersionCreate) AddComfyNodes(c ...*ComfyNode) *NodeVersionCreate { + ids := make([]string, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return nvc.AddComfyNodeIDs(ids...) +} + // Mutation returns the NodeVersionMutation object of the builder. func (nvc *NodeVersionCreate) Mutation() *NodeVersionMutation { return nvc.mutation @@ -364,6 +380,22 @@ func (nvc *NodeVersionCreate) createSpec() (*NodeVersion, *sqlgraph.CreateSpec) _node.node_version_storage_file = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } + if nodes := nvc.mutation.ComfyNodesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: nodeversion.ComfyNodesTable, + Columns: []string{nodeversion.ComfyNodesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/ent/nodeversion_query.go b/ent/nodeversion_query.go index 05074c1..1f28c25 100644 --- a/ent/nodeversion_query.go +++ b/ent/nodeversion_query.go @@ -4,8 +4,10 @@ package ent import ( "context" + "database/sql/driver" "fmt" "math" + "registry-backend/ent/comfynode" "registry-backend/ent/node" "registry-backend/ent/nodeversion" "registry-backend/ent/predicate" @@ -27,6 +29,7 @@ type NodeVersionQuery struct { predicates []predicate.NodeVersion withNode *NodeQuery withStorageFile *StorageFileQuery + withComfyNodes *ComfyNodeQuery withFKs bool modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). @@ -109,6 +112,28 @@ func (nvq *NodeVersionQuery) QueryStorageFile() *StorageFileQuery { return query } +// QueryComfyNodes chains the current query on the "comfy_nodes" edge. +func (nvq *NodeVersionQuery) QueryComfyNodes() *ComfyNodeQuery { + query := (&ComfyNodeClient{config: nvq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := nvq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := nvq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(nodeversion.Table, nodeversion.FieldID, selector), + sqlgraph.To(comfynode.Table, comfynode.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, nodeversion.ComfyNodesTable, nodeversion.ComfyNodesColumn), + ) + fromU = sqlgraph.SetNeighbors(nvq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first NodeVersion entity from the query. // Returns a *NotFoundError when no NodeVersion was found. func (nvq *NodeVersionQuery) First(ctx context.Context) (*NodeVersion, error) { @@ -303,6 +328,7 @@ func (nvq *NodeVersionQuery) Clone() *NodeVersionQuery { predicates: append([]predicate.NodeVersion{}, nvq.predicates...), withNode: nvq.withNode.Clone(), withStorageFile: nvq.withStorageFile.Clone(), + withComfyNodes: nvq.withComfyNodes.Clone(), // clone intermediate query. sql: nvq.sql.Clone(), path: nvq.path, @@ -331,6 +357,17 @@ func (nvq *NodeVersionQuery) WithStorageFile(opts ...func(*StorageFileQuery)) *N return nvq } +// WithComfyNodes tells the query-builder to eager-load the nodes that are connected to +// the "comfy_nodes" edge. The optional arguments are used to configure the query builder of the edge. +func (nvq *NodeVersionQuery) WithComfyNodes(opts ...func(*ComfyNodeQuery)) *NodeVersionQuery { + query := (&ComfyNodeClient{config: nvq.config}).Query() + for _, opt := range opts { + opt(query) + } + nvq.withComfyNodes = query + return nvq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -410,9 +447,10 @@ func (nvq *NodeVersionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] nodes = []*NodeVersion{} withFKs = nvq.withFKs _spec = nvq.querySpec() - loadedTypes = [2]bool{ + loadedTypes = [3]bool{ nvq.withNode != nil, nvq.withStorageFile != nil, + nvq.withComfyNodes != nil, } ) if nvq.withStorageFile != nil { @@ -454,6 +492,13 @@ func (nvq *NodeVersionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] return nil, err } } + if query := nvq.withComfyNodes; query != nil { + if err := nvq.loadComfyNodes(ctx, query, nodes, + func(n *NodeVersion) { n.Edges.ComfyNodes = []*ComfyNode{} }, + func(n *NodeVersion, e *ComfyNode) { n.Edges.ComfyNodes = append(n.Edges.ComfyNodes, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -518,6 +563,36 @@ func (nvq *NodeVersionQuery) loadStorageFile(ctx context.Context, query *Storage } return nil } +func (nvq *NodeVersionQuery) loadComfyNodes(ctx context.Context, query *ComfyNodeQuery, nodes []*NodeVersion, init func(*NodeVersion), assign func(*NodeVersion, *ComfyNode)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*NodeVersion) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(comfynode.FieldNodeVersionID) + } + query.Where(predicate.ComfyNode(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(nodeversion.ComfyNodesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.NodeVersionID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "node_version_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (nvq *NodeVersionQuery) sqlCount(ctx context.Context) (int, error) { _spec := nvq.querySpec() diff --git a/ent/nodeversion_update.go b/ent/nodeversion_update.go index 21fcba9..0160c1a 100644 --- a/ent/nodeversion_update.go +++ b/ent/nodeversion_update.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "registry-backend/ent/comfynode" "registry-backend/ent/node" "registry-backend/ent/nodeversion" "registry-backend/ent/predicate" @@ -166,6 +167,21 @@ func (nvu *NodeVersionUpdate) SetStorageFile(s *StorageFile) *NodeVersionUpdate return nvu.SetStorageFileID(s.ID) } +// AddComfyNodeIDs adds the "comfy_nodes" edge to the ComfyNode entity by IDs. +func (nvu *NodeVersionUpdate) AddComfyNodeIDs(ids ...string) *NodeVersionUpdate { + nvu.mutation.AddComfyNodeIDs(ids...) + return nvu +} + +// AddComfyNodes adds the "comfy_nodes" edges to the ComfyNode entity. +func (nvu *NodeVersionUpdate) AddComfyNodes(c ...*ComfyNode) *NodeVersionUpdate { + ids := make([]string, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return nvu.AddComfyNodeIDs(ids...) +} + // Mutation returns the NodeVersionMutation object of the builder. func (nvu *NodeVersionUpdate) Mutation() *NodeVersionMutation { return nvu.mutation @@ -183,6 +199,27 @@ func (nvu *NodeVersionUpdate) ClearStorageFile() *NodeVersionUpdate { return nvu } +// ClearComfyNodes clears all "comfy_nodes" edges to the ComfyNode entity. +func (nvu *NodeVersionUpdate) ClearComfyNodes() *NodeVersionUpdate { + nvu.mutation.ClearComfyNodes() + return nvu +} + +// RemoveComfyNodeIDs removes the "comfy_nodes" edge to ComfyNode entities by IDs. +func (nvu *NodeVersionUpdate) RemoveComfyNodeIDs(ids ...string) *NodeVersionUpdate { + nvu.mutation.RemoveComfyNodeIDs(ids...) + return nvu +} + +// RemoveComfyNodes removes "comfy_nodes" edges to ComfyNode entities. +func (nvu *NodeVersionUpdate) RemoveComfyNodes(c ...*ComfyNode) *NodeVersionUpdate { + ids := make([]string, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return nvu.RemoveComfyNodeIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (nvu *NodeVersionUpdate) Save(ctx context.Context) (int, error) { nvu.defaults() @@ -337,6 +374,51 @@ func (nvu *NodeVersionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if nvu.mutation.ComfyNodesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: nodeversion.ComfyNodesTable, + Columns: []string{nodeversion.ComfyNodesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nvu.mutation.RemovedComfyNodesIDs(); len(nodes) > 0 && !nvu.mutation.ComfyNodesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: nodeversion.ComfyNodesTable, + Columns: []string{nodeversion.ComfyNodesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nvu.mutation.ComfyNodesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: nodeversion.ComfyNodesTable, + Columns: []string{nodeversion.ComfyNodesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(nvu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, nvu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -491,6 +573,21 @@ func (nvuo *NodeVersionUpdateOne) SetStorageFile(s *StorageFile) *NodeVersionUpd return nvuo.SetStorageFileID(s.ID) } +// AddComfyNodeIDs adds the "comfy_nodes" edge to the ComfyNode entity by IDs. +func (nvuo *NodeVersionUpdateOne) AddComfyNodeIDs(ids ...string) *NodeVersionUpdateOne { + nvuo.mutation.AddComfyNodeIDs(ids...) + return nvuo +} + +// AddComfyNodes adds the "comfy_nodes" edges to the ComfyNode entity. +func (nvuo *NodeVersionUpdateOne) AddComfyNodes(c ...*ComfyNode) *NodeVersionUpdateOne { + ids := make([]string, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return nvuo.AddComfyNodeIDs(ids...) +} + // Mutation returns the NodeVersionMutation object of the builder. func (nvuo *NodeVersionUpdateOne) Mutation() *NodeVersionMutation { return nvuo.mutation @@ -508,6 +605,27 @@ func (nvuo *NodeVersionUpdateOne) ClearStorageFile() *NodeVersionUpdateOne { return nvuo } +// ClearComfyNodes clears all "comfy_nodes" edges to the ComfyNode entity. +func (nvuo *NodeVersionUpdateOne) ClearComfyNodes() *NodeVersionUpdateOne { + nvuo.mutation.ClearComfyNodes() + return nvuo +} + +// RemoveComfyNodeIDs removes the "comfy_nodes" edge to ComfyNode entities by IDs. +func (nvuo *NodeVersionUpdateOne) RemoveComfyNodeIDs(ids ...string) *NodeVersionUpdateOne { + nvuo.mutation.RemoveComfyNodeIDs(ids...) + return nvuo +} + +// RemoveComfyNodes removes "comfy_nodes" edges to ComfyNode entities. +func (nvuo *NodeVersionUpdateOne) RemoveComfyNodes(c ...*ComfyNode) *NodeVersionUpdateOne { + ids := make([]string, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return nvuo.RemoveComfyNodeIDs(ids...) +} + // Where appends a list predicates to the NodeVersionUpdate builder. func (nvuo *NodeVersionUpdateOne) Where(ps ...predicate.NodeVersion) *NodeVersionUpdateOne { nvuo.mutation.Where(ps...) @@ -692,6 +810,51 @@ func (nvuo *NodeVersionUpdateOne) sqlSave(ctx context.Context) (_node *NodeVersi } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if nvuo.mutation.ComfyNodesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: nodeversion.ComfyNodesTable, + Columns: []string{nodeversion.ComfyNodesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nvuo.mutation.RemovedComfyNodesIDs(); len(nodes) > 0 && !nvuo.mutation.ComfyNodesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: nodeversion.ComfyNodesTable, + Columns: []string{nodeversion.ComfyNodesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nvuo.mutation.ComfyNodesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: nodeversion.ComfyNodesTable, + Columns: []string{nodeversion.ComfyNodesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(comfynode.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(nvuo.modifiers...) _node = &NodeVersion{config: nvuo.config} _spec.Assign = _node.assignValues diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go index 37bf309..2f0b9ad 100644 --- a/ent/predicate/predicate.go +++ b/ent/predicate/predicate.go @@ -9,6 +9,9 @@ import ( // CIWorkflowResult is the predicate function for ciworkflowresult builders. type CIWorkflowResult func(*sql.Selector) +// ComfyNode is the predicate function for comfynode builders. +type ComfyNode func(*sql.Selector) + // GitCommit is the predicate function for gitcommit builders. type GitCommit func(*sql.Selector) diff --git a/ent/runtime.go b/ent/runtime.go index 69c967e..a11f7f5 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -4,6 +4,7 @@ package ent import ( "registry-backend/ent/ciworkflowresult" + "registry-backend/ent/comfynode" "registry-backend/ent/gitcommit" "registry-backend/ent/node" "registry-backend/ent/nodereview" @@ -45,6 +46,41 @@ func init() { ciworkflowresultDescID := ciworkflowresultFields[0].Descriptor() // ciworkflowresult.DefaultID holds the default value on creation for the id field. ciworkflowresult.DefaultID = ciworkflowresultDescID.Default.(func() uuid.UUID) + comfynodeMixin := schema.ComfyNode{}.Mixin() + comfynodeMixinFields0 := comfynodeMixin[0].Fields() + _ = comfynodeMixinFields0 + comfynodeFields := schema.ComfyNode{}.Fields() + _ = comfynodeFields + // comfynodeDescCreateTime is the schema descriptor for create_time field. + comfynodeDescCreateTime := comfynodeMixinFields0[0].Descriptor() + // comfynode.DefaultCreateTime holds the default value on creation for the create_time field. + comfynode.DefaultCreateTime = comfynodeDescCreateTime.Default.(func() time.Time) + // comfynodeDescUpdateTime is the schema descriptor for update_time field. + comfynodeDescUpdateTime := comfynodeMixinFields0[1].Descriptor() + // comfynode.DefaultUpdateTime holds the default value on creation for the update_time field. + comfynode.DefaultUpdateTime = comfynodeDescUpdateTime.Default.(func() time.Time) + // comfynode.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + comfynode.UpdateDefaultUpdateTime = comfynodeDescUpdateTime.UpdateDefault.(func() time.Time) + // comfynodeDescDeprecated is the schema descriptor for deprecated field. + comfynodeDescDeprecated := comfynodeFields[5].Descriptor() + // comfynode.DefaultDeprecated holds the default value on creation for the deprecated field. + comfynode.DefaultDeprecated = comfynodeDescDeprecated.Default.(bool) + // comfynodeDescExperimental is the schema descriptor for experimental field. + comfynodeDescExperimental := comfynodeFields[6].Descriptor() + // comfynode.DefaultExperimental holds the default value on creation for the experimental field. + comfynode.DefaultExperimental = comfynodeDescExperimental.Default.(bool) + // comfynodeDescOutputIsList is the schema descriptor for output_is_list field. + comfynodeDescOutputIsList := comfynodeFields[7].Descriptor() + // comfynode.DefaultOutputIsList holds the default value on creation for the output_is_list field. + comfynode.DefaultOutputIsList = comfynodeDescOutputIsList.Default.([]bool) + // comfynodeDescReturnNames is the schema descriptor for return_names field. + comfynodeDescReturnNames := comfynodeFields[8].Descriptor() + // comfynode.DefaultReturnNames holds the default value on creation for the return_names field. + comfynode.DefaultReturnNames = comfynodeDescReturnNames.Default.([]string) + // comfynodeDescReturnTypes is the schema descriptor for return_types field. + comfynodeDescReturnTypes := comfynodeFields[9].Descriptor() + // comfynode.DefaultReturnTypes holds the default value on creation for the return_types field. + comfynode.DefaultReturnTypes = comfynodeDescReturnTypes.Default.([]string) gitcommitMixin := schema.GitCommit{}.Mixin() gitcommitMixinFields0 := gitcommitMixin[0].Fields() _ = gitcommitMixinFields0 diff --git a/ent/schema/comfy_node.go b/ent/schema/comfy_node.go new file mode 100644 index 0000000..d33f97d --- /dev/null +++ b/ent/schema/comfy_node.go @@ -0,0 +1,59 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" + "github.com/google/uuid" +) + +type ComfyNode struct { + ent.Schema +} + +func (ComfyNode) Fields() []ent.Field { + return []ent.Field{ + field.String("id").SchemaType(map[string]string{ + dialect.Postgres: "text", + }), + field.UUID("node_version_id", uuid.UUID{}), + field.String("category").SchemaType(map[string]string{ + dialect.Postgres: "text", + }).Optional(), + field.String("description").SchemaType(map[string]string{ + dialect.Postgres: "text", + }).Optional(), + field.String("input_types").SchemaType(map[string]string{ + dialect.Postgres: "text", + }).Optional(), + field.Bool("deprecated").Default(false), + field.Bool("experimental").Default(false), + field.JSON("output_is_list", []bool{}).Default([]bool{}), + field.Strings("return_names").Default([]string{}), + field.Strings("return_types").Default([]string{}), + field.String("function").SchemaType(map[string]string{ + dialect.Postgres: "text", + }), + } +} + +func (ComfyNode) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixin.Time{}, + } +} + +func (ComfyNode) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("id", "node_version_id").Unique(), + } +} + +func (ComfyNode) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("versions", NodeVersion.Type).Field("node_version_id").Ref("comfy_nodes").Required().Unique(), + } +} diff --git a/ent/schema/node_version.go b/ent/schema/node_version.go index 40c8581..cc8cba1 100644 --- a/ent/schema/node_version.go +++ b/ent/schema/node_version.go @@ -51,6 +51,7 @@ func (NodeVersion) Edges() []ent.Edge { return []ent.Edge{ edge.From("node", Node.Type).Field("node_id").Ref("versions").Required().Unique(), edge.To("storage_file", StorageFile.Type).Unique(), + edge.To("comfy_nodes", ComfyNode.Type), } } diff --git a/ent/tx.go b/ent/tx.go index cfef450..8318a10 100644 --- a/ent/tx.go +++ b/ent/tx.go @@ -14,6 +14,8 @@ type Tx struct { config // CIWorkflowResult is the client for interacting with the CIWorkflowResult builders. CIWorkflowResult *CIWorkflowResultClient + // ComfyNode is the client for interacting with the ComfyNode builders. + ComfyNode *ComfyNodeClient // GitCommit is the client for interacting with the GitCommit builders. GitCommit *GitCommitClient // Node is the client for interacting with the Node builders. @@ -164,6 +166,7 @@ func (tx *Tx) Client() *Client { func (tx *Tx) init() { tx.CIWorkflowResult = NewCIWorkflowResultClient(tx.config) + tx.ComfyNode = NewComfyNodeClient(tx.config) tx.GitCommit = NewGitCommitClient(tx.config) tx.Node = NewNodeClient(tx.config) tx.NodeReview = NewNodeReviewClient(tx.config) diff --git a/integration-tests/registry_integration_test.go b/integration-tests/registry_integration_test.go index bbdd6ab..121f581 100644 --- a/integration-tests/registry_integration_test.go +++ b/integration-tests/registry_integration_test.go @@ -530,8 +530,7 @@ func TestRegistryNodeVersion(t *testing.T) { NodeId: *node.Id, VersionNumber: *createdNodeVersion.Version, Body: &drip.AdminUpdateNodeVersionJSONRequestBody{ - Status: &activeStatus, - StatusReason: proto.String("test reason"), + Status: &activeStatus, }, }) require.NoError(t, err, "should return updated node version") @@ -618,19 +617,6 @@ func TestRegistryNodeVersion(t *testing.T) { Status: &nodeVersionStatus, StatusReason: proto.String(""), }, resVersions200[0], "should be equal") - - // retrieve node versions with the status reason - resVersions, err = withMiddleware(authz, impl.ListNodeVersions)(ctx, drip.ListNodeVersionsRequestObject{ - NodeId: *node.Id, - Params: drip.ListNodeVersionsParams{ - IncludeStatusReason: proto.Bool(true), - }, - }) - require.NoError(t, err, "should not return error") - require.IsType(t, drip.ListNodeVersions200JSONResponse{}, resVersions, "should return 200") - - resVersions200 = resVersions.(drip.ListNodeVersions200JSONResponse) - assert.Equal(t, "test reason", *resVersions200[0].StatusReason) }) t.Run("Update Node Version", func(t *testing.T) { @@ -848,3 +834,178 @@ func isTokenMasked(token string) bool { middle := token[4:tokenLength] return strings.Count(middle, "*") == len(middle) } + +func TestRegistryComfyNode(t *testing.T) { + client, cleanup := setupDB(t, context.Background()) + defer cleanup() + impl, authz := newMockedImpl(client, &config.Config{}) + + ctx, _ := setUpTest(client) + ctx = drip_logging.SetupLogger().WithContext(ctx) + + pub := randomPublisher() + _, err := withMiddleware(authz, impl.CreatePublisher)(ctx, drip.CreatePublisherRequestObject{ + Body: pub, + }) + require.NoError(t, err, "should return created publisher") + // createdPublisher := (respub.(drip.CreatePublisher201JSONResponse)) + + tokenName := "test-token-name" + tokenDescription := "test-token-description" + respat, err := withMiddleware(authz, impl.CreatePersonalAccessToken)(ctx, drip.CreatePersonalAccessTokenRequestObject{ + PublisherId: *pub.Id, + Body: &drip.PersonalAccessToken{ + Name: &tokenName, + Description: &tokenDescription, + }, + }) + require.NoError(t, err, "should return created token") + token := *respat.(drip.CreatePersonalAccessToken201JSONResponse).Token + + // create node version + node := randomNode() + nodeVersion := randomNodeVersion(0) + signedUrl := "test-url" + impl.mockStorageService.On("GenerateSignedURL", mock.Anything, mock.Anything).Return(signedUrl, nil) + impl.mockStorageService.On("GetFileUrl", mock.Anything, mock.Anything, mock.Anything).Return(signedUrl, nil) + impl.mockDiscordService.On("SendSecurityCouncilMessage", mock.Anything, mock.Anything).Return(nil) + _, err = withMiddleware(authz, impl.PublishNodeVersion)(ctx, drip.PublishNodeVersionRequestObject{ + PublisherId: *pub.Id, + NodeId: *node.Id, + Body: &drip.PublishNodeVersionJSONRequestBody{ + PersonalAccessToken: token, + Node: *node, + NodeVersion: *nodeVersion, + }, + }) + require.NoError(t, err, "should not return error") + + // create another node version + _, err = withMiddleware(authz, impl.PublishNodeVersion)(ctx, drip.PublishNodeVersionRequestObject{ + PublisherId: *pub.Id, + NodeId: *node.Id, + Body: &drip.PublishNodeVersionJSONRequestBody{ + PersonalAccessToken: token, + Node: *node, + NodeVersion: *randomNodeVersion(1), + }, + }) + require.NoError(t, err, "should not return error") + + t.Run("NoComfyNode", func(t *testing.T) { + res, err := withMiddleware(authz, impl.GetNodeVersion)(ctx, drip.GetNodeVersionRequestObject{ + NodeId: *node.Id, + VersionId: *nodeVersion.Version, + }) + require.NoError(t, err, "should return created node version") + require.IsType(t, drip.GetNodeVersion200JSONResponse{}, res) + assert.Empty(t, res.(drip.GetNodeVersion200JSONResponse).ComfyNodes) + }) + + comfyNodes := map[string]drip.ComfyNode{ + "node1": { + InputTypes: proto.String(`{"required":{"param":"string"}}`), + Function: proto.String("node1Func"), + Category: proto.String("node1Category"), + Description: proto.String("node1Description"), + Deprecated: proto.Bool(false), + Experimental: proto.Bool(false), + ReturnNames: &[]string{"result1", "result2"}, + ReturnTypes: &[]string{"string", "string"}, + OutputIsList: &[]bool{false, false}, + }, + "node2": { + InputTypes: proto.String(`{"required":{"param":"string"}}`), + Function: proto.String("node2Func"), + Category: proto.String("node2Category"), + Description: proto.String("node2Description"), + Deprecated: proto.Bool(true), + Experimental: proto.Bool(true), + ReturnNames: &[]string{"result1", "result2"}, + ReturnTypes: &[]string{"string", "string"}, + OutputIsList: &[]bool{true, true}, + }, + } + + // create comfy nodes + body := drip.CreateComfyNodesJSONRequestBody(comfyNodes) + res, err := withMiddleware(authz, impl.CreateComfyNodes)(ctx, drip.CreateComfyNodesRequestObject{ + NodeId: *node.Id, + VersionId: *nodeVersion.Version, + Body: &body, + }) + require.NoError(t, err) + require.IsType(t, drip.CreateComfyNodes204Response{}, res) + + t.Run("GetComfyNodes", func(t *testing.T) { + for k, v := range comfyNodes { + v.ComfyNodeId = proto.String(k) + t.Run(k, func(t *testing.T) { + res, err := withMiddleware(authz, impl.GetComfyNode)(ctx, drip.GetComfyNodeRequestObject{ + NodeId: *node.Id, + VersionId: *nodeVersion.Version, + ComfyNodeId: k, + }) + require.NoError(t, err, "should return created node version") + require.IsType(t, drip.GetComfyNode200JSONResponse{}, res) + assert.Equal(t, drip.GetComfyNode200JSONResponse(v), res.(drip.GetComfyNode200JSONResponse)) + }) + } + }) + + t.Run("GetNodeVersion", func(t *testing.T) { + res, err := withMiddleware(authz, impl.GetNodeVersion)(ctx, drip.GetNodeVersionRequestObject{ + NodeId: *node.Id, + VersionId: *nodeVersion.Version, + }) + require.NoError(t, err, "should return created node version") + require.IsType(t, drip.GetNodeVersion200JSONResponse{}, res) + for k, v := range *res.(drip.GetNodeVersion200JSONResponse).ComfyNodes { + ev := comfyNodes[k] + ev.ComfyNodeId = proto.String(k) + assert.Equal(t, ev, v) + } + }) + + t.Run("ListNodeVersion", func(t *testing.T) { + res, err := withMiddleware(authz, impl.ListNodeVersions)(ctx, drip.ListNodeVersionsRequestObject{ + NodeId: *node.Id, + }) + require.NoError(t, err, "should return created node version") + require.IsType(t, drip.ListNodeVersions200JSONResponse{}, res) + found := false + for _, nv := range res.(drip.ListNodeVersions200JSONResponse) { + if *nv.Version == *nodeVersion.Version { + for k, v := range *nv.ComfyNodes { + found = true + ev := comfyNodes[k] + ev.ComfyNodeId = proto.String(k) + assert.Equal(t, ev, v) + } + } else { + assert.Empty(t, nv.ComfyNodes) + } + } + assert.True(t, found) + }) + + t.Run("ListAllNodeVersion", func(t *testing.T) { + res, err := withMiddleware(authz, impl.ListAllNodeVersions)(ctx, drip.ListAllNodeVersionsRequestObject{}) + require.NoError(t, err, "should return created node version") + require.IsType(t, drip.ListAllNodeVersions200JSONResponse{}, res) + found := false + for _, nv := range *res.(drip.ListAllNodeVersions200JSONResponse).Versions { + if *nv.Version == *nodeVersion.Version { + for k, v := range *nv.ComfyNodes { + found = true + ev := comfyNodes[k] + ev.ComfyNodeId = proto.String(k) + assert.Equal(t, ev, v) + } + } else { + assert.Empty(t, nv.ComfyNodes) + } + } + assert.True(t, found) + }) +} diff --git a/mapper/node_version.go b/mapper/node_version.go index a7f822f..13eb0a7 100644 --- a/mapper/node_version.go +++ b/mapper/node_version.go @@ -59,6 +59,15 @@ func DbNodeVersionToApiNodeVersion(dbNodeVersion *ent.NodeVersion) *drip.NodeVer downloadUrl = dbNodeVersion.Edges.StorageFile.FileURL } + var comfyNodes *map[string]drip.ComfyNode + if len(dbNodeVersion.Edges.ComfyNodes) > 0 { + cn := make(map[string]drip.ComfyNode, len(dbNodeVersion.Edges.ComfyNodes)) + for _, v := range dbNodeVersion.Edges.ComfyNodes { + cn[v.ID] = *DBComfyNodeToApiComfyNode(v) + } + comfyNodes = &cn + } + apiVersion := &drip.NodeVersion{ Id: &id, Version: &dbNodeVersion.Version, @@ -69,10 +78,30 @@ func DbNodeVersionToApiNodeVersion(dbNodeVersion *ent.NodeVersion) *drip.NodeVer Status: status, StatusReason: &dbNodeVersion.StatusReason, DownloadUrl: &downloadUrl, + ComfyNodes: comfyNodes, } return apiVersion } +func DBComfyNodeToApiComfyNode(dbComfyNode *ent.ComfyNode) *drip.ComfyNode { + if dbComfyNode == nil { + return nil + } + + return &drip.ComfyNode{ + ComfyNodeId: &dbComfyNode.ID, + Category: &dbComfyNode.Category, + Function: &dbComfyNode.Function, + Description: &dbComfyNode.Description, + Deprecated: &dbComfyNode.Deprecated, + Experimental: &dbComfyNode.Experimental, + InputTypes: &dbComfyNode.InputTypes, + OutputIsList: &dbComfyNode.OutputIsList, + ReturnNames: &dbComfyNode.ReturnNames, + ReturnTypes: &dbComfyNode.ReturnTypes, + } +} + func CheckValidSemv(version string) bool { _, err := semver.NewVersion(version) return err == nil diff --git a/openapi.yml b/openapi.yml index 2773c5d..027a524 100644 --- a/openapi.yml +++ b/openapi.yml @@ -82,10 +82,10 @@ paths: format: int64 description: The end time of the job as a Unix timestamp. avg_vram: - type: integer + type: integer description: The average amount of VRAM used in the run. peak_vram: - type: integer + type: integer description: The peak amount of VRAM used in the run. pr_number: type: string @@ -1502,13 +1502,6 @@ paths: type: array items: $ref: '#/components/schemas/NodeVersionStatus' - # parameter to include status_reason, default to false - - in: query - name: include_status_reason - required: false - schema: - type: boolean - default: false responses: '200': description: List of all node versions @@ -1594,13 +1587,6 @@ paths: type: array items: $ref: '#/components/schemas/NodeVersionStatus' - # parameter to include status_reason, default to false - - in: query - name: include_status_reason - required: false - schema: - type: boolean - default: false - in: query name: page required: false @@ -1677,7 +1663,7 @@ paths: required: true content: application/json: - schema: + schema: type: object properties: status: @@ -1759,6 +1745,104 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' + /nodes/{nodeId}/versions/{versionId}/comfy-nodes: + post: + summary: create comfy-nodes for certain node + operationId: CreateComfyNodes + tags: + - ComfyNodes + parameters: + - in: path + name: nodeId + required: true + schema: + type: string + - in: path + name: versionId + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + additionalProperties: + $ref: '#/components/schemas/ComfyNode' + responses: + '204': + description: Comy Nodes created successfully + '401': + description: Unauthorized + '403': + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '404': + description: Version not found + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + /nodes/{nodeId}/versions/{versionId}/comfy-nodes/{comfyNodeId}: + get: + summary: get specify comfy-node based on its id + operationId: GetComfyNode + tags: + - ComfyNodes + parameters: + - in: path + name: nodeId + required: true + schema: + type: string + - in: path + name: versionId + required: true + schema: + type: string + - in: path + name: comfyNodeId + required: true + schema: + type: string + responses: + '200': + description: Comy Nodes created successfully + content: + application/json: + schema: + $ref: '#/components/schemas/ComfyNode' + '401': + description: Unauthorized + '403': + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '404': + description: Version not found + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + components: schemas: PersonalAccessToken: @@ -1918,7 +2002,7 @@ components: git_repo: type: string description: The repository name - pr_number: + pr_number: type: string description: The pull request number start_time: @@ -1938,12 +2022,12 @@ components: job_trigger_user: type: string description: The user who triggered the job. - author: + author: type: string description: The author of the commit machine_stats: $ref: "#/components/schemas/MachineStats" - status: + status: $ref: "#/components/schemas/WorkflowRunStatus" storage_file: $ref: "#/components/schemas/StorageFile" @@ -2082,6 +2166,49 @@ components: status_reason: type: string description: The reason for the status change. + comfy_nodes: + type: object + additionalProperties: + $ref: "#/components/schemas/ComfyNode" + ComfyNode: + type: object + properties: + comfy_node_id: + type: string + description: Unique identifier for the node + category: + type: string + description: UI category where the node is listed, used for grouping nodes. + description: + type: string + description: Brief description of the node's functionality or purpose. + input_types: + type: string + description: Defines input parameters + deprecated: + type: boolean + description: Indicates if the node is deprecated. Deprecated nodes are hidden in the UI. + experimental: + type: boolean + description: Indicates if the node is experimental, subject to changes or removal. + output_is_list: + type: array + items: + type: boolean + description: Boolean values indicating if each output is a list. + return_names: + type: array + items: + type: string + description: Names of the outputs for clarity in workflows. + return_types: + type: array + items: + type: string + description: Specifies the types of outputs produced by the node. + function: + type: string + description: Name of the entry-point function to execute the node. Error: type: object properties: diff --git a/server/implementation/registry.go b/server/implementation/registry.go index 4a30eb5..b4b0c00 100644 --- a/server/implementation/registry.go +++ b/server/implementation/registry.go @@ -453,9 +453,8 @@ func (s *DripStrictServerImplementation) ListNodeVersions( apiStatus := mapper.ApiNodeVersionStatusesToDbNodeVersionStatuses(request.Params.Statuses) nodeVersionsResult, err := s.RegistryService.ListNodeVersions(ctx, s.Client, &drip_services.NodeVersionFilter{ - NodeId: request.NodeId, - Status: apiStatus, - IncludeStatusReason: mapper.BoolPtrToBool(request.Params.IncludeStatusReason), + NodeId: request.NodeId, + Status: apiStatus, }) if err != nil { log.Ctx(ctx).Error().Msgf("Failed to list node versions for node %s w/ err: %v", request.NodeId, err) @@ -961,9 +960,8 @@ func (s *DripStrictServerImplementation) ListAllNodeVersions( pageSize = *request.Params.PageSize } f := &drip_services.NodeVersionFilter{ - Page: page, - PageSize: pageSize, - IncludeStatusReason: mapper.BoolPtrToBool(request.Params.IncludeStatusReason), + Page: page, + PageSize: pageSize, } if request.Params.Statuses != nil { @@ -1014,3 +1012,41 @@ func (s *DripStrictServerImplementation) ReindexNodes(ctx context.Context, reque log.Ctx(ctx).Info().Msgf("Reindex nodes successful") return drip.ReindexNodes200Response{}, nil } + +// CreateComfyNodes bulk-creates comfy-nodes for a node version +func (impl *DripStrictServerImplementation) CreateComfyNodes(ctx context.Context, request drip.CreateComfyNodesRequestObject) (res drip.CreateComfyNodesResponseObject, err error) { + log.Ctx(ctx).Info().Msg("CreateComfyNodes request received") + err = impl.RegistryService.CreateComfyNodes(ctx, impl.Client, request.NodeId, request.VersionId, *request.Body) + if ent.IsNotFound(err) { + log.Ctx(ctx).Error().Msgf("Node or node version not found w/ err: %v", err) + return drip.CreateComfyNodes404JSONResponse{Message: "Node or node version not found", Error: err.Error()}, nil + } + if err != nil { + log.Ctx(ctx).Error().Msgf("Failed to create comfy nodes w/ err: %v", err) + return drip.CreateComfyNodes500JSONResponse{Message: "Failed to create comfy nodes", Error: err.Error()}, nil + } + + log.Ctx(ctx).Info().Msgf("CreateComfyNodes successful") + return drip.CreateComfyNodes204Response{}, nil +} + +// GetComfyNode return a certain comfy-node of a certain node version +func (impl *DripStrictServerImplementation) GetComfyNode(ctx context.Context, request drip.GetComfyNodeRequestObject) (res drip.GetComfyNodeResponseObject, err error) { + log.Ctx(ctx).Info().Msg("GetComfyNode request received") + + n, err := impl.RegistryService.GetComfyNode(ctx, impl.Client, request.NodeId, request.VersionId, request.ComfyNodeId) + if ent.IsNotFound(err) { + log.Ctx(ctx).Error().Msgf("Node or node version or comfy node not found w/ err: %v", err) + return drip.GetComfyNode404JSONResponse{Message: "Node or node version or comfy node not found", Error: err.Error()}, nil + } + + cn := mapper.DBComfyNodeToApiComfyNode(n) + if cn == nil { + log.Ctx(ctx).Error().Msgf("Comfy Node not found") + return drip.GetComfyNode404JSONResponse{Message: "Comfy Node not found"}, nil + } + + log.Ctx(ctx).Info().Msgf("GetComfyNode successful") + res = drip.GetComfyNode200JSONResponse(*cn) + return +} diff --git a/server/middleware/authentication/firebase_auth.go b/server/middleware/authentication/firebase_auth.go index 30f86ee..139f1b4 100644 --- a/server/middleware/authentication/firebase_auth.go +++ b/server/middleware/authentication/firebase_auth.go @@ -20,28 +20,30 @@ import ( func FirebaseAuthMiddleware(entClient *ent.Client) echo.MiddlewareFunc { // Handlers in here should bypass this middleware. var allowlist = map[*regexp.Regexp][]string{ - regexp.MustCompile(`^/openapi$`): {"GET"}, - regexp.MustCompile(`^/security-scan$`): {"GET"}, - regexp.MustCompile(`^/users/sessions$`): {"DELETE"}, - regexp.MustCompile(`^/vm$`): {"ANY"}, - regexp.MustCompile(`^/health$`): {"GET"}, - regexp.MustCompile(`^/upload-artifact$`): {"POST"}, - regexp.MustCompile(`^/gitcommit$`): {"POST", "GET"}, - regexp.MustCompile(`^/gitcommitsummary$`): {"GET"}, - regexp.MustCompile(`^/workflowresult/[^/]+$`): {"GET"}, - regexp.MustCompile(`^/branch$`): {"GET"}, - regexp.MustCompile(`^/publishers/[^/]+/nodes/[^/]+/versions$`): {"POST"}, - regexp.MustCompile(`^/publishers/[^/]+/nodes$`): {"GET"}, - regexp.MustCompile(`^/publishers/[^/]+$`): {"GET"}, - regexp.MustCompile(`^/nodes$`): {"GET"}, - regexp.MustCompile(`^/versions$`): {"GET"}, - regexp.MustCompile(`^/nodes/[^/]+$`): {"GET"}, - regexp.MustCompile(`^/nodes/[^/]+/versions$`): {"GET"}, - regexp.MustCompile(`^/nodes/[^/]+/versions/[^/]+$`): {"GET"}, - regexp.MustCompile(`^/nodes/[^/]+/install$`): {"GET"}, - regexp.MustCompile(`^/nodes/reindex$`): {"POST"}, - regexp.MustCompile(`^/publishers/[^/]+/ban$`): {"POST"}, - regexp.MustCompile(`^/publishers/[^/]+/nodes/[^/]+/ban$`): {"POST"}, + regexp.MustCompile(`^/openapi$`): {"GET"}, + regexp.MustCompile(`^/security-scan$`): {"GET"}, + regexp.MustCompile(`^/users/sessions$`): {"DELETE"}, + regexp.MustCompile(`^/vm$`): {"ANY"}, + regexp.MustCompile(`^/health$`): {"GET"}, + regexp.MustCompile(`^/upload-artifact$`): {"POST"}, + regexp.MustCompile(`^/gitcommit$`): {"POST", "GET"}, + regexp.MustCompile(`^/gitcommitsummary$`): {"GET"}, + regexp.MustCompile(`^/workflowresult/[^/]+$`): {"GET"}, + regexp.MustCompile(`^/branch$`): {"GET"}, + regexp.MustCompile(`^/publishers/[^/]+/nodes/[^/]+/versions$`): {"POST"}, + regexp.MustCompile(`^/publishers/[^/]+/nodes$`): {"GET"}, + regexp.MustCompile(`^/publishers/[^/]+$`): {"GET"}, + regexp.MustCompile(`^/nodes$`): {"GET"}, + regexp.MustCompile(`^/versions$`): {"GET"}, + regexp.MustCompile(`^/nodes/[^/]+$`): {"GET"}, + regexp.MustCompile(`^/nodes/[^/]+/versions$`): {"GET"}, + regexp.MustCompile(`^/nodes/[^/]+/versions/[^/]+$`): {"GET"}, + regexp.MustCompile(`^/nodes/[^/]+/install$`): {"GET"}, + regexp.MustCompile(`^/nodes/reindex$`): {"POST"}, + regexp.MustCompile(`^/publishers/[^/]+/ban$`): {"POST"}, + regexp.MustCompile(`^/publishers/[^/]+/nodes/[^/]+/ban$`): {"POST"}, + regexp.MustCompile(`^/nodes/[^/]+/versions/[^/]+/comfy-nodes$`): {"POST"}, + regexp.MustCompile(`^/nodes/[^/]+/versions/[^/]+/comfy-nodes/[^/]+$`): {"GET"}, } return func(next echo.HandlerFunc) echo.HandlerFunc { diff --git a/server/middleware/authentication/firebase_auth_test.go b/server/middleware/authentication/firebase_auth_test.go index cf1f758..c466bc3 100644 --- a/server/middleware/authentication/firebase_auth_test.go +++ b/server/middleware/authentication/firebase_auth_test.go @@ -38,13 +38,16 @@ func TestAllowlist(t *testing.T) { {"Git Commit Summary GET", "/gitcommitsummary", "GET", true}, {"Branch GET", "/branch", "GET", true}, {"Node Version Path POST", "/publishers/pub123/nodes/node456/versions", "POST", true}, - {"Publisher POST", "/publishers", "POST", false}, - {"Unauthorized Path", "/nonexistent", "GET", false}, {"Reindex Nodes", "/nodes/reindex", "POST", true}, {"Get All Nodes", "/nodes", "GET", true}, {"Install Nodes", "/nodes/node-id/install", "GET", true}, {"Get all node versions", "/nodes/node-id/versions", "GET", true}, {"Get specific node version", "/nodes/node-id/versions/1.0.0", "GET", true}, + {"Create Comfy Nodes", "/nodes/test/versions/1.0.0/comfy-nodes", "POST", true}, + {"Get a Comfy-Node", "/nodes/test/versions/1.0.0/comfy-nodes/test", "GET", true}, + + {"Publisher POST", "/publishers", "POST", false}, + {"Unauthorized Path", "/nonexistent", "GET", false}, } for _, tt := range tests { diff --git a/server/middleware/authentication/service_account_auth.go b/server/middleware/authentication/service_account_auth.go index 799bb83..b9b35d5 100644 --- a/server/middleware/authentication/service_account_auth.go +++ b/server/middleware/authentication/service_account_auth.go @@ -2,6 +2,7 @@ package drip_authentication import ( "net/http" + "regexp" "strings" "github.com/labstack/echo/v4" @@ -11,29 +12,33 @@ import ( func ServiceAccountAuthMiddleware() echo.MiddlewareFunc { // Handlers in here should be checked by this middleware. - var checklist = map[string][]string{ - "/security-scan": {"GET"}, - "/nodes/reindex": {"POST"}, + var checklistRegex = map[*regexp.Regexp][]string{ + regexp.MustCompile(`^/security-scan$`): {"GET"}, + regexp.MustCompile(`^/nodes/reindex$`): {"POST"}, + regexp.MustCompile(`^/nodes/[^/]+/versions/[^/]+/comfy-nodes$`): {"POST"}, } return func(next echo.HandlerFunc) echo.HandlerFunc { return func(ctx echo.Context) error { - // Check if the request path and method are in the checklist - path := ctx.Request().URL.Path - method := ctx.Request().Method + // Check if the request reqPath and method are in the checklist + reqPath := ctx.Request().URL.Path + reqMethod := ctx.Request().Method + match := false + for pathRe, methods := range checklistRegex { + if !pathRe.MatchString(reqPath) { + continue + } - methods, ok := checklist[path] - if !ok { - return next(ctx) - } + for _, method := range methods { + if method != "ANY" && reqMethod != method { + continue + } - for _, m := range methods { - if method == m { - ok = true + match = true break } } - if !ok { + if !match { return next(ctx) } @@ -48,7 +53,7 @@ func ServiceAccountAuthMiddleware() echo.MiddlewareFunc { return echo.NewHTTPError(http.StatusUnauthorized, "Missing token") } - log.Ctx(ctx.Request().Context()).Info().Msgf("Validating google id token %s for path %s and method %s", token, path, method) + log.Ctx(ctx.Request().Context()).Info().Msgf("Validating google id token %s for path %s and method %s", token, reqPath, reqMethod) payload, err := idtoken.Validate(ctx.Request().Context(), token, "https://api.comfy.org") if err != nil { diff --git a/server/middleware/authentication/service_account_auth_test.go b/server/middleware/authentication/service_account_auth_test.go index 048d1a4..082ceeb 100644 --- a/server/middleware/authentication/service_account_auth_test.go +++ b/server/middleware/authentication/service_account_auth_test.go @@ -37,9 +37,11 @@ func TestServiceAccountAllowList(t *testing.T) { {"Unauthorized Path", "/nonexistent", "GET", true}, {"Get All Nodes", "/nodes", "GET", true}, {"Install Nodes", "/nodes/node-id/install", "GET", true}, + {"Get Comfy-Nodes", "/nodes/test/versions/1.0.0/comfy-nodes/test", "GET", true}, {"Reindex Nodes", "/nodes/reindex", "POST", false}, {"Reindex Nodes", "/security-scan", "GET", false}, + {"Create Comfy-Nodes", "/nodes/test/versions/1.0.0/comfy-nodes", "POST", false}, } for _, tt := range tests { diff --git a/services/registry/registry_svc.go b/services/registry/registry_svc.go index 0cdd45e..ff0a70f 100644 --- a/services/registry/registry_svc.go +++ b/services/registry/registry_svc.go @@ -12,6 +12,7 @@ import ( "registry-backend/db" "registry-backend/drip" "registry-backend/ent" + "registry-backend/ent/comfynode" "registry-backend/ent/node" "registry-backend/ent/nodeversion" "registry-backend/ent/personalaccesstoken" @@ -67,12 +68,11 @@ type NodeFilter struct { } type NodeVersionFilter struct { - NodeId string - Status []schema.NodeVersionStatus - IncludeStatusReason bool - MinAge time.Duration - PageSize int - Page int + NodeId string + Status []schema.NodeVersionStatus + MinAge time.Duration + PageSize int + Page int } type NodeData struct { @@ -431,10 +431,10 @@ type NodeVersionCreation struct { SignedUrl string } -func (s *RegistryService) ListNodeVersions( - ctx context.Context, client *ent.Client, filter *NodeVersionFilter) (*ListNodeVersionsResult, error) { +func (s *RegistryService) ListNodeVersions(ctx context.Context, client *ent.Client, filter *NodeVersionFilter) (*ListNodeVersionsResult, error) { query := client.NodeVersion.Query(). WithStorageFile(). + WithComfyNodes(). Order(ent.Desc(nodeversion.FieldCreateTime)) if filter.NodeId != "" { @@ -451,40 +451,27 @@ func (s *RegistryService) ListNodeVersions( query.Where(nodeversion.CreateTimeLT(time.Now().Add(-filter.MinAge))) } - // Apply pagination if filter.Page > 0 && filter.PageSize > 0 { - query.Offset((filter.Page - 1) * filter.PageSize).Limit(filter.PageSize) + query.Offset((filter.Page - 1) * filter.PageSize) + query.Limit(filter.PageSize) } - - // Note: custom SELECT statement cause errors in the ent framework when using the Count method. - // We need to include the logic to exclude certain fields after the count query is executed. total, err := query.Count(ctx) if err != nil { return nil, fmt.Errorf("failed to count node versions: %w", err) } - - // By default, we are selecting all fields. If the status reason is not required, we will exclude it - if !filter.IncludeStatusReason { - columns := make([]string, 0, len(nodeversion.Columns)) - for _, column := range nodeversion.Columns { - if column != nodeversion.FieldStatusReason { - columns = append(columns, column) - } - } - - query.Select(columns...) - } versions, err := query.All(ctx) if err != nil { return nil, fmt.Errorf("failed to list node versions: %w", err) } - // Calculate total pages totalPages := 0 - if filter.PageSize > 0 { - totalPages = (total + filter.PageSize - 1) / filter.PageSize // Use ceiling division for total pages - } + if total > 0 && filter.PageSize > 0 { + totalPages = total / filter.PageSize + if total%filter.PageSize != 0 { + totalPages += 1 + } + } return &ListNodeVersionsResult{ Total: total, NodeVersions: versions, @@ -540,6 +527,7 @@ func (s *RegistryService) GetNodeVersionByVersion(ctx context.Context, client *e Where(nodeversion.VersionEQ(nodeVersion)). Where(nodeversion.NodeIDEQ(nodeId)). WithStorageFile(). + WithComfyNodes(). Only(ctx) } @@ -584,6 +572,7 @@ func (s *RegistryService) GetLatestNodeVersion(ctx context.Context, client *ent. //Where(nodeversion.StatusEQ(schema.NodeVersionStatusActive)). Order(ent.Desc(nodeversion.FieldCreateTime)). WithStorageFile(). + WithComfyNodes(). First(ctx) if err != nil { @@ -600,6 +589,68 @@ func (s *RegistryService) GetLatestNodeVersion(ctx context.Context, client *ent. return nodeVersion, nil } +func (s *RegistryService) CreateComfyNodes(ctx context.Context, client *ent.Client, nodeID string, nodeVersion string, comfyNodes map[string]drip.ComfyNode) (err error) { + nv, err := client.NodeVersion.Query(). + Where(nodeversion.VersionEQ(nodeVersion)). + Where(nodeversion.NodeIDEQ(nodeID)).Only(ctx) + if err != nil { + return err + } + + comfyNodesCreates := make([]*ent.ComfyNodeCreate, 0, len(comfyNodes)) + for k, n := range comfyNodes { + comfyNodeCreate := client.ComfyNode.Create(). + SetID(k). + SetNodeVersionID(nv.ID) + + if n.Category != nil { + comfyNodeCreate.SetCategory(*n.Category) + } + if n.Description != nil { + comfyNodeCreate.SetDescription(*n.Description) + } + if n.InputTypes != nil { + comfyNodeCreate.SetInputTypes(*n.InputTypes) + } + if n.Deprecated != nil { + comfyNodeCreate.SetDeprecated(*n.Deprecated) + } + if n.Experimental != nil { + comfyNodeCreate.SetExperimental(*n.Experimental) + } + if n.OutputIsList != nil { + comfyNodeCreate.SetOutputIsList(*n.OutputIsList) + } + if n.ReturnNames != nil { + comfyNodeCreate.SetReturnNames(*n.ReturnNames) + } + if n.ReturnTypes != nil { + comfyNodeCreate.SetReturnTypes(*n.ReturnTypes) + } + if n.Function != nil { + comfyNodeCreate.SetFunction(*n.Function) + } + comfyNodesCreates = append(comfyNodesCreates, comfyNodeCreate) + } + return client.ComfyNode. + CreateBulk(comfyNodesCreates...). + Exec(ctx) +} + +func (s *RegistryService) GetComfyNode(ctx context.Context, client *ent.Client, nodeID string, nodeVersion string, comfyNodeID string) (*ent.ComfyNode, error) { + nv, err := client.NodeVersion.Query(). + Where(nodeversion.VersionEQ(nodeVersion)). + Where(nodeversion.NodeIDEQ(nodeID)). + WithComfyNodes(func(cnq *ent.ComfyNodeQuery) { + cnq.Where(comfynode.IDEQ(comfyNodeID)) + }). + Only(ctx) + if err != nil { + return nil, err + } + return nv.Edges.ComfyNodes[0], nil +} + func (s *RegistryService) AssertPublisherPermissions(ctx context.Context, client *ent.Client, publisherID string,