diff --git a/cmd/cli/cmd/internalpolicy/root.go b/cmd/cli/cmd/internalpolicy/root.go index 0120b1f4..3e0f92d1 100644 --- a/cmd/cli/cmd/internalpolicy/root.go +++ b/cmd/cli/cmd/internalpolicy/root.go @@ -88,7 +88,6 @@ func jsonOutput(out any) error { // tableOutput prints the output in a table format func tableOutput(out []openlaneclient.InternalPolicy) { // create a table writer - // TODO: add additional columns to the table writer writer := tables.NewTableWriter(command.OutOrStdout(), "ID", "Name", "Description", "Status", "Type", "Version", "Purpose", "Background") for _, i := range out { writer.AddRow(i.ID, i.Name, *i.Description, *i.Status, *i.PolicyType, *i.Version, *i.PurposeAndScope, *i.Background) diff --git a/cmd/cli/cmd/narrative/create.go b/cmd/cli/cmd/narrative/create.go new file mode 100644 index 00000000..d4df84af --- /dev/null +++ b/cmd/cli/cmd/narrative/create.go @@ -0,0 +1,69 @@ +package narrative + +import ( + "context" + + "github.com/spf13/cobra" + + "github.com/theopenlane/core/cmd/cli/cmd" + "github.com/theopenlane/core/pkg/openlaneclient" +) + +var createCmd = &cobra.Command{ + Use: "create", + Short: "create a new narrative", + Run: func(cmd *cobra.Command, args []string) { + err := create(cmd.Context()) + cobra.CheckErr(err) + }, +} + +func init() { + command.AddCommand(createCmd) + + // command line flags for the create command + createCmd.Flags().StringP("name", "n", "", "name of the narrative") + createCmd.Flags().StringP("description", "d", "", "description of the narrative") + createCmd.Flags().StringP("satisfies", "a", "", "which controls are satisfied by the narrative") + createCmd.Flags().StringSliceP("programs", "p", []string{}, "program ID(s) associated with the narrative") +} + +// createValidation validates the required fields for the command +func createValidation() (input openlaneclient.CreateNarrativeInput, err error) { + // validation of required fields for the create command + // output the input struct with the required fields and optional fields based on the command line flags + input.Name = cmd.Config.String("name") + if input.Name == "" { + return input, cmd.NewRequiredFieldMissingError("name") + } + + input.ProgramIDs = cmd.Config.Strings("programs") + + description := cmd.Config.String("description") + if description != "" { + input.Description = &description + } + + satisfies := cmd.Config.String("satisfies") + if satisfies != "" { + input.Satisfies = &satisfies + } + + return input, nil +} + +// create a new narrative +func create(ctx context.Context) error { + // setup http client + client, err := cmd.SetupClientWithAuth(ctx) + cobra.CheckErr(err) + defer cmd.StoreSessionCookies(client) + + input, err := createValidation() + cobra.CheckErr(err) + + o, err := client.CreateNarrative(ctx, input) + cobra.CheckErr(err) + + return consoleOutput(o) +} diff --git a/cmd/cli/cmd/narrative/delete.go b/cmd/cli/cmd/narrative/delete.go new file mode 100644 index 00000000..8b5a19ba --- /dev/null +++ b/cmd/cli/cmd/narrative/delete.go @@ -0,0 +1,50 @@ +package narrative + +import ( + "context" + + "github.com/spf13/cobra" + + "github.com/theopenlane/core/cmd/cli/cmd" +) + +var deleteCmd = &cobra.Command{ + Use: "delete", + Short: "delete an existing narrative", + Run: func(cmd *cobra.Command, args []string) { + err := delete(cmd.Context()) + cobra.CheckErr(err) + }, +} + +func init() { + command.AddCommand(deleteCmd) + + deleteCmd.Flags().StringP("id", "i", "", "narrative id to delete") +} + +// deleteValidation validates the required fields for the command +func deleteValidation() (string, error) { + id := cmd.Config.String("id") + if id == "" { + return "", cmd.NewRequiredFieldMissingError("narrative id") + } + + return id, nil +} + +// delete an existing narrative in the platform +func delete(ctx context.Context) error { + // setup http client + client, err := cmd.SetupClientWithAuth(ctx) + cobra.CheckErr(err) + defer cmd.StoreSessionCookies(client) + + id, err := deleteValidation() + cobra.CheckErr(err) + + o, err := client.DeleteNarrative(ctx, id) + cobra.CheckErr(err) + + return consoleOutput(o) +} diff --git a/cmd/cli/cmd/narrative/doc.go b/cmd/cli/cmd/narrative/doc.go new file mode 100644 index 00000000..c0a90ad2 --- /dev/null +++ b/cmd/cli/cmd/narrative/doc.go @@ -0,0 +1,2 @@ +// Package narrative is our cobra cli for narrative endpoints +package narrative diff --git a/cmd/cli/cmd/narrative/get.go b/cmd/cli/cmd/narrative/get.go new file mode 100644 index 00000000..306d1f90 --- /dev/null +++ b/cmd/cli/cmd/narrative/get.go @@ -0,0 +1,48 @@ +package narrative + +import ( + "context" + + "github.com/spf13/cobra" + + "github.com/theopenlane/core/cmd/cli/cmd" +) + +var getCmd = &cobra.Command{ + Use: "get", + Short: "get an existing narrative", + Run: func(cmd *cobra.Command, args []string) { + err := get(cmd.Context()) + cobra.CheckErr(err) + }, +} + +func init() { + command.AddCommand(getCmd) + getCmd.Flags().StringP("id", "i", "", "narrative id to query") +} + +// get an existing narrative in the platform +func get(ctx context.Context) error { + // setup http client + client, err := cmd.SetupClientWithAuth(ctx) + cobra.CheckErr(err) + defer cmd.StoreSessionCookies(client) + + // filter options + id := cmd.Config.String("id") + + // if an narrative ID is provided, filter on that narrative, otherwise get all + if id != "" { + o, err := client.GetNarrativeByID(ctx, id) + cobra.CheckErr(err) + + return consoleOutput(o) + } + + // get all will be filtered for the authorized organization(s) + o, err := client.GetAllNarratives(ctx) + cobra.CheckErr(err) + + return consoleOutput(o) +} diff --git a/cmd/cli/cmd/narrative/root.go b/cmd/cli/cmd/narrative/root.go new file mode 100644 index 00000000..e8eeaa30 --- /dev/null +++ b/cmd/cli/cmd/narrative/root.go @@ -0,0 +1,113 @@ +package narrative + +import ( + "encoding/json" + "strings" + + "github.com/spf13/cobra" + + "github.com/theopenlane/utils/cli/tables" + + "github.com/theopenlane/core/cmd/cli/cmd" + "github.com/theopenlane/core/pkg/openlaneclient" +) + +// command represents the base narrative command when called without any subcommands +var command = &cobra.Command{ + Use: "narrative", + Short: "the subcommands for working with narratives", +} + +func init() { + cmd.RootCmd.AddCommand(command) +} + +// consoleOutput prints the output in the console +func consoleOutput(e any) error { + // check if the output format is JSON and print the narratives in JSON format + if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) { + return jsonOutput(e) + } + + // check the type of the narratives and print them in a table format + switch v := e.(type) { + case *openlaneclient.GetAllNarratives: + var nodes []*openlaneclient.GetAllNarratives_Narratives_Edges_Node + + for _, i := range v.Narratives.Edges { + nodes = append(nodes, i.Node) + } + + e = nodes + case *openlaneclient.GetNarratives: + var nodes []*openlaneclient.GetNarratives_Narratives_Edges_Node + + for _, i := range v.Narratives.Edges { + nodes = append(nodes, i.Node) + } + + e = nodes + case *openlaneclient.GetNarrativeByID: + e = v.Narrative + case *openlaneclient.CreateNarrative: + e = v.CreateNarrative.Narrative + case *openlaneclient.UpdateNarrative: + e = v.UpdateNarrative.Narrative + case *openlaneclient.DeleteNarrative: + deletedTableOutput(v) + return nil + } + + s, err := json.Marshal(e) + cobra.CheckErr(err) + + var list []openlaneclient.Narrative + + err = json.Unmarshal(s, &list) + if err != nil { + var in openlaneclient.Narrative + err = json.Unmarshal(s, &in) + cobra.CheckErr(err) + + list = append(list, in) + } + + tableOutput(list) + + return nil +} + +// jsonOutput prints the output in a JSON format +func jsonOutput(out any) error { + s, err := json.Marshal(out) + cobra.CheckErr(err) + + return cmd.JSONPrint(s) +} + +// tableOutput prints the output in a table format +func tableOutput(out []openlaneclient.Narrative) { + // create a table writer + writer := tables.NewTableWriter(command.OutOrStdout(), "ID", "Name", "Description", "Satisfies", "Programs") + + for _, i := range out { + programs := []string{} + + for _, p := range i.Programs { + programs = append(programs, p.Name) + } + + writer.AddRow(i.ID, i.Name, *i.Description, *i.Satisfies, strings.Join(programs, ", ")) + } + + writer.Render() +} + +// deleteTableOutput prints the deleted id in a table format +func deletedTableOutput(e *openlaneclient.DeleteNarrative) { + writer := tables.NewTableWriter(command.OutOrStdout(), "DeletedID") + + writer.AddRow(e.DeleteNarrative.DeletedID) + + writer.Render() +} diff --git a/cmd/cli/cmd/narrative/update.go b/cmd/cli/cmd/narrative/update.go new file mode 100644 index 00000000..6459919c --- /dev/null +++ b/cmd/cli/cmd/narrative/update.go @@ -0,0 +1,85 @@ +package narrative + +import ( + "context" + + "github.com/spf13/cobra" + + "github.com/theopenlane/core/cmd/cli/cmd" + "github.com/theopenlane/core/pkg/openlaneclient" +) + +var updateCmd = &cobra.Command{ + Use: "update", + Short: "update an existing narrative", + Run: func(cmd *cobra.Command, args []string) { + err := update(cmd.Context()) + cobra.CheckErr(err) + }, +} + +func init() { + command.AddCommand(updateCmd) + + updateCmd.Flags().StringP("id", "i", "", "narrative id to update") + + // command line flags for the update command + updateCmd.Flags().StringP("name", "n", "", "name of the narrative") + updateCmd.Flags().StringP("description", "d", "", "description of the narrative") + updateCmd.Flags().StringP("satisfies", "a", "", "which controls are satisfied by the narrative") + updateCmd.Flags().StringSlice("add-programs", []string{}, "add program(s) to the narrative") + updateCmd.Flags().StringSlice("remove-programs", []string{}, "remove program(s) from the narrative") +} + +// updateValidation validates the required fields for the command +func updateValidation() (id string, input openlaneclient.UpdateNarrativeInput, err error) { + id = cmd.Config.String("id") + if id == "" { + return id, input, cmd.NewRequiredFieldMissingError("narrative id") + } + + // validation of required fields for the update command + // output the input struct with the required fields and optional fields based on the command line flags + name := cmd.Config.String("name") + if name != "" { + input.Name = &name + } + + description := cmd.Config.String("description") + if description != "" { + input.Description = &description + } + + satisfies := cmd.Config.String("satisfies") + if satisfies != "" { + input.Satisfies = &satisfies + } + + addPrograms := cmd.Config.Strings("add-programs") + if len(addPrograms) > 0 { + input.AddProgramIDs = addPrograms + } + + removePrograms := cmd.Config.Strings("remove-programs") + if len(removePrograms) > 0 { + input.RemoveProgramIDs = removePrograms + } + + return id, input, nil +} + +// update an existing narrative in the platform +func update(ctx context.Context) error { + // setup http client + client, err := cmd.SetupClientWithAuth(ctx) + cobra.CheckErr(err) + defer cmd.StoreSessionCookies(client) + + id, input, err := updateValidation() + cobra.CheckErr(err) + + o, err := client.UpdateNarrative(ctx, id, input) + cobra.CheckErr(err) + + return consoleOutput(o) +} diff --git a/cmd/cli/cmd/narrativehistory/doc.go b/cmd/cli/cmd/narrativehistory/doc.go new file mode 100644 index 00000000..d7f2493b --- /dev/null +++ b/cmd/cli/cmd/narrativehistory/doc.go @@ -0,0 +1,2 @@ +// Package narrativehistory is our cobra cli for narrativeHistory endpoints +package narrativehistory diff --git a/cmd/cli/cmd/narrativehistory/get.go b/cmd/cli/cmd/narrativehistory/get.go new file mode 100644 index 00000000..b9d86414 --- /dev/null +++ b/cmd/cli/cmd/narrativehistory/get.go @@ -0,0 +1,49 @@ +package narrativehistory + +import ( + "context" + + "github.com/spf13/cobra" + + "github.com/theopenlane/core/cmd/cli/cmd" + "github.com/theopenlane/core/pkg/openlaneclient" +) + +var getCmd = &cobra.Command{ + Use: "get", + Short: "get an existing narrativeHistory", + Run: func(cmd *cobra.Command, args []string) { + err := get(cmd.Context()) + cobra.CheckErr(err) + }, +} + +func init() { + command.AddCommand(getCmd) + getCmd.Flags().StringP("id", "i", "", "id to query") +} + +// get an existing narrativeHistory in the platform +func get(ctx context.Context) error { + // setup http client + client, err := cmd.SetupClientWithAuth(ctx) + cobra.CheckErr(err) + defer cmd.StoreSessionCookies(client) + + // filter options + id := cmd.Config.String("id") + if id != "" { + o, err := client.GetNarrativeHistories(ctx, &openlaneclient.NarrativeHistoryWhereInput{ + Ref: &id, + }) + cobra.CheckErr(err) + + return consoleOutput(o) + } + + // get all will be filtered for the authorized organization(s) + o, err := client.GetAllNarrativeHistories(ctx) + cobra.CheckErr(err) + + return consoleOutput(o) +} diff --git a/cmd/cli/cmd/narrativehistory/root.go b/cmd/cli/cmd/narrativehistory/root.go new file mode 100644 index 00000000..db4cc2ab --- /dev/null +++ b/cmd/cli/cmd/narrativehistory/root.go @@ -0,0 +1,88 @@ +package narrativehistory + +import ( + "encoding/json" + "strings" + + "github.com/spf13/cobra" + + "github.com/theopenlane/utils/cli/tables" + + "github.com/theopenlane/core/cmd/cli/cmd" + "github.com/theopenlane/core/pkg/openlaneclient" +) + +// command represents the base narrativeHistory command when called without any subcommands +var command = &cobra.Command{ + Use: "narrative-history", + Short: "the subcommands for working with narrativeHistories", +} + +func init() { + cmd.RootCmd.AddCommand(command) +} + +// consoleOutput prints the output in the console +func consoleOutput(e any) error { + // check if the output format is JSON and print the narrativeHistories in JSON format + if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) { + return jsonOutput(e) + } + + // check the type of the narrativeHistories and print them in a table format + switch v := e.(type) { + case *openlaneclient.GetAllNarrativeHistories: + var nodes []*openlaneclient.GetAllNarrativeHistories_NarrativeHistories_Edges_Node + + for _, i := range v.NarrativeHistories.Edges { + nodes = append(nodes, i.Node) + } + + e = nodes + case *openlaneclient.GetNarrativeHistories: + var nodes []*openlaneclient.GetNarrativeHistories_NarrativeHistories_Edges_Node + + for _, i := range v.NarrativeHistories.Edges { + nodes = append(nodes, i.Node) + } + + e = nodes + } + + s, err := json.Marshal(e) + cobra.CheckErr(err) + + var list []openlaneclient.NarrativeHistory + + err = json.Unmarshal(s, &list) + if err != nil { + var in openlaneclient.NarrativeHistory + err = json.Unmarshal(s, &in) + cobra.CheckErr(err) + + list = append(list, in) + } + + tableOutput(list) + + return nil +} + +// jsonOutput prints the output in a JSON format +func jsonOutput(out any) error { + s, err := json.Marshal(out) + cobra.CheckErr(err) + + return cmd.JSONPrint(s) +} + +// tableOutput prints the output in a table format +func tableOutput(out []openlaneclient.NarrativeHistory) { + // create a table writer + writer := tables.NewTableWriter(command.OutOrStdout(), "ID", "Ref", "Operation", "UpdatedAt", "UpdatedBy") + for _, i := range out { + writer.AddRow(i.ID, *i.Ref, i.Operation, *i.UpdatedAt, *i.UpdatedBy) + } + + writer.Render() +} diff --git a/cmd/cli/cmd/procedure/root.go b/cmd/cli/cmd/procedure/root.go index 3ee00013..4faec835 100644 --- a/cmd/cli/cmd/procedure/root.go +++ b/cmd/cli/cmd/procedure/root.go @@ -88,7 +88,6 @@ func jsonOutput(out any) error { // tableOutput prints the output in a table format func tableOutput(out []openlaneclient.Procedure) { // create a table writer - // TODO: add additional columns to the table writer writer := tables.NewTableWriter(command.OutOrStdout(), "ID", "Name", "Description", "Status", "Type", "Version", "Purpose", "Background", "Satisfies") for _, i := range out { writer.AddRow(i.ID, i.Name, *i.Description, *i.Status, *i.ProcedureType, *i.Version, *i.PurposeAndScope, *i.Background, *i.Satisfies) diff --git a/cmd/cli/cmd/program/root.go b/cmd/cli/cmd/program/root.go index d69415c4..60d8efa1 100644 --- a/cmd/cli/cmd/program/root.go +++ b/cmd/cli/cmd/program/root.go @@ -88,7 +88,6 @@ func jsonOutput(out any) error { // tableOutput prints the output in a table format func tableOutput(out []openlaneclient.Program) { // create a table writer - // TODO: add additional columns to the table writer writer := tables.NewTableWriter(command.OutOrStdout(), "ID", "Name", "Description", "Status", "AuditorReady", "AuditorWriteComments", "AuditorReadComments", "StartDate", "EndDate") for _, i := range out { writer.AddRow(i.ID, i.Name, *i.Description, i.Status, i.AuditorReady, i.AuditorWriteComments, i.AuditorReadComments, i.StartDate, i.EndDate) diff --git a/cmd/cli/cmd/risk/update.go b/cmd/cli/cmd/risk/update.go index 513a5ce5..6940fa7e 100644 --- a/cmd/cli/cmd/risk/update.go +++ b/cmd/cli/cmd/risk/update.go @@ -25,6 +25,7 @@ func init() { updateCmd.Flags().StringP("id", "i", "", "risk id to update") // command line flags for the update command + updateCmd.Flags().StringP("name", "n", "", "name of the risk") updateCmd.Flags().StringP("description", "d", "", "description of the risk") updateCmd.Flags().StringP("status", "s", "", "status of the risk") updateCmd.Flags().StringP("type", "t", "", "type of the risk") @@ -46,6 +47,11 @@ func updateValidation() (id string, input openlaneclient.UpdateRiskInput, err er // validation of required fields for the update command // output the input struct with the required fields and optional fields based on the command line flags + name := cmd.Config.String("name") + if name != "" { + input.Name = &name + } + description := cmd.Config.String("description") if description != "" { input.Description = &description diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 1ec861f5..a61ba338 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -23,6 +23,7 @@ import ( _ "github.com/theopenlane/core/cmd/cli/cmd/internalpolicy" _ "github.com/theopenlane/core/cmd/cli/cmd/invite" _ "github.com/theopenlane/core/cmd/cli/cmd/login" + _ "github.com/theopenlane/core/cmd/cli/cmd/narrative" _ "github.com/theopenlane/core/cmd/cli/cmd/organization" _ "github.com/theopenlane/core/cmd/cli/cmd/organizationsetting" _ "github.com/theopenlane/core/cmd/cli/cmd/orgmembers" @@ -58,6 +59,7 @@ import ( _ "github.com/theopenlane/core/cmd/cli/cmd/hushhistory" _ "github.com/theopenlane/core/cmd/cli/cmd/integrationhistory" _ "github.com/theopenlane/core/cmd/cli/cmd/internalpolicyhistory" + _ "github.com/theopenlane/core/cmd/cli/cmd/narrativehistory" _ "github.com/theopenlane/core/cmd/cli/cmd/oauthproviderhistory" _ "github.com/theopenlane/core/cmd/cli/cmd/organizationhistory" _ "github.com/theopenlane/core/cmd/cli/cmd/organizationsettinghistory" diff --git a/db/migrations-goose-postgres/20241126232457_narratives.sql b/db/migrations-goose-postgres/20241126232457_narratives.sql new file mode 100644 index 00000000..20c41fd7 --- /dev/null +++ b/db/migrations-goose-postgres/20241126232457_narratives.sql @@ -0,0 +1,23 @@ +-- +goose Up +-- modify "narrative_history" table +ALTER TABLE "narrative_history" ADD COLUMN "owner_id" character varying NOT NULL; +-- modify "narratives" table +ALTER TABLE "narratives" ADD COLUMN "owner_id" character varying NOT NULL, ADD CONSTRAINT "narratives_organizations_narratives" FOREIGN KEY ("owner_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- create "narrative_blocked_groups" table +CREATE TABLE "narrative_blocked_groups" ("narrative_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("narrative_id", "group_id"), CONSTRAINT "narrative_blocked_groups_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "narrative_blocked_groups_narrative_id" FOREIGN KEY ("narrative_id") REFERENCES "narratives" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); +-- create "narrative_editors" table +CREATE TABLE "narrative_editors" ("narrative_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("narrative_id", "group_id"), CONSTRAINT "narrative_editors_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "narrative_editors_narrative_id" FOREIGN KEY ("narrative_id") REFERENCES "narratives" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); +-- create "narrative_viewers" table +CREATE TABLE "narrative_viewers" ("narrative_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("narrative_id", "group_id"), CONSTRAINT "narrative_viewers_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "narrative_viewers_narrative_id" FOREIGN KEY ("narrative_id") REFERENCES "narratives" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); + +-- +goose Down +-- reverse: create "narrative_viewers" table +DROP TABLE "narrative_viewers"; +-- reverse: create "narrative_editors" table +DROP TABLE "narrative_editors"; +-- reverse: create "narrative_blocked_groups" table +DROP TABLE "narrative_blocked_groups"; +-- reverse: modify "narratives" table +ALTER TABLE "narratives" DROP CONSTRAINT "narratives_organizations_narratives", DROP COLUMN "owner_id"; +-- reverse: modify "narrative_history" table +ALTER TABLE "narrative_history" DROP COLUMN "owner_id"; diff --git a/db/migrations-goose-postgres/atlas.sum b/db/migrations-goose-postgres/atlas.sum index d81a9a23..712dcac9 100644 --- a/db/migrations-goose-postgres/atlas.sum +++ b/db/migrations-goose-postgres/atlas.sum @@ -1,4 +1,4 @@ -h1:Kv4cfafrF3KiaMXj/G5497zbzimq4JN+17zJlF3+oX0= +h1:NYzr1NLzN6WBFAHW0DyJTi8FIavBJTc706b5YYSxYeQ= 20240827061503_init.sql h1:D0Ce7h0FSKpjtQOHZK5gXOpaPvlNAFHHzqfQQ8re0T4= 20241014185634_object_upload.sql h1:xeeCqYCpQ3RFWgNjnKV1GMHgTEoZK2aWv5a2EvU4DP8= 20241030173034_base.sql h1:+eJ3JGD5lzsP16mz7q+yD78Jvs7sTX8nBZQmS68hjoA= @@ -9,3 +9,4 @@ h1:Kv4cfafrF3KiaMXj/G5497zbzimq4JN+17zJlF3+oX0= 20241121200815_policy_procedure_program_edges.sql h1:/7c7pj5XlsNPOKE7CK2n6EFbW8KdSbxmua05V9IWAWg= 20241125224128_risks.sql h1:Zu3O/C4g+GA3hvq7VXsEFf+AfybQdWygAU98fUd/wLM= 20241126203309_control_objectives.sql h1:wo56TBIY22BZwoGMetReVarOQKyEyiOCeLJolOJew38= +20241126232457_narratives.sql h1:i7t3h2BYDIR11xWdu4BfKbcZjO2OWx0ZG5glve4WBv8= diff --git a/db/migrations/20241126232456_narratives.sql b/db/migrations/20241126232456_narratives.sql new file mode 100644 index 00000000..ad6b6a30 --- /dev/null +++ b/db/migrations/20241126232456_narratives.sql @@ -0,0 +1,10 @@ +-- Modify "narrative_history" table +ALTER TABLE "narrative_history" ADD COLUMN "owner_id" character varying NOT NULL; +-- Modify "narratives" table +ALTER TABLE "narratives" ADD COLUMN "owner_id" character varying NOT NULL, ADD CONSTRAINT "narratives_organizations_narratives" FOREIGN KEY ("owner_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Create "narrative_blocked_groups" table +CREATE TABLE "narrative_blocked_groups" ("narrative_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("narrative_id", "group_id"), CONSTRAINT "narrative_blocked_groups_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "narrative_blocked_groups_narrative_id" FOREIGN KEY ("narrative_id") REFERENCES "narratives" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); +-- Create "narrative_editors" table +CREATE TABLE "narrative_editors" ("narrative_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("narrative_id", "group_id"), CONSTRAINT "narrative_editors_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "narrative_editors_narrative_id" FOREIGN KEY ("narrative_id") REFERENCES "narratives" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); +-- Create "narrative_viewers" table +CREATE TABLE "narrative_viewers" ("narrative_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("narrative_id", "group_id"), CONSTRAINT "narrative_viewers_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "narrative_viewers_narrative_id" FOREIGN KEY ("narrative_id") REFERENCES "narratives" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); diff --git a/db/migrations/atlas.sum b/db/migrations/atlas.sum index ac4d62e4..e1bee102 100644 --- a/db/migrations/atlas.sum +++ b/db/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:0huuGW7N64WUhLrY2A3WasuT6fmhrcNwh34rzNYr5R4= +h1:VWu5haUzuojjmboCX9JLM/o8JCLUzv8+o9vjxB7OMNk= 20240827061437_init.sql h1:9pQTZIsiDF3hW0HraVTzaU3M25iiy3MdxvhsZosxgvo= 20241014185633_object_upload.sql h1:0lzY0vj0gav3gMHGc8gm793zPeSQSMMHjt4c2V+7Eok= 20241108062010_compliance.sql h1:vmJyf1VhoKSRw9zRQKXsRtWJEEUYDbqZmpkyp89O/Tc= @@ -8,3 +8,4 @@ h1:0huuGW7N64WUhLrY2A3WasuT6fmhrcNwh34rzNYr5R4= 20241121200811_policy_procedure_program_edges.sql h1:K5HuAgBqYM2CMYpb8Gc9rgQrOxdLeD8BwXtRkti9Ud0= 20241125224127_risks.sql h1:zqgRud+GNfsz9niYb3u1VSzhpeMW+ghGzJXwhVytuXk= 20241126203308_control_objectives.sql h1:e2DUn9RTWOR8fJl3PGdQ/YgzLfj585nNTeTiuvkAh+A= +20241126232456_narratives.sql h1:DhXbazPI/iSE0tDUGMoS/WHKXtQfO04v9b6qQPZ4aoQ= diff --git a/fga/model/model.fga b/fga/model/model.fga index 4a32b0ee..5e3684a2 100644 --- a/fga/model/model.fga +++ b/fga/model/model.fga @@ -66,7 +66,7 @@ type file define can_view: [user] or can_delete or can_edit or can_view from parent define can_edit: [user] or can_delete or can_edit from parent define can_delete: [user] or can_delete from parent - define parent: [user, program, organization, control, procedure, group, template, documentdata, contact, internalpolicy] + define parent: [user, program, organization, control, procedure, group, template, documentdata, contact, internalpolicy, narrative] # programs are associated with an organization but do not inherit access from the organization with # the exception of the owner of the organization who will have access to all programs # the program creator will be made the admin of the program and all other access with be assigned directly @@ -138,6 +138,15 @@ type risk define viewer: [group#member] define editor: [group#member] define blocked: [user, group#member] +type narrative + relations + define can_view: [user] or ((can_view from parent or viewer) but not blocked) + define can_edit: [user] or ((can_edit from parent or editor) but not blocked) + define can_delete: [user] or ((can_delete from parent or editor) but not blocked) + define parent: [user, service, program] + define viewer: [group#member] + define editor: [group#member] + define blocked: [user, group#member] # policies are always assigned to an organization and by default all org members can view # groups can be used to exclude users from being able to view a internal policy # groups can be used to give edit (or delete) access to users diff --git a/internal/ent/generated/auditing.go b/internal/ent/generated/auditing.go index 01463711..c7eca3e4 100644 --- a/internal/ent/generated/auditing.go +++ b/internal/ent/generated/auditing.go @@ -1455,6 +1455,9 @@ func (nh *NarrativeHistory) changes(new *NarrativeHistory) []Change { if !reflect.DeepEqual(nh.Tags, new.Tags) { changes = append(changes, NewChange(narrativehistory.FieldTags, nh.Tags, new.Tags)) } + if !reflect.DeepEqual(nh.OwnerID, new.OwnerID) { + changes = append(changes, NewChange(narrativehistory.FieldOwnerID, nh.OwnerID, new.OwnerID)) + } if !reflect.DeepEqual(nh.Name, new.Name) { changes = append(changes, NewChange(narrativehistory.FieldName, nh.Name, new.Name)) } diff --git a/internal/ent/generated/authz_checks.go b/internal/ent/generated/authz_checks.go index ca1335d7..b3d4eb75 100644 --- a/internal/ent/generated/authz_checks.go +++ b/internal/ent/generated/authz_checks.go @@ -15,6 +15,7 @@ import ( "github.com/theopenlane/core/internal/ent/generated/groupmembership" "github.com/theopenlane/core/internal/ent/generated/groupsetting" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" + "github.com/theopenlane/core/internal/ent/generated/narrative" "github.com/theopenlane/core/internal/ent/generated/organization" "github.com/theopenlane/core/internal/ent/generated/organizationsetting" "github.com/theopenlane/core/internal/ent/generated/orgmembership" @@ -3809,6 +3810,234 @@ func (m *InviteMutation) CheckAccessForDelete(ctx context.Context) error { return ErrPermissionDenied } +func (q *NarrativeQuery) CheckAccess(ctx context.Context) error { + gCtx := graphql.GetFieldContext(ctx) + + if gCtx != nil { + ac := fgax.AccessCheck{ + Relation: fgax.CanView, + ObjectType: "narrative", + SubjectType: auth.GetAuthzSubjectType(ctx), + } + + // check id from graphql arg context + // when all objects are requested, the interceptor will check object access + // check the where input first + whereArg := gCtx.Args["where"] + if whereArg != nil { + where, ok := whereArg.(*NarrativeWhereInput) + if ok && where != nil && where.ID != nil { + ac.ObjectID = *where.ID + } + } + + // if that doesn't work, check for the id in the args + if ac.ObjectID == "" { + ac.ObjectID, _ = gCtx.Args["id"].(string) + } + + // if we still don't have an object id, run the query and grab the object ID + // from the result + // this happens on join tables where we have the join ID (for updates and deletes) + // and not the actual object id + if ac.ObjectID == "" && "id" != "id" { + // allow this query to run + reqCtx := privacy.DecisionContext(ctx, privacy.Allow) + ob, err := q.Clone().Only(reqCtx) + if err != nil { + return privacy.Allowf("nil request, bypassing auth check") + } + ac.ObjectID = ob.ID + } + + // request is for a list objects, will get filtered in interceptors + if ac.ObjectID == "" { + return privacy.Allowf("nil request, bypassing auth check") + } + + var err error + ac.SubjectID, err = auth.GetUserIDFromContext(ctx) + if err != nil { + return err + } + + access, err := q.Authz.CheckAccess(ctx, ac) + if err != nil { + return privacy.Skipf("unable to check access, %s", err.Error()) + } + + if access { + return privacy.Allow + } + } + + // Skip to the next privacy rule (equivalent to return nil) + return privacy.Skip +} +func (m *NarrativeMutation) CheckAccessForEdit(ctx context.Context) error { + ac := fgax.AccessCheck{ + Relation: fgax.CanEdit, + ObjectType: "narrative", + SubjectType: auth.GetAuthzSubjectType(ctx), + } + + gCtx := graphql.GetFieldContext(ctx) + + // check the id from the args + if ac.ObjectID == "" { + ac.ObjectID, _ = gCtx.Args["id"].(string) + } + + // if this is still empty, we need to query the object to get the object id + // this happens on join tables where we have the join ID (for updates and deletes) + if ac.ObjectID == "" && "id" != "id" { + id, ok := gCtx.Args["id"].(string) + if ok { + // allow this query to run + reqCtx := privacy.DecisionContext(ctx, privacy.Allow) + ob, err := m.Client().Narrative.Query().Where(narrative.ID(id)).Only(reqCtx) + if err != nil { + return privacy.Skipf("nil request, skipping auth check") + } + ac.ObjectID = ob.ID + } + } + + // request is for a list objects, will get filtered in interceptors + if ac.ObjectID == "" { + return privacy.Allowf("nil request, bypassing auth check") + } + + log.Debug().Msg("checking mutation access") + + var err error + ac.SubjectID, err = auth.GetUserIDFromContext(ctx) + if err != nil { + return err + } + + log.Info().Str("relation", ac.Relation).Str("object_id", ac.ObjectID).Msg("checking relationship tuples") + + access, err := m.Authz.CheckAccess(ctx, ac) + if err != nil { + return privacy.Skipf("unable to check access, %s", err.Error()) + } + + if access { + log.Debug().Str("relation", ac.Relation).Str("object_id", ac.ObjectID).Msg("access allowed") + + return privacy.Allow + } + + // return error if the action is not allowed + return ErrPermissionDenied +} + +func (m *NarrativeMutation) CheckAccessForDelete(ctx context.Context) error { + ac := fgax.AccessCheck{ + Relation: fgax.CanDelete, + ObjectType: "narrative", + SubjectType: auth.GetAuthzSubjectType(ctx), + } + + gCtx := graphql.GetFieldContext(ctx) + + var ok bool + ac.ObjectID, ok = gCtx.Args["id"].(string) + if !ok { + return privacy.Allowf("nil request, bypassing auth check") + } + + log.Debug().Msg("checking mutation access") + + var err error + ac.SubjectID, err = auth.GetUserIDFromContext(ctx) + if err != nil { + return err + } + + log.Info().Str("relation", ac.Relation).Str("object_id", ac.ObjectID).Msg("checking relationship tuples") + + access, err := m.Authz.CheckAccess(ctx, ac) + if err != nil { + return privacy.Skipf("unable to check access, %s", err.Error()) + } + + if access { + log.Debug().Str("relation", ac.Relation).Str("object_id", ac.ObjectID).Msg("access allowed") + + return privacy.Allow + } + + // return error if the action is not allowed + return ErrPermissionDenied +} + +func (q *NarrativeHistoryQuery) CheckAccess(ctx context.Context) error { + gCtx := graphql.GetFieldContext(ctx) + + if gCtx != nil { + ac := fgax.AccessCheck{ + Relation: fgax.CanView, + ObjectType: "narrative", + SubjectType: auth.GetAuthzSubjectType(ctx), + } + + // check id from graphql arg context + // when all objects are requested, the interceptor will check object access + // check the where input first + whereArg := gCtx.Args["where"] + if whereArg != nil { + where, ok := whereArg.(*NarrativeHistoryWhereInput) + if ok && where != nil && where.Ref != nil { + ac.ObjectID = *where.Ref + } + } + + // if that doesn't work, check for the id in the args + if ac.ObjectID == "" { + ac.ObjectID, _ = gCtx.Args["ref"].(string) + } + + // if we still don't have an object id, run the query and grab the object ID + // from the result + // this happens on join tables where we have the join ID (for updates and deletes) + // and not the actual object id + if ac.ObjectID == "" && "id" != "ref" { + // allow this query to run + reqCtx := privacy.DecisionContext(ctx, privacy.Allow) + ob, err := q.Clone().Only(reqCtx) + if err != nil { + return privacy.Allowf("nil request, bypassing auth check") + } + ac.ObjectID = ob.Ref + } + + // request is for a list objects, will get filtered in interceptors + if ac.ObjectID == "" { + return privacy.Allowf("nil request, bypassing auth check") + } + + var err error + ac.SubjectID, err = auth.GetUserIDFromContext(ctx) + if err != nil { + return err + } + + access, err := q.Authz.CheckAccess(ctx, ac) + if err != nil { + return privacy.Skipf("unable to check access, %s", err.Error()) + } + + if access { + return privacy.Allow + } + } + + // Skip to the next privacy rule (equivalent to return nil) + return privacy.Skip +} + func (q *NoteQuery) CheckAccess(ctx context.Context) error { gCtx := graphql.GetFieldContext(ctx) diff --git a/internal/ent/generated/client.go b/internal/ent/generated/client.go index 7e9baffc..beccf626 100644 --- a/internal/ent/generated/client.go +++ b/internal/ent/generated/client.go @@ -7002,6 +7002,63 @@ func (c *GroupClient) QueryControlobjectiveBlockedGroups(gr *Group) *ControlObje return query } +// QueryNarrativeViewers queries the narrative_viewers edge of a Group. +func (c *GroupClient) QueryNarrativeViewers(gr *Group) *NarrativeQuery { + query := (&NarrativeClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := gr.ID + step := sqlgraph.NewStep( + sqlgraph.From(group.Table, group.FieldID, id), + sqlgraph.To(narrative.Table, narrative.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, group.NarrativeViewersTable, group.NarrativeViewersPrimaryKey...), + ) + schemaConfig := gr.schemaConfig + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeViewers + fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryNarrativeEditors queries the narrative_editors edge of a Group. +func (c *GroupClient) QueryNarrativeEditors(gr *Group) *NarrativeQuery { + query := (&NarrativeClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := gr.ID + step := sqlgraph.NewStep( + sqlgraph.From(group.Table, group.FieldID, id), + sqlgraph.To(narrative.Table, narrative.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, group.NarrativeEditorsTable, group.NarrativeEditorsPrimaryKey...), + ) + schemaConfig := gr.schemaConfig + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeEditors + fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryNarrativeBlockedGroups queries the narrative_blocked_groups edge of a Group. +func (c *GroupClient) QueryNarrativeBlockedGroups(gr *Group) *NarrativeQuery { + query := (&NarrativeClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := gr.ID + step := sqlgraph.NewStep( + sqlgraph.From(group.Table, group.FieldID, id), + sqlgraph.To(narrative.Table, narrative.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, group.NarrativeBlockedGroupsTable, group.NarrativeBlockedGroupsPrimaryKey...), + ) + schemaConfig := gr.schemaConfig + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeBlockedGroups + fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryMembers queries the members edge of a Group. func (c *GroupClient) QueryMembers(gr *Group) *GroupMembershipQuery { query := (&GroupMembershipClient{config: c.config}).Query() @@ -9211,6 +9268,82 @@ func (c *NarrativeClient) GetX(ctx context.Context, id string) *Narrative { return obj } +// QueryOwner queries the owner edge of a Narrative. +func (c *NarrativeClient) QueryOwner(n *Narrative) *OrganizationQuery { + query := (&OrganizationClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := n.ID + step := sqlgraph.NewStep( + sqlgraph.From(narrative.Table, narrative.FieldID, id), + sqlgraph.To(organization.Table, organization.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, narrative.OwnerTable, narrative.OwnerColumn), + ) + schemaConfig := n.schemaConfig + step.To.Schema = schemaConfig.Organization + step.Edge.Schema = schemaConfig.Narrative + fromV = sqlgraph.Neighbors(n.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryBlockedGroups queries the blocked_groups edge of a Narrative. +func (c *NarrativeClient) QueryBlockedGroups(n *Narrative) *GroupQuery { + query := (&GroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := n.ID + step := sqlgraph.NewStep( + sqlgraph.From(narrative.Table, narrative.FieldID, id), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, narrative.BlockedGroupsTable, narrative.BlockedGroupsPrimaryKey...), + ) + schemaConfig := n.schemaConfig + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeBlockedGroups + fromV = sqlgraph.Neighbors(n.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryEditors queries the editors edge of a Narrative. +func (c *NarrativeClient) QueryEditors(n *Narrative) *GroupQuery { + query := (&GroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := n.ID + step := sqlgraph.NewStep( + sqlgraph.From(narrative.Table, narrative.FieldID, id), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, narrative.EditorsTable, narrative.EditorsPrimaryKey...), + ) + schemaConfig := n.schemaConfig + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeEditors + fromV = sqlgraph.Neighbors(n.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryViewers queries the viewers edge of a Narrative. +func (c *NarrativeClient) QueryViewers(n *Narrative) *GroupQuery { + query := (&GroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := n.ID + step := sqlgraph.NewStep( + sqlgraph.From(narrative.Table, narrative.FieldID, id), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, narrative.ViewersTable, narrative.ViewersPrimaryKey...), + ) + schemaConfig := n.schemaConfig + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeViewers + fromV = sqlgraph.Neighbors(n.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryPolicy queries the policy edge of a Narrative. func (c *NarrativeClient) QueryPolicy(n *Narrative) *InternalPolicyQuery { query := (&InternalPolicyClient{config: c.config}).Query() @@ -9287,15 +9420,15 @@ func (c *NarrativeClient) QueryControlobjective(n *Narrative) *ControlObjectiveQ return query } -// QueryProgram queries the program edge of a Narrative. -func (c *NarrativeClient) QueryProgram(n *Narrative) *ProgramQuery { +// QueryPrograms queries the programs edge of a Narrative. +func (c *NarrativeClient) QueryPrograms(n *Narrative) *ProgramQuery { query := (&ProgramClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := n.ID step := sqlgraph.NewStep( sqlgraph.From(narrative.Table, narrative.FieldID, id), sqlgraph.To(program.Table, program.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, narrative.ProgramTable, narrative.ProgramPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, narrative.ProgramsTable, narrative.ProgramsPrimaryKey...), ) schemaConfig := n.schemaConfig step.To.Schema = schemaConfig.Program @@ -9443,12 +9576,14 @@ func (c *NarrativeHistoryClient) GetX(ctx context.Context, id string) *Narrative // Hooks returns the client hooks. func (c *NarrativeHistoryClient) Hooks() []Hook { - return c.hooks.NarrativeHistory + hooks := c.hooks.NarrativeHistory + return append(hooks[:len(hooks):len(hooks)], narrativehistory.Hooks[:]...) } // Interceptors returns the client interceptors. func (c *NarrativeHistoryClient) Interceptors() []Interceptor { - return c.inters.NarrativeHistory + inters := c.inters.NarrativeHistory + return append(inters[:len(inters):len(inters)], narrativehistory.Interceptors[:]...) } func (c *NarrativeHistoryClient) mutate(ctx context.Context, m *NarrativeHistoryMutation) (Value, error) { @@ -11315,6 +11450,25 @@ func (c *OrganizationClient) QueryControlobjectives(o *Organization) *ControlObj return query } +// QueryNarratives queries the narratives edge of a Organization. +func (c *OrganizationClient) QueryNarratives(o *Organization) *NarrativeQuery { + query := (&NarrativeClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := o.ID + step := sqlgraph.NewStep( + sqlgraph.From(organization.Table, organization.FieldID, id), + sqlgraph.To(narrative.Table, narrative.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, organization.NarrativesTable, organization.NarrativesColumn), + ) + schemaConfig := o.schemaConfig + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.Narrative + fromV = sqlgraph.Neighbors(o.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryMembers queries the members edge of a Organization. func (c *OrganizationClient) QueryMembers(o *Organization) *OrgMembershipQuery { query := (&OrgMembershipClient{config: c.config}).Query() diff --git a/internal/ent/generated/edge_cleanup.go b/internal/ent/generated/edge_cleanup.go index 782634e1..880db4a5 100644 --- a/internal/ent/generated/edge_cleanup.go +++ b/internal/ent/generated/edge_cleanup.go @@ -22,6 +22,7 @@ import ( "github.com/theopenlane/core/internal/ent/generated/integration" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" "github.com/theopenlane/core/internal/ent/generated/invite" + "github.com/theopenlane/core/internal/ent/generated/narrative" "github.com/theopenlane/core/internal/ent/generated/note" "github.com/theopenlane/core/internal/ent/generated/organization" "github.com/theopenlane/core/internal/ent/generated/organizationsetting" @@ -564,6 +565,13 @@ func OrganizationEdgeCleanup(ctx context.Context, id string) error { } } + if exists, err := FromContext(ctx).Narrative.Query().Where((narrative.HasOwnerWith(organization.ID(id)))).Exist(ctx); err == nil && exists { + if narrativeCount, err := FromContext(ctx).Narrative.Delete().Where(narrative.HasOwnerWith(organization.ID(id))).Exec(ctx); err != nil { + log.Debug().Err(err).Int("count", narrativeCount).Msg("deleting narrative") + return err + } + } + if exists, err := FromContext(ctx).OrgMembership.Query().Where((orgmembership.HasOrganizationWith(organization.ID(id)))).Exist(ctx); err == nil && exists { if orgmembershipCount, err := FromContext(ctx).OrgMembership.Delete().Where(orgmembership.HasOrganizationWith(organization.ID(id))).Exec(ctx); err != nil { log.Debug().Err(err).Int("count", orgmembershipCount).Msg("deleting orgmembership") diff --git a/internal/ent/generated/entql.go b/internal/ent/generated/entql.go index fdf690c8..7f949fa4 100644 --- a/internal/ent/generated/entql.go +++ b/internal/ent/generated/entql.go @@ -1309,6 +1309,7 @@ var schemaGraph = func() *sqlgraph.Schema { narrative.FieldDeletedBy: {Type: field.TypeString, Column: narrative.FieldDeletedBy}, narrative.FieldMappingID: {Type: field.TypeString, Column: narrative.FieldMappingID}, narrative.FieldTags: {Type: field.TypeJSON, Column: narrative.FieldTags}, + narrative.FieldOwnerID: {Type: field.TypeString, Column: narrative.FieldOwnerID}, narrative.FieldName: {Type: field.TypeString, Column: narrative.FieldName}, narrative.FieldDescription: {Type: field.TypeString, Column: narrative.FieldDescription}, narrative.FieldSatisfies: {Type: field.TypeString, Column: narrative.FieldSatisfies}, @@ -1337,6 +1338,7 @@ var schemaGraph = func() *sqlgraph.Schema { narrativehistory.FieldDeletedBy: {Type: field.TypeString, Column: narrativehistory.FieldDeletedBy}, narrativehistory.FieldMappingID: {Type: field.TypeString, Column: narrativehistory.FieldMappingID}, narrativehistory.FieldTags: {Type: field.TypeJSON, Column: narrativehistory.FieldTags}, + narrativehistory.FieldOwnerID: {Type: field.TypeString, Column: narrativehistory.FieldOwnerID}, narrativehistory.FieldName: {Type: field.TypeString, Column: narrativehistory.FieldName}, narrativehistory.FieldDescription: {Type: field.TypeString, Column: narrativehistory.FieldDescription}, narrativehistory.FieldSatisfies: {Type: field.TypeString, Column: narrativehistory.FieldSatisfies}, @@ -3805,6 +3807,42 @@ var schemaGraph = func() *sqlgraph.Schema { "Group", "ControlObjective", ) + graph.MustAddE( + "narrative_viewers", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeViewersTable, + Columns: group.NarrativeViewersPrimaryKey, + Bidi: false, + }, + "Group", + "Narrative", + ) + graph.MustAddE( + "narrative_editors", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeEditorsTable, + Columns: group.NarrativeEditorsPrimaryKey, + Bidi: false, + }, + "Group", + "Narrative", + ) + graph.MustAddE( + "narrative_blocked_groups", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeBlockedGroupsTable, + Columns: group.NarrativeBlockedGroupsPrimaryKey, + Bidi: false, + }, + "Group", + "Narrative", + ) graph.MustAddE( "members", &sqlgraph.EdgeSpec{ @@ -4093,6 +4131,54 @@ var schemaGraph = func() *sqlgraph.Schema { "Invite", "Event", ) + graph.MustAddE( + "owner", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: narrative.OwnerTable, + Columns: []string{narrative.OwnerColumn}, + Bidi: false, + }, + "Narrative", + "Organization", + ) + graph.MustAddE( + "blocked_groups", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.BlockedGroupsTable, + Columns: narrative.BlockedGroupsPrimaryKey, + Bidi: false, + }, + "Narrative", + "Group", + ) + graph.MustAddE( + "editors", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.EditorsTable, + Columns: narrative.EditorsPrimaryKey, + Bidi: false, + }, + "Narrative", + "Group", + ) + graph.MustAddE( + "viewers", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.ViewersTable, + Columns: narrative.ViewersPrimaryKey, + Bidi: false, + }, + "Narrative", + "Group", + ) graph.MustAddE( "policy", &sqlgraph.EdgeSpec{ @@ -4142,12 +4228,12 @@ var schemaGraph = func() *sqlgraph.Schema { "ControlObjective", ) graph.MustAddE( - "program", + "programs", &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: narrative.ProgramTable, - Columns: narrative.ProgramPrimaryKey, + Table: narrative.ProgramsTable, + Columns: narrative.ProgramsPrimaryKey, Bidi: false, }, "Narrative", @@ -4657,6 +4743,18 @@ var schemaGraph = func() *sqlgraph.Schema { "Organization", "ControlObjective", ) + graph.MustAddE( + "narratives", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: organization.NarrativesTable, + Columns: []string{organization.NarrativesColumn}, + Bidi: false, + }, + "Organization", + "Narrative", + ) graph.MustAddE( "members", &sqlgraph.EdgeSpec{ @@ -10934,6 +11032,48 @@ func (f *GroupFilter) WhereHasControlobjectiveBlockedGroupsWith(preds ...predica }))) } +// WhereHasNarrativeViewers applies a predicate to check if query has an edge narrative_viewers. +func (f *GroupFilter) WhereHasNarrativeViewers() { + f.Where(entql.HasEdge("narrative_viewers")) +} + +// WhereHasNarrativeViewersWith applies a predicate to check if query has an edge narrative_viewers with a given conditions (other predicates). +func (f *GroupFilter) WhereHasNarrativeViewersWith(preds ...predicate.Narrative) { + f.Where(entql.HasEdgeWith("narrative_viewers", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + +// WhereHasNarrativeEditors applies a predicate to check if query has an edge narrative_editors. +func (f *GroupFilter) WhereHasNarrativeEditors() { + f.Where(entql.HasEdge("narrative_editors")) +} + +// WhereHasNarrativeEditorsWith applies a predicate to check if query has an edge narrative_editors with a given conditions (other predicates). +func (f *GroupFilter) WhereHasNarrativeEditorsWith(preds ...predicate.Narrative) { + f.Where(entql.HasEdgeWith("narrative_editors", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + +// WhereHasNarrativeBlockedGroups applies a predicate to check if query has an edge narrative_blocked_groups. +func (f *GroupFilter) WhereHasNarrativeBlockedGroups() { + f.Where(entql.HasEdge("narrative_blocked_groups")) +} + +// WhereHasNarrativeBlockedGroupsWith applies a predicate to check if query has an edge narrative_blocked_groups with a given conditions (other predicates). +func (f *GroupFilter) WhereHasNarrativeBlockedGroupsWith(preds ...predicate.Narrative) { + f.Where(entql.HasEdgeWith("narrative_blocked_groups", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + // WhereHasMembers applies a predicate to check if query has an edge members. func (f *GroupFilter) WhereHasMembers() { f.Where(entql.HasEdge("members")) @@ -12710,6 +12850,11 @@ func (f *NarrativeFilter) WhereTags(p entql.BytesP) { f.Where(p.Field(narrative.FieldTags)) } +// WhereOwnerID applies the entql string predicate on the owner_id field. +func (f *NarrativeFilter) WhereOwnerID(p entql.StringP) { + f.Where(p.Field(narrative.FieldOwnerID)) +} + // WhereName applies the entql string predicate on the name field. func (f *NarrativeFilter) WhereName(p entql.StringP) { f.Where(p.Field(narrative.FieldName)) @@ -12730,6 +12875,62 @@ func (f *NarrativeFilter) WhereDetails(p entql.BytesP) { f.Where(p.Field(narrative.FieldDetails)) } +// WhereHasOwner applies a predicate to check if query has an edge owner. +func (f *NarrativeFilter) WhereHasOwner() { + f.Where(entql.HasEdge("owner")) +} + +// WhereHasOwnerWith applies a predicate to check if query has an edge owner with a given conditions (other predicates). +func (f *NarrativeFilter) WhereHasOwnerWith(preds ...predicate.Organization) { + f.Where(entql.HasEdgeWith("owner", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + +// WhereHasBlockedGroups applies a predicate to check if query has an edge blocked_groups. +func (f *NarrativeFilter) WhereHasBlockedGroups() { + f.Where(entql.HasEdge("blocked_groups")) +} + +// WhereHasBlockedGroupsWith applies a predicate to check if query has an edge blocked_groups with a given conditions (other predicates). +func (f *NarrativeFilter) WhereHasBlockedGroupsWith(preds ...predicate.Group) { + f.Where(entql.HasEdgeWith("blocked_groups", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + +// WhereHasEditors applies a predicate to check if query has an edge editors. +func (f *NarrativeFilter) WhereHasEditors() { + f.Where(entql.HasEdge("editors")) +} + +// WhereHasEditorsWith applies a predicate to check if query has an edge editors with a given conditions (other predicates). +func (f *NarrativeFilter) WhereHasEditorsWith(preds ...predicate.Group) { + f.Where(entql.HasEdgeWith("editors", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + +// WhereHasViewers applies a predicate to check if query has an edge viewers. +func (f *NarrativeFilter) WhereHasViewers() { + f.Where(entql.HasEdge("viewers")) +} + +// WhereHasViewersWith applies a predicate to check if query has an edge viewers with a given conditions (other predicates). +func (f *NarrativeFilter) WhereHasViewersWith(preds ...predicate.Group) { + f.Where(entql.HasEdgeWith("viewers", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + // WhereHasPolicy applies a predicate to check if query has an edge policy. func (f *NarrativeFilter) WhereHasPolicy() { f.Where(entql.HasEdge("policy")) @@ -12786,14 +12987,14 @@ func (f *NarrativeFilter) WhereHasControlobjectiveWith(preds ...predicate.Contro }))) } -// WhereHasProgram applies a predicate to check if query has an edge program. -func (f *NarrativeFilter) WhereHasProgram() { - f.Where(entql.HasEdge("program")) +// WhereHasPrograms applies a predicate to check if query has an edge programs. +func (f *NarrativeFilter) WhereHasPrograms() { + f.Where(entql.HasEdge("programs")) } -// WhereHasProgramWith applies a predicate to check if query has an edge program with a given conditions (other predicates). -func (f *NarrativeFilter) WhereHasProgramWith(preds ...predicate.Program) { - f.Where(entql.HasEdgeWith("program", sqlgraph.WrapFunc(func(s *sql.Selector) { +// WhereHasProgramsWith applies a predicate to check if query has an edge programs with a given conditions (other predicates). +func (f *NarrativeFilter) WhereHasProgramsWith(preds ...predicate.Program) { + f.Where(entql.HasEdgeWith("programs", sqlgraph.WrapFunc(func(s *sql.Selector) { for _, p := range preds { p(s) } @@ -12895,6 +13096,11 @@ func (f *NarrativeHistoryFilter) WhereTags(p entql.BytesP) { f.Where(p.Field(narrativehistory.FieldTags)) } +// WhereOwnerID applies the entql string predicate on the owner_id field. +func (f *NarrativeHistoryFilter) WhereOwnerID(p entql.StringP) { + f.Where(p.Field(narrativehistory.FieldOwnerID)) +} + // WhereName applies the entql string predicate on the name field. func (f *NarrativeHistoryFilter) WhereName(p entql.StringP) { f.Where(p.Field(narrativehistory.FieldName)) @@ -14393,6 +14599,20 @@ func (f *OrganizationFilter) WhereHasControlobjectivesWith(preds ...predicate.Co }))) } +// WhereHasNarratives applies a predicate to check if query has an edge narratives. +func (f *OrganizationFilter) WhereHasNarratives() { + f.Where(entql.HasEdge("narratives")) +} + +// WhereHasNarrativesWith applies a predicate to check if query has an edge narratives with a given conditions (other predicates). +func (f *OrganizationFilter) WhereHasNarrativesWith(preds ...predicate.Narrative) { + f.Where(entql.HasEdgeWith("narratives", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + // WhereHasMembers applies a predicate to check if query has an edge members. func (f *OrganizationFilter) WhereHasMembers() { f.Where(entql.HasEdge("members")) diff --git a/internal/ent/generated/gql_collection.go b/internal/ent/generated/gql_collection.go index 20e8c8ec..a7613ba1 100644 --- a/internal/ent/generated/gql_collection.go +++ b/internal/ent/generated/gql_collection.go @@ -5465,6 +5465,45 @@ func (gr *GroupQuery) collectField(ctx context.Context, oneNode bool, opCtx *gra *wq = *query }) + case "narrativeViewers": + var ( + alias = field.Alias + path = append(path, alias) + query = (&NarrativeClient{config: gr.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, narrativeImplementors)...); err != nil { + return err + } + gr.WithNamedNarrativeViewers(alias, func(wq *NarrativeQuery) { + *wq = *query + }) + + case "narrativeEditors": + var ( + alias = field.Alias + path = append(path, alias) + query = (&NarrativeClient{config: gr.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, narrativeImplementors)...); err != nil { + return err + } + gr.WithNamedNarrativeEditors(alias, func(wq *NarrativeQuery) { + *wq = *query + }) + + case "narrativeBlockedGroups": + var ( + alias = field.Alias + path = append(path, alias) + query = (&NarrativeClient{config: gr.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, narrativeImplementors)...); err != nil { + return err + } + gr.WithNamedNarrativeBlockedGroups(alias, func(wq *NarrativeQuery) { + *wq = *query + }) + case "members": var ( alias = field.Alias @@ -7592,6 +7631,60 @@ func (n *NarrativeQuery) collectField(ctx context.Context, oneNode bool, opCtx * for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "owner": + var ( + alias = field.Alias + path = append(path, alias) + query = (&OrganizationClient{config: n.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, organizationImplementors)...); err != nil { + return err + } + n.withOwner = query + if _, ok := fieldSeen[narrative.FieldOwnerID]; !ok { + selectedFields = append(selectedFields, narrative.FieldOwnerID) + fieldSeen[narrative.FieldOwnerID] = struct{}{} + } + + case "blockedGroups": + var ( + alias = field.Alias + path = append(path, alias) + query = (&GroupClient{config: n.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, groupImplementors)...); err != nil { + return err + } + n.WithNamedBlockedGroups(alias, func(wq *GroupQuery) { + *wq = *query + }) + + case "editors": + var ( + alias = field.Alias + path = append(path, alias) + query = (&GroupClient{config: n.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, groupImplementors)...); err != nil { + return err + } + n.WithNamedEditors(alias, func(wq *GroupQuery) { + *wq = *query + }) + + case "viewers": + var ( + alias = field.Alias + path = append(path, alias) + query = (&GroupClient{config: n.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, groupImplementors)...); err != nil { + return err + } + n.WithNamedViewers(alias, func(wq *GroupQuery) { + *wq = *query + }) + case "policy": var ( alias = field.Alias @@ -7644,7 +7737,7 @@ func (n *NarrativeQuery) collectField(ctx context.Context, oneNode bool, opCtx * *wq = *query }) - case "program": + case "programs": var ( alias = field.Alias path = append(path, alias) @@ -7653,7 +7746,7 @@ func (n *NarrativeQuery) collectField(ctx context.Context, oneNode bool, opCtx * if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, programImplementors)...); err != nil { return err } - n.WithNamedProgram(alias, func(wq *ProgramQuery) { + n.WithNamedPrograms(alias, func(wq *ProgramQuery) { *wq = *query }) case "createdAt": @@ -7691,6 +7784,11 @@ func (n *NarrativeQuery) collectField(ctx context.Context, oneNode bool, opCtx * selectedFields = append(selectedFields, narrative.FieldTags) fieldSeen[narrative.FieldTags] = struct{}{} } + case "ownerID": + if _, ok := fieldSeen[narrative.FieldOwnerID]; !ok { + selectedFields = append(selectedFields, narrative.FieldOwnerID) + fieldSeen[narrative.FieldOwnerID] = struct{}{} + } case "name": if _, ok := fieldSeen[narrative.FieldName]; !ok { selectedFields = append(selectedFields, narrative.FieldName) @@ -7823,6 +7921,11 @@ func (nh *NarrativeHistoryQuery) collectField(ctx context.Context, oneNode bool, selectedFields = append(selectedFields, narrativehistory.FieldTags) fieldSeen[narrativehistory.FieldTags] = struct{}{} } + case "ownerID": + if _, ok := fieldSeen[narrativehistory.FieldOwnerID]; !ok { + selectedFields = append(selectedFields, narrativehistory.FieldOwnerID) + fieldSeen[narrativehistory.FieldOwnerID] = struct{}{} + } case "name": if _, ok := fieldSeen[narrativehistory.FieldName]; !ok { selectedFields = append(selectedFields, narrativehistory.FieldName) @@ -9428,6 +9531,19 @@ func (o *OrganizationQuery) collectField(ctx context.Context, oneNode bool, opCt *wq = *query }) + case "narratives": + var ( + alias = field.Alias + path = append(path, alias) + query = (&NarrativeClient{config: o.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, narrativeImplementors)...); err != nil { + return err + } + o.WithNamedNarratives(alias, func(wq *NarrativeQuery) { + *wq = *query + }) + case "members": var ( alias = field.Alias diff --git a/internal/ent/generated/gql_edge.go b/internal/ent/generated/gql_edge.go index eb0d2662..4da0733c 100644 --- a/internal/ent/generated/gql_edge.go +++ b/internal/ent/generated/gql_edge.go @@ -1232,6 +1232,42 @@ func (gr *Group) ControlobjectiveBlockedGroups(ctx context.Context) (result []*C return result, err } +func (gr *Group) NarrativeViewers(ctx context.Context) (result []*Narrative, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = gr.NamedNarrativeViewers(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = gr.Edges.NarrativeViewersOrErr() + } + if IsNotLoaded(err) { + result, err = gr.QueryNarrativeViewers().All(ctx) + } + return result, err +} + +func (gr *Group) NarrativeEditors(ctx context.Context) (result []*Narrative, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = gr.NamedNarrativeEditors(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = gr.Edges.NarrativeEditorsOrErr() + } + if IsNotLoaded(err) { + result, err = gr.QueryNarrativeEditors().All(ctx) + } + return result, err +} + +func (gr *Group) NarrativeBlockedGroups(ctx context.Context) (result []*Narrative, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = gr.NamedNarrativeBlockedGroups(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = gr.Edges.NarrativeBlockedGroupsOrErr() + } + if IsNotLoaded(err) { + result, err = gr.QueryNarrativeBlockedGroups().All(ctx) + } + return result, err +} + func (gr *Group) Members(ctx context.Context) (result []*GroupMembership, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { result, err = gr.NamedMembers(graphql.GetFieldContext(ctx).Field.Alias) @@ -1496,6 +1532,50 @@ func (i *Invite) Events(ctx context.Context) (result []*Event, err error) { return result, err } +func (n *Narrative) Owner(ctx context.Context) (*Organization, error) { + result, err := n.Edges.OwnerOrErr() + if IsNotLoaded(err) { + result, err = n.QueryOwner().Only(ctx) + } + return result, err +} + +func (n *Narrative) BlockedGroups(ctx context.Context) (result []*Group, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = n.NamedBlockedGroups(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = n.Edges.BlockedGroupsOrErr() + } + if IsNotLoaded(err) { + result, err = n.QueryBlockedGroups().All(ctx) + } + return result, err +} + +func (n *Narrative) Editors(ctx context.Context) (result []*Group, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = n.NamedEditors(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = n.Edges.EditorsOrErr() + } + if IsNotLoaded(err) { + result, err = n.QueryEditors().All(ctx) + } + return result, err +} + +func (n *Narrative) Viewers(ctx context.Context) (result []*Group, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = n.NamedViewers(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = n.Edges.ViewersOrErr() + } + if IsNotLoaded(err) { + result, err = n.QueryViewers().All(ctx) + } + return result, err +} + func (n *Narrative) Policy(ctx context.Context) (result []*InternalPolicy, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { result, err = n.NamedPolicy(graphql.GetFieldContext(ctx).Field.Alias) @@ -1544,14 +1624,14 @@ func (n *Narrative) Controlobjective(ctx context.Context) (result []*ControlObje return result, err } -func (n *Narrative) Program(ctx context.Context) (result []*Program, err error) { +func (n *Narrative) Programs(ctx context.Context) (result []*Program, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = n.NamedProgram(graphql.GetFieldContext(ctx).Field.Alias) + result, err = n.NamedPrograms(graphql.GetFieldContext(ctx).Field.Alias) } else { - result, err = n.Edges.ProgramOrErr() + result, err = n.Edges.ProgramsOrErr() } if IsNotLoaded(err) { - result, err = n.QueryProgram().All(ctx) + result, err = n.QueryPrograms().All(ctx) } return result, err } @@ -2041,6 +2121,18 @@ func (o *Organization) Controlobjectives(ctx context.Context) (result []*Control return result, err } +func (o *Organization) Narratives(ctx context.Context) (result []*Narrative, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = o.NamedNarratives(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = o.Edges.NarrativesOrErr() + } + if IsNotLoaded(err) { + result, err = o.QueryNarratives().All(ctx) + } + return result, err +} + func (o *Organization) Members(ctx context.Context) (result []*OrgMembership, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { result, err = o.NamedMembers(graphql.GetFieldContext(ctx).Field.Alias) diff --git a/internal/ent/generated/gql_mutation_input.go b/internal/ent/generated/gql_mutation_input.go index b1699749..47d7d998 100644 --- a/internal/ent/generated/gql_mutation_input.go +++ b/internal/ent/generated/gql_mutation_input.go @@ -2903,6 +2903,9 @@ type CreateGroupInput struct { ControlobjectiveViewerIDs []string ControlobjectiveEditorIDs []string ControlobjectiveBlockedGroupIDs []string + NarrativeViewerIDs []string + NarrativeEditorIDs []string + NarrativeBlockedGroupIDs []string } // Mutate applies the CreateGroupInput on the GroupMutation builder. @@ -2981,6 +2984,15 @@ func (i *CreateGroupInput) Mutate(m *GroupMutation) { if v := i.ControlobjectiveBlockedGroupIDs; len(v) > 0 { m.AddControlobjectiveBlockedGroupIDs(v...) } + if v := i.NarrativeViewerIDs; len(v) > 0 { + m.AddNarrativeViewerIDs(v...) + } + if v := i.NarrativeEditorIDs; len(v) > 0 { + m.AddNarrativeEditorIDs(v...) + } + if v := i.NarrativeBlockedGroupIDs; len(v) > 0 { + m.AddNarrativeBlockedGroupIDs(v...) + } } // SetInput applies the change-set in the CreateGroupInput on the GroupCreate builder. @@ -3059,6 +3071,15 @@ type UpdateGroupInput struct { ClearControlobjectiveBlockedGroups bool AddControlobjectiveBlockedGroupIDs []string RemoveControlobjectiveBlockedGroupIDs []string + ClearNarrativeViewers bool + AddNarrativeViewerIDs []string + RemoveNarrativeViewerIDs []string + ClearNarrativeEditors bool + AddNarrativeEditorIDs []string + RemoveNarrativeEditorIDs []string + ClearNarrativeBlockedGroups bool + AddNarrativeBlockedGroupIDs []string + RemoveNarrativeBlockedGroupIDs []string } // Mutate applies the UpdateGroupInput on the GroupMutation builder. @@ -3267,6 +3288,33 @@ func (i *UpdateGroupInput) Mutate(m *GroupMutation) { if v := i.RemoveControlobjectiveBlockedGroupIDs; len(v) > 0 { m.RemoveControlobjectiveBlockedGroupIDs(v...) } + if i.ClearNarrativeViewers { + m.ClearNarrativeViewers() + } + if v := i.AddNarrativeViewerIDs; len(v) > 0 { + m.AddNarrativeViewerIDs(v...) + } + if v := i.RemoveNarrativeViewerIDs; len(v) > 0 { + m.RemoveNarrativeViewerIDs(v...) + } + if i.ClearNarrativeEditors { + m.ClearNarrativeEditors() + } + if v := i.AddNarrativeEditorIDs; len(v) > 0 { + m.AddNarrativeEditorIDs(v...) + } + if v := i.RemoveNarrativeEditorIDs; len(v) > 0 { + m.RemoveNarrativeEditorIDs(v...) + } + if i.ClearNarrativeBlockedGroups { + m.ClearNarrativeBlockedGroups() + } + if v := i.AddNarrativeBlockedGroupIDs; len(v) > 0 { + m.AddNarrativeBlockedGroupIDs(v...) + } + if v := i.RemoveNarrativeBlockedGroupIDs; len(v) > 0 { + m.RemoveNarrativeBlockedGroupIDs(v...) + } } // SetInput applies the change-set in the UpdateGroupInput on the GroupUpdate builder. @@ -4112,6 +4160,10 @@ type CreateNarrativeInput struct { Description *string Satisfies *string Details map[string]interface{} + OwnerID string + BlockedGroupIDs []string + EditorIDs []string + ViewerIDs []string PolicyIDs []string ControlIDs []string ProcedureIDs []string @@ -4134,6 +4186,16 @@ func (i *CreateNarrativeInput) Mutate(m *NarrativeMutation) { if v := i.Details; v != nil { m.SetDetails(v) } + m.SetOwnerID(i.OwnerID) + if v := i.BlockedGroupIDs; len(v) > 0 { + m.AddBlockedGroupIDs(v...) + } + if v := i.EditorIDs; len(v) > 0 { + m.AddEditorIDs(v...) + } + if v := i.ViewerIDs; len(v) > 0 { + m.AddViewerIDs(v...) + } if v := i.PolicyIDs; len(v) > 0 { m.AddPolicyIDs(v...) } @@ -4169,6 +4231,16 @@ type UpdateNarrativeInput struct { Satisfies *string ClearDetails bool Details map[string]interface{} + OwnerID *string + ClearBlockedGroups bool + AddBlockedGroupIDs []string + RemoveBlockedGroupIDs []string + ClearEditors bool + AddEditorIDs []string + RemoveEditorIDs []string + ClearViewers bool + AddViewerIDs []string + RemoveViewerIDs []string ClearPolicy bool AddPolicyIDs []string RemovePolicyIDs []string @@ -4181,7 +4253,7 @@ type UpdateNarrativeInput struct { ClearControlobjective bool AddControlobjectiveIDs []string RemoveControlobjectiveIDs []string - ClearProgram bool + ClearPrograms bool AddProgramIDs []string RemoveProgramIDs []string } @@ -4218,6 +4290,36 @@ func (i *UpdateNarrativeInput) Mutate(m *NarrativeMutation) { if v := i.Details; v != nil { m.SetDetails(v) } + if v := i.OwnerID; v != nil { + m.SetOwnerID(*v) + } + if i.ClearBlockedGroups { + m.ClearBlockedGroups() + } + if v := i.AddBlockedGroupIDs; len(v) > 0 { + m.AddBlockedGroupIDs(v...) + } + if v := i.RemoveBlockedGroupIDs; len(v) > 0 { + m.RemoveBlockedGroupIDs(v...) + } + if i.ClearEditors { + m.ClearEditors() + } + if v := i.AddEditorIDs; len(v) > 0 { + m.AddEditorIDs(v...) + } + if v := i.RemoveEditorIDs; len(v) > 0 { + m.RemoveEditorIDs(v...) + } + if i.ClearViewers { + m.ClearViewers() + } + if v := i.AddViewerIDs; len(v) > 0 { + m.AddViewerIDs(v...) + } + if v := i.RemoveViewerIDs; len(v) > 0 { + m.RemoveViewerIDs(v...) + } if i.ClearPolicy { m.ClearPolicy() } @@ -4254,8 +4356,8 @@ func (i *UpdateNarrativeInput) Mutate(m *NarrativeMutation) { if v := i.RemoveControlobjectiveIDs; len(v) > 0 { m.RemoveControlobjectiveIDs(v...) } - if i.ClearProgram { - m.ClearProgram() + if i.ClearPrograms { + m.ClearPrograms() } if v := i.AddProgramIDs; len(v) > 0 { m.AddProgramIDs(v...) @@ -4792,6 +4894,7 @@ type CreateOrganizationInput struct { InternalpolicyIDs []string RiskIDs []string ControlobjectiveIDs []string + NarrativeIDs []string } // Mutate applies the CreateOrganizationInput on the OrganizationMutation builder. @@ -4905,6 +5008,9 @@ func (i *CreateOrganizationInput) Mutate(m *OrganizationMutation) { if v := i.ControlobjectiveIDs; len(v) > 0 { m.AddControlobjectiveIDs(v...) } + if v := i.NarrativeIDs; len(v) > 0 { + m.AddNarrativeIDs(v...) + } } // SetInput applies the change-set in the CreateOrganizationInput on the OrganizationCreate builder. @@ -5010,6 +5116,9 @@ type UpdateOrganizationInput struct { ClearControlobjectives bool AddControlobjectiveIDs []string RemoveControlobjectiveIDs []string + ClearNarratives bool + AddNarrativeIDs []string + RemoveNarrativeIDs []string } // Mutate applies the UpdateOrganizationInput on the OrganizationMutation builder. @@ -5299,6 +5408,15 @@ func (i *UpdateOrganizationInput) Mutate(m *OrganizationMutation) { if v := i.RemoveControlobjectiveIDs; len(v) > 0 { m.RemoveControlobjectiveIDs(v...) } + if i.ClearNarratives { + m.ClearNarratives() + } + if v := i.AddNarrativeIDs; len(v) > 0 { + m.AddNarrativeIDs(v...) + } + if v := i.RemoveNarrativeIDs; len(v) > 0 { + m.RemoveNarrativeIDs(v...) + } } // SetInput applies the change-set in the UpdateOrganizationInput on the OrganizationUpdate builder. diff --git a/internal/ent/generated/gql_where_input.go b/internal/ent/generated/gql_where_input.go index 19d07de9..b370e3cb 100644 --- a/internal/ent/generated/gql_where_input.go +++ b/internal/ent/generated/gql_where_input.go @@ -25834,6 +25834,18 @@ type GroupWhereInput struct { HasControlobjectiveBlockedGroups *bool `json:"hasControlobjectiveBlockedGroups,omitempty"` HasControlobjectiveBlockedGroupsWith []*ControlObjectiveWhereInput `json:"hasControlobjectiveBlockedGroupsWith,omitempty"` + // "narrative_viewers" edge predicates. + HasNarrativeViewers *bool `json:"hasNarrativeViewers,omitempty"` + HasNarrativeViewersWith []*NarrativeWhereInput `json:"hasNarrativeViewersWith,omitempty"` + + // "narrative_editors" edge predicates. + HasNarrativeEditors *bool `json:"hasNarrativeEditors,omitempty"` + HasNarrativeEditorsWith []*NarrativeWhereInput `json:"hasNarrativeEditorsWith,omitempty"` + + // "narrative_blocked_groups" edge predicates. + HasNarrativeBlockedGroups *bool `json:"hasNarrativeBlockedGroups,omitempty"` + HasNarrativeBlockedGroupsWith []*NarrativeWhereInput `json:"hasNarrativeBlockedGroupsWith,omitempty"` + // "members" edge predicates. HasMembers *bool `json:"hasMembers,omitempty"` HasMembersWith []*GroupMembershipWhereInput `json:"hasMembersWith,omitempty"` @@ -26649,6 +26661,60 @@ func (i *GroupWhereInput) P() (predicate.Group, error) { } predicates = append(predicates, group.HasControlobjectiveBlockedGroupsWith(with...)) } + if i.HasNarrativeViewers != nil { + p := group.HasNarrativeViewers() + if !*i.HasNarrativeViewers { + p = group.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasNarrativeViewersWith) > 0 { + with := make([]predicate.Narrative, 0, len(i.HasNarrativeViewersWith)) + for _, w := range i.HasNarrativeViewersWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasNarrativeViewersWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, group.HasNarrativeViewersWith(with...)) + } + if i.HasNarrativeEditors != nil { + p := group.HasNarrativeEditors() + if !*i.HasNarrativeEditors { + p = group.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasNarrativeEditorsWith) > 0 { + with := make([]predicate.Narrative, 0, len(i.HasNarrativeEditorsWith)) + for _, w := range i.HasNarrativeEditorsWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasNarrativeEditorsWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, group.HasNarrativeEditorsWith(with...)) + } + if i.HasNarrativeBlockedGroups != nil { + p := group.HasNarrativeBlockedGroups() + if !*i.HasNarrativeBlockedGroups { + p = group.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasNarrativeBlockedGroupsWith) > 0 { + with := make([]predicate.Narrative, 0, len(i.HasNarrativeBlockedGroupsWith)) + for _, w := range i.HasNarrativeBlockedGroupsWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasNarrativeBlockedGroupsWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, group.HasNarrativeBlockedGroupsWith(with...)) + } if i.HasMembers != nil { p := group.HasMembers() if !*i.HasMembers { @@ -35969,6 +36035,21 @@ type NarrativeWhereInput struct { DeletedByEqualFold *string `json:"deletedByEqualFold,omitempty"` DeletedByContainsFold *string `json:"deletedByContainsFold,omitempty"` + // "owner_id" field predicates. + OwnerID *string `json:"ownerID,omitempty"` + OwnerIDNEQ *string `json:"ownerIDNEQ,omitempty"` + OwnerIDIn []string `json:"ownerIDIn,omitempty"` + OwnerIDNotIn []string `json:"ownerIDNotIn,omitempty"` + OwnerIDGT *string `json:"ownerIDGT,omitempty"` + OwnerIDGTE *string `json:"ownerIDGTE,omitempty"` + OwnerIDLT *string `json:"ownerIDLT,omitempty"` + OwnerIDLTE *string `json:"ownerIDLTE,omitempty"` + OwnerIDContains *string `json:"ownerIDContains,omitempty"` + OwnerIDHasPrefix *string `json:"ownerIDHasPrefix,omitempty"` + OwnerIDHasSuffix *string `json:"ownerIDHasSuffix,omitempty"` + OwnerIDEqualFold *string `json:"ownerIDEqualFold,omitempty"` + OwnerIDContainsFold *string `json:"ownerIDContainsFold,omitempty"` + // "name" field predicates. Name *string `json:"name,omitempty"` NameNEQ *string `json:"nameNEQ,omitempty"` @@ -36018,6 +36099,22 @@ type NarrativeWhereInput struct { SatisfiesEqualFold *string `json:"satisfiesEqualFold,omitempty"` SatisfiesContainsFold *string `json:"satisfiesContainsFold,omitempty"` + // "owner" edge predicates. + HasOwner *bool `json:"hasOwner,omitempty"` + HasOwnerWith []*OrganizationWhereInput `json:"hasOwnerWith,omitempty"` + + // "blocked_groups" edge predicates. + HasBlockedGroups *bool `json:"hasBlockedGroups,omitempty"` + HasBlockedGroupsWith []*GroupWhereInput `json:"hasBlockedGroupsWith,omitempty"` + + // "editors" edge predicates. + HasEditors *bool `json:"hasEditors,omitempty"` + HasEditorsWith []*GroupWhereInput `json:"hasEditorsWith,omitempty"` + + // "viewers" edge predicates. + HasViewers *bool `json:"hasViewers,omitempty"` + HasViewersWith []*GroupWhereInput `json:"hasViewersWith,omitempty"` + // "policy" edge predicates. HasPolicy *bool `json:"hasPolicy,omitempty"` HasPolicyWith []*InternalPolicyWhereInput `json:"hasPolicyWith,omitempty"` @@ -36034,9 +36131,9 @@ type NarrativeWhereInput struct { HasControlobjective *bool `json:"hasControlobjective,omitempty"` HasControlobjectiveWith []*ControlObjectiveWhereInput `json:"hasControlobjectiveWith,omitempty"` - // "program" edge predicates. - HasProgram *bool `json:"hasProgram,omitempty"` - HasProgramWith []*ProgramWhereInput `json:"hasProgramWith,omitempty"` + // "programs" edge predicates. + HasPrograms *bool `json:"hasPrograms,omitempty"` + HasProgramsWith []*ProgramWhereInput `json:"hasProgramsWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -36365,6 +36462,45 @@ func (i *NarrativeWhereInput) P() (predicate.Narrative, error) { if i.DeletedByContainsFold != nil { predicates = append(predicates, narrative.DeletedByContainsFold(*i.DeletedByContainsFold)) } + if i.OwnerID != nil { + predicates = append(predicates, narrative.OwnerIDEQ(*i.OwnerID)) + } + if i.OwnerIDNEQ != nil { + predicates = append(predicates, narrative.OwnerIDNEQ(*i.OwnerIDNEQ)) + } + if len(i.OwnerIDIn) > 0 { + predicates = append(predicates, narrative.OwnerIDIn(i.OwnerIDIn...)) + } + if len(i.OwnerIDNotIn) > 0 { + predicates = append(predicates, narrative.OwnerIDNotIn(i.OwnerIDNotIn...)) + } + if i.OwnerIDGT != nil { + predicates = append(predicates, narrative.OwnerIDGT(*i.OwnerIDGT)) + } + if i.OwnerIDGTE != nil { + predicates = append(predicates, narrative.OwnerIDGTE(*i.OwnerIDGTE)) + } + if i.OwnerIDLT != nil { + predicates = append(predicates, narrative.OwnerIDLT(*i.OwnerIDLT)) + } + if i.OwnerIDLTE != nil { + predicates = append(predicates, narrative.OwnerIDLTE(*i.OwnerIDLTE)) + } + if i.OwnerIDContains != nil { + predicates = append(predicates, narrative.OwnerIDContains(*i.OwnerIDContains)) + } + if i.OwnerIDHasPrefix != nil { + predicates = append(predicates, narrative.OwnerIDHasPrefix(*i.OwnerIDHasPrefix)) + } + if i.OwnerIDHasSuffix != nil { + predicates = append(predicates, narrative.OwnerIDHasSuffix(*i.OwnerIDHasSuffix)) + } + if i.OwnerIDEqualFold != nil { + predicates = append(predicates, narrative.OwnerIDEqualFold(*i.OwnerIDEqualFold)) + } + if i.OwnerIDContainsFold != nil { + predicates = append(predicates, narrative.OwnerIDContainsFold(*i.OwnerIDContainsFold)) + } if i.Name != nil { predicates = append(predicates, narrative.NameEQ(*i.Name)) } @@ -36495,6 +36631,78 @@ func (i *NarrativeWhereInput) P() (predicate.Narrative, error) { predicates = append(predicates, narrative.SatisfiesContainsFold(*i.SatisfiesContainsFold)) } + if i.HasOwner != nil { + p := narrative.HasOwner() + if !*i.HasOwner { + p = narrative.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasOwnerWith) > 0 { + with := make([]predicate.Organization, 0, len(i.HasOwnerWith)) + for _, w := range i.HasOwnerWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasOwnerWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, narrative.HasOwnerWith(with...)) + } + if i.HasBlockedGroups != nil { + p := narrative.HasBlockedGroups() + if !*i.HasBlockedGroups { + p = narrative.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasBlockedGroupsWith) > 0 { + with := make([]predicate.Group, 0, len(i.HasBlockedGroupsWith)) + for _, w := range i.HasBlockedGroupsWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasBlockedGroupsWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, narrative.HasBlockedGroupsWith(with...)) + } + if i.HasEditors != nil { + p := narrative.HasEditors() + if !*i.HasEditors { + p = narrative.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasEditorsWith) > 0 { + with := make([]predicate.Group, 0, len(i.HasEditorsWith)) + for _, w := range i.HasEditorsWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasEditorsWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, narrative.HasEditorsWith(with...)) + } + if i.HasViewers != nil { + p := narrative.HasViewers() + if !*i.HasViewers { + p = narrative.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasViewersWith) > 0 { + with := make([]predicate.Group, 0, len(i.HasViewersWith)) + for _, w := range i.HasViewersWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasViewersWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, narrative.HasViewersWith(with...)) + } if i.HasPolicy != nil { p := narrative.HasPolicy() if !*i.HasPolicy { @@ -36567,23 +36775,23 @@ func (i *NarrativeWhereInput) P() (predicate.Narrative, error) { } predicates = append(predicates, narrative.HasControlobjectiveWith(with...)) } - if i.HasProgram != nil { - p := narrative.HasProgram() - if !*i.HasProgram { + if i.HasPrograms != nil { + p := narrative.HasPrograms() + if !*i.HasPrograms { p = narrative.Not(p) } predicates = append(predicates, p) } - if len(i.HasProgramWith) > 0 { - with := make([]predicate.Program, 0, len(i.HasProgramWith)) - for _, w := range i.HasProgramWith { + if len(i.HasProgramsWith) > 0 { + with := make([]predicate.Program, 0, len(i.HasProgramsWith)) + for _, w := range i.HasProgramsWith { p, err := w.P() if err != nil { - return nil, fmt.Errorf("%w: field 'HasProgramWith'", err) + return nil, fmt.Errorf("%w: field 'HasProgramsWith'", err) } with = append(with, p) } - predicates = append(predicates, narrative.HasProgramWith(with...)) + predicates = append(predicates, narrative.HasProgramsWith(with...)) } switch len(predicates) { case 0: @@ -36734,6 +36942,21 @@ type NarrativeHistoryWhereInput struct { DeletedByEqualFold *string `json:"deletedByEqualFold,omitempty"` DeletedByContainsFold *string `json:"deletedByContainsFold,omitempty"` + // "owner_id" field predicates. + OwnerID *string `json:"ownerID,omitempty"` + OwnerIDNEQ *string `json:"ownerIDNEQ,omitempty"` + OwnerIDIn []string `json:"ownerIDIn,omitempty"` + OwnerIDNotIn []string `json:"ownerIDNotIn,omitempty"` + OwnerIDGT *string `json:"ownerIDGT,omitempty"` + OwnerIDGTE *string `json:"ownerIDGTE,omitempty"` + OwnerIDLT *string `json:"ownerIDLT,omitempty"` + OwnerIDLTE *string `json:"ownerIDLTE,omitempty"` + OwnerIDContains *string `json:"ownerIDContains,omitempty"` + OwnerIDHasPrefix *string `json:"ownerIDHasPrefix,omitempty"` + OwnerIDHasSuffix *string `json:"ownerIDHasSuffix,omitempty"` + OwnerIDEqualFold *string `json:"ownerIDEqualFold,omitempty"` + OwnerIDContainsFold *string `json:"ownerIDContainsFold,omitempty"` + // "name" field predicates. Name *string `json:"name,omitempty"` NameNEQ *string `json:"nameNEQ,omitempty"` @@ -37191,6 +37414,45 @@ func (i *NarrativeHistoryWhereInput) P() (predicate.NarrativeHistory, error) { if i.DeletedByContainsFold != nil { predicates = append(predicates, narrativehistory.DeletedByContainsFold(*i.DeletedByContainsFold)) } + if i.OwnerID != nil { + predicates = append(predicates, narrativehistory.OwnerIDEQ(*i.OwnerID)) + } + if i.OwnerIDNEQ != nil { + predicates = append(predicates, narrativehistory.OwnerIDNEQ(*i.OwnerIDNEQ)) + } + if len(i.OwnerIDIn) > 0 { + predicates = append(predicates, narrativehistory.OwnerIDIn(i.OwnerIDIn...)) + } + if len(i.OwnerIDNotIn) > 0 { + predicates = append(predicates, narrativehistory.OwnerIDNotIn(i.OwnerIDNotIn...)) + } + if i.OwnerIDGT != nil { + predicates = append(predicates, narrativehistory.OwnerIDGT(*i.OwnerIDGT)) + } + if i.OwnerIDGTE != nil { + predicates = append(predicates, narrativehistory.OwnerIDGTE(*i.OwnerIDGTE)) + } + if i.OwnerIDLT != nil { + predicates = append(predicates, narrativehistory.OwnerIDLT(*i.OwnerIDLT)) + } + if i.OwnerIDLTE != nil { + predicates = append(predicates, narrativehistory.OwnerIDLTE(*i.OwnerIDLTE)) + } + if i.OwnerIDContains != nil { + predicates = append(predicates, narrativehistory.OwnerIDContains(*i.OwnerIDContains)) + } + if i.OwnerIDHasPrefix != nil { + predicates = append(predicates, narrativehistory.OwnerIDHasPrefix(*i.OwnerIDHasPrefix)) + } + if i.OwnerIDHasSuffix != nil { + predicates = append(predicates, narrativehistory.OwnerIDHasSuffix(*i.OwnerIDHasSuffix)) + } + if i.OwnerIDEqualFold != nil { + predicates = append(predicates, narrativehistory.OwnerIDEqualFold(*i.OwnerIDEqualFold)) + } + if i.OwnerIDContainsFold != nil { + predicates = append(predicates, narrativehistory.OwnerIDContainsFold(*i.OwnerIDContainsFold)) + } if i.Name != nil { predicates = append(predicates, narrativehistory.NameEQ(*i.Name)) } @@ -42940,6 +43202,10 @@ type OrganizationWhereInput struct { HasControlobjectives *bool `json:"hasControlobjectives,omitempty"` HasControlobjectivesWith []*ControlObjectiveWhereInput `json:"hasControlobjectivesWith,omitempty"` + // "narratives" edge predicates. + HasNarratives *bool `json:"hasNarratives,omitempty"` + HasNarrativesWith []*NarrativeWhereInput `json:"hasNarrativesWith,omitempty"` + // "members" edge predicates. HasMembers *bool `json:"hasMembers,omitempty"` HasMembersWith []*OrgMembershipWhereInput `json:"hasMembersWith,omitempty"` @@ -43989,6 +44255,24 @@ func (i *OrganizationWhereInput) P() (predicate.Organization, error) { } predicates = append(predicates, organization.HasControlobjectivesWith(with...)) } + if i.HasNarratives != nil { + p := organization.HasNarratives() + if !*i.HasNarratives { + p = organization.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasNarrativesWith) > 0 { + with := make([]predicate.Narrative, 0, len(i.HasNarrativesWith)) + for _, w := range i.HasNarrativesWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasNarrativesWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, organization.HasNarrativesWith(with...)) + } if i.HasMembers != nil { p := organization.HasMembers() if !*i.HasMembers { diff --git a/internal/ent/generated/group.go b/internal/ent/generated/group.go index 0767d919..e0f841a0 100644 --- a/internal/ent/generated/group.go +++ b/internal/ent/generated/group.go @@ -96,13 +96,19 @@ type GroupEdges struct { ControlobjectiveEditors []*ControlObjective `json:"controlobjective_editors,omitempty"` // ControlobjectiveBlockedGroups holds the value of the controlobjective_blocked_groups edge. ControlobjectiveBlockedGroups []*ControlObjective `json:"controlobjective_blocked_groups,omitempty"` + // NarrativeViewers holds the value of the narrative_viewers edge. + NarrativeViewers []*Narrative `json:"narrative_viewers,omitempty"` + // NarrativeEditors holds the value of the narrative_editors edge. + NarrativeEditors []*Narrative `json:"narrative_editors,omitempty"` + // NarrativeBlockedGroups holds the value of the narrative_blocked_groups edge. + NarrativeBlockedGroups []*Narrative `json:"narrative_blocked_groups,omitempty"` // Members holds the value of the members edge. Members []*GroupMembership `json:"members,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [21]bool + loadedTypes [24]bool // totalCount holds the count of the edges above. - totalCount [21]map[string]int + totalCount [24]map[string]int namedUsers map[string][]*User namedEvents map[string][]*Event @@ -122,6 +128,9 @@ type GroupEdges struct { namedControlobjectiveViewers map[string][]*ControlObjective namedControlobjectiveEditors map[string][]*ControlObjective namedControlobjectiveBlockedGroups map[string][]*ControlObjective + namedNarrativeViewers map[string][]*Narrative + namedNarrativeEditors map[string][]*Narrative + namedNarrativeBlockedGroups map[string][]*Narrative namedMembers map[string][]*GroupMembership } @@ -309,10 +318,37 @@ func (e GroupEdges) ControlobjectiveBlockedGroupsOrErr() ([]*ControlObjective, e return nil, &NotLoadedError{edge: "controlobjective_blocked_groups"} } +// NarrativeViewersOrErr returns the NarrativeViewers value or an error if the edge +// was not loaded in eager-loading. +func (e GroupEdges) NarrativeViewersOrErr() ([]*Narrative, error) { + if e.loadedTypes[20] { + return e.NarrativeViewers, nil + } + return nil, &NotLoadedError{edge: "narrative_viewers"} +} + +// NarrativeEditorsOrErr returns the NarrativeEditors value or an error if the edge +// was not loaded in eager-loading. +func (e GroupEdges) NarrativeEditorsOrErr() ([]*Narrative, error) { + if e.loadedTypes[21] { + return e.NarrativeEditors, nil + } + return nil, &NotLoadedError{edge: "narrative_editors"} +} + +// NarrativeBlockedGroupsOrErr returns the NarrativeBlockedGroups value or an error if the edge +// was not loaded in eager-loading. +func (e GroupEdges) NarrativeBlockedGroupsOrErr() ([]*Narrative, error) { + if e.loadedTypes[22] { + return e.NarrativeBlockedGroups, nil + } + return nil, &NotLoadedError{edge: "narrative_blocked_groups"} +} + // MembersOrErr returns the Members value or an error if the edge // was not loaded in eager-loading. func (e GroupEdges) MembersOrErr() ([]*GroupMembership, error) { - if e.loadedTypes[20] { + if e.loadedTypes[23] { return e.Members, nil } return nil, &NotLoadedError{edge: "members"} @@ -549,6 +585,21 @@ func (gr *Group) QueryControlobjectiveBlockedGroups() *ControlObjectiveQuery { return NewGroupClient(gr.config).QueryControlobjectiveBlockedGroups(gr) } +// QueryNarrativeViewers queries the "narrative_viewers" edge of the Group entity. +func (gr *Group) QueryNarrativeViewers() *NarrativeQuery { + return NewGroupClient(gr.config).QueryNarrativeViewers(gr) +} + +// QueryNarrativeEditors queries the "narrative_editors" edge of the Group entity. +func (gr *Group) QueryNarrativeEditors() *NarrativeQuery { + return NewGroupClient(gr.config).QueryNarrativeEditors(gr) +} + +// QueryNarrativeBlockedGroups queries the "narrative_blocked_groups" edge of the Group entity. +func (gr *Group) QueryNarrativeBlockedGroups() *NarrativeQuery { + return NewGroupClient(gr.config).QueryNarrativeBlockedGroups(gr) +} + // QueryMembers queries the "members" edge of the Group entity. func (gr *Group) QueryMembers() *GroupMembershipQuery { return NewGroupClient(gr.config).QueryMembers(gr) @@ -1054,6 +1105,78 @@ func (gr *Group) appendNamedControlobjectiveBlockedGroups(name string, edges ... } } +// NamedNarrativeViewers returns the NarrativeViewers named value or an error if the edge was not +// loaded in eager-loading with this name. +func (gr *Group) NamedNarrativeViewers(name string) ([]*Narrative, error) { + if gr.Edges.namedNarrativeViewers == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := gr.Edges.namedNarrativeViewers[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (gr *Group) appendNamedNarrativeViewers(name string, edges ...*Narrative) { + if gr.Edges.namedNarrativeViewers == nil { + gr.Edges.namedNarrativeViewers = make(map[string][]*Narrative) + } + if len(edges) == 0 { + gr.Edges.namedNarrativeViewers[name] = []*Narrative{} + } else { + gr.Edges.namedNarrativeViewers[name] = append(gr.Edges.namedNarrativeViewers[name], edges...) + } +} + +// NamedNarrativeEditors returns the NarrativeEditors named value or an error if the edge was not +// loaded in eager-loading with this name. +func (gr *Group) NamedNarrativeEditors(name string) ([]*Narrative, error) { + if gr.Edges.namedNarrativeEditors == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := gr.Edges.namedNarrativeEditors[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (gr *Group) appendNamedNarrativeEditors(name string, edges ...*Narrative) { + if gr.Edges.namedNarrativeEditors == nil { + gr.Edges.namedNarrativeEditors = make(map[string][]*Narrative) + } + if len(edges) == 0 { + gr.Edges.namedNarrativeEditors[name] = []*Narrative{} + } else { + gr.Edges.namedNarrativeEditors[name] = append(gr.Edges.namedNarrativeEditors[name], edges...) + } +} + +// NamedNarrativeBlockedGroups returns the NarrativeBlockedGroups named value or an error if the edge was not +// loaded in eager-loading with this name. +func (gr *Group) NamedNarrativeBlockedGroups(name string) ([]*Narrative, error) { + if gr.Edges.namedNarrativeBlockedGroups == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := gr.Edges.namedNarrativeBlockedGroups[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (gr *Group) appendNamedNarrativeBlockedGroups(name string, edges ...*Narrative) { + if gr.Edges.namedNarrativeBlockedGroups == nil { + gr.Edges.namedNarrativeBlockedGroups = make(map[string][]*Narrative) + } + if len(edges) == 0 { + gr.Edges.namedNarrativeBlockedGroups[name] = []*Narrative{} + } else { + gr.Edges.namedNarrativeBlockedGroups[name] = append(gr.Edges.namedNarrativeBlockedGroups[name], edges...) + } +} + // NamedMembers returns the Members named value or an error if the edge was not // loaded in eager-loading with this name. func (gr *Group) NamedMembers(name string) ([]*GroupMembership, error) { diff --git a/internal/ent/generated/group/group.go b/internal/ent/generated/group/group.go index 65a8712e..99139764 100644 --- a/internal/ent/generated/group/group.go +++ b/internal/ent/generated/group/group.go @@ -83,6 +83,12 @@ const ( EdgeControlobjectiveEditors = "controlobjective_editors" // EdgeControlobjectiveBlockedGroups holds the string denoting the controlobjective_blocked_groups edge name in mutations. EdgeControlobjectiveBlockedGroups = "controlobjective_blocked_groups" + // EdgeNarrativeViewers holds the string denoting the narrative_viewers edge name in mutations. + EdgeNarrativeViewers = "narrative_viewers" + // EdgeNarrativeEditors holds the string denoting the narrative_editors edge name in mutations. + EdgeNarrativeEditors = "narrative_editors" + // EdgeNarrativeBlockedGroups holds the string denoting the narrative_blocked_groups edge name in mutations. + EdgeNarrativeBlockedGroups = "narrative_blocked_groups" // EdgeMembers holds the string denoting the members edge name in mutations. EdgeMembers = "members" // Table holds the table name of the group in the database. @@ -193,6 +199,21 @@ const ( // ControlobjectiveBlockedGroupsInverseTable is the table name for the ControlObjective entity. // It exists in this package in order to avoid circular dependency with the "controlobjective" package. ControlobjectiveBlockedGroupsInverseTable = "control_objectives" + // NarrativeViewersTable is the table that holds the narrative_viewers relation/edge. The primary key declared below. + NarrativeViewersTable = "narrative_viewers" + // NarrativeViewersInverseTable is the table name for the Narrative entity. + // It exists in this package in order to avoid circular dependency with the "narrative" package. + NarrativeViewersInverseTable = "narratives" + // NarrativeEditorsTable is the table that holds the narrative_editors relation/edge. The primary key declared below. + NarrativeEditorsTable = "narrative_editors" + // NarrativeEditorsInverseTable is the table name for the Narrative entity. + // It exists in this package in order to avoid circular dependency with the "narrative" package. + NarrativeEditorsInverseTable = "narratives" + // NarrativeBlockedGroupsTable is the table that holds the narrative_blocked_groups relation/edge. The primary key declared below. + NarrativeBlockedGroupsTable = "narrative_blocked_groups" + // NarrativeBlockedGroupsInverseTable is the table name for the Narrative entity. + // It exists in this package in order to avoid circular dependency with the "narrative" package. + NarrativeBlockedGroupsInverseTable = "narratives" // MembersTable is the table that holds the members relation/edge. MembersTable = "group_memberships" // MembersInverseTable is the table name for the GroupMembership entity. @@ -273,6 +294,15 @@ var ( // ControlobjectiveBlockedGroupsPrimaryKey and ControlobjectiveBlockedGroupsColumn2 are the table columns denoting the // primary key for the controlobjective_blocked_groups relation (M2M). ControlobjectiveBlockedGroupsPrimaryKey = []string{"control_objective_id", "group_id"} + // NarrativeViewersPrimaryKey and NarrativeViewersColumn2 are the table columns denoting the + // primary key for the narrative_viewers relation (M2M). + NarrativeViewersPrimaryKey = []string{"narrative_id", "group_id"} + // NarrativeEditorsPrimaryKey and NarrativeEditorsColumn2 are the table columns denoting the + // primary key for the narrative_editors relation (M2M). + NarrativeEditorsPrimaryKey = []string{"narrative_id", "group_id"} + // NarrativeBlockedGroupsPrimaryKey and NarrativeBlockedGroupsColumn2 are the table columns denoting the + // primary key for the narrative_blocked_groups relation (M2M). + NarrativeBlockedGroupsPrimaryKey = []string{"narrative_id", "group_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -655,6 +685,48 @@ func ByControlobjectiveBlockedGroups(term sql.OrderTerm, terms ...sql.OrderTerm) } } +// ByNarrativeViewersCount orders the results by narrative_viewers count. +func ByNarrativeViewersCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newNarrativeViewersStep(), opts...) + } +} + +// ByNarrativeViewers orders the results by narrative_viewers terms. +func ByNarrativeViewers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newNarrativeViewersStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByNarrativeEditorsCount orders the results by narrative_editors count. +func ByNarrativeEditorsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newNarrativeEditorsStep(), opts...) + } +} + +// ByNarrativeEditors orders the results by narrative_editors terms. +func ByNarrativeEditors(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newNarrativeEditorsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByNarrativeBlockedGroupsCount orders the results by narrative_blocked_groups count. +func ByNarrativeBlockedGroupsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newNarrativeBlockedGroupsStep(), opts...) + } +} + +// ByNarrativeBlockedGroups orders the results by narrative_blocked_groups terms. +func ByNarrativeBlockedGroups(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newNarrativeBlockedGroupsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByMembersCount orders the results by members count. func ByMembersCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -808,6 +880,27 @@ func newControlobjectiveBlockedGroupsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, true, ControlobjectiveBlockedGroupsTable, ControlobjectiveBlockedGroupsPrimaryKey...), ) } +func newNarrativeViewersStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(NarrativeViewersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, NarrativeViewersTable, NarrativeViewersPrimaryKey...), + ) +} +func newNarrativeEditorsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(NarrativeEditorsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, NarrativeEditorsTable, NarrativeEditorsPrimaryKey...), + ) +} +func newNarrativeBlockedGroupsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(NarrativeBlockedGroupsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, NarrativeBlockedGroupsTable, NarrativeBlockedGroupsPrimaryKey...), + ) +} func newMembersStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/internal/ent/generated/group/where.go b/internal/ent/generated/group/where.go index 1408d07c..2df5af14 100644 --- a/internal/ent/generated/group/where.go +++ b/internal/ent/generated/group/where.go @@ -1592,6 +1592,93 @@ func HasControlobjectiveBlockedGroupsWith(preds ...predicate.ControlObjective) p }) } +// HasNarrativeViewers applies the HasEdge predicate on the "narrative_viewers" edge. +func HasNarrativeViewers() predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, NarrativeViewersTable, NarrativeViewersPrimaryKey...), + ) + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeViewers + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasNarrativeViewersWith applies the HasEdge predicate on the "narrative_viewers" edge with a given conditions (other predicates). +func HasNarrativeViewersWith(preds ...predicate.Narrative) predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := newNarrativeViewersStep() + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeViewers + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasNarrativeEditors applies the HasEdge predicate on the "narrative_editors" edge. +func HasNarrativeEditors() predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, NarrativeEditorsTable, NarrativeEditorsPrimaryKey...), + ) + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeEditors + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasNarrativeEditorsWith applies the HasEdge predicate on the "narrative_editors" edge with a given conditions (other predicates). +func HasNarrativeEditorsWith(preds ...predicate.Narrative) predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := newNarrativeEditorsStep() + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeEditors + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasNarrativeBlockedGroups applies the HasEdge predicate on the "narrative_blocked_groups" edge. +func HasNarrativeBlockedGroups() predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, NarrativeBlockedGroupsTable, NarrativeBlockedGroupsPrimaryKey...), + ) + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeBlockedGroups + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasNarrativeBlockedGroupsWith applies the HasEdge predicate on the "narrative_blocked_groups" edge with a given conditions (other predicates). +func HasNarrativeBlockedGroupsWith(preds ...predicate.Narrative) predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := newNarrativeBlockedGroupsStep() + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeBlockedGroups + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasMembers applies the HasEdge predicate on the "members" edge. func HasMembers() predicate.Group { return predicate.Group(func(s *sql.Selector) { diff --git a/internal/ent/generated/group_create.go b/internal/ent/generated/group_create.go index 29ec295b..805627f9 100644 --- a/internal/ent/generated/group_create.go +++ b/internal/ent/generated/group_create.go @@ -18,6 +18,7 @@ import ( "github.com/theopenlane/core/internal/ent/generated/groupsetting" "github.com/theopenlane/core/internal/ent/generated/integration" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" + "github.com/theopenlane/core/internal/ent/generated/narrative" "github.com/theopenlane/core/internal/ent/generated/organization" "github.com/theopenlane/core/internal/ent/generated/procedure" "github.com/theopenlane/core/internal/ent/generated/program" @@ -513,6 +514,51 @@ func (gc *GroupCreate) AddControlobjectiveBlockedGroups(c ...*ControlObjective) return gc.AddControlobjectiveBlockedGroupIDs(ids...) } +// AddNarrativeViewerIDs adds the "narrative_viewers" edge to the Narrative entity by IDs. +func (gc *GroupCreate) AddNarrativeViewerIDs(ids ...string) *GroupCreate { + gc.mutation.AddNarrativeViewerIDs(ids...) + return gc +} + +// AddNarrativeViewers adds the "narrative_viewers" edges to the Narrative entity. +func (gc *GroupCreate) AddNarrativeViewers(n ...*Narrative) *GroupCreate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return gc.AddNarrativeViewerIDs(ids...) +} + +// AddNarrativeEditorIDs adds the "narrative_editors" edge to the Narrative entity by IDs. +func (gc *GroupCreate) AddNarrativeEditorIDs(ids ...string) *GroupCreate { + gc.mutation.AddNarrativeEditorIDs(ids...) + return gc +} + +// AddNarrativeEditors adds the "narrative_editors" edges to the Narrative entity. +func (gc *GroupCreate) AddNarrativeEditors(n ...*Narrative) *GroupCreate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return gc.AddNarrativeEditorIDs(ids...) +} + +// AddNarrativeBlockedGroupIDs adds the "narrative_blocked_groups" edge to the Narrative entity by IDs. +func (gc *GroupCreate) AddNarrativeBlockedGroupIDs(ids ...string) *GroupCreate { + gc.mutation.AddNarrativeBlockedGroupIDs(ids...) + return gc +} + +// AddNarrativeBlockedGroups adds the "narrative_blocked_groups" edges to the Narrative entity. +func (gc *GroupCreate) AddNarrativeBlockedGroups(n ...*Narrative) *GroupCreate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return gc.AddNarrativeBlockedGroupIDs(ids...) +} + // AddMemberIDs adds the "members" edge to the GroupMembership entity by IDs. func (gc *GroupCreate) AddMemberIDs(ids ...string) *GroupCreate { gc.mutation.AddMemberIDs(ids...) @@ -1069,6 +1115,57 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := gc.mutation.NarrativeViewersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeViewersTable, + Columns: group.NarrativeViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gc.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := gc.mutation.NarrativeEditorsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeEditorsTable, + Columns: group.NarrativeEditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gc.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := gc.mutation.NarrativeBlockedGroupsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeBlockedGroupsTable, + Columns: group.NarrativeBlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gc.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := gc.mutation.MembersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/internal/ent/generated/group_query.go b/internal/ent/generated/group_query.go index 91031799..a81a813d 100644 --- a/internal/ent/generated/group_query.go +++ b/internal/ent/generated/group_query.go @@ -21,6 +21,7 @@ import ( "github.com/theopenlane/core/internal/ent/generated/groupsetting" "github.com/theopenlane/core/internal/ent/generated/integration" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" + "github.com/theopenlane/core/internal/ent/generated/narrative" "github.com/theopenlane/core/internal/ent/generated/organization" "github.com/theopenlane/core/internal/ent/generated/predicate" "github.com/theopenlane/core/internal/ent/generated/procedure" @@ -59,6 +60,9 @@ type GroupQuery struct { withControlobjectiveViewers *ControlObjectiveQuery withControlobjectiveEditors *ControlObjectiveQuery withControlobjectiveBlockedGroups *ControlObjectiveQuery + withNarrativeViewers *NarrativeQuery + withNarrativeEditors *NarrativeQuery + withNarrativeBlockedGroups *NarrativeQuery withMembers *GroupMembershipQuery loadTotal []func(context.Context, []*Group) error modifiers []func(*sql.Selector) @@ -80,6 +84,9 @@ type GroupQuery struct { withNamedControlobjectiveViewers map[string]*ControlObjectiveQuery withNamedControlobjectiveEditors map[string]*ControlObjectiveQuery withNamedControlobjectiveBlockedGroups map[string]*ControlObjectiveQuery + withNamedNarrativeViewers map[string]*NarrativeQuery + withNamedNarrativeEditors map[string]*NarrativeQuery + withNamedNarrativeBlockedGroups map[string]*NarrativeQuery withNamedMembers map[string]*GroupMembershipQuery // intermediate query (i.e. traversal path). sql *sql.Selector @@ -617,6 +624,81 @@ func (gq *GroupQuery) QueryControlobjectiveBlockedGroups() *ControlObjectiveQuer return query } +// QueryNarrativeViewers chains the current query on the "narrative_viewers" edge. +func (gq *GroupQuery) QueryNarrativeViewers() *NarrativeQuery { + query := (&NarrativeClient{config: gq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := gq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := gq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(group.Table, group.FieldID, selector), + sqlgraph.To(narrative.Table, narrative.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, group.NarrativeViewersTable, group.NarrativeViewersPrimaryKey...), + ) + schemaConfig := gq.schemaConfig + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeViewers + fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryNarrativeEditors chains the current query on the "narrative_editors" edge. +func (gq *GroupQuery) QueryNarrativeEditors() *NarrativeQuery { + query := (&NarrativeClient{config: gq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := gq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := gq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(group.Table, group.FieldID, selector), + sqlgraph.To(narrative.Table, narrative.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, group.NarrativeEditorsTable, group.NarrativeEditorsPrimaryKey...), + ) + schemaConfig := gq.schemaConfig + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeEditors + fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryNarrativeBlockedGroups chains the current query on the "narrative_blocked_groups" edge. +func (gq *GroupQuery) QueryNarrativeBlockedGroups() *NarrativeQuery { + query := (&NarrativeClient{config: gq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := gq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := gq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(group.Table, group.FieldID, selector), + sqlgraph.To(narrative.Table, narrative.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, group.NarrativeBlockedGroupsTable, group.NarrativeBlockedGroupsPrimaryKey...), + ) + schemaConfig := gq.schemaConfig + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.NarrativeBlockedGroups + fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryMembers chains the current query on the "members" edge. func (gq *GroupQuery) QueryMembers() *GroupMembershipQuery { query := (&GroupMembershipClient{config: gq.config}).Query() @@ -854,6 +936,9 @@ func (gq *GroupQuery) Clone() *GroupQuery { withControlobjectiveViewers: gq.withControlobjectiveViewers.Clone(), withControlobjectiveEditors: gq.withControlobjectiveEditors.Clone(), withControlobjectiveBlockedGroups: gq.withControlobjectiveBlockedGroups.Clone(), + withNarrativeViewers: gq.withNarrativeViewers.Clone(), + withNarrativeEditors: gq.withNarrativeEditors.Clone(), + withNarrativeBlockedGroups: gq.withNarrativeBlockedGroups.Clone(), withMembers: gq.withMembers.Clone(), // clone intermediate query. sql: gq.sql.Clone(), @@ -1082,6 +1167,39 @@ func (gq *GroupQuery) WithControlobjectiveBlockedGroups(opts ...func(*ControlObj return gq } +// WithNarrativeViewers tells the query-builder to eager-load the nodes that are connected to +// the "narrative_viewers" edge. The optional arguments are used to configure the query builder of the edge. +func (gq *GroupQuery) WithNarrativeViewers(opts ...func(*NarrativeQuery)) *GroupQuery { + query := (&NarrativeClient{config: gq.config}).Query() + for _, opt := range opts { + opt(query) + } + gq.withNarrativeViewers = query + return gq +} + +// WithNarrativeEditors tells the query-builder to eager-load the nodes that are connected to +// the "narrative_editors" edge. The optional arguments are used to configure the query builder of the edge. +func (gq *GroupQuery) WithNarrativeEditors(opts ...func(*NarrativeQuery)) *GroupQuery { + query := (&NarrativeClient{config: gq.config}).Query() + for _, opt := range opts { + opt(query) + } + gq.withNarrativeEditors = query + return gq +} + +// WithNarrativeBlockedGroups tells the query-builder to eager-load the nodes that are connected to +// the "narrative_blocked_groups" edge. The optional arguments are used to configure the query builder of the edge. +func (gq *GroupQuery) WithNarrativeBlockedGroups(opts ...func(*NarrativeQuery)) *GroupQuery { + query := (&NarrativeClient{config: gq.config}).Query() + for _, opt := range opts { + opt(query) + } + gq.withNarrativeBlockedGroups = query + return gq +} + // WithMembers tells the query-builder to eager-load the nodes that are connected to // the "members" edge. The optional arguments are used to configure the query builder of the edge. func (gq *GroupQuery) WithMembers(opts ...func(*GroupMembershipQuery)) *GroupQuery { @@ -1177,7 +1295,7 @@ func (gq *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, var ( nodes = []*Group{} _spec = gq.querySpec() - loadedTypes = [21]bool{ + loadedTypes = [24]bool{ gq.withOwner != nil, gq.withSetting != nil, gq.withUsers != nil, @@ -1198,6 +1316,9 @@ func (gq *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, gq.withControlobjectiveViewers != nil, gq.withControlobjectiveEditors != nil, gq.withControlobjectiveBlockedGroups != nil, + gq.withNarrativeViewers != nil, + gq.withNarrativeEditors != nil, + gq.withNarrativeBlockedGroups != nil, gq.withMembers != nil, } ) @@ -1374,6 +1495,29 @@ func (gq *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, return nil, err } } + if query := gq.withNarrativeViewers; query != nil { + if err := gq.loadNarrativeViewers(ctx, query, nodes, + func(n *Group) { n.Edges.NarrativeViewers = []*Narrative{} }, + func(n *Group, e *Narrative) { n.Edges.NarrativeViewers = append(n.Edges.NarrativeViewers, e) }); err != nil { + return nil, err + } + } + if query := gq.withNarrativeEditors; query != nil { + if err := gq.loadNarrativeEditors(ctx, query, nodes, + func(n *Group) { n.Edges.NarrativeEditors = []*Narrative{} }, + func(n *Group, e *Narrative) { n.Edges.NarrativeEditors = append(n.Edges.NarrativeEditors, e) }); err != nil { + return nil, err + } + } + if query := gq.withNarrativeBlockedGroups; query != nil { + if err := gq.loadNarrativeBlockedGroups(ctx, query, nodes, + func(n *Group) { n.Edges.NarrativeBlockedGroups = []*Narrative{} }, + func(n *Group, e *Narrative) { + n.Edges.NarrativeBlockedGroups = append(n.Edges.NarrativeBlockedGroups, e) + }); err != nil { + return nil, err + } + } if query := gq.withMembers; query != nil { if err := gq.loadMembers(ctx, query, nodes, func(n *Group) { n.Edges.Members = []*GroupMembership{} }, @@ -1507,6 +1651,27 @@ func (gq *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, return nil, err } } + for name, query := range gq.withNamedNarrativeViewers { + if err := gq.loadNarrativeViewers(ctx, query, nodes, + func(n *Group) { n.appendNamedNarrativeViewers(name) }, + func(n *Group, e *Narrative) { n.appendNamedNarrativeViewers(name, e) }); err != nil { + return nil, err + } + } + for name, query := range gq.withNamedNarrativeEditors { + if err := gq.loadNarrativeEditors(ctx, query, nodes, + func(n *Group) { n.appendNamedNarrativeEditors(name) }, + func(n *Group, e *Narrative) { n.appendNamedNarrativeEditors(name, e) }); err != nil { + return nil, err + } + } + for name, query := range gq.withNamedNarrativeBlockedGroups { + if err := gq.loadNarrativeBlockedGroups(ctx, query, nodes, + func(n *Group) { n.appendNamedNarrativeBlockedGroups(name) }, + func(n *Group, e *Narrative) { n.appendNamedNarrativeBlockedGroups(name, e) }); err != nil { + return nil, err + } + } for name, query := range gq.withNamedMembers { if err := gq.loadMembers(ctx, query, nodes, func(n *Group) { n.appendNamedMembers(name) }, @@ -2663,6 +2828,192 @@ func (gq *GroupQuery) loadControlobjectiveBlockedGroups(ctx context.Context, que } return nil } +func (gq *GroupQuery) loadNarrativeViewers(ctx context.Context, query *NarrativeQuery, nodes []*Group, init func(*Group), assign func(*Group, *Narrative)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Group) + nids := make(map[string]map[*Group]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(group.NarrativeViewersTable) + joinT.Schema(gq.schemaConfig.NarrativeViewers) + s.Join(joinT).On(s.C(narrative.FieldID), joinT.C(group.NarrativeViewersPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(group.NarrativeViewersPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(group.NarrativeViewersPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Group]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Narrative](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "narrative_viewers" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (gq *GroupQuery) loadNarrativeEditors(ctx context.Context, query *NarrativeQuery, nodes []*Group, init func(*Group), assign func(*Group, *Narrative)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Group) + nids := make(map[string]map[*Group]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(group.NarrativeEditorsTable) + joinT.Schema(gq.schemaConfig.NarrativeEditors) + s.Join(joinT).On(s.C(narrative.FieldID), joinT.C(group.NarrativeEditorsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(group.NarrativeEditorsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(group.NarrativeEditorsPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Group]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Narrative](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "narrative_editors" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (gq *GroupQuery) loadNarrativeBlockedGroups(ctx context.Context, query *NarrativeQuery, nodes []*Group, init func(*Group), assign func(*Group, *Narrative)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Group) + nids := make(map[string]map[*Group]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(group.NarrativeBlockedGroupsTable) + joinT.Schema(gq.schemaConfig.NarrativeBlockedGroups) + s.Join(joinT).On(s.C(narrative.FieldID), joinT.C(group.NarrativeBlockedGroupsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(group.NarrativeBlockedGroupsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(group.NarrativeBlockedGroupsPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Group]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Narrative](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "narrative_blocked_groups" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} func (gq *GroupQuery) loadMembers(ctx context.Context, query *GroupMembershipQuery, nodes []*Group, init func(*Group), assign func(*Group, *GroupMembership)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[string]*Group) @@ -3047,6 +3398,48 @@ func (gq *GroupQuery) WithNamedControlobjectiveBlockedGroups(name string, opts . return gq } +// WithNamedNarrativeViewers tells the query-builder to eager-load the nodes that are connected to the "narrative_viewers" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (gq *GroupQuery) WithNamedNarrativeViewers(name string, opts ...func(*NarrativeQuery)) *GroupQuery { + query := (&NarrativeClient{config: gq.config}).Query() + for _, opt := range opts { + opt(query) + } + if gq.withNamedNarrativeViewers == nil { + gq.withNamedNarrativeViewers = make(map[string]*NarrativeQuery) + } + gq.withNamedNarrativeViewers[name] = query + return gq +} + +// WithNamedNarrativeEditors tells the query-builder to eager-load the nodes that are connected to the "narrative_editors" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (gq *GroupQuery) WithNamedNarrativeEditors(name string, opts ...func(*NarrativeQuery)) *GroupQuery { + query := (&NarrativeClient{config: gq.config}).Query() + for _, opt := range opts { + opt(query) + } + if gq.withNamedNarrativeEditors == nil { + gq.withNamedNarrativeEditors = make(map[string]*NarrativeQuery) + } + gq.withNamedNarrativeEditors[name] = query + return gq +} + +// WithNamedNarrativeBlockedGroups tells the query-builder to eager-load the nodes that are connected to the "narrative_blocked_groups" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (gq *GroupQuery) WithNamedNarrativeBlockedGroups(name string, opts ...func(*NarrativeQuery)) *GroupQuery { + query := (&NarrativeClient{config: gq.config}).Query() + for _, opt := range opts { + opt(query) + } + if gq.withNamedNarrativeBlockedGroups == nil { + gq.withNamedNarrativeBlockedGroups = make(map[string]*NarrativeQuery) + } + gq.withNamedNarrativeBlockedGroups[name] = query + return gq +} + // WithNamedMembers tells the query-builder to eager-load the nodes that are connected to the "members" // edge with the given name. The optional arguments are used to configure the query builder of the edge. func (gq *GroupQuery) WithNamedMembers(name string, opts ...func(*GroupMembershipQuery)) *GroupQuery { diff --git a/internal/ent/generated/group_update.go b/internal/ent/generated/group_update.go index b3537eb9..50641bb0 100644 --- a/internal/ent/generated/group_update.go +++ b/internal/ent/generated/group_update.go @@ -20,6 +20,7 @@ import ( "github.com/theopenlane/core/internal/ent/generated/groupsetting" "github.com/theopenlane/core/internal/ent/generated/integration" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" + "github.com/theopenlane/core/internal/ent/generated/narrative" "github.com/theopenlane/core/internal/ent/generated/organization" "github.com/theopenlane/core/internal/ent/generated/predicate" "github.com/theopenlane/core/internal/ent/generated/procedure" @@ -529,6 +530,51 @@ func (gu *GroupUpdate) AddControlobjectiveBlockedGroups(c ...*ControlObjective) return gu.AddControlobjectiveBlockedGroupIDs(ids...) } +// AddNarrativeViewerIDs adds the "narrative_viewers" edge to the Narrative entity by IDs. +func (gu *GroupUpdate) AddNarrativeViewerIDs(ids ...string) *GroupUpdate { + gu.mutation.AddNarrativeViewerIDs(ids...) + return gu +} + +// AddNarrativeViewers adds the "narrative_viewers" edges to the Narrative entity. +func (gu *GroupUpdate) AddNarrativeViewers(n ...*Narrative) *GroupUpdate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return gu.AddNarrativeViewerIDs(ids...) +} + +// AddNarrativeEditorIDs adds the "narrative_editors" edge to the Narrative entity by IDs. +func (gu *GroupUpdate) AddNarrativeEditorIDs(ids ...string) *GroupUpdate { + gu.mutation.AddNarrativeEditorIDs(ids...) + return gu +} + +// AddNarrativeEditors adds the "narrative_editors" edges to the Narrative entity. +func (gu *GroupUpdate) AddNarrativeEditors(n ...*Narrative) *GroupUpdate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return gu.AddNarrativeEditorIDs(ids...) +} + +// AddNarrativeBlockedGroupIDs adds the "narrative_blocked_groups" edge to the Narrative entity by IDs. +func (gu *GroupUpdate) AddNarrativeBlockedGroupIDs(ids ...string) *GroupUpdate { + gu.mutation.AddNarrativeBlockedGroupIDs(ids...) + return gu +} + +// AddNarrativeBlockedGroups adds the "narrative_blocked_groups" edges to the Narrative entity. +func (gu *GroupUpdate) AddNarrativeBlockedGroups(n ...*Narrative) *GroupUpdate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return gu.AddNarrativeBlockedGroupIDs(ids...) +} + // AddMemberIDs adds the "members" edge to the GroupMembership entity by IDs. func (gu *GroupUpdate) AddMemberIDs(ids ...string) *GroupUpdate { gu.mutation.AddMemberIDs(ids...) @@ -939,6 +985,69 @@ func (gu *GroupUpdate) RemoveControlobjectiveBlockedGroups(c ...*ControlObjectiv return gu.RemoveControlobjectiveBlockedGroupIDs(ids...) } +// ClearNarrativeViewers clears all "narrative_viewers" edges to the Narrative entity. +func (gu *GroupUpdate) ClearNarrativeViewers() *GroupUpdate { + gu.mutation.ClearNarrativeViewers() + return gu +} + +// RemoveNarrativeViewerIDs removes the "narrative_viewers" edge to Narrative entities by IDs. +func (gu *GroupUpdate) RemoveNarrativeViewerIDs(ids ...string) *GroupUpdate { + gu.mutation.RemoveNarrativeViewerIDs(ids...) + return gu +} + +// RemoveNarrativeViewers removes "narrative_viewers" edges to Narrative entities. +func (gu *GroupUpdate) RemoveNarrativeViewers(n ...*Narrative) *GroupUpdate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return gu.RemoveNarrativeViewerIDs(ids...) +} + +// ClearNarrativeEditors clears all "narrative_editors" edges to the Narrative entity. +func (gu *GroupUpdate) ClearNarrativeEditors() *GroupUpdate { + gu.mutation.ClearNarrativeEditors() + return gu +} + +// RemoveNarrativeEditorIDs removes the "narrative_editors" edge to Narrative entities by IDs. +func (gu *GroupUpdate) RemoveNarrativeEditorIDs(ids ...string) *GroupUpdate { + gu.mutation.RemoveNarrativeEditorIDs(ids...) + return gu +} + +// RemoveNarrativeEditors removes "narrative_editors" edges to Narrative entities. +func (gu *GroupUpdate) RemoveNarrativeEditors(n ...*Narrative) *GroupUpdate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return gu.RemoveNarrativeEditorIDs(ids...) +} + +// ClearNarrativeBlockedGroups clears all "narrative_blocked_groups" edges to the Narrative entity. +func (gu *GroupUpdate) ClearNarrativeBlockedGroups() *GroupUpdate { + gu.mutation.ClearNarrativeBlockedGroups() + return gu +} + +// RemoveNarrativeBlockedGroupIDs removes the "narrative_blocked_groups" edge to Narrative entities by IDs. +func (gu *GroupUpdate) RemoveNarrativeBlockedGroupIDs(ids ...string) *GroupUpdate { + gu.mutation.RemoveNarrativeBlockedGroupIDs(ids...) + return gu +} + +// RemoveNarrativeBlockedGroups removes "narrative_blocked_groups" edges to Narrative entities. +func (gu *GroupUpdate) RemoveNarrativeBlockedGroups(n ...*Narrative) *GroupUpdate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return gu.RemoveNarrativeBlockedGroupIDs(ids...) +} + // ClearMembers clears all "members" edges to the GroupMembership entity. func (gu *GroupUpdate) ClearMembers() *GroupUpdate { gu.mutation.ClearMembers() @@ -2055,6 +2164,150 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if gu.mutation.NarrativeViewersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeViewersTable, + Columns: group.NarrativeViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gu.schemaConfig.NarrativeViewers + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gu.mutation.RemovedNarrativeViewersIDs(); len(nodes) > 0 && !gu.mutation.NarrativeViewersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeViewersTable, + Columns: group.NarrativeViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gu.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gu.mutation.NarrativeViewersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeViewersTable, + Columns: group.NarrativeViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gu.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if gu.mutation.NarrativeEditorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeEditorsTable, + Columns: group.NarrativeEditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gu.schemaConfig.NarrativeEditors + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gu.mutation.RemovedNarrativeEditorsIDs(); len(nodes) > 0 && !gu.mutation.NarrativeEditorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeEditorsTable, + Columns: group.NarrativeEditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gu.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gu.mutation.NarrativeEditorsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeEditorsTable, + Columns: group.NarrativeEditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gu.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if gu.mutation.NarrativeBlockedGroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeBlockedGroupsTable, + Columns: group.NarrativeBlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gu.schemaConfig.NarrativeBlockedGroups + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gu.mutation.RemovedNarrativeBlockedGroupsIDs(); len(nodes) > 0 && !gu.mutation.NarrativeBlockedGroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeBlockedGroupsTable, + Columns: group.NarrativeBlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gu.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gu.mutation.NarrativeBlockedGroupsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeBlockedGroupsTable, + Columns: group.NarrativeBlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = gu.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if gu.mutation.MembersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -2611,6 +2864,51 @@ func (guo *GroupUpdateOne) AddControlobjectiveBlockedGroups(c ...*ControlObjecti return guo.AddControlobjectiveBlockedGroupIDs(ids...) } +// AddNarrativeViewerIDs adds the "narrative_viewers" edge to the Narrative entity by IDs. +func (guo *GroupUpdateOne) AddNarrativeViewerIDs(ids ...string) *GroupUpdateOne { + guo.mutation.AddNarrativeViewerIDs(ids...) + return guo +} + +// AddNarrativeViewers adds the "narrative_viewers" edges to the Narrative entity. +func (guo *GroupUpdateOne) AddNarrativeViewers(n ...*Narrative) *GroupUpdateOne { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return guo.AddNarrativeViewerIDs(ids...) +} + +// AddNarrativeEditorIDs adds the "narrative_editors" edge to the Narrative entity by IDs. +func (guo *GroupUpdateOne) AddNarrativeEditorIDs(ids ...string) *GroupUpdateOne { + guo.mutation.AddNarrativeEditorIDs(ids...) + return guo +} + +// AddNarrativeEditors adds the "narrative_editors" edges to the Narrative entity. +func (guo *GroupUpdateOne) AddNarrativeEditors(n ...*Narrative) *GroupUpdateOne { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return guo.AddNarrativeEditorIDs(ids...) +} + +// AddNarrativeBlockedGroupIDs adds the "narrative_blocked_groups" edge to the Narrative entity by IDs. +func (guo *GroupUpdateOne) AddNarrativeBlockedGroupIDs(ids ...string) *GroupUpdateOne { + guo.mutation.AddNarrativeBlockedGroupIDs(ids...) + return guo +} + +// AddNarrativeBlockedGroups adds the "narrative_blocked_groups" edges to the Narrative entity. +func (guo *GroupUpdateOne) AddNarrativeBlockedGroups(n ...*Narrative) *GroupUpdateOne { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return guo.AddNarrativeBlockedGroupIDs(ids...) +} + // AddMemberIDs adds the "members" edge to the GroupMembership entity by IDs. func (guo *GroupUpdateOne) AddMemberIDs(ids ...string) *GroupUpdateOne { guo.mutation.AddMemberIDs(ids...) @@ -3021,6 +3319,69 @@ func (guo *GroupUpdateOne) RemoveControlobjectiveBlockedGroups(c ...*ControlObje return guo.RemoveControlobjectiveBlockedGroupIDs(ids...) } +// ClearNarrativeViewers clears all "narrative_viewers" edges to the Narrative entity. +func (guo *GroupUpdateOne) ClearNarrativeViewers() *GroupUpdateOne { + guo.mutation.ClearNarrativeViewers() + return guo +} + +// RemoveNarrativeViewerIDs removes the "narrative_viewers" edge to Narrative entities by IDs. +func (guo *GroupUpdateOne) RemoveNarrativeViewerIDs(ids ...string) *GroupUpdateOne { + guo.mutation.RemoveNarrativeViewerIDs(ids...) + return guo +} + +// RemoveNarrativeViewers removes "narrative_viewers" edges to Narrative entities. +func (guo *GroupUpdateOne) RemoveNarrativeViewers(n ...*Narrative) *GroupUpdateOne { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return guo.RemoveNarrativeViewerIDs(ids...) +} + +// ClearNarrativeEditors clears all "narrative_editors" edges to the Narrative entity. +func (guo *GroupUpdateOne) ClearNarrativeEditors() *GroupUpdateOne { + guo.mutation.ClearNarrativeEditors() + return guo +} + +// RemoveNarrativeEditorIDs removes the "narrative_editors" edge to Narrative entities by IDs. +func (guo *GroupUpdateOne) RemoveNarrativeEditorIDs(ids ...string) *GroupUpdateOne { + guo.mutation.RemoveNarrativeEditorIDs(ids...) + return guo +} + +// RemoveNarrativeEditors removes "narrative_editors" edges to Narrative entities. +func (guo *GroupUpdateOne) RemoveNarrativeEditors(n ...*Narrative) *GroupUpdateOne { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return guo.RemoveNarrativeEditorIDs(ids...) +} + +// ClearNarrativeBlockedGroups clears all "narrative_blocked_groups" edges to the Narrative entity. +func (guo *GroupUpdateOne) ClearNarrativeBlockedGroups() *GroupUpdateOne { + guo.mutation.ClearNarrativeBlockedGroups() + return guo +} + +// RemoveNarrativeBlockedGroupIDs removes the "narrative_blocked_groups" edge to Narrative entities by IDs. +func (guo *GroupUpdateOne) RemoveNarrativeBlockedGroupIDs(ids ...string) *GroupUpdateOne { + guo.mutation.RemoveNarrativeBlockedGroupIDs(ids...) + return guo +} + +// RemoveNarrativeBlockedGroups removes "narrative_blocked_groups" edges to Narrative entities. +func (guo *GroupUpdateOne) RemoveNarrativeBlockedGroups(n ...*Narrative) *GroupUpdateOne { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return guo.RemoveNarrativeBlockedGroupIDs(ids...) +} + // ClearMembers clears all "members" edges to the GroupMembership entity. func (guo *GroupUpdateOne) ClearMembers() *GroupUpdateOne { guo.mutation.ClearMembers() @@ -4167,6 +4528,150 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if guo.mutation.NarrativeViewersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeViewersTable, + Columns: group.NarrativeViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = guo.schemaConfig.NarrativeViewers + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := guo.mutation.RemovedNarrativeViewersIDs(); len(nodes) > 0 && !guo.mutation.NarrativeViewersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeViewersTable, + Columns: group.NarrativeViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = guo.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := guo.mutation.NarrativeViewersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeViewersTable, + Columns: group.NarrativeViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = guo.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if guo.mutation.NarrativeEditorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeEditorsTable, + Columns: group.NarrativeEditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = guo.schemaConfig.NarrativeEditors + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := guo.mutation.RemovedNarrativeEditorsIDs(); len(nodes) > 0 && !guo.mutation.NarrativeEditorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeEditorsTable, + Columns: group.NarrativeEditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = guo.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := guo.mutation.NarrativeEditorsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeEditorsTable, + Columns: group.NarrativeEditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = guo.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if guo.mutation.NarrativeBlockedGroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeBlockedGroupsTable, + Columns: group.NarrativeBlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = guo.schemaConfig.NarrativeBlockedGroups + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := guo.mutation.RemovedNarrativeBlockedGroupsIDs(); len(nodes) > 0 && !guo.mutation.NarrativeBlockedGroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeBlockedGroupsTable, + Columns: group.NarrativeBlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = guo.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := guo.mutation.NarrativeBlockedGroupsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: group.NarrativeBlockedGroupsTable, + Columns: group.NarrativeBlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = guo.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if guo.mutation.MembersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/internal/ent/generated/history_from_mutation.go b/internal/ent/generated/history_from_mutation.go index 842a04d7..fea97a07 100644 --- a/internal/ent/generated/history_from_mutation.go +++ b/internal/ent/generated/history_from_mutation.go @@ -4802,6 +4802,10 @@ func (m *NarrativeMutation) CreateHistoryFromCreate(ctx context.Context) error { create = create.SetTags(tags) } + if ownerID, exists := m.OwnerID(); exists { + create = create.SetOwnerID(ownerID) + } + if name, exists := m.Name(); exists { create = create.SetName(name) } @@ -4896,6 +4900,12 @@ func (m *NarrativeMutation) CreateHistoryFromUpdate(ctx context.Context) error { create = create.SetTags(narrative.Tags) } + if ownerID, exists := m.OwnerID(); exists { + create = create.SetOwnerID(ownerID) + } else { + create = create.SetOwnerID(narrative.OwnerID) + } + if name, exists := m.Name(); exists { create = create.SetName(name) } else { @@ -4960,6 +4970,7 @@ func (m *NarrativeMutation) CreateHistoryFromDelete(ctx context.Context) error { SetDeletedBy(narrative.DeletedBy). SetMappingID(narrative.MappingID). SetTags(narrative.Tags). + SetOwnerID(narrative.OwnerID). SetName(narrative.Name). SetDescription(narrative.Description). SetSatisfies(narrative.Satisfies). diff --git a/internal/ent/generated/internal/schemaconfig.go b/internal/ent/generated/internal/schemaconfig.go index 177a6703..0f8c7965 100644 --- a/internal/ent/generated/internal/schemaconfig.go +++ b/internal/ent/generated/internal/schemaconfig.go @@ -86,6 +86,9 @@ type SchemaConfig struct { Invite string // Invite table. InviteEvents string // Invite-events->Event table. Narrative string // Narrative table. + NarrativeBlockedGroups string // Narrative-blocked_groups->Group table. + NarrativeEditors string // Narrative-editors->Group table. + NarrativeViewers string // Narrative-viewers->Group table. NarrativeHistory string // NarrativeHistory table. Note string // Note table. NoteHistory string // NoteHistory table. diff --git a/internal/ent/generated/migrate/schema.go b/internal/ent/generated/migrate/schema.go index aeef73ce..25c94566 100644 --- a/internal/ent/generated/migrate/schema.go +++ b/internal/ent/generated/migrate/schema.go @@ -1551,12 +1551,21 @@ var ( {Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "satisfies", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "details", Type: field.TypeJSON, Nullable: true}, + {Name: "owner_id", Type: field.TypeString}, } // NarrativesTable holds the schema information for the "narratives" table. NarrativesTable = &schema.Table{ Name: "narratives", Columns: NarrativesColumns, PrimaryKey: []*schema.Column{NarrativesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "narratives_organizations_narratives", + Columns: []*schema.Column{NarrativesColumns[13]}, + RefColumns: []*schema.Column{OrganizationsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, } // NarrativeHistoryColumns holds the columns for the "narrative_history" table. NarrativeHistoryColumns = []*schema.Column{ @@ -1572,6 +1581,7 @@ var ( {Name: "deleted_by", Type: field.TypeString, Nullable: true}, {Name: "mapping_id", Type: field.TypeString}, {Name: "tags", Type: field.TypeJSON, Nullable: true}, + {Name: "owner_id", Type: field.TypeString}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "satisfies", Type: field.TypeString, Nullable: true, Size: 2147483647}, @@ -3992,6 +4002,81 @@ var ( }, }, } + // NarrativeBlockedGroupsColumns holds the columns for the "narrative_blocked_groups" table. + NarrativeBlockedGroupsColumns = []*schema.Column{ + {Name: "narrative_id", Type: field.TypeString}, + {Name: "group_id", Type: field.TypeString}, + } + // NarrativeBlockedGroupsTable holds the schema information for the "narrative_blocked_groups" table. + NarrativeBlockedGroupsTable = &schema.Table{ + Name: "narrative_blocked_groups", + Columns: NarrativeBlockedGroupsColumns, + PrimaryKey: []*schema.Column{NarrativeBlockedGroupsColumns[0], NarrativeBlockedGroupsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "narrative_blocked_groups_narrative_id", + Columns: []*schema.Column{NarrativeBlockedGroupsColumns[0]}, + RefColumns: []*schema.Column{NarrativesColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "narrative_blocked_groups_group_id", + Columns: []*schema.Column{NarrativeBlockedGroupsColumns[1]}, + RefColumns: []*schema.Column{GroupsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // NarrativeEditorsColumns holds the columns for the "narrative_editors" table. + NarrativeEditorsColumns = []*schema.Column{ + {Name: "narrative_id", Type: field.TypeString}, + {Name: "group_id", Type: field.TypeString}, + } + // NarrativeEditorsTable holds the schema information for the "narrative_editors" table. + NarrativeEditorsTable = &schema.Table{ + Name: "narrative_editors", + Columns: NarrativeEditorsColumns, + PrimaryKey: []*schema.Column{NarrativeEditorsColumns[0], NarrativeEditorsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "narrative_editors_narrative_id", + Columns: []*schema.Column{NarrativeEditorsColumns[0]}, + RefColumns: []*schema.Column{NarrativesColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "narrative_editors_group_id", + Columns: []*schema.Column{NarrativeEditorsColumns[1]}, + RefColumns: []*schema.Column{GroupsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // NarrativeViewersColumns holds the columns for the "narrative_viewers" table. + NarrativeViewersColumns = []*schema.Column{ + {Name: "narrative_id", Type: field.TypeString}, + {Name: "group_id", Type: field.TypeString}, + } + // NarrativeViewersTable holds the schema information for the "narrative_viewers" table. + NarrativeViewersTable = &schema.Table{ + Name: "narrative_viewers", + Columns: NarrativeViewersColumns, + PrimaryKey: []*schema.Column{NarrativeViewersColumns[0], NarrativeViewersColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "narrative_viewers_narrative_id", + Columns: []*schema.Column{NarrativeViewersColumns[0]}, + RefColumns: []*schema.Column{NarrativesColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "narrative_viewers_group_id", + Columns: []*schema.Column{NarrativeViewersColumns[1]}, + RefColumns: []*schema.Column{GroupsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } // OhAuthTooTokenEventsColumns holds the columns for the "oh_auth_too_token_events" table. OhAuthTooTokenEventsColumns = []*schema.Column{ {Name: "oh_auth_too_token_id", Type: field.TypeString}, @@ -5237,6 +5322,9 @@ var ( InternalPolicyNarrativesTable, InternalPolicyTasksTable, InviteEventsTable, + NarrativeBlockedGroupsTable, + NarrativeEditorsTable, + NarrativeViewersTable, OhAuthTooTokenEventsTable, OrgMembershipEventsTable, OrganizationPersonalAccessTokensTable, @@ -5372,6 +5460,7 @@ func init() { Table: "internal_policy_history", } InvitesTable.ForeignKeys[0].RefTable = OrganizationsTable + NarrativesTable.ForeignKeys[0].RefTable = OrganizationsTable NarrativeHistoryTable.Annotation = &entsql.Annotation{ Table: "narrative_history", } @@ -5526,6 +5615,12 @@ func init() { InternalPolicyTasksTable.ForeignKeys[1].RefTable = TasksTable InviteEventsTable.ForeignKeys[0].RefTable = InvitesTable InviteEventsTable.ForeignKeys[1].RefTable = EventsTable + NarrativeBlockedGroupsTable.ForeignKeys[0].RefTable = NarrativesTable + NarrativeBlockedGroupsTable.ForeignKeys[1].RefTable = GroupsTable + NarrativeEditorsTable.ForeignKeys[0].RefTable = NarrativesTable + NarrativeEditorsTable.ForeignKeys[1].RefTable = GroupsTable + NarrativeViewersTable.ForeignKeys[0].RefTable = NarrativesTable + NarrativeViewersTable.ForeignKeys[1].RefTable = GroupsTable OhAuthTooTokenEventsTable.ForeignKeys[0].RefTable = OhAuthTooTokensTable OhAuthTooTokenEventsTable.ForeignKeys[1].RefTable = EventsTable OrgMembershipEventsTable.ForeignKeys[0].RefTable = OrgMembershipsTable diff --git a/internal/ent/generated/mutation.go b/internal/ent/generated/mutation.go index f52d974b..f56ad721 100644 --- a/internal/ent/generated/mutation.go +++ b/internal/ent/generated/mutation.go @@ -48040,6 +48040,15 @@ type GroupMutation struct { controlobjective_blocked_groups map[string]struct{} removedcontrolobjective_blocked_groups map[string]struct{} clearedcontrolobjective_blocked_groups bool + narrative_viewers map[string]struct{} + removednarrative_viewers map[string]struct{} + clearednarrative_viewers bool + narrative_editors map[string]struct{} + removednarrative_editors map[string]struct{} + clearednarrative_editors bool + narrative_blocked_groups map[string]struct{} + removednarrative_blocked_groups map[string]struct{} + clearednarrative_blocked_groups bool members map[string]struct{} removedmembers map[string]struct{} clearedmembers bool @@ -49853,6 +49862,168 @@ func (m *GroupMutation) ResetControlobjectiveBlockedGroups() { m.removedcontrolobjective_blocked_groups = nil } +// AddNarrativeViewerIDs adds the "narrative_viewers" edge to the Narrative entity by ids. +func (m *GroupMutation) AddNarrativeViewerIDs(ids ...string) { + if m.narrative_viewers == nil { + m.narrative_viewers = make(map[string]struct{}) + } + for i := range ids { + m.narrative_viewers[ids[i]] = struct{}{} + } +} + +// ClearNarrativeViewers clears the "narrative_viewers" edge to the Narrative entity. +func (m *GroupMutation) ClearNarrativeViewers() { + m.clearednarrative_viewers = true +} + +// NarrativeViewersCleared reports if the "narrative_viewers" edge to the Narrative entity was cleared. +func (m *GroupMutation) NarrativeViewersCleared() bool { + return m.clearednarrative_viewers +} + +// RemoveNarrativeViewerIDs removes the "narrative_viewers" edge to the Narrative entity by IDs. +func (m *GroupMutation) RemoveNarrativeViewerIDs(ids ...string) { + if m.removednarrative_viewers == nil { + m.removednarrative_viewers = make(map[string]struct{}) + } + for i := range ids { + delete(m.narrative_viewers, ids[i]) + m.removednarrative_viewers[ids[i]] = struct{}{} + } +} + +// RemovedNarrativeViewers returns the removed IDs of the "narrative_viewers" edge to the Narrative entity. +func (m *GroupMutation) RemovedNarrativeViewersIDs() (ids []string) { + for id := range m.removednarrative_viewers { + ids = append(ids, id) + } + return +} + +// NarrativeViewersIDs returns the "narrative_viewers" edge IDs in the mutation. +func (m *GroupMutation) NarrativeViewersIDs() (ids []string) { + for id := range m.narrative_viewers { + ids = append(ids, id) + } + return +} + +// ResetNarrativeViewers resets all changes to the "narrative_viewers" edge. +func (m *GroupMutation) ResetNarrativeViewers() { + m.narrative_viewers = nil + m.clearednarrative_viewers = false + m.removednarrative_viewers = nil +} + +// AddNarrativeEditorIDs adds the "narrative_editors" edge to the Narrative entity by ids. +func (m *GroupMutation) AddNarrativeEditorIDs(ids ...string) { + if m.narrative_editors == nil { + m.narrative_editors = make(map[string]struct{}) + } + for i := range ids { + m.narrative_editors[ids[i]] = struct{}{} + } +} + +// ClearNarrativeEditors clears the "narrative_editors" edge to the Narrative entity. +func (m *GroupMutation) ClearNarrativeEditors() { + m.clearednarrative_editors = true +} + +// NarrativeEditorsCleared reports if the "narrative_editors" edge to the Narrative entity was cleared. +func (m *GroupMutation) NarrativeEditorsCleared() bool { + return m.clearednarrative_editors +} + +// RemoveNarrativeEditorIDs removes the "narrative_editors" edge to the Narrative entity by IDs. +func (m *GroupMutation) RemoveNarrativeEditorIDs(ids ...string) { + if m.removednarrative_editors == nil { + m.removednarrative_editors = make(map[string]struct{}) + } + for i := range ids { + delete(m.narrative_editors, ids[i]) + m.removednarrative_editors[ids[i]] = struct{}{} + } +} + +// RemovedNarrativeEditors returns the removed IDs of the "narrative_editors" edge to the Narrative entity. +func (m *GroupMutation) RemovedNarrativeEditorsIDs() (ids []string) { + for id := range m.removednarrative_editors { + ids = append(ids, id) + } + return +} + +// NarrativeEditorsIDs returns the "narrative_editors" edge IDs in the mutation. +func (m *GroupMutation) NarrativeEditorsIDs() (ids []string) { + for id := range m.narrative_editors { + ids = append(ids, id) + } + return +} + +// ResetNarrativeEditors resets all changes to the "narrative_editors" edge. +func (m *GroupMutation) ResetNarrativeEditors() { + m.narrative_editors = nil + m.clearednarrative_editors = false + m.removednarrative_editors = nil +} + +// AddNarrativeBlockedGroupIDs adds the "narrative_blocked_groups" edge to the Narrative entity by ids. +func (m *GroupMutation) AddNarrativeBlockedGroupIDs(ids ...string) { + if m.narrative_blocked_groups == nil { + m.narrative_blocked_groups = make(map[string]struct{}) + } + for i := range ids { + m.narrative_blocked_groups[ids[i]] = struct{}{} + } +} + +// ClearNarrativeBlockedGroups clears the "narrative_blocked_groups" edge to the Narrative entity. +func (m *GroupMutation) ClearNarrativeBlockedGroups() { + m.clearednarrative_blocked_groups = true +} + +// NarrativeBlockedGroupsCleared reports if the "narrative_blocked_groups" edge to the Narrative entity was cleared. +func (m *GroupMutation) NarrativeBlockedGroupsCleared() bool { + return m.clearednarrative_blocked_groups +} + +// RemoveNarrativeBlockedGroupIDs removes the "narrative_blocked_groups" edge to the Narrative entity by IDs. +func (m *GroupMutation) RemoveNarrativeBlockedGroupIDs(ids ...string) { + if m.removednarrative_blocked_groups == nil { + m.removednarrative_blocked_groups = make(map[string]struct{}) + } + for i := range ids { + delete(m.narrative_blocked_groups, ids[i]) + m.removednarrative_blocked_groups[ids[i]] = struct{}{} + } +} + +// RemovedNarrativeBlockedGroups returns the removed IDs of the "narrative_blocked_groups" edge to the Narrative entity. +func (m *GroupMutation) RemovedNarrativeBlockedGroupsIDs() (ids []string) { + for id := range m.removednarrative_blocked_groups { + ids = append(ids, id) + } + return +} + +// NarrativeBlockedGroupsIDs returns the "narrative_blocked_groups" edge IDs in the mutation. +func (m *GroupMutation) NarrativeBlockedGroupsIDs() (ids []string) { + for id := range m.narrative_blocked_groups { + ids = append(ids, id) + } + return +} + +// ResetNarrativeBlockedGroups resets all changes to the "narrative_blocked_groups" edge. +func (m *GroupMutation) ResetNarrativeBlockedGroups() { + m.narrative_blocked_groups = nil + m.clearednarrative_blocked_groups = false + m.removednarrative_blocked_groups = nil +} + // AddMemberIDs adds the "members" edge to the GroupMembership entity by ids. func (m *GroupMutation) AddMemberIDs(ids ...string) { if m.members == nil { @@ -50330,7 +50501,7 @@ func (m *GroupMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *GroupMutation) AddedEdges() []string { - edges := make([]string, 0, 21) + edges := make([]string, 0, 24) if m.owner != nil { edges = append(edges, group.EdgeOwner) } @@ -50391,6 +50562,15 @@ func (m *GroupMutation) AddedEdges() []string { if m.controlobjective_blocked_groups != nil { edges = append(edges, group.EdgeControlobjectiveBlockedGroups) } + if m.narrative_viewers != nil { + edges = append(edges, group.EdgeNarrativeViewers) + } + if m.narrative_editors != nil { + edges = append(edges, group.EdgeNarrativeEditors) + } + if m.narrative_blocked_groups != nil { + edges = append(edges, group.EdgeNarrativeBlockedGroups) + } if m.members != nil { edges = append(edges, group.EdgeMembers) } @@ -50517,6 +50697,24 @@ func (m *GroupMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case group.EdgeNarrativeViewers: + ids := make([]ent.Value, 0, len(m.narrative_viewers)) + for id := range m.narrative_viewers { + ids = append(ids, id) + } + return ids + case group.EdgeNarrativeEditors: + ids := make([]ent.Value, 0, len(m.narrative_editors)) + for id := range m.narrative_editors { + ids = append(ids, id) + } + return ids + case group.EdgeNarrativeBlockedGroups: + ids := make([]ent.Value, 0, len(m.narrative_blocked_groups)) + for id := range m.narrative_blocked_groups { + ids = append(ids, id) + } + return ids case group.EdgeMembers: ids := make([]ent.Value, 0, len(m.members)) for id := range m.members { @@ -50529,7 +50727,7 @@ func (m *GroupMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *GroupMutation) RemovedEdges() []string { - edges := make([]string, 0, 21) + edges := make([]string, 0, 24) if m.removedusers != nil { edges = append(edges, group.EdgeUsers) } @@ -50584,6 +50782,15 @@ func (m *GroupMutation) RemovedEdges() []string { if m.removedcontrolobjective_blocked_groups != nil { edges = append(edges, group.EdgeControlobjectiveBlockedGroups) } + if m.removednarrative_viewers != nil { + edges = append(edges, group.EdgeNarrativeViewers) + } + if m.removednarrative_editors != nil { + edges = append(edges, group.EdgeNarrativeEditors) + } + if m.removednarrative_blocked_groups != nil { + edges = append(edges, group.EdgeNarrativeBlockedGroups) + } if m.removedmembers != nil { edges = append(edges, group.EdgeMembers) } @@ -50702,6 +50909,24 @@ func (m *GroupMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case group.EdgeNarrativeViewers: + ids := make([]ent.Value, 0, len(m.removednarrative_viewers)) + for id := range m.removednarrative_viewers { + ids = append(ids, id) + } + return ids + case group.EdgeNarrativeEditors: + ids := make([]ent.Value, 0, len(m.removednarrative_editors)) + for id := range m.removednarrative_editors { + ids = append(ids, id) + } + return ids + case group.EdgeNarrativeBlockedGroups: + ids := make([]ent.Value, 0, len(m.removednarrative_blocked_groups)) + for id := range m.removednarrative_blocked_groups { + ids = append(ids, id) + } + return ids case group.EdgeMembers: ids := make([]ent.Value, 0, len(m.removedmembers)) for id := range m.removedmembers { @@ -50714,7 +50939,7 @@ func (m *GroupMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *GroupMutation) ClearedEdges() []string { - edges := make([]string, 0, 21) + edges := make([]string, 0, 24) if m.clearedowner { edges = append(edges, group.EdgeOwner) } @@ -50775,6 +51000,15 @@ func (m *GroupMutation) ClearedEdges() []string { if m.clearedcontrolobjective_blocked_groups { edges = append(edges, group.EdgeControlobjectiveBlockedGroups) } + if m.clearednarrative_viewers { + edges = append(edges, group.EdgeNarrativeViewers) + } + if m.clearednarrative_editors { + edges = append(edges, group.EdgeNarrativeEditors) + } + if m.clearednarrative_blocked_groups { + edges = append(edges, group.EdgeNarrativeBlockedGroups) + } if m.clearedmembers { edges = append(edges, group.EdgeMembers) } @@ -50825,6 +51059,12 @@ func (m *GroupMutation) EdgeCleared(name string) bool { return m.clearedcontrolobjective_editors case group.EdgeControlobjectiveBlockedGroups: return m.clearedcontrolobjective_blocked_groups + case group.EdgeNarrativeViewers: + return m.clearednarrative_viewers + case group.EdgeNarrativeEditors: + return m.clearednarrative_editors + case group.EdgeNarrativeBlockedGroups: + return m.clearednarrative_blocked_groups case group.EdgeMembers: return m.clearedmembers } @@ -50909,6 +51149,15 @@ func (m *GroupMutation) ResetEdge(name string) error { case group.EdgeControlobjectiveBlockedGroups: m.ResetControlobjectiveBlockedGroups() return nil + case group.EdgeNarrativeViewers: + m.ResetNarrativeViewers() + return nil + case group.EdgeNarrativeEditors: + m.ResetNarrativeEditors() + return nil + case group.EdgeNarrativeBlockedGroups: + m.ResetNarrativeBlockedGroups() + return nil case group.EdgeMembers: m.ResetMembers() return nil @@ -68144,6 +68393,17 @@ type NarrativeMutation struct { satisfies *string details *map[string]interface{} clearedFields map[string]struct{} + owner *string + clearedowner bool + blocked_groups map[string]struct{} + removedblocked_groups map[string]struct{} + clearedblocked_groups bool + editors map[string]struct{} + removededitors map[string]struct{} + clearededitors bool + viewers map[string]struct{} + removedviewers map[string]struct{} + clearedviewers bool policy map[string]struct{} removedpolicy map[string]struct{} clearedpolicy bool @@ -68156,9 +68416,9 @@ type NarrativeMutation struct { controlobjective map[string]struct{} removedcontrolobjective map[string]struct{} clearedcontrolobjective bool - program map[string]struct{} - removedprogram map[string]struct{} - clearedprogram bool + programs map[string]struct{} + removedprograms map[string]struct{} + clearedprograms bool done bool oldValue func(context.Context) (*Narrative, error) predicates []predicate.Narrative @@ -68663,6 +68923,42 @@ func (m *NarrativeMutation) ResetTags() { delete(m.clearedFields, narrative.FieldTags) } +// SetOwnerID sets the "owner_id" field. +func (m *NarrativeMutation) SetOwnerID(s string) { + m.owner = &s +} + +// OwnerID returns the value of the "owner_id" field in the mutation. +func (m *NarrativeMutation) OwnerID() (r string, exists bool) { + v := m.owner + if v == nil { + return + } + return *v, true +} + +// OldOwnerID returns the old "owner_id" field's value of the Narrative entity. +// If the Narrative 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 *NarrativeMutation) OldOwnerID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOwnerID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOwnerID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOwnerID: %w", err) + } + return oldValue.OwnerID, nil +} + +// ResetOwnerID resets all changes to the "owner_id" field. +func (m *NarrativeMutation) ResetOwnerID() { + m.owner = nil +} + // SetName sets the "name" field. func (m *NarrativeMutation) SetName(s string) { m.name = &s @@ -68846,6 +69142,195 @@ func (m *NarrativeMutation) ResetDetails() { delete(m.clearedFields, narrative.FieldDetails) } +// ClearOwner clears the "owner" edge to the Organization entity. +func (m *NarrativeMutation) ClearOwner() { + m.clearedowner = true + m.clearedFields[narrative.FieldOwnerID] = struct{}{} +} + +// OwnerCleared reports if the "owner" edge to the Organization entity was cleared. +func (m *NarrativeMutation) OwnerCleared() bool { + return m.clearedowner +} + +// OwnerIDs returns the "owner" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OwnerID instead. It exists only for internal usage by the builders. +func (m *NarrativeMutation) OwnerIDs() (ids []string) { + if id := m.owner; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOwner resets all changes to the "owner" edge. +func (m *NarrativeMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false +} + +// AddBlockedGroupIDs adds the "blocked_groups" edge to the Group entity by ids. +func (m *NarrativeMutation) AddBlockedGroupIDs(ids ...string) { + if m.blocked_groups == nil { + m.blocked_groups = make(map[string]struct{}) + } + for i := range ids { + m.blocked_groups[ids[i]] = struct{}{} + } +} + +// ClearBlockedGroups clears the "blocked_groups" edge to the Group entity. +func (m *NarrativeMutation) ClearBlockedGroups() { + m.clearedblocked_groups = true +} + +// BlockedGroupsCleared reports if the "blocked_groups" edge to the Group entity was cleared. +func (m *NarrativeMutation) BlockedGroupsCleared() bool { + return m.clearedblocked_groups +} + +// RemoveBlockedGroupIDs removes the "blocked_groups" edge to the Group entity by IDs. +func (m *NarrativeMutation) RemoveBlockedGroupIDs(ids ...string) { + if m.removedblocked_groups == nil { + m.removedblocked_groups = make(map[string]struct{}) + } + for i := range ids { + delete(m.blocked_groups, ids[i]) + m.removedblocked_groups[ids[i]] = struct{}{} + } +} + +// RemovedBlockedGroups returns the removed IDs of the "blocked_groups" edge to the Group entity. +func (m *NarrativeMutation) RemovedBlockedGroupsIDs() (ids []string) { + for id := range m.removedblocked_groups { + ids = append(ids, id) + } + return +} + +// BlockedGroupsIDs returns the "blocked_groups" edge IDs in the mutation. +func (m *NarrativeMutation) BlockedGroupsIDs() (ids []string) { + for id := range m.blocked_groups { + ids = append(ids, id) + } + return +} + +// ResetBlockedGroups resets all changes to the "blocked_groups" edge. +func (m *NarrativeMutation) ResetBlockedGroups() { + m.blocked_groups = nil + m.clearedblocked_groups = false + m.removedblocked_groups = nil +} + +// AddEditorIDs adds the "editors" edge to the Group entity by ids. +func (m *NarrativeMutation) AddEditorIDs(ids ...string) { + if m.editors == nil { + m.editors = make(map[string]struct{}) + } + for i := range ids { + m.editors[ids[i]] = struct{}{} + } +} + +// ClearEditors clears the "editors" edge to the Group entity. +func (m *NarrativeMutation) ClearEditors() { + m.clearededitors = true +} + +// EditorsCleared reports if the "editors" edge to the Group entity was cleared. +func (m *NarrativeMutation) EditorsCleared() bool { + return m.clearededitors +} + +// RemoveEditorIDs removes the "editors" edge to the Group entity by IDs. +func (m *NarrativeMutation) RemoveEditorIDs(ids ...string) { + if m.removededitors == nil { + m.removededitors = make(map[string]struct{}) + } + for i := range ids { + delete(m.editors, ids[i]) + m.removededitors[ids[i]] = struct{}{} + } +} + +// RemovedEditors returns the removed IDs of the "editors" edge to the Group entity. +func (m *NarrativeMutation) RemovedEditorsIDs() (ids []string) { + for id := range m.removededitors { + ids = append(ids, id) + } + return +} + +// EditorsIDs returns the "editors" edge IDs in the mutation. +func (m *NarrativeMutation) EditorsIDs() (ids []string) { + for id := range m.editors { + ids = append(ids, id) + } + return +} + +// ResetEditors resets all changes to the "editors" edge. +func (m *NarrativeMutation) ResetEditors() { + m.editors = nil + m.clearededitors = false + m.removededitors = nil +} + +// AddViewerIDs adds the "viewers" edge to the Group entity by ids. +func (m *NarrativeMutation) AddViewerIDs(ids ...string) { + if m.viewers == nil { + m.viewers = make(map[string]struct{}) + } + for i := range ids { + m.viewers[ids[i]] = struct{}{} + } +} + +// ClearViewers clears the "viewers" edge to the Group entity. +func (m *NarrativeMutation) ClearViewers() { + m.clearedviewers = true +} + +// ViewersCleared reports if the "viewers" edge to the Group entity was cleared. +func (m *NarrativeMutation) ViewersCleared() bool { + return m.clearedviewers +} + +// RemoveViewerIDs removes the "viewers" edge to the Group entity by IDs. +func (m *NarrativeMutation) RemoveViewerIDs(ids ...string) { + if m.removedviewers == nil { + m.removedviewers = make(map[string]struct{}) + } + for i := range ids { + delete(m.viewers, ids[i]) + m.removedviewers[ids[i]] = struct{}{} + } +} + +// RemovedViewers returns the removed IDs of the "viewers" edge to the Group entity. +func (m *NarrativeMutation) RemovedViewersIDs() (ids []string) { + for id := range m.removedviewers { + ids = append(ids, id) + } + return +} + +// ViewersIDs returns the "viewers" edge IDs in the mutation. +func (m *NarrativeMutation) ViewersIDs() (ids []string) { + for id := range m.viewers { + ids = append(ids, id) + } + return +} + +// ResetViewers resets all changes to the "viewers" edge. +func (m *NarrativeMutation) ResetViewers() { + m.viewers = nil + m.clearedviewers = false + m.removedviewers = nil +} + // AddPolicyIDs adds the "policy" edge to the InternalPolicy entity by ids. func (m *NarrativeMutation) AddPolicyIDs(ids ...string) { if m.policy == nil { @@ -69062,58 +69547,58 @@ func (m *NarrativeMutation) ResetControlobjective() { m.removedcontrolobjective = nil } -// AddProgramIDs adds the "program" edge to the Program entity by ids. +// AddProgramIDs adds the "programs" edge to the Program entity by ids. func (m *NarrativeMutation) AddProgramIDs(ids ...string) { - if m.program == nil { - m.program = make(map[string]struct{}) + if m.programs == nil { + m.programs = make(map[string]struct{}) } for i := range ids { - m.program[ids[i]] = struct{}{} + m.programs[ids[i]] = struct{}{} } } -// ClearProgram clears the "program" edge to the Program entity. -func (m *NarrativeMutation) ClearProgram() { - m.clearedprogram = true +// ClearPrograms clears the "programs" edge to the Program entity. +func (m *NarrativeMutation) ClearPrograms() { + m.clearedprograms = true } -// ProgramCleared reports if the "program" edge to the Program entity was cleared. -func (m *NarrativeMutation) ProgramCleared() bool { - return m.clearedprogram +// ProgramsCleared reports if the "programs" edge to the Program entity was cleared. +func (m *NarrativeMutation) ProgramsCleared() bool { + return m.clearedprograms } -// RemoveProgramIDs removes the "program" edge to the Program entity by IDs. +// RemoveProgramIDs removes the "programs" edge to the Program entity by IDs. func (m *NarrativeMutation) RemoveProgramIDs(ids ...string) { - if m.removedprogram == nil { - m.removedprogram = make(map[string]struct{}) + if m.removedprograms == nil { + m.removedprograms = make(map[string]struct{}) } for i := range ids { - delete(m.program, ids[i]) - m.removedprogram[ids[i]] = struct{}{} + delete(m.programs, ids[i]) + m.removedprograms[ids[i]] = struct{}{} } } -// RemovedProgram returns the removed IDs of the "program" edge to the Program entity. -func (m *NarrativeMutation) RemovedProgramIDs() (ids []string) { - for id := range m.removedprogram { +// RemovedPrograms returns the removed IDs of the "programs" edge to the Program entity. +func (m *NarrativeMutation) RemovedProgramsIDs() (ids []string) { + for id := range m.removedprograms { ids = append(ids, id) } return } -// ProgramIDs returns the "program" edge IDs in the mutation. -func (m *NarrativeMutation) ProgramIDs() (ids []string) { - for id := range m.program { +// ProgramsIDs returns the "programs" edge IDs in the mutation. +func (m *NarrativeMutation) ProgramsIDs() (ids []string) { + for id := range m.programs { ids = append(ids, id) } return } -// ResetProgram resets all changes to the "program" edge. -func (m *NarrativeMutation) ResetProgram() { - m.program = nil - m.clearedprogram = false - m.removedprogram = nil +// ResetPrograms resets all changes to the "programs" edge. +func (m *NarrativeMutation) ResetPrograms() { + m.programs = nil + m.clearedprograms = false + m.removedprograms = nil } // Where appends a list predicates to the NarrativeMutation builder. @@ -69150,7 +69635,7 @@ func (m *NarrativeMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *NarrativeMutation) Fields() []string { - fields := make([]string, 0, 12) + fields := make([]string, 0, 13) if m.created_at != nil { fields = append(fields, narrative.FieldCreatedAt) } @@ -69175,6 +69660,9 @@ func (m *NarrativeMutation) Fields() []string { if m.tags != nil { fields = append(fields, narrative.FieldTags) } + if m.owner != nil { + fields = append(fields, narrative.FieldOwnerID) + } if m.name != nil { fields = append(fields, narrative.FieldName) } @@ -69211,6 +69699,8 @@ func (m *NarrativeMutation) Field(name string) (ent.Value, bool) { return m.MappingID() case narrative.FieldTags: return m.Tags() + case narrative.FieldOwnerID: + return m.OwnerID() case narrative.FieldName: return m.Name() case narrative.FieldDescription: @@ -69244,6 +69734,8 @@ func (m *NarrativeMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldMappingID(ctx) case narrative.FieldTags: return m.OldTags(ctx) + case narrative.FieldOwnerID: + return m.OldOwnerID(ctx) case narrative.FieldName: return m.OldName(ctx) case narrative.FieldDescription: @@ -69317,6 +69809,13 @@ func (m *NarrativeMutation) SetField(name string, value ent.Value) error { } m.SetTags(v) return nil + case narrative.FieldOwnerID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOwnerID(v) + return nil case narrative.FieldName: v, ok := value.(string) if !ok { @@ -69481,6 +69980,9 @@ func (m *NarrativeMutation) ResetField(name string) error { case narrative.FieldTags: m.ResetTags() return nil + case narrative.FieldOwnerID: + m.ResetOwnerID() + return nil case narrative.FieldName: m.ResetName() return nil @@ -69499,7 +70001,19 @@ func (m *NarrativeMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *NarrativeMutation) AddedEdges() []string { - edges := make([]string, 0, 5) + edges := make([]string, 0, 9) + if m.owner != nil { + edges = append(edges, narrative.EdgeOwner) + } + if m.blocked_groups != nil { + edges = append(edges, narrative.EdgeBlockedGroups) + } + if m.editors != nil { + edges = append(edges, narrative.EdgeEditors) + } + if m.viewers != nil { + edges = append(edges, narrative.EdgeViewers) + } if m.policy != nil { edges = append(edges, narrative.EdgePolicy) } @@ -69512,8 +70026,8 @@ func (m *NarrativeMutation) AddedEdges() []string { if m.controlobjective != nil { edges = append(edges, narrative.EdgeControlobjective) } - if m.program != nil { - edges = append(edges, narrative.EdgeProgram) + if m.programs != nil { + edges = append(edges, narrative.EdgePrograms) } return edges } @@ -69522,6 +70036,28 @@ func (m *NarrativeMutation) AddedEdges() []string { // name in this mutation. func (m *NarrativeMutation) AddedIDs(name string) []ent.Value { switch name { + case narrative.EdgeOwner: + if id := m.owner; id != nil { + return []ent.Value{*id} + } + case narrative.EdgeBlockedGroups: + ids := make([]ent.Value, 0, len(m.blocked_groups)) + for id := range m.blocked_groups { + ids = append(ids, id) + } + return ids + case narrative.EdgeEditors: + ids := make([]ent.Value, 0, len(m.editors)) + for id := range m.editors { + ids = append(ids, id) + } + return ids + case narrative.EdgeViewers: + ids := make([]ent.Value, 0, len(m.viewers)) + for id := range m.viewers { + ids = append(ids, id) + } + return ids case narrative.EdgePolicy: ids := make([]ent.Value, 0, len(m.policy)) for id := range m.policy { @@ -69546,9 +70082,9 @@ func (m *NarrativeMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case narrative.EdgeProgram: - ids := make([]ent.Value, 0, len(m.program)) - for id := range m.program { + case narrative.EdgePrograms: + ids := make([]ent.Value, 0, len(m.programs)) + for id := range m.programs { ids = append(ids, id) } return ids @@ -69558,7 +70094,16 @@ func (m *NarrativeMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *NarrativeMutation) RemovedEdges() []string { - edges := make([]string, 0, 5) + edges := make([]string, 0, 9) + if m.removedblocked_groups != nil { + edges = append(edges, narrative.EdgeBlockedGroups) + } + if m.removededitors != nil { + edges = append(edges, narrative.EdgeEditors) + } + if m.removedviewers != nil { + edges = append(edges, narrative.EdgeViewers) + } if m.removedpolicy != nil { edges = append(edges, narrative.EdgePolicy) } @@ -69571,8 +70116,8 @@ func (m *NarrativeMutation) RemovedEdges() []string { if m.removedcontrolobjective != nil { edges = append(edges, narrative.EdgeControlobjective) } - if m.removedprogram != nil { - edges = append(edges, narrative.EdgeProgram) + if m.removedprograms != nil { + edges = append(edges, narrative.EdgePrograms) } return edges } @@ -69581,6 +70126,24 @@ func (m *NarrativeMutation) RemovedEdges() []string { // the given name in this mutation. func (m *NarrativeMutation) RemovedIDs(name string) []ent.Value { switch name { + case narrative.EdgeBlockedGroups: + ids := make([]ent.Value, 0, len(m.removedblocked_groups)) + for id := range m.removedblocked_groups { + ids = append(ids, id) + } + return ids + case narrative.EdgeEditors: + ids := make([]ent.Value, 0, len(m.removededitors)) + for id := range m.removededitors { + ids = append(ids, id) + } + return ids + case narrative.EdgeViewers: + ids := make([]ent.Value, 0, len(m.removedviewers)) + for id := range m.removedviewers { + ids = append(ids, id) + } + return ids case narrative.EdgePolicy: ids := make([]ent.Value, 0, len(m.removedpolicy)) for id := range m.removedpolicy { @@ -69605,9 +70168,9 @@ func (m *NarrativeMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case narrative.EdgeProgram: - ids := make([]ent.Value, 0, len(m.removedprogram)) - for id := range m.removedprogram { + case narrative.EdgePrograms: + ids := make([]ent.Value, 0, len(m.removedprograms)) + for id := range m.removedprograms { ids = append(ids, id) } return ids @@ -69617,7 +70180,19 @@ func (m *NarrativeMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *NarrativeMutation) ClearedEdges() []string { - edges := make([]string, 0, 5) + edges := make([]string, 0, 9) + if m.clearedowner { + edges = append(edges, narrative.EdgeOwner) + } + if m.clearedblocked_groups { + edges = append(edges, narrative.EdgeBlockedGroups) + } + if m.clearededitors { + edges = append(edges, narrative.EdgeEditors) + } + if m.clearedviewers { + edges = append(edges, narrative.EdgeViewers) + } if m.clearedpolicy { edges = append(edges, narrative.EdgePolicy) } @@ -69630,8 +70205,8 @@ func (m *NarrativeMutation) ClearedEdges() []string { if m.clearedcontrolobjective { edges = append(edges, narrative.EdgeControlobjective) } - if m.clearedprogram { - edges = append(edges, narrative.EdgeProgram) + if m.clearedprograms { + edges = append(edges, narrative.EdgePrograms) } return edges } @@ -69640,6 +70215,14 @@ func (m *NarrativeMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *NarrativeMutation) EdgeCleared(name string) bool { switch name { + case narrative.EdgeOwner: + return m.clearedowner + case narrative.EdgeBlockedGroups: + return m.clearedblocked_groups + case narrative.EdgeEditors: + return m.clearededitors + case narrative.EdgeViewers: + return m.clearedviewers case narrative.EdgePolicy: return m.clearedpolicy case narrative.EdgeControl: @@ -69648,8 +70231,8 @@ func (m *NarrativeMutation) EdgeCleared(name string) bool { return m.clearedprocedure case narrative.EdgeControlobjective: return m.clearedcontrolobjective - case narrative.EdgeProgram: - return m.clearedprogram + case narrative.EdgePrograms: + return m.clearedprograms } return false } @@ -69658,6 +70241,9 @@ func (m *NarrativeMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *NarrativeMutation) ClearEdge(name string) error { switch name { + case narrative.EdgeOwner: + m.ClearOwner() + return nil } return fmt.Errorf("unknown Narrative unique edge %s", name) } @@ -69666,6 +70252,18 @@ func (m *NarrativeMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *NarrativeMutation) ResetEdge(name string) error { switch name { + case narrative.EdgeOwner: + m.ResetOwner() + return nil + case narrative.EdgeBlockedGroups: + m.ResetBlockedGroups() + return nil + case narrative.EdgeEditors: + m.ResetEditors() + return nil + case narrative.EdgeViewers: + m.ResetViewers() + return nil case narrative.EdgePolicy: m.ResetPolicy() return nil @@ -69678,8 +70276,8 @@ func (m *NarrativeMutation) ResetEdge(name string) error { case narrative.EdgeControlobjective: m.ResetControlobjective() return nil - case narrative.EdgeProgram: - m.ResetProgram() + case narrative.EdgePrograms: + m.ResetPrograms() return nil } return fmt.Errorf("unknown Narrative edge %s", name) @@ -69703,6 +70301,7 @@ type NarrativeHistoryMutation struct { mapping_id *string tags *[]string appendtags []string + owner_id *string name *string description *string satisfies *string @@ -70333,6 +70932,42 @@ func (m *NarrativeHistoryMutation) ResetTags() { delete(m.clearedFields, narrativehistory.FieldTags) } +// SetOwnerID sets the "owner_id" field. +func (m *NarrativeHistoryMutation) SetOwnerID(s string) { + m.owner_id = &s +} + +// OwnerID returns the value of the "owner_id" field in the mutation. +func (m *NarrativeHistoryMutation) OwnerID() (r string, exists bool) { + v := m.owner_id + if v == nil { + return + } + return *v, true +} + +// OldOwnerID returns the old "owner_id" field's value of the NarrativeHistory entity. +// If the NarrativeHistory 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 *NarrativeHistoryMutation) OldOwnerID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOwnerID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOwnerID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOwnerID: %w", err) + } + return oldValue.OwnerID, nil +} + +// ResetOwnerID resets all changes to the "owner_id" field. +func (m *NarrativeHistoryMutation) ResetOwnerID() { + m.owner_id = nil +} + // SetName sets the "name" field. func (m *NarrativeHistoryMutation) SetName(s string) { m.name = &s @@ -70550,7 +71185,7 @@ func (m *NarrativeHistoryMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *NarrativeHistoryMutation) Fields() []string { - fields := make([]string, 0, 15) + fields := make([]string, 0, 16) if m.history_time != nil { fields = append(fields, narrativehistory.FieldHistoryTime) } @@ -70584,6 +71219,9 @@ func (m *NarrativeHistoryMutation) Fields() []string { if m.tags != nil { fields = append(fields, narrativehistory.FieldTags) } + if m.owner_id != nil { + fields = append(fields, narrativehistory.FieldOwnerID) + } if m.name != nil { fields = append(fields, narrativehistory.FieldName) } @@ -70626,6 +71264,8 @@ func (m *NarrativeHistoryMutation) Field(name string) (ent.Value, bool) { return m.MappingID() case narrativehistory.FieldTags: return m.Tags() + case narrativehistory.FieldOwnerID: + return m.OwnerID() case narrativehistory.FieldName: return m.Name() case narrativehistory.FieldDescription: @@ -70665,6 +71305,8 @@ func (m *NarrativeHistoryMutation) OldField(ctx context.Context, name string) (e return m.OldMappingID(ctx) case narrativehistory.FieldTags: return m.OldTags(ctx) + case narrativehistory.FieldOwnerID: + return m.OldOwnerID(ctx) case narrativehistory.FieldName: return m.OldName(ctx) case narrativehistory.FieldDescription: @@ -70759,6 +71401,13 @@ func (m *NarrativeHistoryMutation) SetField(name string, value ent.Value) error } m.SetTags(v) return nil + case narrativehistory.FieldOwnerID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOwnerID(v) + return nil case narrativehistory.FieldName: v, ok := value.(string) if !ok { @@ -70938,6 +71587,9 @@ func (m *NarrativeHistoryMutation) ResetField(name string) error { case narrativehistory.FieldTags: m.ResetTags() return nil + case narrativehistory.FieldOwnerID: + m.ResetOwnerID() + return nil case narrativehistory.FieldName: m.ResetName() return nil @@ -80304,6 +80956,9 @@ type OrganizationMutation struct { controlobjectives map[string]struct{} removedcontrolobjectives map[string]struct{} clearedcontrolobjectives bool + narratives map[string]struct{} + removednarratives map[string]struct{} + clearednarratives bool members map[string]struct{} removedmembers map[string]struct{} clearedmembers bool @@ -82814,6 +83469,60 @@ func (m *OrganizationMutation) ResetControlobjectives() { m.removedcontrolobjectives = nil } +// AddNarrativeIDs adds the "narratives" edge to the Narrative entity by ids. +func (m *OrganizationMutation) AddNarrativeIDs(ids ...string) { + if m.narratives == nil { + m.narratives = make(map[string]struct{}) + } + for i := range ids { + m.narratives[ids[i]] = struct{}{} + } +} + +// ClearNarratives clears the "narratives" edge to the Narrative entity. +func (m *OrganizationMutation) ClearNarratives() { + m.clearednarratives = true +} + +// NarrativesCleared reports if the "narratives" edge to the Narrative entity was cleared. +func (m *OrganizationMutation) NarrativesCleared() bool { + return m.clearednarratives +} + +// RemoveNarrativeIDs removes the "narratives" edge to the Narrative entity by IDs. +func (m *OrganizationMutation) RemoveNarrativeIDs(ids ...string) { + if m.removednarratives == nil { + m.removednarratives = make(map[string]struct{}) + } + for i := range ids { + delete(m.narratives, ids[i]) + m.removednarratives[ids[i]] = struct{}{} + } +} + +// RemovedNarratives returns the removed IDs of the "narratives" edge to the Narrative entity. +func (m *OrganizationMutation) RemovedNarrativesIDs() (ids []string) { + for id := range m.removednarratives { + ids = append(ids, id) + } + return +} + +// NarrativesIDs returns the "narratives" edge IDs in the mutation. +func (m *OrganizationMutation) NarrativesIDs() (ids []string) { + for id := range m.narratives { + ids = append(ids, id) + } + return +} + +// ResetNarratives resets all changes to the "narratives" edge. +func (m *OrganizationMutation) ResetNarratives() { + m.narratives = nil + m.clearednarratives = false + m.removednarratives = nil +} + // AddMemberIDs adds the "members" edge to the OrgMembership entity by ids. func (m *OrganizationMutation) AddMemberIDs(ids ...string) { if m.members == nil { @@ -83308,7 +84017,7 @@ func (m *OrganizationMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *OrganizationMutation) AddedEdges() []string { - edges := make([]string, 0, 33) + edges := make([]string, 0, 34) if m.parent != nil { edges = append(edges, organization.EdgeParent) } @@ -83405,6 +84114,9 @@ func (m *OrganizationMutation) AddedEdges() []string { if m.controlobjectives != nil { edges = append(edges, organization.EdgeControlobjectives) } + if m.narratives != nil { + edges = append(edges, organization.EdgeNarratives) + } if m.members != nil { edges = append(edges, organization.EdgeMembers) } @@ -83603,6 +84315,12 @@ func (m *OrganizationMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case organization.EdgeNarratives: + ids := make([]ent.Value, 0, len(m.narratives)) + for id := range m.narratives { + ids = append(ids, id) + } + return ids case organization.EdgeMembers: ids := make([]ent.Value, 0, len(m.members)) for id := range m.members { @@ -83615,7 +84333,7 @@ func (m *OrganizationMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *OrganizationMutation) RemovedEdges() []string { - edges := make([]string, 0, 33) + edges := make([]string, 0, 34) if m.removedchildren != nil { edges = append(edges, organization.EdgeChildren) } @@ -83706,6 +84424,9 @@ func (m *OrganizationMutation) RemovedEdges() []string { if m.removedcontrolobjectives != nil { edges = append(edges, organization.EdgeControlobjectives) } + if m.removednarratives != nil { + edges = append(edges, organization.EdgeNarratives) + } if m.removedmembers != nil { edges = append(edges, organization.EdgeMembers) } @@ -83896,6 +84617,12 @@ func (m *OrganizationMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case organization.EdgeNarratives: + ids := make([]ent.Value, 0, len(m.removednarratives)) + for id := range m.removednarratives { + ids = append(ids, id) + } + return ids case organization.EdgeMembers: ids := make([]ent.Value, 0, len(m.removedmembers)) for id := range m.removedmembers { @@ -83908,7 +84635,7 @@ func (m *OrganizationMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *OrganizationMutation) ClearedEdges() []string { - edges := make([]string, 0, 33) + edges := make([]string, 0, 34) if m.clearedparent { edges = append(edges, organization.EdgeParent) } @@ -84005,6 +84732,9 @@ func (m *OrganizationMutation) ClearedEdges() []string { if m.clearedcontrolobjectives { edges = append(edges, organization.EdgeControlobjectives) } + if m.clearednarratives { + edges = append(edges, organization.EdgeNarratives) + } if m.clearedmembers { edges = append(edges, organization.EdgeMembers) } @@ -84079,6 +84809,8 @@ func (m *OrganizationMutation) EdgeCleared(name string) bool { return m.clearedrisks case organization.EdgeControlobjectives: return m.clearedcontrolobjectives + case organization.EdgeNarratives: + return m.clearednarratives case organization.EdgeMembers: return m.clearedmembers } @@ -84199,6 +84931,9 @@ func (m *OrganizationMutation) ResetEdge(name string) error { case organization.EdgeControlobjectives: m.ResetControlobjectives() return nil + case organization.EdgeNarratives: + m.ResetNarratives() + return nil case organization.EdgeMembers: m.ResetMembers() return nil diff --git a/internal/ent/generated/narrative.go b/internal/ent/generated/narrative.go index 64dba026..d6f14ed4 100644 --- a/internal/ent/generated/narrative.go +++ b/internal/ent/generated/narrative.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/theopenlane/core/internal/ent/generated/narrative" + "github.com/theopenlane/core/internal/ent/generated/organization" ) // Narrative is the model entity for the Narrative schema. @@ -34,6 +35,8 @@ type Narrative struct { MappingID string `json:"mapping_id,omitempty"` // tags associated with the object Tags []string `json:"tags,omitempty"` + // the ID of the organization owner of the object + OwnerID string `json:"owner_id,omitempty"` // the name of the narrative Name string `json:"name,omitempty"` // the description of the narrative @@ -50,6 +53,14 @@ type Narrative struct { // NarrativeEdges holds the relations/edges for other nodes in the graph. type NarrativeEdges struct { + // Owner holds the value of the owner edge. + Owner *Organization `json:"owner,omitempty"` + // groups that are blocked from viewing or editing the risk + BlockedGroups []*Group `json:"blocked_groups,omitempty"` + // provides edit access to the risk to members of the group + Editors []*Group `json:"editors,omitempty"` + // provides view access to the risk to members of the group + Viewers []*Group `json:"viewers,omitempty"` // Policy holds the value of the policy edge. Policy []*InternalPolicy `json:"policy,omitempty"` // Control holds the value of the control edge. @@ -58,25 +69,66 @@ type NarrativeEdges struct { Procedure []*Procedure `json:"procedure,omitempty"` // Controlobjective holds the value of the controlobjective edge. Controlobjective []*ControlObjective `json:"controlobjective,omitempty"` - // Program holds the value of the program edge. - Program []*Program `json:"program,omitempty"` + // Programs holds the value of the programs edge. + Programs []*Program `json:"programs,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [5]bool + loadedTypes [9]bool // totalCount holds the count of the edges above. - totalCount [5]map[string]int + totalCount [9]map[string]int + namedBlockedGroups map[string][]*Group + namedEditors map[string][]*Group + namedViewers map[string][]*Group namedPolicy map[string][]*InternalPolicy namedControl map[string][]*Control namedProcedure map[string][]*Procedure namedControlobjective map[string][]*ControlObjective - namedProgram map[string][]*Program + namedPrograms map[string][]*Program +} + +// OwnerOrErr returns the Owner value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e NarrativeEdges) OwnerOrErr() (*Organization, error) { + if e.Owner != nil { + return e.Owner, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: organization.Label} + } + return nil, &NotLoadedError{edge: "owner"} +} + +// BlockedGroupsOrErr returns the BlockedGroups value or an error if the edge +// was not loaded in eager-loading. +func (e NarrativeEdges) BlockedGroupsOrErr() ([]*Group, error) { + if e.loadedTypes[1] { + return e.BlockedGroups, nil + } + return nil, &NotLoadedError{edge: "blocked_groups"} +} + +// EditorsOrErr returns the Editors value or an error if the edge +// was not loaded in eager-loading. +func (e NarrativeEdges) EditorsOrErr() ([]*Group, error) { + if e.loadedTypes[2] { + return e.Editors, nil + } + return nil, &NotLoadedError{edge: "editors"} +} + +// ViewersOrErr returns the Viewers value or an error if the edge +// was not loaded in eager-loading. +func (e NarrativeEdges) ViewersOrErr() ([]*Group, error) { + if e.loadedTypes[3] { + return e.Viewers, nil + } + return nil, &NotLoadedError{edge: "viewers"} } // PolicyOrErr returns the Policy value or an error if the edge // was not loaded in eager-loading. func (e NarrativeEdges) PolicyOrErr() ([]*InternalPolicy, error) { - if e.loadedTypes[0] { + if e.loadedTypes[4] { return e.Policy, nil } return nil, &NotLoadedError{edge: "policy"} @@ -85,7 +137,7 @@ func (e NarrativeEdges) PolicyOrErr() ([]*InternalPolicy, error) { // ControlOrErr returns the Control value or an error if the edge // was not loaded in eager-loading. func (e NarrativeEdges) ControlOrErr() ([]*Control, error) { - if e.loadedTypes[1] { + if e.loadedTypes[5] { return e.Control, nil } return nil, &NotLoadedError{edge: "control"} @@ -94,7 +146,7 @@ func (e NarrativeEdges) ControlOrErr() ([]*Control, error) { // ProcedureOrErr returns the Procedure value or an error if the edge // was not loaded in eager-loading. func (e NarrativeEdges) ProcedureOrErr() ([]*Procedure, error) { - if e.loadedTypes[2] { + if e.loadedTypes[6] { return e.Procedure, nil } return nil, &NotLoadedError{edge: "procedure"} @@ -103,19 +155,19 @@ func (e NarrativeEdges) ProcedureOrErr() ([]*Procedure, error) { // ControlobjectiveOrErr returns the Controlobjective value or an error if the edge // was not loaded in eager-loading. func (e NarrativeEdges) ControlobjectiveOrErr() ([]*ControlObjective, error) { - if e.loadedTypes[3] { + if e.loadedTypes[7] { return e.Controlobjective, nil } return nil, &NotLoadedError{edge: "controlobjective"} } -// ProgramOrErr returns the Program value or an error if the edge +// ProgramsOrErr returns the Programs value or an error if the edge // was not loaded in eager-loading. -func (e NarrativeEdges) ProgramOrErr() ([]*Program, error) { - if e.loadedTypes[4] { - return e.Program, nil +func (e NarrativeEdges) ProgramsOrErr() ([]*Program, error) { + if e.loadedTypes[8] { + return e.Programs, nil } - return nil, &NotLoadedError{edge: "program"} + return nil, &NotLoadedError{edge: "programs"} } // scanValues returns the types for scanning values from sql.Rows. @@ -125,7 +177,7 @@ func (*Narrative) scanValues(columns []string) ([]any, error) { switch columns[i] { case narrative.FieldTags, narrative.FieldDetails: values[i] = new([]byte) - case narrative.FieldID, narrative.FieldCreatedBy, narrative.FieldUpdatedBy, narrative.FieldDeletedBy, narrative.FieldMappingID, narrative.FieldName, narrative.FieldDescription, narrative.FieldSatisfies: + case narrative.FieldID, narrative.FieldCreatedBy, narrative.FieldUpdatedBy, narrative.FieldDeletedBy, narrative.FieldMappingID, narrative.FieldOwnerID, narrative.FieldName, narrative.FieldDescription, narrative.FieldSatisfies: values[i] = new(sql.NullString) case narrative.FieldCreatedAt, narrative.FieldUpdatedAt, narrative.FieldDeletedAt: values[i] = new(sql.NullTime) @@ -200,6 +252,12 @@ func (n *Narrative) assignValues(columns []string, values []any) error { return fmt.Errorf("unmarshal field tags: %w", err) } } + case narrative.FieldOwnerID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field owner_id", values[i]) + } else if value.Valid { + n.OwnerID = value.String + } case narrative.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) @@ -239,6 +297,26 @@ func (n *Narrative) Value(name string) (ent.Value, error) { return n.selectValues.Get(name) } +// QueryOwner queries the "owner" edge of the Narrative entity. +func (n *Narrative) QueryOwner() *OrganizationQuery { + return NewNarrativeClient(n.config).QueryOwner(n) +} + +// QueryBlockedGroups queries the "blocked_groups" edge of the Narrative entity. +func (n *Narrative) QueryBlockedGroups() *GroupQuery { + return NewNarrativeClient(n.config).QueryBlockedGroups(n) +} + +// QueryEditors queries the "editors" edge of the Narrative entity. +func (n *Narrative) QueryEditors() *GroupQuery { + return NewNarrativeClient(n.config).QueryEditors(n) +} + +// QueryViewers queries the "viewers" edge of the Narrative entity. +func (n *Narrative) QueryViewers() *GroupQuery { + return NewNarrativeClient(n.config).QueryViewers(n) +} + // QueryPolicy queries the "policy" edge of the Narrative entity. func (n *Narrative) QueryPolicy() *InternalPolicyQuery { return NewNarrativeClient(n.config).QueryPolicy(n) @@ -259,9 +337,9 @@ func (n *Narrative) QueryControlobjective() *ControlObjectiveQuery { return NewNarrativeClient(n.config).QueryControlobjective(n) } -// QueryProgram queries the "program" edge of the Narrative entity. -func (n *Narrative) QueryProgram() *ProgramQuery { - return NewNarrativeClient(n.config).QueryProgram(n) +// QueryPrograms queries the "programs" edge of the Narrative entity. +func (n *Narrative) QueryPrograms() *ProgramQuery { + return NewNarrativeClient(n.config).QueryPrograms(n) } // Update returns a builder for updating this Narrative. @@ -311,6 +389,9 @@ func (n *Narrative) String() string { builder.WriteString("tags=") builder.WriteString(fmt.Sprintf("%v", n.Tags)) builder.WriteString(", ") + builder.WriteString("owner_id=") + builder.WriteString(n.OwnerID) + builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(n.Name) builder.WriteString(", ") @@ -326,6 +407,78 @@ func (n *Narrative) String() string { return builder.String() } +// NamedBlockedGroups returns the BlockedGroups named value or an error if the edge was not +// loaded in eager-loading with this name. +func (n *Narrative) NamedBlockedGroups(name string) ([]*Group, error) { + if n.Edges.namedBlockedGroups == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := n.Edges.namedBlockedGroups[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (n *Narrative) appendNamedBlockedGroups(name string, edges ...*Group) { + if n.Edges.namedBlockedGroups == nil { + n.Edges.namedBlockedGroups = make(map[string][]*Group) + } + if len(edges) == 0 { + n.Edges.namedBlockedGroups[name] = []*Group{} + } else { + n.Edges.namedBlockedGroups[name] = append(n.Edges.namedBlockedGroups[name], edges...) + } +} + +// NamedEditors returns the Editors named value or an error if the edge was not +// loaded in eager-loading with this name. +func (n *Narrative) NamedEditors(name string) ([]*Group, error) { + if n.Edges.namedEditors == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := n.Edges.namedEditors[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (n *Narrative) appendNamedEditors(name string, edges ...*Group) { + if n.Edges.namedEditors == nil { + n.Edges.namedEditors = make(map[string][]*Group) + } + if len(edges) == 0 { + n.Edges.namedEditors[name] = []*Group{} + } else { + n.Edges.namedEditors[name] = append(n.Edges.namedEditors[name], edges...) + } +} + +// NamedViewers returns the Viewers named value or an error if the edge was not +// loaded in eager-loading with this name. +func (n *Narrative) NamedViewers(name string) ([]*Group, error) { + if n.Edges.namedViewers == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := n.Edges.namedViewers[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (n *Narrative) appendNamedViewers(name string, edges ...*Group) { + if n.Edges.namedViewers == nil { + n.Edges.namedViewers = make(map[string][]*Group) + } + if len(edges) == 0 { + n.Edges.namedViewers[name] = []*Group{} + } else { + n.Edges.namedViewers[name] = append(n.Edges.namedViewers[name], edges...) + } +} + // NamedPolicy returns the Policy named value or an error if the edge was not // loaded in eager-loading with this name. func (n *Narrative) NamedPolicy(name string) ([]*InternalPolicy, error) { @@ -422,27 +575,27 @@ func (n *Narrative) appendNamedControlobjective(name string, edges ...*ControlOb } } -// NamedProgram returns the Program named value or an error if the edge was not +// NamedPrograms returns the Programs named value or an error if the edge was not // loaded in eager-loading with this name. -func (n *Narrative) NamedProgram(name string) ([]*Program, error) { - if n.Edges.namedProgram == nil { +func (n *Narrative) NamedPrograms(name string) ([]*Program, error) { + if n.Edges.namedPrograms == nil { return nil, &NotLoadedError{edge: name} } - nodes, ok := n.Edges.namedProgram[name] + nodes, ok := n.Edges.namedPrograms[name] if !ok { return nil, &NotLoadedError{edge: name} } return nodes, nil } -func (n *Narrative) appendNamedProgram(name string, edges ...*Program) { - if n.Edges.namedProgram == nil { - n.Edges.namedProgram = make(map[string][]*Program) +func (n *Narrative) appendNamedPrograms(name string, edges ...*Program) { + if n.Edges.namedPrograms == nil { + n.Edges.namedPrograms = make(map[string][]*Program) } if len(edges) == 0 { - n.Edges.namedProgram[name] = []*Program{} + n.Edges.namedPrograms[name] = []*Program{} } else { - n.Edges.namedProgram[name] = append(n.Edges.namedProgram[name], edges...) + n.Edges.namedPrograms[name] = append(n.Edges.namedPrograms[name], edges...) } } diff --git a/internal/ent/generated/narrative/narrative.go b/internal/ent/generated/narrative/narrative.go index 6182b456..55c69b8b 100644 --- a/internal/ent/generated/narrative/narrative.go +++ b/internal/ent/generated/narrative/narrative.go @@ -31,6 +31,8 @@ const ( FieldMappingID = "mapping_id" // FieldTags holds the string denoting the tags field in the database. FieldTags = "tags" + // FieldOwnerID holds the string denoting the owner_id field in the database. + FieldOwnerID = "owner_id" // FieldName holds the string denoting the name field in the database. FieldName = "name" // FieldDescription holds the string denoting the description field in the database. @@ -39,6 +41,14 @@ const ( FieldSatisfies = "satisfies" // FieldDetails holds the string denoting the details field in the database. FieldDetails = "details" + // EdgeOwner holds the string denoting the owner edge name in mutations. + EdgeOwner = "owner" + // EdgeBlockedGroups holds the string denoting the blocked_groups edge name in mutations. + EdgeBlockedGroups = "blocked_groups" + // EdgeEditors holds the string denoting the editors edge name in mutations. + EdgeEditors = "editors" + // EdgeViewers holds the string denoting the viewers edge name in mutations. + EdgeViewers = "viewers" // EdgePolicy holds the string denoting the policy edge name in mutations. EdgePolicy = "policy" // EdgeControl holds the string denoting the control edge name in mutations. @@ -47,10 +57,32 @@ const ( EdgeProcedure = "procedure" // EdgeControlobjective holds the string denoting the controlobjective edge name in mutations. EdgeControlobjective = "controlobjective" - // EdgeProgram holds the string denoting the program edge name in mutations. - EdgeProgram = "program" + // EdgePrograms holds the string denoting the programs edge name in mutations. + EdgePrograms = "programs" // Table holds the table name of the narrative in the database. Table = "narratives" + // OwnerTable is the table that holds the owner relation/edge. + OwnerTable = "narratives" + // OwnerInverseTable is the table name for the Organization entity. + // It exists in this package in order to avoid circular dependency with the "organization" package. + OwnerInverseTable = "organizations" + // OwnerColumn is the table column denoting the owner relation/edge. + OwnerColumn = "owner_id" + // BlockedGroupsTable is the table that holds the blocked_groups relation/edge. The primary key declared below. + BlockedGroupsTable = "narrative_blocked_groups" + // BlockedGroupsInverseTable is the table name for the Group entity. + // It exists in this package in order to avoid circular dependency with the "group" package. + BlockedGroupsInverseTable = "groups" + // EditorsTable is the table that holds the editors relation/edge. The primary key declared below. + EditorsTable = "narrative_editors" + // EditorsInverseTable is the table name for the Group entity. + // It exists in this package in order to avoid circular dependency with the "group" package. + EditorsInverseTable = "groups" + // ViewersTable is the table that holds the viewers relation/edge. The primary key declared below. + ViewersTable = "narrative_viewers" + // ViewersInverseTable is the table name for the Group entity. + // It exists in this package in order to avoid circular dependency with the "group" package. + ViewersInverseTable = "groups" // PolicyTable is the table that holds the policy relation/edge. The primary key declared below. PolicyTable = "internal_policy_narratives" // PolicyInverseTable is the table name for the InternalPolicy entity. @@ -71,11 +103,11 @@ const ( // ControlobjectiveInverseTable is the table name for the ControlObjective entity. // It exists in this package in order to avoid circular dependency with the "controlobjective" package. ControlobjectiveInverseTable = "control_objectives" - // ProgramTable is the table that holds the program relation/edge. The primary key declared below. - ProgramTable = "program_narratives" - // ProgramInverseTable is the table name for the Program entity. + // ProgramsTable is the table that holds the programs relation/edge. The primary key declared below. + ProgramsTable = "program_narratives" + // ProgramsInverseTable is the table name for the Program entity. // It exists in this package in order to avoid circular dependency with the "program" package. - ProgramInverseTable = "programs" + ProgramsInverseTable = "programs" ) // Columns holds all SQL columns for narrative fields. @@ -89,6 +121,7 @@ var Columns = []string{ FieldDeletedBy, FieldMappingID, FieldTags, + FieldOwnerID, FieldName, FieldDescription, FieldSatisfies, @@ -96,6 +129,15 @@ var Columns = []string{ } var ( + // BlockedGroupsPrimaryKey and BlockedGroupsColumn2 are the table columns denoting the + // primary key for the blocked_groups relation (M2M). + BlockedGroupsPrimaryKey = []string{"narrative_id", "group_id"} + // EditorsPrimaryKey and EditorsColumn2 are the table columns denoting the + // primary key for the editors relation (M2M). + EditorsPrimaryKey = []string{"narrative_id", "group_id"} + // ViewersPrimaryKey and ViewersColumn2 are the table columns denoting the + // primary key for the viewers relation (M2M). + ViewersPrimaryKey = []string{"narrative_id", "group_id"} // PolicyPrimaryKey and PolicyColumn2 are the table columns denoting the // primary key for the policy relation (M2M). PolicyPrimaryKey = []string{"internal_policy_id", "narrative_id"} @@ -108,9 +150,9 @@ var ( // ControlobjectivePrimaryKey and ControlobjectiveColumn2 are the table columns denoting the // primary key for the controlobjective relation (M2M). ControlobjectivePrimaryKey = []string{"control_objective_id", "narrative_id"} - // ProgramPrimaryKey and ProgramColumn2 are the table columns denoting the - // primary key for the program relation (M2M). - ProgramPrimaryKey = []string{"program_id", "narrative_id"} + // ProgramsPrimaryKey and ProgramsColumn2 are the table columns denoting the + // primary key for the programs relation (M2M). + ProgramsPrimaryKey = []string{"program_id", "narrative_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -129,8 +171,9 @@ func ValidColumn(column string) bool { // // import _ "github.com/theopenlane/core/internal/ent/generated/runtime" var ( - Hooks [2]ent.Hook - Interceptors [1]ent.Interceptor + Hooks [9]ent.Hook + Interceptors [2]ent.Interceptor + Policy ent.Policy // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. @@ -141,6 +184,10 @@ var ( DefaultMappingID func() string // DefaultTags holds the default value on creation for the "tags" field. DefaultTags []string + // OwnerIDValidator is a validator for the "owner_id" field. It is called by the builders before save. + OwnerIDValidator func(string) error + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error // DefaultID holds the default value on creation for the "id" field. DefaultID func() string ) @@ -188,6 +235,11 @@ func ByMappingID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldMappingID, opts...).ToFunc() } +// ByOwnerID orders the results by the owner_id field. +func ByOwnerID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOwnerID, opts...).ToFunc() +} + // ByName orders the results by the name field. func ByName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldName, opts...).ToFunc() @@ -203,6 +255,55 @@ func BySatisfies(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSatisfies, opts...).ToFunc() } +// ByOwnerField orders the results by owner field. +func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...)) + } +} + +// ByBlockedGroupsCount orders the results by blocked_groups count. +func ByBlockedGroupsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newBlockedGroupsStep(), opts...) + } +} + +// ByBlockedGroups orders the results by blocked_groups terms. +func ByBlockedGroups(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newBlockedGroupsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByEditorsCount orders the results by editors count. +func ByEditorsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newEditorsStep(), opts...) + } +} + +// ByEditors orders the results by editors terms. +func ByEditors(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newEditorsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByViewersCount orders the results by viewers count. +func ByViewersCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newViewersStep(), opts...) + } +} + +// ByViewers orders the results by viewers terms. +func ByViewers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newViewersStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByPolicyCount orders the results by policy count. func ByPolicyCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -259,19 +360,47 @@ func ByControlobjective(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption } } -// ByProgramCount orders the results by program count. -func ByProgramCount(opts ...sql.OrderTermOption) OrderOption { +// ByProgramsCount orders the results by programs count. +func ByProgramsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newProgramStep(), opts...) + sqlgraph.OrderByNeighborsCount(s, newProgramsStep(), opts...) } } -// ByProgram orders the results by program terms. -func ByProgram(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { +// ByPrograms orders the results by programs terms. +func ByPrograms(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newProgramStep(), append([]sql.OrderTerm{term}, terms...)...) + sqlgraph.OrderByNeighborTerms(s, newProgramsStep(), append([]sql.OrderTerm{term}, terms...)...) } } +func newOwnerStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OwnerInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), + ) +} +func newBlockedGroupsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(BlockedGroupsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, BlockedGroupsTable, BlockedGroupsPrimaryKey...), + ) +} +func newEditorsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(EditorsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, EditorsTable, EditorsPrimaryKey...), + ) +} +func newViewersStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ViewersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ViewersTable, ViewersPrimaryKey...), + ) +} func newPolicyStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -300,10 +429,10 @@ func newControlobjectiveStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, true, ControlobjectiveTable, ControlobjectivePrimaryKey...), ) } -func newProgramStep() *sqlgraph.Step { +func newProgramsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(ProgramInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, ProgramTable, ProgramPrimaryKey...), + sqlgraph.To(ProgramsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ProgramsTable, ProgramsPrimaryKey...), ) } diff --git a/internal/ent/generated/narrative/where.go b/internal/ent/generated/narrative/where.go index 01f3222c..6d608c73 100644 --- a/internal/ent/generated/narrative/where.go +++ b/internal/ent/generated/narrative/where.go @@ -102,6 +102,11 @@ func MappingID(v string) predicate.Narrative { return predicate.Narrative(sql.FieldEQ(FieldMappingID, v)) } +// OwnerID applies equality check predicate on the "owner_id" field. It's identical to OwnerIDEQ. +func OwnerID(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldEQ(FieldOwnerID, v)) +} + // Name applies equality check predicate on the "name" field. It's identical to NameEQ. func Name(v string) predicate.Narrative { return predicate.Narrative(sql.FieldEQ(FieldName, v)) @@ -567,6 +572,71 @@ func TagsNotNil() predicate.Narrative { return predicate.Narrative(sql.FieldNotNull(FieldTags)) } +// OwnerIDEQ applies the EQ predicate on the "owner_id" field. +func OwnerIDEQ(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldEQ(FieldOwnerID, v)) +} + +// OwnerIDNEQ applies the NEQ predicate on the "owner_id" field. +func OwnerIDNEQ(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldNEQ(FieldOwnerID, v)) +} + +// OwnerIDIn applies the In predicate on the "owner_id" field. +func OwnerIDIn(vs ...string) predicate.Narrative { + return predicate.Narrative(sql.FieldIn(FieldOwnerID, vs...)) +} + +// OwnerIDNotIn applies the NotIn predicate on the "owner_id" field. +func OwnerIDNotIn(vs ...string) predicate.Narrative { + return predicate.Narrative(sql.FieldNotIn(FieldOwnerID, vs...)) +} + +// OwnerIDGT applies the GT predicate on the "owner_id" field. +func OwnerIDGT(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldGT(FieldOwnerID, v)) +} + +// OwnerIDGTE applies the GTE predicate on the "owner_id" field. +func OwnerIDGTE(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldGTE(FieldOwnerID, v)) +} + +// OwnerIDLT applies the LT predicate on the "owner_id" field. +func OwnerIDLT(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldLT(FieldOwnerID, v)) +} + +// OwnerIDLTE applies the LTE predicate on the "owner_id" field. +func OwnerIDLTE(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldLTE(FieldOwnerID, v)) +} + +// OwnerIDContains applies the Contains predicate on the "owner_id" field. +func OwnerIDContains(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldContains(FieldOwnerID, v)) +} + +// OwnerIDHasPrefix applies the HasPrefix predicate on the "owner_id" field. +func OwnerIDHasPrefix(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldHasPrefix(FieldOwnerID, v)) +} + +// OwnerIDHasSuffix applies the HasSuffix predicate on the "owner_id" field. +func OwnerIDHasSuffix(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldHasSuffix(FieldOwnerID, v)) +} + +// OwnerIDEqualFold applies the EqualFold predicate on the "owner_id" field. +func OwnerIDEqualFold(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldEqualFold(FieldOwnerID, v)) +} + +// OwnerIDContainsFold applies the ContainsFold predicate on the "owner_id" field. +func OwnerIDContainsFold(v string) predicate.Narrative { + return predicate.Narrative(sql.FieldContainsFold(FieldOwnerID, v)) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Narrative { return predicate.Narrative(sql.FieldEQ(FieldName, v)) @@ -792,6 +862,122 @@ func DetailsNotNil() predicate.Narrative { return predicate.Narrative(sql.FieldNotNull(FieldDetails)) } +// HasOwner applies the HasEdge predicate on the "owner" edge. +func HasOwner() predicate.Narrative { + return predicate.Narrative(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), + ) + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Organization + step.Edge.Schema = schemaConfig.Narrative + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates). +func HasOwnerWith(preds ...predicate.Organization) predicate.Narrative { + return predicate.Narrative(func(s *sql.Selector) { + step := newOwnerStep() + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Organization + step.Edge.Schema = schemaConfig.Narrative + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasBlockedGroups applies the HasEdge predicate on the "blocked_groups" edge. +func HasBlockedGroups() predicate.Narrative { + return predicate.Narrative(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, BlockedGroupsTable, BlockedGroupsPrimaryKey...), + ) + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeBlockedGroups + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasBlockedGroupsWith applies the HasEdge predicate on the "blocked_groups" edge with a given conditions (other predicates). +func HasBlockedGroupsWith(preds ...predicate.Group) predicate.Narrative { + return predicate.Narrative(func(s *sql.Selector) { + step := newBlockedGroupsStep() + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeBlockedGroups + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasEditors applies the HasEdge predicate on the "editors" edge. +func HasEditors() predicate.Narrative { + return predicate.Narrative(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, EditorsTable, EditorsPrimaryKey...), + ) + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeEditors + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasEditorsWith applies the HasEdge predicate on the "editors" edge with a given conditions (other predicates). +func HasEditorsWith(preds ...predicate.Group) predicate.Narrative { + return predicate.Narrative(func(s *sql.Selector) { + step := newEditorsStep() + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeEditors + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasViewers applies the HasEdge predicate on the "viewers" edge. +func HasViewers() predicate.Narrative { + return predicate.Narrative(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ViewersTable, ViewersPrimaryKey...), + ) + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeViewers + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasViewersWith applies the HasEdge predicate on the "viewers" edge with a given conditions (other predicates). +func HasViewersWith(preds ...predicate.Group) predicate.Narrative { + return predicate.Narrative(func(s *sql.Selector) { + step := newViewersStep() + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeViewers + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasPolicy applies the HasEdge predicate on the "policy" edge. func HasPolicy() predicate.Narrative { return predicate.Narrative(func(s *sql.Selector) { @@ -908,12 +1094,12 @@ func HasControlobjectiveWith(preds ...predicate.ControlObjective) predicate.Narr }) } -// HasProgram applies the HasEdge predicate on the "program" edge. -func HasProgram() predicate.Narrative { +// HasPrograms applies the HasEdge predicate on the "programs" edge. +func HasPrograms() predicate.Narrative { return predicate.Narrative(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, ProgramTable, ProgramPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, ProgramsTable, ProgramsPrimaryKey...), ) schemaConfig := internal.SchemaConfigFromContext(s.Context()) step.To.Schema = schemaConfig.Program @@ -922,10 +1108,10 @@ func HasProgram() predicate.Narrative { }) } -// HasProgramWith applies the HasEdge predicate on the "program" edge with a given conditions (other predicates). -func HasProgramWith(preds ...predicate.Program) predicate.Narrative { +// HasProgramsWith applies the HasEdge predicate on the "programs" edge with a given conditions (other predicates). +func HasProgramsWith(preds ...predicate.Program) predicate.Narrative { return predicate.Narrative(func(s *sql.Selector) { - step := newProgramStep() + step := newProgramsStep() schemaConfig := internal.SchemaConfigFromContext(s.Context()) step.To.Schema = schemaConfig.Program step.Edge.Schema = schemaConfig.ProgramNarratives diff --git a/internal/ent/generated/narrative_create.go b/internal/ent/generated/narrative_create.go index a9beeee5..742bf143 100644 --- a/internal/ent/generated/narrative_create.go +++ b/internal/ent/generated/narrative_create.go @@ -12,8 +12,10 @@ import ( "entgo.io/ent/schema/field" "github.com/theopenlane/core/internal/ent/generated/control" "github.com/theopenlane/core/internal/ent/generated/controlobjective" + "github.com/theopenlane/core/internal/ent/generated/group" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" "github.com/theopenlane/core/internal/ent/generated/narrative" + "github.com/theopenlane/core/internal/ent/generated/organization" "github.com/theopenlane/core/internal/ent/generated/procedure" "github.com/theopenlane/core/internal/ent/generated/program" ) @@ -129,6 +131,12 @@ func (nc *NarrativeCreate) SetTags(s []string) *NarrativeCreate { return nc } +// SetOwnerID sets the "owner_id" field. +func (nc *NarrativeCreate) SetOwnerID(s string) *NarrativeCreate { + nc.mutation.SetOwnerID(s) + return nc +} + // SetName sets the "name" field. func (nc *NarrativeCreate) SetName(s string) *NarrativeCreate { nc.mutation.SetName(s) @@ -183,6 +191,56 @@ func (nc *NarrativeCreate) SetNillableID(s *string) *NarrativeCreate { return nc } +// SetOwner sets the "owner" edge to the Organization entity. +func (nc *NarrativeCreate) SetOwner(o *Organization) *NarrativeCreate { + return nc.SetOwnerID(o.ID) +} + +// AddBlockedGroupIDs adds the "blocked_groups" edge to the Group entity by IDs. +func (nc *NarrativeCreate) AddBlockedGroupIDs(ids ...string) *NarrativeCreate { + nc.mutation.AddBlockedGroupIDs(ids...) + return nc +} + +// AddBlockedGroups adds the "blocked_groups" edges to the Group entity. +func (nc *NarrativeCreate) AddBlockedGroups(g ...*Group) *NarrativeCreate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nc.AddBlockedGroupIDs(ids...) +} + +// AddEditorIDs adds the "editors" edge to the Group entity by IDs. +func (nc *NarrativeCreate) AddEditorIDs(ids ...string) *NarrativeCreate { + nc.mutation.AddEditorIDs(ids...) + return nc +} + +// AddEditors adds the "editors" edges to the Group entity. +func (nc *NarrativeCreate) AddEditors(g ...*Group) *NarrativeCreate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nc.AddEditorIDs(ids...) +} + +// AddViewerIDs adds the "viewers" edge to the Group entity by IDs. +func (nc *NarrativeCreate) AddViewerIDs(ids ...string) *NarrativeCreate { + nc.mutation.AddViewerIDs(ids...) + return nc +} + +// AddViewers adds the "viewers" edges to the Group entity. +func (nc *NarrativeCreate) AddViewers(g ...*Group) *NarrativeCreate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nc.AddViewerIDs(ids...) +} + // AddPolicyIDs adds the "policy" edge to the InternalPolicy entity by IDs. func (nc *NarrativeCreate) AddPolicyIDs(ids ...string) *NarrativeCreate { nc.mutation.AddPolicyIDs(ids...) @@ -243,14 +301,14 @@ func (nc *NarrativeCreate) AddControlobjective(c ...*ControlObjective) *Narrativ return nc.AddControlobjectiveIDs(ids...) } -// AddProgramIDs adds the "program" edge to the Program entity by IDs. +// AddProgramIDs adds the "programs" edge to the Program entity by IDs. func (nc *NarrativeCreate) AddProgramIDs(ids ...string) *NarrativeCreate { nc.mutation.AddProgramIDs(ids...) return nc } -// AddProgram adds the "program" edges to the Program entity. -func (nc *NarrativeCreate) AddProgram(p ...*Program) *NarrativeCreate { +// AddPrograms adds the "programs" edges to the Program entity. +func (nc *NarrativeCreate) AddPrograms(p ...*Program) *NarrativeCreate { ids := make([]string, len(p)) for i := range p { ids[i] = p[i].ID @@ -335,9 +393,25 @@ func (nc *NarrativeCreate) check() error { if _, ok := nc.mutation.MappingID(); !ok { return &ValidationError{Name: "mapping_id", err: errors.New(`generated: missing required field "Narrative.mapping_id"`)} } + if _, ok := nc.mutation.OwnerID(); !ok { + return &ValidationError{Name: "owner_id", err: errors.New(`generated: missing required field "Narrative.owner_id"`)} + } + if v, ok := nc.mutation.OwnerID(); ok { + if err := narrative.OwnerIDValidator(v); err != nil { + return &ValidationError{Name: "owner_id", err: fmt.Errorf(`generated: validator failed for field "Narrative.owner_id": %w`, err)} + } + } if _, ok := nc.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`generated: missing required field "Narrative.name"`)} } + if v, ok := nc.mutation.Name(); ok { + if err := narrative.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`generated: validator failed for field "Narrative.name": %w`, err)} + } + } + if len(nc.mutation.OwnerIDs()) == 0 { + return &ValidationError{Name: "owner", err: errors.New(`generated: missing required edge "Narrative.owner"`)} + } return nil } @@ -422,6 +496,75 @@ func (nc *NarrativeCreate) createSpec() (*Narrative, *sqlgraph.CreateSpec) { _spec.SetField(narrative.FieldDetails, field.TypeJSON, value) _node.Details = value } + if nodes := nc.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: narrative.OwnerTable, + Columns: []string{narrative.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeString), + }, + } + edge.Schema = nc.schemaConfig.Narrative + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.OwnerID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := nc.mutation.BlockedGroupsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.BlockedGroupsTable, + Columns: narrative.BlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nc.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := nc.mutation.EditorsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.EditorsTable, + Columns: narrative.EditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nc.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := nc.mutation.ViewersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.ViewersTable, + Columns: narrative.ViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nc.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := nc.mutation.PolicyIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -490,12 +633,12 @@ func (nc *NarrativeCreate) createSpec() (*Narrative, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := nc.mutation.ProgramIDs(); len(nodes) > 0 { + if nodes := nc.mutation.ProgramsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: narrative.ProgramTable, - Columns: narrative.ProgramPrimaryKey, + Table: narrative.ProgramsTable, + Columns: narrative.ProgramsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(program.FieldID, field.TypeString), diff --git a/internal/ent/generated/narrative_query.go b/internal/ent/generated/narrative_query.go index 4027c0a9..4163feac 100644 --- a/internal/ent/generated/narrative_query.go +++ b/internal/ent/generated/narrative_query.go @@ -5,6 +5,7 @@ package generated import ( "context" "database/sql/driver" + "errors" "fmt" "math" @@ -14,8 +15,10 @@ import ( "entgo.io/ent/schema/field" "github.com/theopenlane/core/internal/ent/generated/control" "github.com/theopenlane/core/internal/ent/generated/controlobjective" + "github.com/theopenlane/core/internal/ent/generated/group" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" "github.com/theopenlane/core/internal/ent/generated/narrative" + "github.com/theopenlane/core/internal/ent/generated/organization" "github.com/theopenlane/core/internal/ent/generated/predicate" "github.com/theopenlane/core/internal/ent/generated/procedure" "github.com/theopenlane/core/internal/ent/generated/program" @@ -30,18 +33,25 @@ type NarrativeQuery struct { order []narrative.OrderOption inters []Interceptor predicates []predicate.Narrative + withOwner *OrganizationQuery + withBlockedGroups *GroupQuery + withEditors *GroupQuery + withViewers *GroupQuery withPolicy *InternalPolicyQuery withControl *ControlQuery withProcedure *ProcedureQuery withControlobjective *ControlObjectiveQuery - withProgram *ProgramQuery + withPrograms *ProgramQuery loadTotal []func(context.Context, []*Narrative) error modifiers []func(*sql.Selector) + withNamedBlockedGroups map[string]*GroupQuery + withNamedEditors map[string]*GroupQuery + withNamedViewers map[string]*GroupQuery withNamedPolicy map[string]*InternalPolicyQuery withNamedControl map[string]*ControlQuery withNamedProcedure map[string]*ProcedureQuery withNamedControlobjective map[string]*ControlObjectiveQuery - withNamedProgram map[string]*ProgramQuery + withNamedPrograms map[string]*ProgramQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -78,6 +88,106 @@ func (nq *NarrativeQuery) Order(o ...narrative.OrderOption) *NarrativeQuery { return nq } +// QueryOwner chains the current query on the "owner" edge. +func (nq *NarrativeQuery) QueryOwner() *OrganizationQuery { + query := (&OrganizationClient{config: nq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := nq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := nq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(narrative.Table, narrative.FieldID, selector), + sqlgraph.To(organization.Table, organization.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, narrative.OwnerTable, narrative.OwnerColumn), + ) + schemaConfig := nq.schemaConfig + step.To.Schema = schemaConfig.Organization + step.Edge.Schema = schemaConfig.Narrative + fromU = sqlgraph.SetNeighbors(nq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryBlockedGroups chains the current query on the "blocked_groups" edge. +func (nq *NarrativeQuery) QueryBlockedGroups() *GroupQuery { + query := (&GroupClient{config: nq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := nq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := nq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(narrative.Table, narrative.FieldID, selector), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, narrative.BlockedGroupsTable, narrative.BlockedGroupsPrimaryKey...), + ) + schemaConfig := nq.schemaConfig + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeBlockedGroups + fromU = sqlgraph.SetNeighbors(nq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryEditors chains the current query on the "editors" edge. +func (nq *NarrativeQuery) QueryEditors() *GroupQuery { + query := (&GroupClient{config: nq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := nq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := nq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(narrative.Table, narrative.FieldID, selector), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, narrative.EditorsTable, narrative.EditorsPrimaryKey...), + ) + schemaConfig := nq.schemaConfig + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeEditors + fromU = sqlgraph.SetNeighbors(nq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryViewers chains the current query on the "viewers" edge. +func (nq *NarrativeQuery) QueryViewers() *GroupQuery { + query := (&GroupClient{config: nq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := nq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := nq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(narrative.Table, narrative.FieldID, selector), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, narrative.ViewersTable, narrative.ViewersPrimaryKey...), + ) + schemaConfig := nq.schemaConfig + step.To.Schema = schemaConfig.Group + step.Edge.Schema = schemaConfig.NarrativeViewers + fromU = sqlgraph.SetNeighbors(nq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryPolicy chains the current query on the "policy" edge. func (nq *NarrativeQuery) QueryPolicy() *InternalPolicyQuery { query := (&InternalPolicyClient{config: nq.config}).Query() @@ -178,8 +288,8 @@ func (nq *NarrativeQuery) QueryControlobjective() *ControlObjectiveQuery { return query } -// QueryProgram chains the current query on the "program" edge. -func (nq *NarrativeQuery) QueryProgram() *ProgramQuery { +// QueryPrograms chains the current query on the "programs" edge. +func (nq *NarrativeQuery) QueryPrograms() *ProgramQuery { query := (&ProgramClient{config: nq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := nq.prepareQuery(ctx); err != nil { @@ -192,7 +302,7 @@ func (nq *NarrativeQuery) QueryProgram() *ProgramQuery { step := sqlgraph.NewStep( sqlgraph.From(narrative.Table, narrative.FieldID, selector), sqlgraph.To(program.Table, program.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, narrative.ProgramTable, narrative.ProgramPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, narrative.ProgramsTable, narrative.ProgramsPrimaryKey...), ) schemaConfig := nq.schemaConfig step.To.Schema = schemaConfig.Program @@ -395,11 +505,15 @@ func (nq *NarrativeQuery) Clone() *NarrativeQuery { order: append([]narrative.OrderOption{}, nq.order...), inters: append([]Interceptor{}, nq.inters...), predicates: append([]predicate.Narrative{}, nq.predicates...), + withOwner: nq.withOwner.Clone(), + withBlockedGroups: nq.withBlockedGroups.Clone(), + withEditors: nq.withEditors.Clone(), + withViewers: nq.withViewers.Clone(), withPolicy: nq.withPolicy.Clone(), withControl: nq.withControl.Clone(), withProcedure: nq.withProcedure.Clone(), withControlobjective: nq.withControlobjective.Clone(), - withProgram: nq.withProgram.Clone(), + withPrograms: nq.withPrograms.Clone(), // clone intermediate query. sql: nq.sql.Clone(), path: nq.path, @@ -407,6 +521,50 @@ func (nq *NarrativeQuery) Clone() *NarrativeQuery { } } +// WithOwner tells the query-builder to eager-load the nodes that are connected to +// the "owner" edge. The optional arguments are used to configure the query builder of the edge. +func (nq *NarrativeQuery) WithOwner(opts ...func(*OrganizationQuery)) *NarrativeQuery { + query := (&OrganizationClient{config: nq.config}).Query() + for _, opt := range opts { + opt(query) + } + nq.withOwner = query + return nq +} + +// WithBlockedGroups tells the query-builder to eager-load the nodes that are connected to +// the "blocked_groups" edge. The optional arguments are used to configure the query builder of the edge. +func (nq *NarrativeQuery) WithBlockedGroups(opts ...func(*GroupQuery)) *NarrativeQuery { + query := (&GroupClient{config: nq.config}).Query() + for _, opt := range opts { + opt(query) + } + nq.withBlockedGroups = query + return nq +} + +// WithEditors tells the query-builder to eager-load the nodes that are connected to +// the "editors" edge. The optional arguments are used to configure the query builder of the edge. +func (nq *NarrativeQuery) WithEditors(opts ...func(*GroupQuery)) *NarrativeQuery { + query := (&GroupClient{config: nq.config}).Query() + for _, opt := range opts { + opt(query) + } + nq.withEditors = query + return nq +} + +// WithViewers tells the query-builder to eager-load the nodes that are connected to +// the "viewers" edge. The optional arguments are used to configure the query builder of the edge. +func (nq *NarrativeQuery) WithViewers(opts ...func(*GroupQuery)) *NarrativeQuery { + query := (&GroupClient{config: nq.config}).Query() + for _, opt := range opts { + opt(query) + } + nq.withViewers = query + return nq +} + // WithPolicy tells the query-builder to eager-load the nodes that are connected to // the "policy" edge. The optional arguments are used to configure the query builder of the edge. func (nq *NarrativeQuery) WithPolicy(opts ...func(*InternalPolicyQuery)) *NarrativeQuery { @@ -451,14 +609,14 @@ func (nq *NarrativeQuery) WithControlobjective(opts ...func(*ControlObjectiveQue return nq } -// WithProgram tells the query-builder to eager-load the nodes that are connected to -// the "program" edge. The optional arguments are used to configure the query builder of the edge. -func (nq *NarrativeQuery) WithProgram(opts ...func(*ProgramQuery)) *NarrativeQuery { +// WithPrograms tells the query-builder to eager-load the nodes that are connected to +// the "programs" edge. The optional arguments are used to configure the query builder of the edge. +func (nq *NarrativeQuery) WithPrograms(opts ...func(*ProgramQuery)) *NarrativeQuery { query := (&ProgramClient{config: nq.config}).Query() for _, opt := range opts { opt(query) } - nq.withProgram = query + nq.withPrograms = query return nq } @@ -533,6 +691,12 @@ func (nq *NarrativeQuery) prepareQuery(ctx context.Context) error { } nq.sql = prev } + if narrative.Policy == nil { + return errors.New("generated: uninitialized narrative.Policy (forgotten import generated/runtime?)") + } + if err := narrative.Policy.EvalQuery(ctx, nq); err != nil { + return err + } return nil } @@ -540,12 +704,16 @@ func (nq *NarrativeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Na var ( nodes = []*Narrative{} _spec = nq.querySpec() - loadedTypes = [5]bool{ + loadedTypes = [9]bool{ + nq.withOwner != nil, + nq.withBlockedGroups != nil, + nq.withEditors != nil, + nq.withViewers != nil, nq.withPolicy != nil, nq.withControl != nil, nq.withProcedure != nil, nq.withControlobjective != nil, - nq.withProgram != nil, + nq.withPrograms != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -571,6 +739,33 @@ func (nq *NarrativeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Na if len(nodes) == 0 { return nodes, nil } + if query := nq.withOwner; query != nil { + if err := nq.loadOwner(ctx, query, nodes, nil, + func(n *Narrative, e *Organization) { n.Edges.Owner = e }); err != nil { + return nil, err + } + } + if query := nq.withBlockedGroups; query != nil { + if err := nq.loadBlockedGroups(ctx, query, nodes, + func(n *Narrative) { n.Edges.BlockedGroups = []*Group{} }, + func(n *Narrative, e *Group) { n.Edges.BlockedGroups = append(n.Edges.BlockedGroups, e) }); err != nil { + return nil, err + } + } + if query := nq.withEditors; query != nil { + if err := nq.loadEditors(ctx, query, nodes, + func(n *Narrative) { n.Edges.Editors = []*Group{} }, + func(n *Narrative, e *Group) { n.Edges.Editors = append(n.Edges.Editors, e) }); err != nil { + return nil, err + } + } + if query := nq.withViewers; query != nil { + if err := nq.loadViewers(ctx, query, nodes, + func(n *Narrative) { n.Edges.Viewers = []*Group{} }, + func(n *Narrative, e *Group) { n.Edges.Viewers = append(n.Edges.Viewers, e) }); err != nil { + return nil, err + } + } if query := nq.withPolicy; query != nil { if err := nq.loadPolicy(ctx, query, nodes, func(n *Narrative) { n.Edges.Policy = []*InternalPolicy{} }, @@ -601,10 +796,31 @@ func (nq *NarrativeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Na return nil, err } } - if query := nq.withProgram; query != nil { - if err := nq.loadProgram(ctx, query, nodes, - func(n *Narrative) { n.Edges.Program = []*Program{} }, - func(n *Narrative, e *Program) { n.Edges.Program = append(n.Edges.Program, e) }); err != nil { + if query := nq.withPrograms; query != nil { + if err := nq.loadPrograms(ctx, query, nodes, + func(n *Narrative) { n.Edges.Programs = []*Program{} }, + func(n *Narrative, e *Program) { n.Edges.Programs = append(n.Edges.Programs, e) }); err != nil { + return nil, err + } + } + for name, query := range nq.withNamedBlockedGroups { + if err := nq.loadBlockedGroups(ctx, query, nodes, + func(n *Narrative) { n.appendNamedBlockedGroups(name) }, + func(n *Narrative, e *Group) { n.appendNamedBlockedGroups(name, e) }); err != nil { + return nil, err + } + } + for name, query := range nq.withNamedEditors { + if err := nq.loadEditors(ctx, query, nodes, + func(n *Narrative) { n.appendNamedEditors(name) }, + func(n *Narrative, e *Group) { n.appendNamedEditors(name, e) }); err != nil { + return nil, err + } + } + for name, query := range nq.withNamedViewers { + if err := nq.loadViewers(ctx, query, nodes, + func(n *Narrative) { n.appendNamedViewers(name) }, + func(n *Narrative, e *Group) { n.appendNamedViewers(name, e) }); err != nil { return nil, err } } @@ -636,10 +852,10 @@ func (nq *NarrativeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Na return nil, err } } - for name, query := range nq.withNamedProgram { - if err := nq.loadProgram(ctx, query, nodes, - func(n *Narrative) { n.appendNamedProgram(name) }, - func(n *Narrative, e *Program) { n.appendNamedProgram(name, e) }); err != nil { + for name, query := range nq.withNamedPrograms { + if err := nq.loadPrograms(ctx, query, nodes, + func(n *Narrative) { n.appendNamedPrograms(name) }, + func(n *Narrative, e *Program) { n.appendNamedPrograms(name, e) }); err != nil { return nil, err } } @@ -651,6 +867,221 @@ func (nq *NarrativeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Na return nodes, nil } +func (nq *NarrativeQuery) loadOwner(ctx context.Context, query *OrganizationQuery, nodes []*Narrative, init func(*Narrative), assign func(*Narrative, *Organization)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*Narrative) + for i := range nodes { + fk := nodes[i].OwnerID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(organization.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 "owner_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (nq *NarrativeQuery) loadBlockedGroups(ctx context.Context, query *GroupQuery, nodes []*Narrative, init func(*Narrative), assign func(*Narrative, *Group)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Narrative) + nids := make(map[string]map[*Narrative]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(narrative.BlockedGroupsTable) + joinT.Schema(nq.schemaConfig.NarrativeBlockedGroups) + s.Join(joinT).On(s.C(group.FieldID), joinT.C(narrative.BlockedGroupsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(narrative.BlockedGroupsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(narrative.BlockedGroupsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Narrative]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Group](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "blocked_groups" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (nq *NarrativeQuery) loadEditors(ctx context.Context, query *GroupQuery, nodes []*Narrative, init func(*Narrative), assign func(*Narrative, *Group)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Narrative) + nids := make(map[string]map[*Narrative]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(narrative.EditorsTable) + joinT.Schema(nq.schemaConfig.NarrativeEditors) + s.Join(joinT).On(s.C(group.FieldID), joinT.C(narrative.EditorsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(narrative.EditorsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(narrative.EditorsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Narrative]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Group](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "editors" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (nq *NarrativeQuery) loadViewers(ctx context.Context, query *GroupQuery, nodes []*Narrative, init func(*Narrative), assign func(*Narrative, *Group)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Narrative) + nids := make(map[string]map[*Narrative]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(narrative.ViewersTable) + joinT.Schema(nq.schemaConfig.NarrativeViewers) + s.Join(joinT).On(s.C(group.FieldID), joinT.C(narrative.ViewersPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(narrative.ViewersPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(narrative.ViewersPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Narrative]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Group](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "viewers" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} func (nq *NarrativeQuery) loadPolicy(ctx context.Context, query *InternalPolicyQuery, nodes []*Narrative, init func(*Narrative), assign func(*Narrative, *InternalPolicy)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[string]*Narrative) @@ -899,7 +1330,7 @@ func (nq *NarrativeQuery) loadControlobjective(ctx context.Context, query *Contr } return nil } -func (nq *NarrativeQuery) loadProgram(ctx context.Context, query *ProgramQuery, nodes []*Narrative, init func(*Narrative), assign func(*Narrative, *Program)) error { +func (nq *NarrativeQuery) loadPrograms(ctx context.Context, query *ProgramQuery, nodes []*Narrative, init func(*Narrative), assign func(*Narrative, *Program)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[string]*Narrative) nids := make(map[string]map[*Narrative]struct{}) @@ -911,12 +1342,12 @@ func (nq *NarrativeQuery) loadProgram(ctx context.Context, query *ProgramQuery, } } query.Where(func(s *sql.Selector) { - joinT := sql.Table(narrative.ProgramTable) + joinT := sql.Table(narrative.ProgramsTable) joinT.Schema(nq.schemaConfig.ProgramNarratives) - s.Join(joinT).On(s.C(program.FieldID), joinT.C(narrative.ProgramPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(narrative.ProgramPrimaryKey[1]), edgeIDs...)) + s.Join(joinT).On(s.C(program.FieldID), joinT.C(narrative.ProgramsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(narrative.ProgramsPrimaryKey[1]), edgeIDs...)) columns := s.SelectedColumns() - s.Select(joinT.C(narrative.ProgramPrimaryKey[1])) + s.Select(joinT.C(narrative.ProgramsPrimaryKey[1])) s.AppendSelect(columns...) s.SetDistinct(false) }) @@ -953,7 +1384,7 @@ func (nq *NarrativeQuery) loadProgram(ctx context.Context, query *ProgramQuery, for _, n := range neighbors { nodes, ok := nids[n.ID] if !ok { - return fmt.Errorf(`unexpected "program" node returned %v`, n.ID) + return fmt.Errorf(`unexpected "programs" node returned %v`, n.ID) } for kn := range nodes { assign(kn, n) @@ -992,6 +1423,9 @@ func (nq *NarrativeQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } + if nq.withOwner != nil { + _spec.Node.AddColumnOnce(narrative.FieldOwnerID) + } } if ps := nq.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { @@ -1060,6 +1494,48 @@ func (nq *NarrativeQuery) Modify(modifiers ...func(s *sql.Selector)) *NarrativeS return nq.Select() } +// WithNamedBlockedGroups tells the query-builder to eager-load the nodes that are connected to the "blocked_groups" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (nq *NarrativeQuery) WithNamedBlockedGroups(name string, opts ...func(*GroupQuery)) *NarrativeQuery { + query := (&GroupClient{config: nq.config}).Query() + for _, opt := range opts { + opt(query) + } + if nq.withNamedBlockedGroups == nil { + nq.withNamedBlockedGroups = make(map[string]*GroupQuery) + } + nq.withNamedBlockedGroups[name] = query + return nq +} + +// WithNamedEditors tells the query-builder to eager-load the nodes that are connected to the "editors" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (nq *NarrativeQuery) WithNamedEditors(name string, opts ...func(*GroupQuery)) *NarrativeQuery { + query := (&GroupClient{config: nq.config}).Query() + for _, opt := range opts { + opt(query) + } + if nq.withNamedEditors == nil { + nq.withNamedEditors = make(map[string]*GroupQuery) + } + nq.withNamedEditors[name] = query + return nq +} + +// WithNamedViewers tells the query-builder to eager-load the nodes that are connected to the "viewers" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (nq *NarrativeQuery) WithNamedViewers(name string, opts ...func(*GroupQuery)) *NarrativeQuery { + query := (&GroupClient{config: nq.config}).Query() + for _, opt := range opts { + opt(query) + } + if nq.withNamedViewers == nil { + nq.withNamedViewers = make(map[string]*GroupQuery) + } + nq.withNamedViewers[name] = query + return nq +} + // WithNamedPolicy tells the query-builder to eager-load the nodes that are connected to the "policy" // edge with the given name. The optional arguments are used to configure the query builder of the edge. func (nq *NarrativeQuery) WithNamedPolicy(name string, opts ...func(*InternalPolicyQuery)) *NarrativeQuery { @@ -1116,17 +1592,17 @@ func (nq *NarrativeQuery) WithNamedControlobjective(name string, opts ...func(*C return nq } -// WithNamedProgram tells the query-builder to eager-load the nodes that are connected to the "program" +// WithNamedPrograms tells the query-builder to eager-load the nodes that are connected to the "programs" // edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (nq *NarrativeQuery) WithNamedProgram(name string, opts ...func(*ProgramQuery)) *NarrativeQuery { +func (nq *NarrativeQuery) WithNamedPrograms(name string, opts ...func(*ProgramQuery)) *NarrativeQuery { query := (&ProgramClient{config: nq.config}).Query() for _, opt := range opts { opt(query) } - if nq.withNamedProgram == nil { - nq.withNamedProgram = make(map[string]*ProgramQuery) + if nq.withNamedPrograms == nil { + nq.withNamedPrograms = make(map[string]*ProgramQuery) } - nq.withNamedProgram[name] = query + nq.withNamedPrograms[name] = query return nq } diff --git a/internal/ent/generated/narrative_update.go b/internal/ent/generated/narrative_update.go index eb25dc08..54fde3c2 100644 --- a/internal/ent/generated/narrative_update.go +++ b/internal/ent/generated/narrative_update.go @@ -14,8 +14,10 @@ import ( "entgo.io/ent/schema/field" "github.com/theopenlane/core/internal/ent/generated/control" "github.com/theopenlane/core/internal/ent/generated/controlobjective" + "github.com/theopenlane/core/internal/ent/generated/group" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" "github.com/theopenlane/core/internal/ent/generated/narrative" + "github.com/theopenlane/core/internal/ent/generated/organization" "github.com/theopenlane/core/internal/ent/generated/predicate" "github.com/theopenlane/core/internal/ent/generated/procedure" "github.com/theopenlane/core/internal/ent/generated/program" @@ -127,6 +129,20 @@ func (nu *NarrativeUpdate) ClearTags() *NarrativeUpdate { return nu } +// SetOwnerID sets the "owner_id" field. +func (nu *NarrativeUpdate) SetOwnerID(s string) *NarrativeUpdate { + nu.mutation.SetOwnerID(s) + return nu +} + +// SetNillableOwnerID sets the "owner_id" field if the given value is not nil. +func (nu *NarrativeUpdate) SetNillableOwnerID(s *string) *NarrativeUpdate { + if s != nil { + nu.SetOwnerID(*s) + } + return nu +} + // SetName sets the "name" field. func (nu *NarrativeUpdate) SetName(s string) *NarrativeUpdate { nu.mutation.SetName(s) @@ -193,6 +209,56 @@ func (nu *NarrativeUpdate) ClearDetails() *NarrativeUpdate { return nu } +// SetOwner sets the "owner" edge to the Organization entity. +func (nu *NarrativeUpdate) SetOwner(o *Organization) *NarrativeUpdate { + return nu.SetOwnerID(o.ID) +} + +// AddBlockedGroupIDs adds the "blocked_groups" edge to the Group entity by IDs. +func (nu *NarrativeUpdate) AddBlockedGroupIDs(ids ...string) *NarrativeUpdate { + nu.mutation.AddBlockedGroupIDs(ids...) + return nu +} + +// AddBlockedGroups adds the "blocked_groups" edges to the Group entity. +func (nu *NarrativeUpdate) AddBlockedGroups(g ...*Group) *NarrativeUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nu.AddBlockedGroupIDs(ids...) +} + +// AddEditorIDs adds the "editors" edge to the Group entity by IDs. +func (nu *NarrativeUpdate) AddEditorIDs(ids ...string) *NarrativeUpdate { + nu.mutation.AddEditorIDs(ids...) + return nu +} + +// AddEditors adds the "editors" edges to the Group entity. +func (nu *NarrativeUpdate) AddEditors(g ...*Group) *NarrativeUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nu.AddEditorIDs(ids...) +} + +// AddViewerIDs adds the "viewers" edge to the Group entity by IDs. +func (nu *NarrativeUpdate) AddViewerIDs(ids ...string) *NarrativeUpdate { + nu.mutation.AddViewerIDs(ids...) + return nu +} + +// AddViewers adds the "viewers" edges to the Group entity. +func (nu *NarrativeUpdate) AddViewers(g ...*Group) *NarrativeUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nu.AddViewerIDs(ids...) +} + // AddPolicyIDs adds the "policy" edge to the InternalPolicy entity by IDs. func (nu *NarrativeUpdate) AddPolicyIDs(ids ...string) *NarrativeUpdate { nu.mutation.AddPolicyIDs(ids...) @@ -253,14 +319,14 @@ func (nu *NarrativeUpdate) AddControlobjective(c ...*ControlObjective) *Narrativ return nu.AddControlobjectiveIDs(ids...) } -// AddProgramIDs adds the "program" edge to the Program entity by IDs. +// AddProgramIDs adds the "programs" edge to the Program entity by IDs. func (nu *NarrativeUpdate) AddProgramIDs(ids ...string) *NarrativeUpdate { nu.mutation.AddProgramIDs(ids...) return nu } -// AddProgram adds the "program" edges to the Program entity. -func (nu *NarrativeUpdate) AddProgram(p ...*Program) *NarrativeUpdate { +// AddPrograms adds the "programs" edges to the Program entity. +func (nu *NarrativeUpdate) AddPrograms(p ...*Program) *NarrativeUpdate { ids := make([]string, len(p)) for i := range p { ids[i] = p[i].ID @@ -273,6 +339,75 @@ func (nu *NarrativeUpdate) Mutation() *NarrativeMutation { return nu.mutation } +// ClearOwner clears the "owner" edge to the Organization entity. +func (nu *NarrativeUpdate) ClearOwner() *NarrativeUpdate { + nu.mutation.ClearOwner() + return nu +} + +// ClearBlockedGroups clears all "blocked_groups" edges to the Group entity. +func (nu *NarrativeUpdate) ClearBlockedGroups() *NarrativeUpdate { + nu.mutation.ClearBlockedGroups() + return nu +} + +// RemoveBlockedGroupIDs removes the "blocked_groups" edge to Group entities by IDs. +func (nu *NarrativeUpdate) RemoveBlockedGroupIDs(ids ...string) *NarrativeUpdate { + nu.mutation.RemoveBlockedGroupIDs(ids...) + return nu +} + +// RemoveBlockedGroups removes "blocked_groups" edges to Group entities. +func (nu *NarrativeUpdate) RemoveBlockedGroups(g ...*Group) *NarrativeUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nu.RemoveBlockedGroupIDs(ids...) +} + +// ClearEditors clears all "editors" edges to the Group entity. +func (nu *NarrativeUpdate) ClearEditors() *NarrativeUpdate { + nu.mutation.ClearEditors() + return nu +} + +// RemoveEditorIDs removes the "editors" edge to Group entities by IDs. +func (nu *NarrativeUpdate) RemoveEditorIDs(ids ...string) *NarrativeUpdate { + nu.mutation.RemoveEditorIDs(ids...) + return nu +} + +// RemoveEditors removes "editors" edges to Group entities. +func (nu *NarrativeUpdate) RemoveEditors(g ...*Group) *NarrativeUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nu.RemoveEditorIDs(ids...) +} + +// ClearViewers clears all "viewers" edges to the Group entity. +func (nu *NarrativeUpdate) ClearViewers() *NarrativeUpdate { + nu.mutation.ClearViewers() + return nu +} + +// RemoveViewerIDs removes the "viewers" edge to Group entities by IDs. +func (nu *NarrativeUpdate) RemoveViewerIDs(ids ...string) *NarrativeUpdate { + nu.mutation.RemoveViewerIDs(ids...) + return nu +} + +// RemoveViewers removes "viewers" edges to Group entities. +func (nu *NarrativeUpdate) RemoveViewers(g ...*Group) *NarrativeUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nu.RemoveViewerIDs(ids...) +} + // ClearPolicy clears all "policy" edges to the InternalPolicy entity. func (nu *NarrativeUpdate) ClearPolicy() *NarrativeUpdate { nu.mutation.ClearPolicy() @@ -357,20 +492,20 @@ func (nu *NarrativeUpdate) RemoveControlobjective(c ...*ControlObjective) *Narra return nu.RemoveControlobjectiveIDs(ids...) } -// ClearProgram clears all "program" edges to the Program entity. -func (nu *NarrativeUpdate) ClearProgram() *NarrativeUpdate { - nu.mutation.ClearProgram() +// ClearPrograms clears all "programs" edges to the Program entity. +func (nu *NarrativeUpdate) ClearPrograms() *NarrativeUpdate { + nu.mutation.ClearPrograms() return nu } -// RemoveProgramIDs removes the "program" edge to Program entities by IDs. +// RemoveProgramIDs removes the "programs" edge to Program entities by IDs. func (nu *NarrativeUpdate) RemoveProgramIDs(ids ...string) *NarrativeUpdate { nu.mutation.RemoveProgramIDs(ids...) return nu } -// RemoveProgram removes "program" edges to Program entities. -func (nu *NarrativeUpdate) RemoveProgram(p ...*Program) *NarrativeUpdate { +// RemovePrograms removes "programs" edges to Program entities. +func (nu *NarrativeUpdate) RemovePrograms(p ...*Program) *NarrativeUpdate { ids := make([]string, len(p)) for i := range p { ids[i] = p[i].ID @@ -420,6 +555,24 @@ func (nu *NarrativeUpdate) defaults() error { return nil } +// check runs all checks and user-defined validators on the builder. +func (nu *NarrativeUpdate) check() error { + if v, ok := nu.mutation.OwnerID(); ok { + if err := narrative.OwnerIDValidator(v); err != nil { + return &ValidationError{Name: "owner_id", err: fmt.Errorf(`generated: validator failed for field "Narrative.owner_id": %w`, err)} + } + } + if v, ok := nu.mutation.Name(); ok { + if err := narrative.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`generated: validator failed for field "Narrative.name": %w`, err)} + } + } + if nu.mutation.OwnerCleared() && len(nu.mutation.OwnerIDs()) > 0 { + return errors.New(`generated: clearing a required unique edge "Narrative.owner"`) + } + return nil +} + // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (nu *NarrativeUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NarrativeUpdate { nu.modifiers = append(nu.modifiers, modifiers...) @@ -427,6 +580,9 @@ func (nu *NarrativeUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *Narr } func (nu *NarrativeUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := nu.check(); err != nil { + return n, err + } _spec := sqlgraph.NewUpdateSpec(narrative.Table, narrative.Columns, sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString)) if ps := nu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { @@ -497,6 +653,181 @@ func (nu *NarrativeUpdate) sqlSave(ctx context.Context) (n int, err error) { if nu.mutation.DetailsCleared() { _spec.ClearField(narrative.FieldDetails, field.TypeJSON) } + if nu.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: narrative.OwnerTable, + Columns: []string{narrative.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.Narrative + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nu.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: narrative.OwnerTable, + Columns: []string{narrative.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.Narrative + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if nu.mutation.BlockedGroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.BlockedGroupsTable, + Columns: narrative.BlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.NarrativeBlockedGroups + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nu.mutation.RemovedBlockedGroupsIDs(); len(nodes) > 0 && !nu.mutation.BlockedGroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.BlockedGroupsTable, + Columns: narrative.BlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nu.mutation.BlockedGroupsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.BlockedGroupsTable, + Columns: narrative.BlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if nu.mutation.EditorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.EditorsTable, + Columns: narrative.EditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.NarrativeEditors + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nu.mutation.RemovedEditorsIDs(); len(nodes) > 0 && !nu.mutation.EditorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.EditorsTable, + Columns: narrative.EditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nu.mutation.EditorsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.EditorsTable, + Columns: narrative.EditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if nu.mutation.ViewersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.ViewersTable, + Columns: narrative.ViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.NarrativeViewers + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nu.mutation.RemovedViewersIDs(); len(nodes) > 0 && !nu.mutation.ViewersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.ViewersTable, + Columns: narrative.ViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nu.mutation.ViewersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.ViewersTable, + Columns: narrative.ViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nu.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if nu.mutation.PolicyCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -689,12 +1020,12 @@ func (nu *NarrativeUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if nu.mutation.ProgramCleared() { + if nu.mutation.ProgramsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: narrative.ProgramTable, - Columns: narrative.ProgramPrimaryKey, + Table: narrative.ProgramsTable, + Columns: narrative.ProgramsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(program.FieldID, field.TypeString), @@ -703,12 +1034,12 @@ func (nu *NarrativeUpdate) sqlSave(ctx context.Context) (n int, err error) { edge.Schema = nu.schemaConfig.ProgramNarratives _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := nu.mutation.RemovedProgramIDs(); len(nodes) > 0 && !nu.mutation.ProgramCleared() { + if nodes := nu.mutation.RemovedProgramsIDs(); len(nodes) > 0 && !nu.mutation.ProgramsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: narrative.ProgramTable, - Columns: narrative.ProgramPrimaryKey, + Table: narrative.ProgramsTable, + Columns: narrative.ProgramsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(program.FieldID, field.TypeString), @@ -720,12 +1051,12 @@ func (nu *NarrativeUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := nu.mutation.ProgramIDs(); len(nodes) > 0 { + if nodes := nu.mutation.ProgramsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: narrative.ProgramTable, - Columns: narrative.ProgramPrimaryKey, + Table: narrative.ProgramsTable, + Columns: narrative.ProgramsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(program.FieldID, field.TypeString), @@ -851,6 +1182,20 @@ func (nuo *NarrativeUpdateOne) ClearTags() *NarrativeUpdateOne { return nuo } +// SetOwnerID sets the "owner_id" field. +func (nuo *NarrativeUpdateOne) SetOwnerID(s string) *NarrativeUpdateOne { + nuo.mutation.SetOwnerID(s) + return nuo +} + +// SetNillableOwnerID sets the "owner_id" field if the given value is not nil. +func (nuo *NarrativeUpdateOne) SetNillableOwnerID(s *string) *NarrativeUpdateOne { + if s != nil { + nuo.SetOwnerID(*s) + } + return nuo +} + // SetName sets the "name" field. func (nuo *NarrativeUpdateOne) SetName(s string) *NarrativeUpdateOne { nuo.mutation.SetName(s) @@ -917,6 +1262,56 @@ func (nuo *NarrativeUpdateOne) ClearDetails() *NarrativeUpdateOne { return nuo } +// SetOwner sets the "owner" edge to the Organization entity. +func (nuo *NarrativeUpdateOne) SetOwner(o *Organization) *NarrativeUpdateOne { + return nuo.SetOwnerID(o.ID) +} + +// AddBlockedGroupIDs adds the "blocked_groups" edge to the Group entity by IDs. +func (nuo *NarrativeUpdateOne) AddBlockedGroupIDs(ids ...string) *NarrativeUpdateOne { + nuo.mutation.AddBlockedGroupIDs(ids...) + return nuo +} + +// AddBlockedGroups adds the "blocked_groups" edges to the Group entity. +func (nuo *NarrativeUpdateOne) AddBlockedGroups(g ...*Group) *NarrativeUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nuo.AddBlockedGroupIDs(ids...) +} + +// AddEditorIDs adds the "editors" edge to the Group entity by IDs. +func (nuo *NarrativeUpdateOne) AddEditorIDs(ids ...string) *NarrativeUpdateOne { + nuo.mutation.AddEditorIDs(ids...) + return nuo +} + +// AddEditors adds the "editors" edges to the Group entity. +func (nuo *NarrativeUpdateOne) AddEditors(g ...*Group) *NarrativeUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nuo.AddEditorIDs(ids...) +} + +// AddViewerIDs adds the "viewers" edge to the Group entity by IDs. +func (nuo *NarrativeUpdateOne) AddViewerIDs(ids ...string) *NarrativeUpdateOne { + nuo.mutation.AddViewerIDs(ids...) + return nuo +} + +// AddViewers adds the "viewers" edges to the Group entity. +func (nuo *NarrativeUpdateOne) AddViewers(g ...*Group) *NarrativeUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nuo.AddViewerIDs(ids...) +} + // AddPolicyIDs adds the "policy" edge to the InternalPolicy entity by IDs. func (nuo *NarrativeUpdateOne) AddPolicyIDs(ids ...string) *NarrativeUpdateOne { nuo.mutation.AddPolicyIDs(ids...) @@ -977,14 +1372,14 @@ func (nuo *NarrativeUpdateOne) AddControlobjective(c ...*ControlObjective) *Narr return nuo.AddControlobjectiveIDs(ids...) } -// AddProgramIDs adds the "program" edge to the Program entity by IDs. +// AddProgramIDs adds the "programs" edge to the Program entity by IDs. func (nuo *NarrativeUpdateOne) AddProgramIDs(ids ...string) *NarrativeUpdateOne { nuo.mutation.AddProgramIDs(ids...) return nuo } -// AddProgram adds the "program" edges to the Program entity. -func (nuo *NarrativeUpdateOne) AddProgram(p ...*Program) *NarrativeUpdateOne { +// AddPrograms adds the "programs" edges to the Program entity. +func (nuo *NarrativeUpdateOne) AddPrograms(p ...*Program) *NarrativeUpdateOne { ids := make([]string, len(p)) for i := range p { ids[i] = p[i].ID @@ -997,6 +1392,75 @@ func (nuo *NarrativeUpdateOne) Mutation() *NarrativeMutation { return nuo.mutation } +// ClearOwner clears the "owner" edge to the Organization entity. +func (nuo *NarrativeUpdateOne) ClearOwner() *NarrativeUpdateOne { + nuo.mutation.ClearOwner() + return nuo +} + +// ClearBlockedGroups clears all "blocked_groups" edges to the Group entity. +func (nuo *NarrativeUpdateOne) ClearBlockedGroups() *NarrativeUpdateOne { + nuo.mutation.ClearBlockedGroups() + return nuo +} + +// RemoveBlockedGroupIDs removes the "blocked_groups" edge to Group entities by IDs. +func (nuo *NarrativeUpdateOne) RemoveBlockedGroupIDs(ids ...string) *NarrativeUpdateOne { + nuo.mutation.RemoveBlockedGroupIDs(ids...) + return nuo +} + +// RemoveBlockedGroups removes "blocked_groups" edges to Group entities. +func (nuo *NarrativeUpdateOne) RemoveBlockedGroups(g ...*Group) *NarrativeUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nuo.RemoveBlockedGroupIDs(ids...) +} + +// ClearEditors clears all "editors" edges to the Group entity. +func (nuo *NarrativeUpdateOne) ClearEditors() *NarrativeUpdateOne { + nuo.mutation.ClearEditors() + return nuo +} + +// RemoveEditorIDs removes the "editors" edge to Group entities by IDs. +func (nuo *NarrativeUpdateOne) RemoveEditorIDs(ids ...string) *NarrativeUpdateOne { + nuo.mutation.RemoveEditorIDs(ids...) + return nuo +} + +// RemoveEditors removes "editors" edges to Group entities. +func (nuo *NarrativeUpdateOne) RemoveEditors(g ...*Group) *NarrativeUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nuo.RemoveEditorIDs(ids...) +} + +// ClearViewers clears all "viewers" edges to the Group entity. +func (nuo *NarrativeUpdateOne) ClearViewers() *NarrativeUpdateOne { + nuo.mutation.ClearViewers() + return nuo +} + +// RemoveViewerIDs removes the "viewers" edge to Group entities by IDs. +func (nuo *NarrativeUpdateOne) RemoveViewerIDs(ids ...string) *NarrativeUpdateOne { + nuo.mutation.RemoveViewerIDs(ids...) + return nuo +} + +// RemoveViewers removes "viewers" edges to Group entities. +func (nuo *NarrativeUpdateOne) RemoveViewers(g ...*Group) *NarrativeUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return nuo.RemoveViewerIDs(ids...) +} + // ClearPolicy clears all "policy" edges to the InternalPolicy entity. func (nuo *NarrativeUpdateOne) ClearPolicy() *NarrativeUpdateOne { nuo.mutation.ClearPolicy() @@ -1081,20 +1545,20 @@ func (nuo *NarrativeUpdateOne) RemoveControlobjective(c ...*ControlObjective) *N return nuo.RemoveControlobjectiveIDs(ids...) } -// ClearProgram clears all "program" edges to the Program entity. -func (nuo *NarrativeUpdateOne) ClearProgram() *NarrativeUpdateOne { - nuo.mutation.ClearProgram() +// ClearPrograms clears all "programs" edges to the Program entity. +func (nuo *NarrativeUpdateOne) ClearPrograms() *NarrativeUpdateOne { + nuo.mutation.ClearPrograms() return nuo } -// RemoveProgramIDs removes the "program" edge to Program entities by IDs. +// RemoveProgramIDs removes the "programs" edge to Program entities by IDs. func (nuo *NarrativeUpdateOne) RemoveProgramIDs(ids ...string) *NarrativeUpdateOne { nuo.mutation.RemoveProgramIDs(ids...) return nuo } -// RemoveProgram removes "program" edges to Program entities. -func (nuo *NarrativeUpdateOne) RemoveProgram(p ...*Program) *NarrativeUpdateOne { +// RemovePrograms removes "programs" edges to Program entities. +func (nuo *NarrativeUpdateOne) RemovePrograms(p ...*Program) *NarrativeUpdateOne { ids := make([]string, len(p)) for i := range p { ids[i] = p[i].ID @@ -1157,6 +1621,24 @@ func (nuo *NarrativeUpdateOne) defaults() error { return nil } +// check runs all checks and user-defined validators on the builder. +func (nuo *NarrativeUpdateOne) check() error { + if v, ok := nuo.mutation.OwnerID(); ok { + if err := narrative.OwnerIDValidator(v); err != nil { + return &ValidationError{Name: "owner_id", err: fmt.Errorf(`generated: validator failed for field "Narrative.owner_id": %w`, err)} + } + } + if v, ok := nuo.mutation.Name(); ok { + if err := narrative.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`generated: validator failed for field "Narrative.name": %w`, err)} + } + } + if nuo.mutation.OwnerCleared() && len(nuo.mutation.OwnerIDs()) > 0 { + return errors.New(`generated: clearing a required unique edge "Narrative.owner"`) + } + return nil +} + // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (nuo *NarrativeUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NarrativeUpdateOne { nuo.modifiers = append(nuo.modifiers, modifiers...) @@ -1164,6 +1646,9 @@ func (nuo *NarrativeUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) * } func (nuo *NarrativeUpdateOne) sqlSave(ctx context.Context) (_node *Narrative, err error) { + if err := nuo.check(); err != nil { + return _node, err + } _spec := sqlgraph.NewUpdateSpec(narrative.Table, narrative.Columns, sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString)) id, ok := nuo.mutation.ID() if !ok { @@ -1251,6 +1736,181 @@ func (nuo *NarrativeUpdateOne) sqlSave(ctx context.Context) (_node *Narrative, e if nuo.mutation.DetailsCleared() { _spec.ClearField(narrative.FieldDetails, field.TypeJSON) } + if nuo.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: narrative.OwnerTable, + Columns: []string{narrative.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.Narrative + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nuo.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: narrative.OwnerTable, + Columns: []string{narrative.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.Narrative + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if nuo.mutation.BlockedGroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.BlockedGroupsTable, + Columns: narrative.BlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.NarrativeBlockedGroups + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nuo.mutation.RemovedBlockedGroupsIDs(); len(nodes) > 0 && !nuo.mutation.BlockedGroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.BlockedGroupsTable, + Columns: narrative.BlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nuo.mutation.BlockedGroupsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.BlockedGroupsTable, + Columns: narrative.BlockedGroupsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.NarrativeBlockedGroups + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if nuo.mutation.EditorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.EditorsTable, + Columns: narrative.EditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.NarrativeEditors + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nuo.mutation.RemovedEditorsIDs(); len(nodes) > 0 && !nuo.mutation.EditorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.EditorsTable, + Columns: narrative.EditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nuo.mutation.EditorsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.EditorsTable, + Columns: narrative.EditorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.NarrativeEditors + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if nuo.mutation.ViewersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.ViewersTable, + Columns: narrative.ViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.NarrativeViewers + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nuo.mutation.RemovedViewersIDs(); len(nodes) > 0 && !nuo.mutation.ViewersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.ViewersTable, + Columns: narrative.ViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := nuo.mutation.ViewersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: narrative.ViewersTable, + Columns: narrative.ViewersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeString), + }, + } + edge.Schema = nuo.schemaConfig.NarrativeViewers + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if nuo.mutation.PolicyCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -1443,12 +2103,12 @@ func (nuo *NarrativeUpdateOne) sqlSave(ctx context.Context) (_node *Narrative, e } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if nuo.mutation.ProgramCleared() { + if nuo.mutation.ProgramsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: narrative.ProgramTable, - Columns: narrative.ProgramPrimaryKey, + Table: narrative.ProgramsTable, + Columns: narrative.ProgramsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(program.FieldID, field.TypeString), @@ -1457,12 +2117,12 @@ func (nuo *NarrativeUpdateOne) sqlSave(ctx context.Context) (_node *Narrative, e edge.Schema = nuo.schemaConfig.ProgramNarratives _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := nuo.mutation.RemovedProgramIDs(); len(nodes) > 0 && !nuo.mutation.ProgramCleared() { + if nodes := nuo.mutation.RemovedProgramsIDs(); len(nodes) > 0 && !nuo.mutation.ProgramsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: narrative.ProgramTable, - Columns: narrative.ProgramPrimaryKey, + Table: narrative.ProgramsTable, + Columns: narrative.ProgramsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(program.FieldID, field.TypeString), @@ -1474,12 +2134,12 @@ func (nuo *NarrativeUpdateOne) sqlSave(ctx context.Context) (_node *Narrative, e } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := nuo.mutation.ProgramIDs(); len(nodes) > 0 { + if nodes := nuo.mutation.ProgramsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: narrative.ProgramTable, - Columns: narrative.ProgramPrimaryKey, + Table: narrative.ProgramsTable, + Columns: narrative.ProgramsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(program.FieldID, field.TypeString), diff --git a/internal/ent/generated/narrativehistory.go b/internal/ent/generated/narrativehistory.go index adf3365e..011adf3e 100644 --- a/internal/ent/generated/narrativehistory.go +++ b/internal/ent/generated/narrativehistory.go @@ -41,6 +41,8 @@ type NarrativeHistory struct { MappingID string `json:"mapping_id,omitempty"` // tags associated with the object Tags []string `json:"tags,omitempty"` + // the ID of the organization owner of the object + OwnerID string `json:"owner_id,omitempty"` // the name of the narrative Name string `json:"name,omitempty"` // the description of the narrative @@ -61,7 +63,7 @@ func (*NarrativeHistory) scanValues(columns []string) ([]any, error) { values[i] = new([]byte) case narrativehistory.FieldOperation: values[i] = new(history.OpType) - case narrativehistory.FieldID, narrativehistory.FieldRef, narrativehistory.FieldCreatedBy, narrativehistory.FieldUpdatedBy, narrativehistory.FieldDeletedBy, narrativehistory.FieldMappingID, narrativehistory.FieldName, narrativehistory.FieldDescription, narrativehistory.FieldSatisfies: + case narrativehistory.FieldID, narrativehistory.FieldRef, narrativehistory.FieldCreatedBy, narrativehistory.FieldUpdatedBy, narrativehistory.FieldDeletedBy, narrativehistory.FieldMappingID, narrativehistory.FieldOwnerID, narrativehistory.FieldName, narrativehistory.FieldDescription, narrativehistory.FieldSatisfies: values[i] = new(sql.NullString) case narrativehistory.FieldHistoryTime, narrativehistory.FieldCreatedAt, narrativehistory.FieldUpdatedAt, narrativehistory.FieldDeletedAt: values[i] = new(sql.NullTime) @@ -154,6 +156,12 @@ func (nh *NarrativeHistory) assignValues(columns []string, values []any) error { return fmt.Errorf("unmarshal field tags: %w", err) } } + case narrativehistory.FieldOwnerID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field owner_id", values[i]) + } else if value.Valid { + nh.OwnerID = value.String + } case narrativehistory.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) @@ -249,6 +257,9 @@ func (nh *NarrativeHistory) String() string { builder.WriteString("tags=") builder.WriteString(fmt.Sprintf("%v", nh.Tags)) builder.WriteString(", ") + builder.WriteString("owner_id=") + builder.WriteString(nh.OwnerID) + builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(nh.Name) builder.WriteString(", ") diff --git a/internal/ent/generated/narrativehistory/narrativehistory.go b/internal/ent/generated/narrativehistory/narrativehistory.go index d7ac9c33..1eb2596f 100644 --- a/internal/ent/generated/narrativehistory/narrativehistory.go +++ b/internal/ent/generated/narrativehistory/narrativehistory.go @@ -6,6 +6,7 @@ import ( "fmt" "time" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" "github.com/theopenlane/entx/history" @@ -38,6 +39,8 @@ const ( FieldMappingID = "mapping_id" // FieldTags holds the string denoting the tags field in the database. FieldTags = "tags" + // FieldOwnerID holds the string denoting the owner_id field in the database. + FieldOwnerID = "owner_id" // FieldName holds the string denoting the name field in the database. FieldName = "name" // FieldDescription holds the string denoting the description field in the database. @@ -64,6 +67,7 @@ var Columns = []string{ FieldDeletedBy, FieldMappingID, FieldTags, + FieldOwnerID, FieldName, FieldDescription, FieldSatisfies, @@ -80,7 +84,15 @@ func ValidColumn(column string) bool { return false } +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/theopenlane/core/internal/ent/generated/runtime" var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + Policy ent.Policy // DefaultHistoryTime holds the default value on creation for the "history_time" field. DefaultHistoryTime func() time.Time // DefaultCreatedAt holds the default value on creation for the "created_at" field. @@ -165,6 +177,11 @@ func ByMappingID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldMappingID, opts...).ToFunc() } +// ByOwnerID orders the results by the owner_id field. +func ByOwnerID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOwnerID, opts...).ToFunc() +} + // ByName orders the results by the name field. func ByName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldName, opts...).ToFunc() diff --git a/internal/ent/generated/narrativehistory/where.go b/internal/ent/generated/narrativehistory/where.go index 2327fd3d..ea7cf35a 100644 --- a/internal/ent/generated/narrativehistory/where.go +++ b/internal/ent/generated/narrativehistory/where.go @@ -110,6 +110,11 @@ func MappingID(v string) predicate.NarrativeHistory { return predicate.NarrativeHistory(sql.FieldEQ(FieldMappingID, v)) } +// OwnerID applies equality check predicate on the "owner_id" field. It's identical to OwnerIDEQ. +func OwnerID(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldEQ(FieldOwnerID, v)) +} + // Name applies equality check predicate on the "name" field. It's identical to NameEQ. func Name(v string) predicate.NarrativeHistory { return predicate.NarrativeHistory(sql.FieldEQ(FieldName, v)) @@ -710,6 +715,71 @@ func TagsNotNil() predicate.NarrativeHistory { return predicate.NarrativeHistory(sql.FieldNotNull(FieldTags)) } +// OwnerIDEQ applies the EQ predicate on the "owner_id" field. +func OwnerIDEQ(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldEQ(FieldOwnerID, v)) +} + +// OwnerIDNEQ applies the NEQ predicate on the "owner_id" field. +func OwnerIDNEQ(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldNEQ(FieldOwnerID, v)) +} + +// OwnerIDIn applies the In predicate on the "owner_id" field. +func OwnerIDIn(vs ...string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldIn(FieldOwnerID, vs...)) +} + +// OwnerIDNotIn applies the NotIn predicate on the "owner_id" field. +func OwnerIDNotIn(vs ...string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldNotIn(FieldOwnerID, vs...)) +} + +// OwnerIDGT applies the GT predicate on the "owner_id" field. +func OwnerIDGT(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldGT(FieldOwnerID, v)) +} + +// OwnerIDGTE applies the GTE predicate on the "owner_id" field. +func OwnerIDGTE(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldGTE(FieldOwnerID, v)) +} + +// OwnerIDLT applies the LT predicate on the "owner_id" field. +func OwnerIDLT(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldLT(FieldOwnerID, v)) +} + +// OwnerIDLTE applies the LTE predicate on the "owner_id" field. +func OwnerIDLTE(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldLTE(FieldOwnerID, v)) +} + +// OwnerIDContains applies the Contains predicate on the "owner_id" field. +func OwnerIDContains(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldContains(FieldOwnerID, v)) +} + +// OwnerIDHasPrefix applies the HasPrefix predicate on the "owner_id" field. +func OwnerIDHasPrefix(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldHasPrefix(FieldOwnerID, v)) +} + +// OwnerIDHasSuffix applies the HasSuffix predicate on the "owner_id" field. +func OwnerIDHasSuffix(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldHasSuffix(FieldOwnerID, v)) +} + +// OwnerIDEqualFold applies the EqualFold predicate on the "owner_id" field. +func OwnerIDEqualFold(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldEqualFold(FieldOwnerID, v)) +} + +// OwnerIDContainsFold applies the ContainsFold predicate on the "owner_id" field. +func OwnerIDContainsFold(v string) predicate.NarrativeHistory { + return predicate.NarrativeHistory(sql.FieldContainsFold(FieldOwnerID, v)) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.NarrativeHistory { return predicate.NarrativeHistory(sql.FieldEQ(FieldName, v)) diff --git a/internal/ent/generated/narrativehistory_create.go b/internal/ent/generated/narrativehistory_create.go index 082154d8..fb78c95d 100644 --- a/internal/ent/generated/narrativehistory_create.go +++ b/internal/ent/generated/narrativehistory_create.go @@ -159,6 +159,12 @@ func (nhc *NarrativeHistoryCreate) SetTags(s []string) *NarrativeHistoryCreate { return nhc } +// SetOwnerID sets the "owner_id" field. +func (nhc *NarrativeHistoryCreate) SetOwnerID(s string) *NarrativeHistoryCreate { + nhc.mutation.SetOwnerID(s) + return nhc +} + // SetName sets the "name" field. func (nhc *NarrativeHistoryCreate) SetName(s string) *NarrativeHistoryCreate { nhc.mutation.SetName(s) @@ -220,7 +226,9 @@ func (nhc *NarrativeHistoryCreate) Mutation() *NarrativeHistoryMutation { // Save creates the NarrativeHistory in the database. func (nhc *NarrativeHistoryCreate) Save(ctx context.Context) (*NarrativeHistory, error) { - nhc.defaults() + if err := nhc.defaults(); err != nil { + return nil, err + } return withHooks(ctx, nhc.sqlSave, nhc.mutation, nhc.hooks) } @@ -247,20 +255,32 @@ func (nhc *NarrativeHistoryCreate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (nhc *NarrativeHistoryCreate) defaults() { +func (nhc *NarrativeHistoryCreate) defaults() error { if _, ok := nhc.mutation.HistoryTime(); !ok { + if narrativehistory.DefaultHistoryTime == nil { + return fmt.Errorf("generated: uninitialized narrativehistory.DefaultHistoryTime (forgotten import generated/runtime?)") + } v := narrativehistory.DefaultHistoryTime() nhc.mutation.SetHistoryTime(v) } if _, ok := nhc.mutation.CreatedAt(); !ok { + if narrativehistory.DefaultCreatedAt == nil { + return fmt.Errorf("generated: uninitialized narrativehistory.DefaultCreatedAt (forgotten import generated/runtime?)") + } v := narrativehistory.DefaultCreatedAt() nhc.mutation.SetCreatedAt(v) } if _, ok := nhc.mutation.UpdatedAt(); !ok { + if narrativehistory.DefaultUpdatedAt == nil { + return fmt.Errorf("generated: uninitialized narrativehistory.DefaultUpdatedAt (forgotten import generated/runtime?)") + } v := narrativehistory.DefaultUpdatedAt() nhc.mutation.SetUpdatedAt(v) } if _, ok := nhc.mutation.MappingID(); !ok { + if narrativehistory.DefaultMappingID == nil { + return fmt.Errorf("generated: uninitialized narrativehistory.DefaultMappingID (forgotten import generated/runtime?)") + } v := narrativehistory.DefaultMappingID() nhc.mutation.SetMappingID(v) } @@ -269,9 +289,13 @@ func (nhc *NarrativeHistoryCreate) defaults() { nhc.mutation.SetTags(v) } if _, ok := nhc.mutation.ID(); !ok { + if narrativehistory.DefaultID == nil { + return fmt.Errorf("generated: uninitialized narrativehistory.DefaultID (forgotten import generated/runtime?)") + } v := narrativehistory.DefaultID() nhc.mutation.SetID(v) } + return nil } // check runs all checks and user-defined validators on the builder. @@ -290,6 +314,9 @@ func (nhc *NarrativeHistoryCreate) check() error { if _, ok := nhc.mutation.MappingID(); !ok { return &ValidationError{Name: "mapping_id", err: errors.New(`generated: missing required field "NarrativeHistory.mapping_id"`)} } + if _, ok := nhc.mutation.OwnerID(); !ok { + return &ValidationError{Name: "owner_id", err: errors.New(`generated: missing required field "NarrativeHistory.owner_id"`)} + } if _, ok := nhc.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`generated: missing required field "NarrativeHistory.name"`)} } @@ -373,6 +400,10 @@ func (nhc *NarrativeHistoryCreate) createSpec() (*NarrativeHistory, *sqlgraph.Cr _spec.SetField(narrativehistory.FieldTags, field.TypeJSON, value) _node.Tags = value } + if value, ok := nhc.mutation.OwnerID(); ok { + _spec.SetField(narrativehistory.FieldOwnerID, field.TypeString, value) + _node.OwnerID = value + } if value, ok := nhc.mutation.Name(); ok { _spec.SetField(narrativehistory.FieldName, field.TypeString, value) _node.Name = value diff --git a/internal/ent/generated/narrativehistory_query.go b/internal/ent/generated/narrativehistory_query.go index 1d89e103..72e7779f 100644 --- a/internal/ent/generated/narrativehistory_query.go +++ b/internal/ent/generated/narrativehistory_query.go @@ -4,6 +4,7 @@ package generated import ( "context" + "errors" "fmt" "math" @@ -332,6 +333,12 @@ func (nhq *NarrativeHistoryQuery) prepareQuery(ctx context.Context) error { } nhq.sql = prev } + if narrativehistory.Policy == nil { + return errors.New("generated: uninitialized narrativehistory.Policy (forgotten import generated/runtime?)") + } + if err := narrativehistory.Policy.EvalQuery(ctx, nhq); err != nil { + return err + } return nil } diff --git a/internal/ent/generated/narrativehistory_update.go b/internal/ent/generated/narrativehistory_update.go index 5bd24004..347ab90c 100644 --- a/internal/ent/generated/narrativehistory_update.go +++ b/internal/ent/generated/narrativehistory_update.go @@ -122,6 +122,20 @@ func (nhu *NarrativeHistoryUpdate) ClearTags() *NarrativeHistoryUpdate { return nhu } +// SetOwnerID sets the "owner_id" field. +func (nhu *NarrativeHistoryUpdate) SetOwnerID(s string) *NarrativeHistoryUpdate { + nhu.mutation.SetOwnerID(s) + return nhu +} + +// SetNillableOwnerID sets the "owner_id" field if the given value is not nil. +func (nhu *NarrativeHistoryUpdate) SetNillableOwnerID(s *string) *NarrativeHistoryUpdate { + if s != nil { + nhu.SetOwnerID(*s) + } + return nhu +} + // SetName sets the "name" field. func (nhu *NarrativeHistoryUpdate) SetName(s string) *NarrativeHistoryUpdate { nhu.mutation.SetName(s) @@ -195,7 +209,9 @@ func (nhu *NarrativeHistoryUpdate) Mutation() *NarrativeHistoryMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (nhu *NarrativeHistoryUpdate) Save(ctx context.Context) (int, error) { - nhu.defaults() + if err := nhu.defaults(); err != nil { + return 0, err + } return withHooks(ctx, nhu.sqlSave, nhu.mutation, nhu.hooks) } @@ -222,11 +238,15 @@ func (nhu *NarrativeHistoryUpdate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (nhu *NarrativeHistoryUpdate) defaults() { +func (nhu *NarrativeHistoryUpdate) defaults() error { if _, ok := nhu.mutation.UpdatedAt(); !ok && !nhu.mutation.UpdatedAtCleared() { + if narrativehistory.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("generated: uninitialized narrativehistory.UpdateDefaultUpdatedAt (forgotten import generated/runtime?)") + } v := narrativehistory.UpdateDefaultUpdatedAt() nhu.mutation.SetUpdatedAt(v) } + return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. @@ -288,6 +308,9 @@ func (nhu *NarrativeHistoryUpdate) sqlSave(ctx context.Context) (n int, err erro if nhu.mutation.TagsCleared() { _spec.ClearField(narrativehistory.FieldTags, field.TypeJSON) } + if value, ok := nhu.mutation.OwnerID(); ok { + _spec.SetField(narrativehistory.FieldOwnerID, field.TypeString, value) + } if value, ok := nhu.mutation.Name(); ok { _spec.SetField(narrativehistory.FieldName, field.TypeString, value) } @@ -423,6 +446,20 @@ func (nhuo *NarrativeHistoryUpdateOne) ClearTags() *NarrativeHistoryUpdateOne { return nhuo } +// SetOwnerID sets the "owner_id" field. +func (nhuo *NarrativeHistoryUpdateOne) SetOwnerID(s string) *NarrativeHistoryUpdateOne { + nhuo.mutation.SetOwnerID(s) + return nhuo +} + +// SetNillableOwnerID sets the "owner_id" field if the given value is not nil. +func (nhuo *NarrativeHistoryUpdateOne) SetNillableOwnerID(s *string) *NarrativeHistoryUpdateOne { + if s != nil { + nhuo.SetOwnerID(*s) + } + return nhuo +} + // SetName sets the "name" field. func (nhuo *NarrativeHistoryUpdateOne) SetName(s string) *NarrativeHistoryUpdateOne { nhuo.mutation.SetName(s) @@ -509,7 +546,9 @@ func (nhuo *NarrativeHistoryUpdateOne) Select(field string, fields ...string) *N // Save executes the query and returns the updated NarrativeHistory entity. func (nhuo *NarrativeHistoryUpdateOne) Save(ctx context.Context) (*NarrativeHistory, error) { - nhuo.defaults() + if err := nhuo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, nhuo.sqlSave, nhuo.mutation, nhuo.hooks) } @@ -536,11 +575,15 @@ func (nhuo *NarrativeHistoryUpdateOne) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (nhuo *NarrativeHistoryUpdateOne) defaults() { +func (nhuo *NarrativeHistoryUpdateOne) defaults() error { if _, ok := nhuo.mutation.UpdatedAt(); !ok && !nhuo.mutation.UpdatedAtCleared() { + if narrativehistory.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("generated: uninitialized narrativehistory.UpdateDefaultUpdatedAt (forgotten import generated/runtime?)") + } v := narrativehistory.UpdateDefaultUpdatedAt() nhuo.mutation.SetUpdatedAt(v) } + return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. @@ -619,6 +662,9 @@ func (nhuo *NarrativeHistoryUpdateOne) sqlSave(ctx context.Context) (_node *Narr if nhuo.mutation.TagsCleared() { _spec.ClearField(narrativehistory.FieldTags, field.TypeJSON) } + if value, ok := nhuo.mutation.OwnerID(); ok { + _spec.SetField(narrativehistory.FieldOwnerID, field.TypeString, value) + } if value, ok := nhuo.mutation.Name(); ok { _spec.SetField(narrativehistory.FieldName, field.TypeString, value) } diff --git a/internal/ent/generated/organization.go b/internal/ent/generated/organization.go index 6b5a87c8..c994e4c6 100644 --- a/internal/ent/generated/organization.go +++ b/internal/ent/generated/organization.go @@ -121,13 +121,15 @@ type OrganizationEdges struct { Risks []*Risk `json:"risks,omitempty"` // Controlobjectives holds the value of the controlobjectives edge. Controlobjectives []*ControlObjective `json:"controlobjectives,omitempty"` + // Narratives holds the value of the narratives edge. + Narratives []*Narrative `json:"narratives,omitempty"` // Members holds the value of the members edge. Members []*OrgMembership `json:"members,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [33]bool + loadedTypes [34]bool // totalCount holds the count of the edges above. - totalCount [33]map[string]int + totalCount [34]map[string]int namedChildren map[string][]*Organization namedGroups map[string][]*Group @@ -159,6 +161,7 @@ type OrganizationEdges struct { namedInternalpolicies map[string][]*InternalPolicy namedRisks map[string][]*Risk namedControlobjectives map[string][]*ControlObjective + namedNarratives map[string][]*Narrative namedMembers map[string][]*OrgMembership } @@ -454,10 +457,19 @@ func (e OrganizationEdges) ControlobjectivesOrErr() ([]*ControlObjective, error) return nil, &NotLoadedError{edge: "controlobjectives"} } +// NarrativesOrErr returns the Narratives value or an error if the edge +// was not loaded in eager-loading. +func (e OrganizationEdges) NarrativesOrErr() ([]*Narrative, error) { + if e.loadedTypes[32] { + return e.Narratives, nil + } + return nil, &NotLoadedError{edge: "narratives"} +} + // MembersOrErr returns the Members value or an error if the edge // was not loaded in eager-loading. func (e OrganizationEdges) MembersOrErr() ([]*OrgMembership, error) { - if e.loadedTypes[32] { + if e.loadedTypes[33] { return e.Members, nil } return nil, &NotLoadedError{edge: "members"} @@ -763,6 +775,11 @@ func (o *Organization) QueryControlobjectives() *ControlObjectiveQuery { return NewOrganizationClient(o.config).QueryControlobjectives(o) } +// QueryNarratives queries the "narratives" edge of the Organization entity. +func (o *Organization) QueryNarratives() *NarrativeQuery { + return NewOrganizationClient(o.config).QueryNarratives(o) +} + // QueryMembers queries the "members" edge of the Organization entity. func (o *Organization) QueryMembers() *OrgMembershipQuery { return NewOrganizationClient(o.config).QueryMembers(o) @@ -1561,6 +1578,30 @@ func (o *Organization) appendNamedControlobjectives(name string, edges ...*Contr } } +// NamedNarratives returns the Narratives named value or an error if the edge was not +// loaded in eager-loading with this name. +func (o *Organization) NamedNarratives(name string) ([]*Narrative, error) { + if o.Edges.namedNarratives == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := o.Edges.namedNarratives[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (o *Organization) appendNamedNarratives(name string, edges ...*Narrative) { + if o.Edges.namedNarratives == nil { + o.Edges.namedNarratives = make(map[string][]*Narrative) + } + if len(edges) == 0 { + o.Edges.namedNarratives[name] = []*Narrative{} + } else { + o.Edges.namedNarratives[name] = append(o.Edges.namedNarratives[name], edges...) + } +} + // NamedMembers returns the Members named value or an error if the edge was not // loaded in eager-loading with this name. func (o *Organization) NamedMembers(name string) ([]*OrgMembership, error) { diff --git a/internal/ent/generated/organization/organization.go b/internal/ent/generated/organization/organization.go index 47bdd74a..5e2d1756 100644 --- a/internal/ent/generated/organization/organization.go +++ b/internal/ent/generated/organization/organization.go @@ -109,6 +109,8 @@ const ( EdgeRisks = "risks" // EdgeControlobjectives holds the string denoting the controlobjectives edge name in mutations. EdgeControlobjectives = "controlobjectives" + // EdgeNarratives holds the string denoting the narratives edge name in mutations. + EdgeNarratives = "narratives" // EdgeMembers holds the string denoting the members edge name in mutations. EdgeMembers = "members" // Table holds the table name of the organization in the database. @@ -319,6 +321,13 @@ const ( ControlobjectivesInverseTable = "control_objectives" // ControlobjectivesColumn is the table column denoting the controlobjectives relation/edge. ControlobjectivesColumn = "owner_id" + // NarrativesTable is the table that holds the narratives relation/edge. + NarrativesTable = "narratives" + // NarrativesInverseTable is the table name for the Narrative entity. + // It exists in this package in order to avoid circular dependency with the "narrative" package. + NarrativesInverseTable = "narratives" + // NarrativesColumn is the table column denoting the narratives relation/edge. + NarrativesColumn = "owner_id" // MembersTable is the table that holds the members relation/edge. MembersTable = "org_memberships" // MembersInverseTable is the table name for the OrgMembership entity. @@ -926,6 +935,20 @@ func ByControlobjectives(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption } } +// ByNarrativesCount orders the results by narratives count. +func ByNarrativesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newNarrativesStep(), opts...) + } +} + +// ByNarratives orders the results by narratives terms. +func ByNarratives(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newNarrativesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByMembersCount orders the results by members count. func ByMembersCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -1163,6 +1186,13 @@ func newControlobjectivesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, ControlobjectivesTable, ControlobjectivesColumn), ) } +func newNarrativesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(NarrativesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, NarrativesTable, NarrativesColumn), + ) +} func newMembersStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/internal/ent/generated/organization/where.go b/internal/ent/generated/organization/where.go index 65affa4c..9ee6d51c 100644 --- a/internal/ent/generated/organization/where.go +++ b/internal/ent/generated/organization/where.go @@ -1900,6 +1900,35 @@ func HasControlobjectivesWith(preds ...predicate.ControlObjective) predicate.Org }) } +// HasNarratives applies the HasEdge predicate on the "narratives" edge. +func HasNarratives() predicate.Organization { + return predicate.Organization(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, NarrativesTable, NarrativesColumn), + ) + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.Narrative + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasNarrativesWith applies the HasEdge predicate on the "narratives" edge with a given conditions (other predicates). +func HasNarrativesWith(preds ...predicate.Narrative) predicate.Organization { + return predicate.Organization(func(s *sql.Selector) { + step := newNarrativesStep() + schemaConfig := internal.SchemaConfigFromContext(s.Context()) + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.Narrative + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasMembers applies the HasEdge predicate on the "members" edge. func HasMembers() predicate.Organization { return predicate.Organization(func(s *sql.Selector) { diff --git a/internal/ent/generated/organization_create.go b/internal/ent/generated/organization_create.go index 3f69347d..729d7d79 100644 --- a/internal/ent/generated/organization_create.go +++ b/internal/ent/generated/organization_create.go @@ -27,6 +27,7 @@ import ( "github.com/theopenlane/core/internal/ent/generated/integration" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" "github.com/theopenlane/core/internal/ent/generated/invite" + "github.com/theopenlane/core/internal/ent/generated/narrative" "github.com/theopenlane/core/internal/ent/generated/note" "github.com/theopenlane/core/internal/ent/generated/oauthprovider" "github.com/theopenlane/core/internal/ent/generated/organization" @@ -746,6 +747,21 @@ func (oc *OrganizationCreate) AddControlobjectives(c ...*ControlObjective) *Orga return oc.AddControlobjectiveIDs(ids...) } +// AddNarrativeIDs adds the "narratives" edge to the Narrative entity by IDs. +func (oc *OrganizationCreate) AddNarrativeIDs(ids ...string) *OrganizationCreate { + oc.mutation.AddNarrativeIDs(ids...) + return oc +} + +// AddNarratives adds the "narratives" edges to the Narrative entity. +func (oc *OrganizationCreate) AddNarratives(n ...*Narrative) *OrganizationCreate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return oc.AddNarrativeIDs(ids...) +} + // AddMemberIDs adds the "members" edge to the OrgMembership entity by IDs. func (oc *OrganizationCreate) AddMemberIDs(ids ...string) *OrganizationCreate { oc.mutation.AddMemberIDs(ids...) @@ -1518,6 +1534,23 @@ func (oc *OrganizationCreate) createSpec() (*Organization, *sqlgraph.CreateSpec) } _spec.Edges = append(_spec.Edges, edge) } + if nodes := oc.mutation.NarrativesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: organization.NarrativesTable, + Columns: []string{organization.NarrativesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = oc.schemaConfig.Narrative + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := oc.mutation.MembersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/internal/ent/generated/organization_query.go b/internal/ent/generated/organization_query.go index 9b404d08..9e04325a 100644 --- a/internal/ent/generated/organization_query.go +++ b/internal/ent/generated/organization_query.go @@ -30,6 +30,7 @@ import ( "github.com/theopenlane/core/internal/ent/generated/integration" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" "github.com/theopenlane/core/internal/ent/generated/invite" + "github.com/theopenlane/core/internal/ent/generated/narrative" "github.com/theopenlane/core/internal/ent/generated/note" "github.com/theopenlane/core/internal/ent/generated/oauthprovider" "github.com/theopenlane/core/internal/ent/generated/organization" @@ -88,6 +89,7 @@ type OrganizationQuery struct { withInternalpolicies *InternalPolicyQuery withRisks *RiskQuery withControlobjectives *ControlObjectiveQuery + withNarratives *NarrativeQuery withMembers *OrgMembershipQuery loadTotal []func(context.Context, []*Organization) error modifiers []func(*sql.Selector) @@ -121,6 +123,7 @@ type OrganizationQuery struct { withNamedInternalpolicies map[string]*InternalPolicyQuery withNamedRisks map[string]*RiskQuery withNamedControlobjectives map[string]*ControlObjectiveQuery + withNamedNarratives map[string]*NarrativeQuery withNamedMembers map[string]*OrgMembershipQuery // intermediate query (i.e. traversal path). sql *sql.Selector @@ -958,6 +961,31 @@ func (oq *OrganizationQuery) QueryControlobjectives() *ControlObjectiveQuery { return query } +// QueryNarratives chains the current query on the "narratives" edge. +func (oq *OrganizationQuery) QueryNarratives() *NarrativeQuery { + query := (&NarrativeClient{config: oq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := oq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := oq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(organization.Table, organization.FieldID, selector), + sqlgraph.To(narrative.Table, narrative.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, organization.NarrativesTable, organization.NarrativesColumn), + ) + schemaConfig := oq.schemaConfig + step.To.Schema = schemaConfig.Narrative + step.Edge.Schema = schemaConfig.Narrative + fromU = sqlgraph.SetNeighbors(oq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryMembers chains the current query on the "members" edge. func (oq *OrganizationQuery) QueryMembers() *OrgMembershipQuery { query := (&OrgMembershipClient{config: oq.config}).Query() @@ -1207,6 +1235,7 @@ func (oq *OrganizationQuery) Clone() *OrganizationQuery { withInternalpolicies: oq.withInternalpolicies.Clone(), withRisks: oq.withRisks.Clone(), withControlobjectives: oq.withControlobjectives.Clone(), + withNarratives: oq.withNarratives.Clone(), withMembers: oq.withMembers.Clone(), // clone intermediate query. sql: oq.sql.Clone(), @@ -1567,6 +1596,17 @@ func (oq *OrganizationQuery) WithControlobjectives(opts ...func(*ControlObjectiv return oq } +// WithNarratives tells the query-builder to eager-load the nodes that are connected to +// the "narratives" edge. The optional arguments are used to configure the query builder of the edge. +func (oq *OrganizationQuery) WithNarratives(opts ...func(*NarrativeQuery)) *OrganizationQuery { + query := (&NarrativeClient{config: oq.config}).Query() + for _, opt := range opts { + opt(query) + } + oq.withNarratives = query + return oq +} + // WithMembers tells the query-builder to eager-load the nodes that are connected to // the "members" edge. The optional arguments are used to configure the query builder of the edge. func (oq *OrganizationQuery) WithMembers(opts ...func(*OrgMembershipQuery)) *OrganizationQuery { @@ -1662,7 +1702,7 @@ func (oq *OrganizationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] var ( nodes = []*Organization{} _spec = oq.querySpec() - loadedTypes = [33]bool{ + loadedTypes = [34]bool{ oq.withParent != nil, oq.withChildren != nil, oq.withGroups != nil, @@ -1695,6 +1735,7 @@ func (oq *OrganizationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] oq.withInternalpolicies != nil, oq.withRisks != nil, oq.withControlobjectives != nil, + oq.withNarratives != nil, oq.withMembers != nil, } ) @@ -1955,6 +1996,13 @@ func (oq *OrganizationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] return nil, err } } + if query := oq.withNarratives; query != nil { + if err := oq.loadNarratives(ctx, query, nodes, + func(n *Organization) { n.Edges.Narratives = []*Narrative{} }, + func(n *Organization, e *Narrative) { n.Edges.Narratives = append(n.Edges.Narratives, e) }); err != nil { + return nil, err + } + } if query := oq.withMembers; query != nil { if err := oq.loadMembers(ctx, query, nodes, func(n *Organization) { n.Edges.Members = []*OrgMembership{} }, @@ -2172,6 +2220,13 @@ func (oq *OrganizationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] return nil, err } } + for name, query := range oq.withNamedNarratives { + if err := oq.loadNarratives(ctx, query, nodes, + func(n *Organization) { n.appendNamedNarratives(name) }, + func(n *Organization, e *Narrative) { n.appendNamedNarratives(name, e) }); err != nil { + return nil, err + } + } for name, query := range oq.withNamedMembers { if err := oq.loadMembers(ctx, query, nodes, func(n *Organization) { n.appendNamedMembers(name) }, @@ -3341,6 +3396,36 @@ func (oq *OrganizationQuery) loadControlobjectives(ctx context.Context, query *C } return nil } +func (oq *OrganizationQuery) loadNarratives(ctx context.Context, query *NarrativeQuery, nodes []*Organization, init func(*Organization), assign func(*Organization, *Narrative)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Organization) + 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(narrative.FieldOwnerID) + } + query.Where(predicate.Narrative(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(organization.NarrativesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.OwnerID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "owner_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (oq *OrganizationQuery) loadMembers(ctx context.Context, query *OrgMembershipQuery, nodes []*Organization, init func(*Organization), assign func(*Organization, *OrgMembership)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[string]*Organization) @@ -3893,6 +3978,20 @@ func (oq *OrganizationQuery) WithNamedControlobjectives(name string, opts ...fun return oq } +// WithNamedNarratives tells the query-builder to eager-load the nodes that are connected to the "narratives" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (oq *OrganizationQuery) WithNamedNarratives(name string, opts ...func(*NarrativeQuery)) *OrganizationQuery { + query := (&NarrativeClient{config: oq.config}).Query() + for _, opt := range opts { + opt(query) + } + if oq.withNamedNarratives == nil { + oq.withNamedNarratives = make(map[string]*NarrativeQuery) + } + oq.withNamedNarratives[name] = query + return oq +} + // WithNamedMembers tells the query-builder to eager-load the nodes that are connected to the "members" // edge with the given name. The optional arguments are used to configure the query builder of the edge. func (oq *OrganizationQuery) WithNamedMembers(name string, opts ...func(*OrgMembershipQuery)) *OrganizationQuery { diff --git a/internal/ent/generated/organization_update.go b/internal/ent/generated/organization_update.go index b111cec6..8cac0496 100644 --- a/internal/ent/generated/organization_update.go +++ b/internal/ent/generated/organization_update.go @@ -29,6 +29,7 @@ import ( "github.com/theopenlane/core/internal/ent/generated/integration" "github.com/theopenlane/core/internal/ent/generated/internalpolicy" "github.com/theopenlane/core/internal/ent/generated/invite" + "github.com/theopenlane/core/internal/ent/generated/narrative" "github.com/theopenlane/core/internal/ent/generated/note" "github.com/theopenlane/core/internal/ent/generated/oauthprovider" "github.com/theopenlane/core/internal/ent/generated/organization" @@ -703,6 +704,21 @@ func (ou *OrganizationUpdate) AddControlobjectives(c ...*ControlObjective) *Orga return ou.AddControlobjectiveIDs(ids...) } +// AddNarrativeIDs adds the "narratives" edge to the Narrative entity by IDs. +func (ou *OrganizationUpdate) AddNarrativeIDs(ids ...string) *OrganizationUpdate { + ou.mutation.AddNarrativeIDs(ids...) + return ou +} + +// AddNarratives adds the "narratives" edges to the Narrative entity. +func (ou *OrganizationUpdate) AddNarratives(n ...*Narrative) *OrganizationUpdate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return ou.AddNarrativeIDs(ids...) +} + // AddMemberIDs adds the "members" edge to the OrgMembership entity by IDs. func (ou *OrganizationUpdate) AddMemberIDs(ids ...string) *OrganizationUpdate { ou.mutation.AddMemberIDs(ids...) @@ -1359,6 +1375,27 @@ func (ou *OrganizationUpdate) RemoveControlobjectives(c ...*ControlObjective) *O return ou.RemoveControlobjectiveIDs(ids...) } +// ClearNarratives clears all "narratives" edges to the Narrative entity. +func (ou *OrganizationUpdate) ClearNarratives() *OrganizationUpdate { + ou.mutation.ClearNarratives() + return ou +} + +// RemoveNarrativeIDs removes the "narratives" edge to Narrative entities by IDs. +func (ou *OrganizationUpdate) RemoveNarrativeIDs(ids ...string) *OrganizationUpdate { + ou.mutation.RemoveNarrativeIDs(ids...) + return ou +} + +// RemoveNarratives removes "narratives" edges to Narrative entities. +func (ou *OrganizationUpdate) RemoveNarratives(n ...*Narrative) *OrganizationUpdate { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return ou.RemoveNarrativeIDs(ids...) +} + // ClearMembers clears all "members" edges to the OrgMembership entity. func (ou *OrganizationUpdate) ClearMembers() *OrganizationUpdate { ou.mutation.ClearMembers() @@ -3017,6 +3054,54 @@ func (ou *OrganizationUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if ou.mutation.NarrativesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: organization.NarrativesTable, + Columns: []string{organization.NarrativesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = ou.schemaConfig.Narrative + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ou.mutation.RemovedNarrativesIDs(); len(nodes) > 0 && !ou.mutation.NarrativesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: organization.NarrativesTable, + Columns: []string{organization.NarrativesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = ou.schemaConfig.Narrative + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ou.mutation.NarrativesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: organization.NarrativesTable, + Columns: []string{organization.NarrativesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = ou.schemaConfig.Narrative + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if ou.mutation.MembersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -3730,6 +3815,21 @@ func (ouo *OrganizationUpdateOne) AddControlobjectives(c ...*ControlObjective) * return ouo.AddControlobjectiveIDs(ids...) } +// AddNarrativeIDs adds the "narratives" edge to the Narrative entity by IDs. +func (ouo *OrganizationUpdateOne) AddNarrativeIDs(ids ...string) *OrganizationUpdateOne { + ouo.mutation.AddNarrativeIDs(ids...) + return ouo +} + +// AddNarratives adds the "narratives" edges to the Narrative entity. +func (ouo *OrganizationUpdateOne) AddNarratives(n ...*Narrative) *OrganizationUpdateOne { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return ouo.AddNarrativeIDs(ids...) +} + // AddMemberIDs adds the "members" edge to the OrgMembership entity by IDs. func (ouo *OrganizationUpdateOne) AddMemberIDs(ids ...string) *OrganizationUpdateOne { ouo.mutation.AddMemberIDs(ids...) @@ -4386,6 +4486,27 @@ func (ouo *OrganizationUpdateOne) RemoveControlobjectives(c ...*ControlObjective return ouo.RemoveControlobjectiveIDs(ids...) } +// ClearNarratives clears all "narratives" edges to the Narrative entity. +func (ouo *OrganizationUpdateOne) ClearNarratives() *OrganizationUpdateOne { + ouo.mutation.ClearNarratives() + return ouo +} + +// RemoveNarrativeIDs removes the "narratives" edge to Narrative entities by IDs. +func (ouo *OrganizationUpdateOne) RemoveNarrativeIDs(ids ...string) *OrganizationUpdateOne { + ouo.mutation.RemoveNarrativeIDs(ids...) + return ouo +} + +// RemoveNarratives removes "narratives" edges to Narrative entities. +func (ouo *OrganizationUpdateOne) RemoveNarratives(n ...*Narrative) *OrganizationUpdateOne { + ids := make([]string, len(n)) + for i := range n { + ids[i] = n[i].ID + } + return ouo.RemoveNarrativeIDs(ids...) +} + // ClearMembers clears all "members" edges to the OrgMembership entity. func (ouo *OrganizationUpdateOne) ClearMembers() *OrganizationUpdateOne { ouo.mutation.ClearMembers() @@ -6074,6 +6195,54 @@ func (ouo *OrganizationUpdateOne) sqlSave(ctx context.Context) (_node *Organizat } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if ouo.mutation.NarrativesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: organization.NarrativesTable, + Columns: []string{organization.NarrativesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = ouo.schemaConfig.Narrative + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ouo.mutation.RemovedNarrativesIDs(); len(nodes) > 0 && !ouo.mutation.NarrativesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: organization.NarrativesTable, + Columns: []string{organization.NarrativesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = ouo.schemaConfig.Narrative + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ouo.mutation.NarrativesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: organization.NarrativesTable, + Columns: []string{organization.NarrativesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(narrative.FieldID, field.TypeString), + }, + } + edge.Schema = ouo.schemaConfig.Narrative + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if ouo.mutation.MembersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/internal/ent/generated/runtime/runtime.go b/internal/ent/generated/runtime/runtime.go index 45e6123f..b98bb41f 100644 --- a/internal/ent/generated/runtime/runtime.go +++ b/internal/ent/generated/runtime/runtime.go @@ -2278,18 +2278,47 @@ func init() { // invite.DefaultID holds the default value on creation for the id field. invite.DefaultID = inviteDescID.Default.(func() string) narrativeMixin := schema.Narrative{}.Mixin() + narrative.Policy = privacy.NewPolicies(schema.Narrative{}) + narrative.Hooks[0] = func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if err := narrative.Policy.EvalMutation(ctx, m); err != nil { + return nil, err + } + return next.Mutate(ctx, m) + }) + } narrativeMixinHooks0 := narrativeMixin[0].Hooks() narrativeMixinHooks1 := narrativeMixin[1].Hooks() - narrative.Hooks[0] = narrativeMixinHooks0[0] - narrative.Hooks[1] = narrativeMixinHooks1[0] + narrativeMixinHooks4 := narrativeMixin[4].Hooks() + narrativeMixinHooks5 := narrativeMixin[5].Hooks() + + narrative.Hooks[1] = narrativeMixinHooks0[0] + + narrative.Hooks[2] = narrativeMixinHooks1[0] + + narrative.Hooks[3] = narrativeMixinHooks4[0] + + narrative.Hooks[4] = narrativeMixinHooks4[1] + + narrative.Hooks[5] = narrativeMixinHooks4[2] + + narrative.Hooks[6] = narrativeMixinHooks5[0] + + narrative.Hooks[7] = narrativeMixinHooks5[1] + + narrative.Hooks[8] = narrativeMixinHooks5[2] narrativeMixinInters1 := narrativeMixin[1].Interceptors() + narrativeMixinInters4 := narrativeMixin[4].Interceptors() narrative.Interceptors[0] = narrativeMixinInters1[0] + narrative.Interceptors[1] = narrativeMixinInters4[0] narrativeMixinFields0 := narrativeMixin[0].Fields() _ = narrativeMixinFields0 narrativeMixinFields2 := narrativeMixin[2].Fields() _ = narrativeMixinFields2 narrativeMixinFields3 := narrativeMixin[3].Fields() _ = narrativeMixinFields3 + narrativeMixinFields4 := narrativeMixin[4].Fields() + _ = narrativeMixinFields4 narrativeFields := schema.Narrative{}.Fields() _ = narrativeFields // narrativeDescCreatedAt is the schema descriptor for created_at field. @@ -2310,10 +2339,29 @@ func init() { narrativeDescTags := narrativeMixinFields3[0].Descriptor() // narrative.DefaultTags holds the default value on creation for the tags field. narrative.DefaultTags = narrativeDescTags.Default.([]string) + // narrativeDescOwnerID is the schema descriptor for owner_id field. + narrativeDescOwnerID := narrativeMixinFields4[0].Descriptor() + // narrative.OwnerIDValidator is a validator for the "owner_id" field. It is called by the builders before save. + narrative.OwnerIDValidator = narrativeDescOwnerID.Validators[0].(func(string) error) + // narrativeDescName is the schema descriptor for name field. + narrativeDescName := narrativeFields[0].Descriptor() + // narrative.NameValidator is a validator for the "name" field. It is called by the builders before save. + narrative.NameValidator = narrativeDescName.Validators[0].(func(string) error) // narrativeDescID is the schema descriptor for id field. narrativeDescID := narrativeMixinFields2[0].Descriptor() // narrative.DefaultID holds the default value on creation for the id field. narrative.DefaultID = narrativeDescID.Default.(func() string) + narrativehistory.Policy = privacy.NewPolicies(schema.NarrativeHistory{}) + narrativehistory.Hooks[0] = func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if err := narrativehistory.Policy.EvalMutation(ctx, m); err != nil { + return nil, err + } + return next.Mutate(ctx, m) + }) + } + narrativehistoryInters := schema.NarrativeHistory{}.Interceptors() + narrativehistory.Interceptors[0] = narrativehistoryInters[0] narrativehistoryFields := schema.NarrativeHistory{}.Fields() _ = narrativehistoryFields // narrativehistoryDescHistoryTime is the schema descriptor for history_time field. diff --git a/internal/ent/privacy/rule/program.go b/internal/ent/privacy/rule/program.go index 4d057301..e8345d74 100644 --- a/internal/ent/privacy/rule/program.go +++ b/internal/ent/privacy/rule/program.go @@ -85,5 +85,9 @@ func getProgramIDFromEntMutation(m generated.Mutation) ([]string, error) { return o.ProgramsIDs(), nil } + if o, ok := m.(*generated.NarrativeMutation); ok { + return o.ProgramsIDs(), nil + } + return nil, nil } diff --git a/internal/ent/schema/group.go b/internal/ent/schema/group.go index 536a647e..01064101 100644 --- a/internal/ent/schema/group.go +++ b/internal/ent/schema/group.go @@ -120,6 +120,12 @@ func (Group) Edges() []ent.Edge { Ref("editors"), edge.From("controlobjective_blocked_groups", ControlObjective.Type). Ref("blocked_groups"), + edge.From("narrative_viewers", Narrative.Type). + Ref("viewers"), + edge.From("narrative_editors", Narrative.Type). + Ref("editors"), + edge.From("narrative_blocked_groups", Narrative.Type). + Ref("blocked_groups"), } } diff --git a/internal/ent/schema/narrative.go b/internal/ent/schema/narrative.go index 1392de58..d3c44c72 100644 --- a/internal/ent/schema/narrative.go +++ b/internal/ent/schema/narrative.go @@ -1,14 +1,20 @@ package schema import ( + "context" + "entgo.io/contrib/entgql" "entgo.io/ent" "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" emixin "github.com/theopenlane/entx/mixin" + "github.com/theopenlane/iam/entfga" + "github.com/theopenlane/core/internal/ent/generated" + "github.com/theopenlane/core/internal/ent/generated/privacy" "github.com/theopenlane/core/internal/ent/mixin" + "github.com/theopenlane/core/internal/ent/privacy/rule" ) // Narrative defines the narrative schema @@ -20,6 +26,7 @@ type Narrative struct { func (Narrative) Fields() []ent.Field { return []ent.Field{ field.String("name"). + NotEmpty(). Comment("the name of the narrative"), field.Text("description"). Optional(). @@ -44,7 +51,7 @@ func (Narrative) Edges() []ent.Edge { Ref("narratives"), edge.From("controlobjective", ControlObjective.Type). Ref("narratives"), - edge.From("program", Program.Type). + edge.From("programs", Program.Type). Ref("narratives"), } } @@ -56,6 +63,16 @@ func (Narrative) Mixin() []ent.Mixin { mixin.SoftDeleteMixin{}, emixin.IDMixin{}, emixin.TagMixin{}, + // narratives inherit permissions from the associated programs, but must have an organization as well + // this mixin will add the owner_id field using the OrgHook but not organization tuples are created + // it will also create program parent tuples for the narrative when a program is associated to the narrative + NewObjectOwnedMixin(ObjectOwnedMixin{ + FieldNames: []string{"program_id"}, + WithOrganizationOwner: true, + Ref: "narratives", + }), + // add groups permissions with viewer, editor, and blocked groups + NewGroupPermissionsMixin(true), } } @@ -65,5 +82,31 @@ func (Narrative) Annotations() []schema.Annotation { entgql.RelayConnection(), entgql.QueryField(), entgql.Mutations(entgql.MutationCreate(), (entgql.MutationUpdate())), + entfga.Annotations{ + ObjectType: "narrative", // check access to the narrative for update/delete + }, + } +} + +// Policy of the Narrative +func (Narrative) Policy() ent.Policy { + return privacy.Policy{ + Mutation: privacy.MutationPolicy{ + rule.CanCreateObjectsInProgram(), // if mutation contains program_id, check access + privacy.OnMutationOperation( // if there is no program_id, check access for create in org + rule.CanCreateObjectsInOrg(), + ent.OpCreate, + ), + privacy.NarrativeMutationRuleFunc(func(ctx context.Context, m *generated.NarrativeMutation) error { + return m.CheckAccessForEdit(ctx) // check access for edit + }), + privacy.AlwaysDenyRule(), + }, + Query: privacy.QueryPolicy{ + privacy.NarrativeQueryRuleFunc(func(ctx context.Context, q *generated.NarrativeQuery) error { + return q.CheckAccess(ctx) + }), + privacy.AlwaysDenyRule(), + }, } } diff --git a/internal/ent/schema/narrative_history.go b/internal/ent/schema/narrative_history.go index 93950f8e..2c8ec183 100644 --- a/internal/ent/schema/narrative_history.go +++ b/internal/ent/schema/narrative_history.go @@ -2,6 +2,7 @@ package schema import ( + "context" "time" "entgo.io/contrib/entgql" @@ -11,8 +12,12 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "github.com/theopenlane/core/internal/ent/generated" + "github.com/theopenlane/core/internal/ent/generated/privacy" + "github.com/theopenlane/core/internal/ent/interceptors" "github.com/theopenlane/entx" "github.com/theopenlane/entx/history" + "github.com/theopenlane/iam/entfga" ) // NarrativeHistory holds the schema definition for the NarrativeHistory entity. @@ -33,6 +38,11 @@ func (NarrativeHistory) Annotations() []schema.Annotation { }, entgql.QueryField(), entgql.RelayConnection(), + entfga.Annotations{ + ObjectType: "narrative", + IDField: "Ref", + IncludeHooks: false, + }, } } @@ -88,3 +98,22 @@ func (NarrativeHistory) Indexes() []ent.Index { index.Fields("history_time"), } } + +// Interceptors of the NarrativeHistory +func (NarrativeHistory) Interceptors() []ent.Interceptor { + return []ent.Interceptor{ + interceptors.HistoryAccess("audit_log_viewer", true, false), + } +} + +// Policy of the NarrativeHistory +func (NarrativeHistory) Policy() ent.Policy { + return privacy.Policy{ + Query: privacy.QueryPolicy{ + privacy.NarrativeHistoryQueryRuleFunc(func(ctx context.Context, q *generated.NarrativeHistoryQuery) error { + return q.CheckAccess(ctx) + }), + privacy.AlwaysDenyRule(), + }, + } +} diff --git a/internal/ent/schema/organization.go b/internal/ent/schema/organization.go index 17948220..5c32a845 100644 --- a/internal/ent/schema/organization.go +++ b/internal/ent/schema/organization.go @@ -178,6 +178,8 @@ func (Organization) Edges() []ent.Edge { Annotations(entx.CascadeAnnotationField("Owner")), edge.To("controlobjectives", ControlObjective.Type). Annotations(entx.CascadeAnnotationField("Owner")), + edge.To("narratives", Narrative.Type). + Annotations(entx.CascadeAnnotationField("Owner")), } } diff --git a/internal/graphapi/gen_server.go b/internal/graphapi/gen_server.go index 36ba01f8..aab7f8f6 100644 --- a/internal/graphapi/gen_server.go +++ b/internal/graphapi/gen_server.go @@ -1291,6 +1291,9 @@ type ComplexityRoot struct { LogoURL func(childComplexity int) int Members func(childComplexity int) int Name func(childComplexity int) int + NarrativeBlockedGroups func(childComplexity int) int + NarrativeEditors func(childComplexity int) int + NarrativeViewers func(childComplexity int) int Owner func(childComplexity int) int OwnerID func(childComplexity int) int ProcedureBlockedGroups func(childComplexity int) int @@ -2010,6 +2013,7 @@ type ComplexityRoot struct { } Narrative struct { + BlockedGroups func(childComplexity int) int Control func(childComplexity int) int Controlobjective func(childComplexity int) int CreatedAt func(childComplexity int) int @@ -2018,15 +2022,19 @@ type ComplexityRoot struct { DeletedBy func(childComplexity int) int Description func(childComplexity int) int Details func(childComplexity int) int + Editors func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int + Owner func(childComplexity int) int + OwnerID func(childComplexity int) int Policy func(childComplexity int) int Procedure func(childComplexity int) int - Program func(childComplexity int) int + Programs func(childComplexity int) int Satisfies func(childComplexity int) int Tags func(childComplexity int) int UpdatedAt func(childComplexity int) int UpdatedBy func(childComplexity int) int + Viewers func(childComplexity int) int } NarrativeBulkCreatePayload struct { @@ -2063,6 +2071,7 @@ type ComplexityRoot struct { ID func(childComplexity int) int Name func(childComplexity int) int Operation func(childComplexity int) int + OwnerID func(childComplexity int) int Ref func(childComplexity int) int Satisfies func(childComplexity int) int Tags func(childComplexity int) int @@ -2381,6 +2390,7 @@ type ComplexityRoot struct { Invites func(childComplexity int) int Members func(childComplexity int) int Name func(childComplexity int) int + Narratives func(childComplexity int) int Notes func(childComplexity int) int Oauthprovider func(childComplexity int) int OrganizationEntitlement func(childComplexity int) int @@ -9798,6 +9808,27 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Group.Name(childComplexity), true + case "Group.narrativeBlockedGroups": + if e.complexity.Group.NarrativeBlockedGroups == nil { + break + } + + return e.complexity.Group.NarrativeBlockedGroups(childComplexity), true + + case "Group.narrativeEditors": + if e.complexity.Group.NarrativeEditors == nil { + break + } + + return e.complexity.Group.NarrativeEditors(childComplexity), true + + case "Group.narrativeViewers": + if e.complexity.Group.NarrativeViewers == nil { + break + } + + return e.complexity.Group.NarrativeViewers(childComplexity), true + case "Group.owner": if e.complexity.Group.Owner == nil { break @@ -14294,6 +14325,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.UpdateWebhook(childComplexity, args["id"].(string), args["input"].(generated.UpdateWebhookInput)), true + case "Narrative.blockedGroups": + if e.complexity.Narrative.BlockedGroups == nil { + break + } + + return e.complexity.Narrative.BlockedGroups(childComplexity), true + case "Narrative.control": if e.complexity.Narrative.Control == nil { break @@ -14350,6 +14388,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Narrative.Details(childComplexity), true + case "Narrative.editors": + if e.complexity.Narrative.Editors == nil { + break + } + + return e.complexity.Narrative.Editors(childComplexity), true + case "Narrative.id": if e.complexity.Narrative.ID == nil { break @@ -14364,6 +14409,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Narrative.Name(childComplexity), true + case "Narrative.owner": + if e.complexity.Narrative.Owner == nil { + break + } + + return e.complexity.Narrative.Owner(childComplexity), true + + case "Narrative.ownerID": + if e.complexity.Narrative.OwnerID == nil { + break + } + + return e.complexity.Narrative.OwnerID(childComplexity), true + case "Narrative.policy": if e.complexity.Narrative.Policy == nil { break @@ -14378,12 +14437,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Narrative.Procedure(childComplexity), true - case "Narrative.program": - if e.complexity.Narrative.Program == nil { + case "Narrative.programs": + if e.complexity.Narrative.Programs == nil { break } - return e.complexity.Narrative.Program(childComplexity), true + return e.complexity.Narrative.Programs(childComplexity), true case "Narrative.satisfies": if e.complexity.Narrative.Satisfies == nil { @@ -14413,6 +14472,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Narrative.UpdatedBy(childComplexity), true + case "Narrative.viewers": + if e.complexity.Narrative.Viewers == nil { + break + } + + return e.complexity.Narrative.Viewers(childComplexity), true + case "NarrativeBulkCreatePayload.narratives": if e.complexity.NarrativeBulkCreatePayload.Narratives == nil { break @@ -14539,6 +14605,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.NarrativeHistory.Operation(childComplexity), true + case "NarrativeHistory.ownerID": + if e.complexity.NarrativeHistory.OwnerID == nil { + break + } + + return e.complexity.NarrativeHistory.OwnerID(childComplexity), true + case "NarrativeHistory.ref": if e.complexity.NarrativeHistory.Ref == nil { break @@ -15930,6 +16003,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Organization.Name(childComplexity), true + case "Organization.narratives": + if e.complexity.Organization.Narratives == nil { + break + } + + return e.complexity.Organization.Narratives(childComplexity), true + case "Organization.notes": if e.complexity.Organization.Notes == nil { break @@ -29504,6 +29584,9 @@ input CreateGroupInput { controlobjectiveViewerIDs: [ID!] controlobjectiveEditorIDs: [ID!] controlobjectiveBlockedGroupIDs: [ID!] + narrativeViewerIDs: [ID!] + narrativeEditorIDs: [ID!] + narrativeBlockedGroupIDs: [ID!] } """ CreateGroupMembershipInput is used for create GroupMembership object. @@ -29700,6 +29783,10 @@ input CreateNarrativeInput { json data for the narrative document """ details: Map + ownerID: ID! + blockedGroupIDs: [ID!] + editorIDs: [ID!] + viewerIDs: [ID!] policyIDs: [ID!] controlIDs: [ID!] procedureIDs: [ID!] @@ -29868,6 +29955,7 @@ input CreateOrganizationInput { internalpolicyIDs: [ID!] riskIDs: [ID!] controlobjectiveIDs: [ID!] + narrativeIDs: [ID!] } """ CreateOrganizationSettingInput is used for create OrganizationSetting object. @@ -36306,6 +36394,9 @@ type Group implements Node { controlobjectiveViewers: [ControlObjective!] controlobjectiveEditors: [ControlObjective!] controlobjectiveBlockedGroups: [ControlObjective!] + narrativeViewers: [Narrative!] + narrativeEditors: [Narrative!] + narrativeBlockedGroups: [Narrative!] members: [GroupMembership!] } """ @@ -37879,6 +37970,21 @@ input GroupWhereInput { hasControlobjectiveBlockedGroups: Boolean hasControlobjectiveBlockedGroupsWith: [ControlObjectiveWhereInput!] """ + narrative_viewers edge predicates + """ + hasNarrativeViewers: Boolean + hasNarrativeViewersWith: [NarrativeWhereInput!] + """ + narrative_editors edge predicates + """ + hasNarrativeEditors: Boolean + hasNarrativeEditorsWith: [NarrativeWhereInput!] + """ + narrative_blocked_groups edge predicates + """ + hasNarrativeBlockedGroups: Boolean + hasNarrativeBlockedGroupsWith: [NarrativeWhereInput!] + """ members edge predicates """ hasMembers: Boolean @@ -40102,6 +40208,10 @@ type Narrative implements Node { """ tags: [String!] """ + the ID of the organization owner of the object + """ + ownerID: ID! + """ the name of the narrative """ name: String! @@ -40117,11 +40227,24 @@ type Narrative implements Node { json data for the narrative document """ details: Map + owner: Organization! + """ + groups that are blocked from viewing or editing the risk + """ + blockedGroups: [Group!] + """ + provides edit access to the risk to members of the group + """ + editors: [Group!] + """ + provides view access to the risk to members of the group + """ + viewers: [Group!] policy: [InternalPolicy!] control: [Control!] procedure: [Procedure!] controlobjective: [ControlObjective!] - program: [Program!] + programs: [Program!] } """ A connection to a list of items. @@ -40169,6 +40292,10 @@ type NarrativeHistory implements Node { """ tags: [String!] """ + the ID of the organization owner of the object + """ + ownerID: String! + """ the name of the narrative """ name: String! @@ -40374,6 +40501,22 @@ input NarrativeHistoryWhereInput { deletedByEqualFold: String deletedByContainsFold: String """ + owner_id field predicates + """ + ownerID: String + ownerIDNEQ: String + ownerIDIn: [String!] + ownerIDNotIn: [String!] + ownerIDGT: String + ownerIDGTE: String + ownerIDLT: String + ownerIDLTE: String + ownerIDContains: String + ownerIDHasPrefix: String + ownerIDHasSuffix: String + ownerIDEqualFold: String + ownerIDContainsFold: String + """ name field predicates """ name: String @@ -40541,6 +40684,22 @@ input NarrativeWhereInput { deletedByEqualFold: String deletedByContainsFold: String """ + owner_id field predicates + """ + ownerID: ID + ownerIDNEQ: ID + ownerIDIn: [ID!] + ownerIDNotIn: [ID!] + ownerIDGT: ID + ownerIDGTE: ID + ownerIDLT: ID + ownerIDLTE: ID + ownerIDContains: ID + ownerIDHasPrefix: ID + ownerIDHasSuffix: ID + ownerIDEqualFold: ID + ownerIDContainsFold: ID + """ name field predicates """ name: String @@ -40593,6 +40752,26 @@ input NarrativeWhereInput { satisfiesEqualFold: String satisfiesContainsFold: String """ + owner edge predicates + """ + hasOwner: Boolean + hasOwnerWith: [OrganizationWhereInput!] + """ + blocked_groups edge predicates + """ + hasBlockedGroups: Boolean + hasBlockedGroupsWith: [GroupWhereInput!] + """ + editors edge predicates + """ + hasEditors: Boolean + hasEditorsWith: [GroupWhereInput!] + """ + viewers edge predicates + """ + hasViewers: Boolean + hasViewersWith: [GroupWhereInput!] + """ policy edge predicates """ hasPolicy: Boolean @@ -40613,10 +40792,10 @@ input NarrativeWhereInput { hasControlobjective: Boolean hasControlobjectiveWith: [ControlObjectiveWhereInput!] """ - program edge predicates + programs edge predicates """ - hasProgram: Boolean - hasProgramWith: [ProgramWhereInput!] + hasPrograms: Boolean + hasProgramsWith: [ProgramWhereInput!] } """ An object with an ID. @@ -42610,6 +42789,7 @@ type Organization implements Node { internalpolicies: [InternalPolicy!] risks: [Risk!] controlobjectives: [ControlObjective!] + narratives: [Narrative!] members: [OrgMembership!] } """ @@ -44037,6 +44217,11 @@ input OrganizationWhereInput { hasControlobjectives: Boolean hasControlobjectivesWith: [ControlObjectiveWhereInput!] """ + narratives edge predicates + """ + hasNarratives: Boolean + hasNarrativesWith: [NarrativeWhereInput!] + """ members edge predicates """ hasMembers: Boolean @@ -53720,6 +53905,15 @@ input UpdateGroupInput { addControlobjectiveBlockedGroupIDs: [ID!] removeControlobjectiveBlockedGroupIDs: [ID!] clearControlobjectiveBlockedGroups: Boolean + addNarrativeViewerIDs: [ID!] + removeNarrativeViewerIDs: [ID!] + clearNarrativeViewers: Boolean + addNarrativeEditorIDs: [ID!] + removeNarrativeEditorIDs: [ID!] + clearNarrativeEditors: Boolean + addNarrativeBlockedGroupIDs: [ID!] + removeNarrativeBlockedGroupIDs: [ID!] + clearNarrativeBlockedGroups: Boolean } """ UpdateGroupMembershipInput is used for update GroupMembership object. @@ -53961,6 +54155,16 @@ input UpdateNarrativeInput { """ details: Map clearDetails: Boolean + ownerID: ID + addBlockedGroupIDs: [ID!] + removeBlockedGroupIDs: [ID!] + clearBlockedGroups: Boolean + addEditorIDs: [ID!] + removeEditorIDs: [ID!] + clearEditors: Boolean + addViewerIDs: [ID!] + removeViewerIDs: [ID!] + clearViewers: Boolean addPolicyIDs: [ID!] removePolicyIDs: [ID!] clearPolicy: Boolean @@ -53975,7 +54179,7 @@ input UpdateNarrativeInput { clearControlobjective: Boolean addProgramIDs: [ID!] removeProgramIDs: [ID!] - clearProgram: Boolean + clearPrograms: Boolean } """ UpdateNoteInput is used for update Note object. @@ -54214,6 +54418,9 @@ input UpdateOrganizationInput { addControlobjectiveIDs: [ID!] removeControlobjectiveIDs: [ID!] clearControlobjectives: Boolean + addNarrativeIDs: [ID!] + removeNarrativeIDs: [ID!] + clearNarratives: Boolean } """ UpdateOrganizationSettingInput is used for update OrganizationSetting object. @@ -85138,6 +85345,8 @@ func (ec *executionContext) fieldContext_APIToken_owner(_ context.Context, field return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -89855,6 +90064,8 @@ func (ec *executionContext) fieldContext_Contact_owner(_ context.Context, field return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -93038,6 +93249,8 @@ func (ec *executionContext) fieldContext_Control_narratives(_ context.Context, f return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -93046,6 +93259,14 @@ func (ec *executionContext) fieldContext_Control_narratives(_ context.Context, f return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -93054,8 +93275,8 @@ func (ec *executionContext) fieldContext_Control_narratives(_ context.Context, f return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -96179,6 +96400,8 @@ func (ec *executionContext) fieldContext_ControlObjective_owner(_ context.Contex return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -96292,6 +96515,12 @@ func (ec *executionContext) fieldContext_ControlObjective_blockedGroups(_ contex return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -96405,6 +96634,12 @@ func (ec *executionContext) fieldContext_ControlObjective_editors(_ context.Cont return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -96518,6 +96753,12 @@ func (ec *executionContext) fieldContext_ControlObjective_viewers(_ context.Cont return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -97159,6 +97400,8 @@ func (ec *executionContext) fieldContext_ControlObjective_narratives(_ context.C return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -97167,6 +97410,14 @@ func (ec *executionContext) fieldContext_ControlObjective_narratives(_ context.C return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -97175,8 +97426,8 @@ func (ec *executionContext) fieldContext_ControlObjective_narratives(_ context.C return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -100201,6 +100452,8 @@ func (ec *executionContext) fieldContext_DocumentData_owner(_ context.Context, f return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -102863,6 +103116,8 @@ func (ec *executionContext) fieldContext_Entitlement_owner(_ context.Context, fi return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -103091,6 +103346,8 @@ func (ec *executionContext) fieldContext_Entitlement_organization(_ context.Cont return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -105698,6 +105955,8 @@ func (ec *executionContext) fieldContext_EntitlementPlan_owner(_ context.Context return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -107255,6 +107514,8 @@ func (ec *executionContext) fieldContext_EntitlementPlanFeature_owner(_ context. return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -111309,6 +111570,8 @@ func (ec *executionContext) fieldContext_Entity_owner(_ context.Context, field g return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -113852,6 +114115,8 @@ func (ec *executionContext) fieldContext_EntityType_owner(_ context.Context, fie return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -116046,6 +116311,12 @@ func (ec *executionContext) fieldContext_Event_group(_ context.Context, field gr return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -116260,6 +116531,8 @@ func (ec *executionContext) fieldContext_Event_organization(_ context.Context, f return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -119581,6 +119854,8 @@ func (ec *executionContext) fieldContext_Feature_owner(_ context.Context, field return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -122632,6 +122907,8 @@ func (ec *executionContext) fieldContext_File_organization(_ context.Context, fi return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -122745,6 +123022,12 @@ func (ec *executionContext) fieldContext_File_group(_ context.Context, field gra return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -125882,6 +126165,8 @@ func (ec *executionContext) fieldContext_Group_owner(_ context.Context, field gr return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -127793,6 +128078,267 @@ func (ec *executionContext) fieldContext_Group_controlobjectiveBlockedGroups(_ c return fc, nil } +func (ec *executionContext) _Group_narrativeViewers(ctx context.Context, field graphql.CollectedField, obj *generated.Group) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Group_narrativeViewers(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.NarrativeViewers(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*generated.Narrative) + fc.Result = res + return ec.marshalONarrative2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐNarrativeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Group_narrativeViewers(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Group", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Narrative_id(ctx, field) + case "createdAt": + return ec.fieldContext_Narrative_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Narrative_updatedAt(ctx, field) + case "createdBy": + return ec.fieldContext_Narrative_createdBy(ctx, field) + case "updatedBy": + return ec.fieldContext_Narrative_updatedBy(ctx, field) + case "deletedAt": + return ec.fieldContext_Narrative_deletedAt(ctx, field) + case "deletedBy": + return ec.fieldContext_Narrative_deletedBy(ctx, field) + case "tags": + return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) + case "name": + return ec.fieldContext_Narrative_name(ctx, field) + case "description": + return ec.fieldContext_Narrative_description(ctx, field) + case "satisfies": + return ec.fieldContext_Narrative_satisfies(ctx, field) + case "details": + return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) + case "policy": + return ec.fieldContext_Narrative_policy(ctx, field) + case "control": + return ec.fieldContext_Narrative_control(ctx, field) + case "procedure": + return ec.fieldContext_Narrative_procedure(ctx, field) + case "controlobjective": + return ec.fieldContext_Narrative_controlobjective(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Group_narrativeEditors(ctx context.Context, field graphql.CollectedField, obj *generated.Group) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Group_narrativeEditors(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.NarrativeEditors(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*generated.Narrative) + fc.Result = res + return ec.marshalONarrative2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐNarrativeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Group_narrativeEditors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Group", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Narrative_id(ctx, field) + case "createdAt": + return ec.fieldContext_Narrative_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Narrative_updatedAt(ctx, field) + case "createdBy": + return ec.fieldContext_Narrative_createdBy(ctx, field) + case "updatedBy": + return ec.fieldContext_Narrative_updatedBy(ctx, field) + case "deletedAt": + return ec.fieldContext_Narrative_deletedAt(ctx, field) + case "deletedBy": + return ec.fieldContext_Narrative_deletedBy(ctx, field) + case "tags": + return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) + case "name": + return ec.fieldContext_Narrative_name(ctx, field) + case "description": + return ec.fieldContext_Narrative_description(ctx, field) + case "satisfies": + return ec.fieldContext_Narrative_satisfies(ctx, field) + case "details": + return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) + case "policy": + return ec.fieldContext_Narrative_policy(ctx, field) + case "control": + return ec.fieldContext_Narrative_control(ctx, field) + case "procedure": + return ec.fieldContext_Narrative_procedure(ctx, field) + case "controlobjective": + return ec.fieldContext_Narrative_controlobjective(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Group_narrativeBlockedGroups(ctx context.Context, field graphql.CollectedField, obj *generated.Group) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.NarrativeBlockedGroups(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*generated.Narrative) + fc.Result = res + return ec.marshalONarrative2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐNarrativeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Group_narrativeBlockedGroups(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Group", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Narrative_id(ctx, field) + case "createdAt": + return ec.fieldContext_Narrative_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Narrative_updatedAt(ctx, field) + case "createdBy": + return ec.fieldContext_Narrative_createdBy(ctx, field) + case "updatedBy": + return ec.fieldContext_Narrative_updatedBy(ctx, field) + case "deletedAt": + return ec.fieldContext_Narrative_deletedAt(ctx, field) + case "deletedBy": + return ec.fieldContext_Narrative_deletedBy(ctx, field) + case "tags": + return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) + case "name": + return ec.fieldContext_Narrative_name(ctx, field) + case "description": + return ec.fieldContext_Narrative_description(ctx, field) + case "satisfies": + return ec.fieldContext_Narrative_satisfies(ctx, field) + case "details": + return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) + case "policy": + return ec.fieldContext_Narrative_policy(ctx, field) + case "control": + return ec.fieldContext_Narrative_control(ctx, field) + case "procedure": + return ec.fieldContext_Narrative_procedure(ctx, field) + case "controlobjective": + return ec.fieldContext_Narrative_controlobjective(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Group_members(ctx context.Context, field graphql.CollectedField, obj *generated.Group) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Group_members(ctx, field) if err != nil { @@ -127966,6 +128512,12 @@ func (ec *executionContext) fieldContext_GroupBulkCreatePayload_groups(_ context return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -128227,6 +128779,12 @@ func (ec *executionContext) fieldContext_GroupCreatePayload_group(_ context.Cont return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -128384,6 +128942,12 @@ func (ec *executionContext) fieldContext_GroupEdge_node(_ context.Context, field return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -129944,6 +130508,12 @@ func (ec *executionContext) fieldContext_GroupMembership_group(_ context.Context return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -131596,6 +132166,12 @@ func (ec *executionContext) fieldContext_GroupSearchResult_groups(_ context.Cont return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -132251,6 +132827,12 @@ func (ec *executionContext) fieldContext_GroupSetting_group(_ context.Context, f return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -133896,6 +134478,12 @@ func (ec *executionContext) fieldContext_GroupUpdatePayload_group(_ context.Cont return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -134567,6 +135155,8 @@ func (ec *executionContext) fieldContext_Hush_organization(_ context.Context, fi return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -136668,6 +137258,8 @@ func (ec *executionContext) fieldContext_Integration_owner(_ context.Context, fi return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -139345,6 +139937,8 @@ func (ec *executionContext) fieldContext_InternalPolicy_owner(_ context.Context, return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -139458,6 +140052,12 @@ func (ec *executionContext) fieldContext_InternalPolicy_blockedGroups(_ context. return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -139571,6 +140171,12 @@ func (ec *executionContext) fieldContext_InternalPolicy_editors(_ context.Contex return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -139939,6 +140545,8 @@ func (ec *executionContext) fieldContext_InternalPolicy_narratives(_ context.Con return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -139947,6 +140555,14 @@ func (ec *executionContext) fieldContext_InternalPolicy_narratives(_ context.Con return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -139955,8 +140571,8 @@ func (ec *executionContext) fieldContext_InternalPolicy_narratives(_ context.Con return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -142703,6 +143319,8 @@ func (ec *executionContext) fieldContext_Invite_owner(_ context.Context, field g return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -155184,6 +155802,50 @@ func (ec *executionContext) fieldContext_Narrative_tags(_ context.Context, field return fc, nil } +func (ec *executionContext) _Narrative_ownerID(ctx context.Context, field graphql.CollectedField, obj *generated.Narrative) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Narrative_ownerID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OwnerID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Narrative_ownerID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Narrative", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Narrative_name(ctx context.Context, field graphql.CollectedField, obj *generated.Narrative) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Narrative_name(ctx, field) if err != nil { @@ -155351,6 +156013,505 @@ func (ec *executionContext) fieldContext_Narrative_details(_ context.Context, fi return fc, nil } +func (ec *executionContext) _Narrative_owner(ctx context.Context, field graphql.CollectedField, obj *generated.Narrative) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Narrative_owner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Owner(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*generated.Organization) + fc.Result = res + return ec.marshalNOrganization2ᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐOrganization(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Narrative_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Narrative", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Organization_id(ctx, field) + case "createdAt": + return ec.fieldContext_Organization_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Organization_updatedAt(ctx, field) + case "createdBy": + return ec.fieldContext_Organization_createdBy(ctx, field) + case "updatedBy": + return ec.fieldContext_Organization_updatedBy(ctx, field) + case "tags": + return ec.fieldContext_Organization_tags(ctx, field) + case "deletedAt": + return ec.fieldContext_Organization_deletedAt(ctx, field) + case "deletedBy": + return ec.fieldContext_Organization_deletedBy(ctx, field) + case "name": + return ec.fieldContext_Organization_name(ctx, field) + case "displayName": + return ec.fieldContext_Organization_displayName(ctx, field) + case "description": + return ec.fieldContext_Organization_description(ctx, field) + case "personalOrg": + return ec.fieldContext_Organization_personalOrg(ctx, field) + case "avatarRemoteURL": + return ec.fieldContext_Organization_avatarRemoteURL(ctx, field) + case "dedicatedDb": + return ec.fieldContext_Organization_dedicatedDb(ctx, field) + case "parent": + return ec.fieldContext_Organization_parent(ctx, field) + case "children": + return ec.fieldContext_Organization_children(ctx, field) + case "groups": + return ec.fieldContext_Organization_groups(ctx, field) + case "templates": + return ec.fieldContext_Organization_templates(ctx, field) + case "integrations": + return ec.fieldContext_Organization_integrations(ctx, field) + case "setting": + return ec.fieldContext_Organization_setting(ctx, field) + case "documentdata": + return ec.fieldContext_Organization_documentdata(ctx, field) + case "entitlements": + return ec.fieldContext_Organization_entitlements(ctx, field) + case "organizationEntitlement": + return ec.fieldContext_Organization_organizationEntitlement(ctx, field) + case "personalAccessTokens": + return ec.fieldContext_Organization_personalAccessTokens(ctx, field) + case "apiTokens": + return ec.fieldContext_Organization_apiTokens(ctx, field) + case "oauthprovider": + return ec.fieldContext_Organization_oauthprovider(ctx, field) + case "users": + return ec.fieldContext_Organization_users(ctx, field) + case "invites": + return ec.fieldContext_Organization_invites(ctx, field) + case "subscribers": + return ec.fieldContext_Organization_subscribers(ctx, field) + case "webhooks": + return ec.fieldContext_Organization_webhooks(ctx, field) + case "events": + return ec.fieldContext_Organization_events(ctx, field) + case "secrets": + return ec.fieldContext_Organization_secrets(ctx, field) + case "features": + return ec.fieldContext_Organization_features(ctx, field) + case "files": + return ec.fieldContext_Organization_files(ctx, field) + case "entitlementplans": + return ec.fieldContext_Organization_entitlementplans(ctx, field) + case "entitlementplanfeatures": + return ec.fieldContext_Organization_entitlementplanfeatures(ctx, field) + case "entities": + return ec.fieldContext_Organization_entities(ctx, field) + case "entitytypes": + return ec.fieldContext_Organization_entitytypes(ctx, field) + case "contacts": + return ec.fieldContext_Organization_contacts(ctx, field) + case "notes": + return ec.fieldContext_Organization_notes(ctx, field) + case "tasks": + return ec.fieldContext_Organization_tasks(ctx, field) + case "programs": + return ec.fieldContext_Organization_programs(ctx, field) + case "procedures": + return ec.fieldContext_Organization_procedures(ctx, field) + case "internalpolicies": + return ec.fieldContext_Organization_internalpolicies(ctx, field) + case "risks": + return ec.fieldContext_Organization_risks(ctx, field) + case "controlobjectives": + return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) + case "members": + return ec.fieldContext_Organization_members(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Organization", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Narrative_blockedGroups(ctx context.Context, field graphql.CollectedField, obj *generated.Narrative) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Narrative_blockedGroups(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.BlockedGroups(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*generated.Group) + fc.Result = res + return ec.marshalOGroup2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐGroupᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Narrative_blockedGroups(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Narrative", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Group_id(ctx, field) + case "createdAt": + return ec.fieldContext_Group_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Group_updatedAt(ctx, field) + case "createdBy": + return ec.fieldContext_Group_createdBy(ctx, field) + case "updatedBy": + return ec.fieldContext_Group_updatedBy(ctx, field) + case "deletedAt": + return ec.fieldContext_Group_deletedAt(ctx, field) + case "deletedBy": + return ec.fieldContext_Group_deletedBy(ctx, field) + case "tags": + return ec.fieldContext_Group_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Group_ownerID(ctx, field) + case "name": + return ec.fieldContext_Group_name(ctx, field) + case "description": + return ec.fieldContext_Group_description(ctx, field) + case "gravatarLogoURL": + return ec.fieldContext_Group_gravatarLogoURL(ctx, field) + case "logoURL": + return ec.fieldContext_Group_logoURL(ctx, field) + case "displayName": + return ec.fieldContext_Group_displayName(ctx, field) + case "owner": + return ec.fieldContext_Group_owner(ctx, field) + case "setting": + return ec.fieldContext_Group_setting(ctx, field) + case "users": + return ec.fieldContext_Group_users(ctx, field) + case "events": + return ec.fieldContext_Group_events(ctx, field) + case "integrations": + return ec.fieldContext_Group_integrations(ctx, field) + case "files": + return ec.fieldContext_Group_files(ctx, field) + case "tasks": + return ec.fieldContext_Group_tasks(ctx, field) + case "procedureEditors": + return ec.fieldContext_Group_procedureEditors(ctx, field) + case "procedureBlockedGroups": + return ec.fieldContext_Group_procedureBlockedGroups(ctx, field) + case "internalpolicyEditors": + return ec.fieldContext_Group_internalpolicyEditors(ctx, field) + case "internalpolicyBlockedGroups": + return ec.fieldContext_Group_internalpolicyBlockedGroups(ctx, field) + case "programViewers": + return ec.fieldContext_Group_programViewers(ctx, field) + case "programEditors": + return ec.fieldContext_Group_programEditors(ctx, field) + case "programBlockedGroups": + return ec.fieldContext_Group_programBlockedGroups(ctx, field) + case "riskViewers": + return ec.fieldContext_Group_riskViewers(ctx, field) + case "riskEditors": + return ec.fieldContext_Group_riskEditors(ctx, field) + case "riskBlockedGroups": + return ec.fieldContext_Group_riskBlockedGroups(ctx, field) + case "controlobjectiveViewers": + return ec.fieldContext_Group_controlobjectiveViewers(ctx, field) + case "controlobjectiveEditors": + return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) + case "controlobjectiveBlockedGroups": + return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) + case "members": + return ec.fieldContext_Group_members(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Group", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Narrative_editors(ctx context.Context, field graphql.CollectedField, obj *generated.Narrative) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Narrative_editors(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Editors(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*generated.Group) + fc.Result = res + return ec.marshalOGroup2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐGroupᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Narrative_editors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Narrative", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Group_id(ctx, field) + case "createdAt": + return ec.fieldContext_Group_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Group_updatedAt(ctx, field) + case "createdBy": + return ec.fieldContext_Group_createdBy(ctx, field) + case "updatedBy": + return ec.fieldContext_Group_updatedBy(ctx, field) + case "deletedAt": + return ec.fieldContext_Group_deletedAt(ctx, field) + case "deletedBy": + return ec.fieldContext_Group_deletedBy(ctx, field) + case "tags": + return ec.fieldContext_Group_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Group_ownerID(ctx, field) + case "name": + return ec.fieldContext_Group_name(ctx, field) + case "description": + return ec.fieldContext_Group_description(ctx, field) + case "gravatarLogoURL": + return ec.fieldContext_Group_gravatarLogoURL(ctx, field) + case "logoURL": + return ec.fieldContext_Group_logoURL(ctx, field) + case "displayName": + return ec.fieldContext_Group_displayName(ctx, field) + case "owner": + return ec.fieldContext_Group_owner(ctx, field) + case "setting": + return ec.fieldContext_Group_setting(ctx, field) + case "users": + return ec.fieldContext_Group_users(ctx, field) + case "events": + return ec.fieldContext_Group_events(ctx, field) + case "integrations": + return ec.fieldContext_Group_integrations(ctx, field) + case "files": + return ec.fieldContext_Group_files(ctx, field) + case "tasks": + return ec.fieldContext_Group_tasks(ctx, field) + case "procedureEditors": + return ec.fieldContext_Group_procedureEditors(ctx, field) + case "procedureBlockedGroups": + return ec.fieldContext_Group_procedureBlockedGroups(ctx, field) + case "internalpolicyEditors": + return ec.fieldContext_Group_internalpolicyEditors(ctx, field) + case "internalpolicyBlockedGroups": + return ec.fieldContext_Group_internalpolicyBlockedGroups(ctx, field) + case "programViewers": + return ec.fieldContext_Group_programViewers(ctx, field) + case "programEditors": + return ec.fieldContext_Group_programEditors(ctx, field) + case "programBlockedGroups": + return ec.fieldContext_Group_programBlockedGroups(ctx, field) + case "riskViewers": + return ec.fieldContext_Group_riskViewers(ctx, field) + case "riskEditors": + return ec.fieldContext_Group_riskEditors(ctx, field) + case "riskBlockedGroups": + return ec.fieldContext_Group_riskBlockedGroups(ctx, field) + case "controlobjectiveViewers": + return ec.fieldContext_Group_controlobjectiveViewers(ctx, field) + case "controlobjectiveEditors": + return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) + case "controlobjectiveBlockedGroups": + return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) + case "members": + return ec.fieldContext_Group_members(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Group", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Narrative_viewers(ctx context.Context, field graphql.CollectedField, obj *generated.Narrative) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Narrative_viewers(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Viewers(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*generated.Group) + fc.Result = res + return ec.marshalOGroup2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐGroupᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Narrative_viewers(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Narrative", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Group_id(ctx, field) + case "createdAt": + return ec.fieldContext_Group_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Group_updatedAt(ctx, field) + case "createdBy": + return ec.fieldContext_Group_createdBy(ctx, field) + case "updatedBy": + return ec.fieldContext_Group_updatedBy(ctx, field) + case "deletedAt": + return ec.fieldContext_Group_deletedAt(ctx, field) + case "deletedBy": + return ec.fieldContext_Group_deletedBy(ctx, field) + case "tags": + return ec.fieldContext_Group_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Group_ownerID(ctx, field) + case "name": + return ec.fieldContext_Group_name(ctx, field) + case "description": + return ec.fieldContext_Group_description(ctx, field) + case "gravatarLogoURL": + return ec.fieldContext_Group_gravatarLogoURL(ctx, field) + case "logoURL": + return ec.fieldContext_Group_logoURL(ctx, field) + case "displayName": + return ec.fieldContext_Group_displayName(ctx, field) + case "owner": + return ec.fieldContext_Group_owner(ctx, field) + case "setting": + return ec.fieldContext_Group_setting(ctx, field) + case "users": + return ec.fieldContext_Group_users(ctx, field) + case "events": + return ec.fieldContext_Group_events(ctx, field) + case "integrations": + return ec.fieldContext_Group_integrations(ctx, field) + case "files": + return ec.fieldContext_Group_files(ctx, field) + case "tasks": + return ec.fieldContext_Group_tasks(ctx, field) + case "procedureEditors": + return ec.fieldContext_Group_procedureEditors(ctx, field) + case "procedureBlockedGroups": + return ec.fieldContext_Group_procedureBlockedGroups(ctx, field) + case "internalpolicyEditors": + return ec.fieldContext_Group_internalpolicyEditors(ctx, field) + case "internalpolicyBlockedGroups": + return ec.fieldContext_Group_internalpolicyBlockedGroups(ctx, field) + case "programViewers": + return ec.fieldContext_Group_programViewers(ctx, field) + case "programEditors": + return ec.fieldContext_Group_programEditors(ctx, field) + case "programBlockedGroups": + return ec.fieldContext_Group_programBlockedGroups(ctx, field) + case "riskViewers": + return ec.fieldContext_Group_riskViewers(ctx, field) + case "riskEditors": + return ec.fieldContext_Group_riskEditors(ctx, field) + case "riskBlockedGroups": + return ec.fieldContext_Group_riskBlockedGroups(ctx, field) + case "controlobjectiveViewers": + return ec.fieldContext_Group_controlobjectiveViewers(ctx, field) + case "controlobjectiveEditors": + return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) + case "controlobjectiveBlockedGroups": + return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) + case "members": + return ec.fieldContext_Group_members(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Group", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Narrative_policy(ctx context.Context, field graphql.CollectedField, obj *generated.Narrative) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Narrative_policy(ctx, field) if err != nil { @@ -155753,8 +156914,8 @@ func (ec *executionContext) fieldContext_Narrative_controlobjective(_ context.Co return fc, nil } -func (ec *executionContext) _Narrative_program(ctx context.Context, field graphql.CollectedField, obj *generated.Narrative) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Narrative_program(ctx, field) +func (ec *executionContext) _Narrative_programs(ctx context.Context, field graphql.CollectedField, obj *generated.Narrative) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Narrative_programs(ctx, field) if err != nil { return graphql.Null } @@ -155767,7 +156928,7 @@ func (ec *executionContext) _Narrative_program(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Program(ctx) + return obj.Programs(ctx) }) if err != nil { ec.Error(ctx, err) @@ -155781,7 +156942,7 @@ func (ec *executionContext) _Narrative_program(ctx context.Context, field graphq return ec.marshalOProgram2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐProgramᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Narrative_program(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Narrative_programs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Narrative", Field: field, @@ -155918,6 +157079,8 @@ func (ec *executionContext) fieldContext_NarrativeBulkCreatePayload_narratives(_ return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -155926,6 +157089,14 @@ func (ec *executionContext) fieldContext_NarrativeBulkCreatePayload_narratives(_ return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -155934,8 +157105,8 @@ func (ec *executionContext) fieldContext_NarrativeBulkCreatePayload_narratives(_ return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -156143,6 +157314,8 @@ func (ec *executionContext) fieldContext_NarrativeCreatePayload_narrative(_ cont return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -156151,6 +157324,14 @@ func (ec *executionContext) fieldContext_NarrativeCreatePayload_narrative(_ cont return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -156159,8 +157340,8 @@ func (ec *executionContext) fieldContext_NarrativeCreatePayload_narrative(_ cont return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -156264,6 +157445,8 @@ func (ec *executionContext) fieldContext_NarrativeEdge_node(_ context.Context, f return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -156272,6 +157455,14 @@ func (ec *executionContext) fieldContext_NarrativeEdge_node(_ context.Context, f return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -156280,8 +157471,8 @@ func (ec *executionContext) fieldContext_NarrativeEdge_node(_ context.Context, f return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -156793,6 +157984,50 @@ func (ec *executionContext) fieldContext_NarrativeHistory_tags(_ context.Context return fc, nil } +func (ec *executionContext) _NarrativeHistory_ownerID(ctx context.Context, field graphql.CollectedField, obj *generated.NarrativeHistory) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_NarrativeHistory_ownerID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OwnerID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_NarrativeHistory_ownerID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "NarrativeHistory", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _NarrativeHistory_name(ctx context.Context, field graphql.CollectedField, obj *generated.NarrativeHistory) (ret graphql.Marshaler) { fc, err := ec.fieldContext_NarrativeHistory_name(ctx, field) if err != nil { @@ -157163,6 +158398,8 @@ func (ec *executionContext) fieldContext_NarrativeHistoryEdge_node(_ context.Con return ec.fieldContext_NarrativeHistory_deletedBy(ctx, field) case "tags": return ec.fieldContext_NarrativeHistory_tags(ctx, field) + case "ownerID": + return ec.fieldContext_NarrativeHistory_ownerID(ctx, field) case "name": return ec.fieldContext_NarrativeHistory_name(ctx, field) case "description": @@ -157274,6 +158511,8 @@ func (ec *executionContext) fieldContext_NarrativeSearchResult_narratives(_ cont return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -157282,6 +158521,14 @@ func (ec *executionContext) fieldContext_NarrativeSearchResult_narratives(_ cont return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -157290,8 +158537,8 @@ func (ec *executionContext) fieldContext_NarrativeSearchResult_narratives(_ cont return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -157354,6 +158601,8 @@ func (ec *executionContext) fieldContext_NarrativeUpdatePayload_narrative(_ cont return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -157362,6 +158611,14 @@ func (ec *executionContext) fieldContext_NarrativeUpdatePayload_narrative(_ cont return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -157370,8 +158627,8 @@ func (ec *executionContext) fieldContext_NarrativeUpdatePayload_narrative(_ cont return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -157923,6 +159180,8 @@ func (ec *executionContext) fieldContext_Note_owner(_ context.Context, field gra return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -160190,6 +161449,8 @@ func (ec *executionContext) fieldContext_OauthProvider_owner(_ context.Context, return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -163959,6 +165220,8 @@ func (ec *executionContext) fieldContext_OrgMembership_organization(_ context.Co return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -166221,6 +167484,8 @@ func (ec *executionContext) fieldContext_Organization_parent(_ context.Context, return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -166397,6 +167662,12 @@ func (ec *executionContext) fieldContext_Organization_groups(_ context.Context, return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -168897,6 +170168,93 @@ func (ec *executionContext) fieldContext_Organization_controlobjectives(_ contex return fc, nil } +func (ec *executionContext) _Organization_narratives(ctx context.Context, field graphql.CollectedField, obj *generated.Organization) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Organization_narratives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Narratives(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*generated.Narrative) + fc.Result = res + return ec.marshalONarrative2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐNarrativeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Organization_narratives(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Organization", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Narrative_id(ctx, field) + case "createdAt": + return ec.fieldContext_Narrative_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Narrative_updatedAt(ctx, field) + case "createdBy": + return ec.fieldContext_Narrative_createdBy(ctx, field) + case "updatedBy": + return ec.fieldContext_Narrative_updatedBy(ctx, field) + case "deletedAt": + return ec.fieldContext_Narrative_deletedAt(ctx, field) + case "deletedBy": + return ec.fieldContext_Narrative_deletedBy(ctx, field) + case "tags": + return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) + case "name": + return ec.fieldContext_Narrative_name(ctx, field) + case "description": + return ec.fieldContext_Narrative_description(ctx, field) + case "satisfies": + return ec.fieldContext_Narrative_satisfies(ctx, field) + case "details": + return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) + case "policy": + return ec.fieldContext_Narrative_policy(ctx, field) + case "control": + return ec.fieldContext_Narrative_control(ctx, field) + case "procedure": + return ec.fieldContext_Narrative_procedure(ctx, field) + case "controlobjective": + return ec.fieldContext_Narrative_controlobjective(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Organization_members(ctx context.Context, field graphql.CollectedField, obj *generated.Organization) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Organization_members(ctx, field) if err != nil { @@ -169094,6 +170452,8 @@ func (ec *executionContext) fieldContext_OrganizationBulkCreatePayload_organizat return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -169379,6 +170739,8 @@ func (ec *executionContext) fieldContext_OrganizationCreatePayload_organization( return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -169560,6 +170922,8 @@ func (ec *executionContext) fieldContext_OrganizationEdge_node(_ context.Context return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -170722,6 +172086,8 @@ func (ec *executionContext) fieldContext_OrganizationSearchResult_organizations( return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -171559,6 +172925,8 @@ func (ec *executionContext) fieldContext_OrganizationSetting_organization(_ cont return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -173551,6 +174919,8 @@ func (ec *executionContext) fieldContext_OrganizationUpdatePayload_organization( return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -174559,6 +175929,8 @@ func (ec *executionContext) fieldContext_PersonalAccessToken_organizations(_ con return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -176161,6 +177533,8 @@ func (ec *executionContext) fieldContext_Procedure_owner(_ context.Context, fiel return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -176274,6 +177648,12 @@ func (ec *executionContext) fieldContext_Procedure_blockedGroups(_ context.Conte return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -176387,6 +177767,12 @@ func (ec *executionContext) fieldContext_Procedure_editors(_ context.Context, fi return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -176644,6 +178030,8 @@ func (ec *executionContext) fieldContext_Procedure_narratives(_ context.Context, return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -176652,6 +178040,14 @@ func (ec *executionContext) fieldContext_Procedure_narratives(_ context.Context, return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -176660,8 +178056,8 @@ func (ec *executionContext) fieldContext_Procedure_narratives(_ context.Context, return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -179684,6 +181080,8 @@ func (ec *executionContext) fieldContext_Program_owner(_ context.Context, field return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -179797,6 +181195,12 @@ func (ec *executionContext) fieldContext_Program_blockedGroups(_ context.Context return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -179910,6 +181314,12 @@ func (ec *executionContext) fieldContext_Program_editors(_ context.Context, fiel return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -180023,6 +181433,12 @@ func (ec *executionContext) fieldContext_Program_viewers(_ context.Context, fiel return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -180953,6 +182369,8 @@ func (ec *executionContext) fieldContext_Program_narratives(_ context.Context, f return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -180961,6 +182379,14 @@ func (ec *executionContext) fieldContext_Program_narratives(_ context.Context, f return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -180969,8 +182395,8 @@ func (ec *executionContext) fieldContext_Program_narratives(_ context.Context, f return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -193839,6 +195265,12 @@ func (ec *executionContext) fieldContext_Query_group(ctx context.Context, field return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -194456,6 +195888,8 @@ func (ec *executionContext) fieldContext_Query_narrative(ctx context.Context, fi return ec.fieldContext_Narrative_deletedBy(ctx, field) case "tags": return ec.fieldContext_Narrative_tags(ctx, field) + case "ownerID": + return ec.fieldContext_Narrative_ownerID(ctx, field) case "name": return ec.fieldContext_Narrative_name(ctx, field) case "description": @@ -194464,6 +195898,14 @@ func (ec *executionContext) fieldContext_Query_narrative(ctx context.Context, fi return ec.fieldContext_Narrative_satisfies(ctx, field) case "details": return ec.fieldContext_Narrative_details(ctx, field) + case "owner": + return ec.fieldContext_Narrative_owner(ctx, field) + case "blockedGroups": + return ec.fieldContext_Narrative_blockedGroups(ctx, field) + case "editors": + return ec.fieldContext_Narrative_editors(ctx, field) + case "viewers": + return ec.fieldContext_Narrative_viewers(ctx, field) case "policy": return ec.fieldContext_Narrative_policy(ctx, field) case "control": @@ -194472,8 +195914,8 @@ func (ec *executionContext) fieldContext_Query_narrative(ctx context.Context, fi return ec.fieldContext_Narrative_procedure(ctx, field) case "controlobjective": return ec.fieldContext_Narrative_controlobjective(ctx, field) - case "program": - return ec.fieldContext_Narrative_program(ctx, field) + case "programs": + return ec.fieldContext_Narrative_programs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Narrative", field.Name) }, @@ -194807,6 +196249,8 @@ func (ec *executionContext) fieldContext_Query_organization(ctx context.Context, return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -199611,6 +201055,8 @@ func (ec *executionContext) fieldContext_Risk_owner(_ context.Context, field gra return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -199724,6 +201170,12 @@ func (ec *executionContext) fieldContext_Risk_blockedGroups(_ context.Context, f return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -199837,6 +201289,12 @@ func (ec *executionContext) fieldContext_Risk_editors(_ context.Context, field g return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -199950,6 +201408,12 @@ func (ec *executionContext) fieldContext_Risk_viewers(_ context.Context, field g return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -209793,6 +211257,8 @@ func (ec *executionContext) fieldContext_Subscriber_owner(_ context.Context, fie return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -212541,6 +214007,8 @@ func (ec *executionContext) fieldContext_Task_organization(_ context.Context, fi return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -212654,6 +214122,12 @@ func (ec *executionContext) fieldContext_Task_group(_ context.Context, field gra return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -215665,6 +217139,8 @@ func (ec *executionContext) fieldContext_Template_owner(_ context.Context, field return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -218625,6 +220101,12 @@ func (ec *executionContext) fieldContext_User_groups(_ context.Context, field gr return ec.fieldContext_Group_controlobjectiveEditors(ctx, field) case "controlobjectiveBlockedGroups": return ec.fieldContext_Group_controlobjectiveBlockedGroups(ctx, field) + case "narrativeViewers": + return ec.fieldContext_Group_narrativeViewers(ctx, field) + case "narrativeEditors": + return ec.fieldContext_Group_narrativeEditors(ctx, field) + case "narrativeBlockedGroups": + return ec.fieldContext_Group_narrativeBlockedGroups(ctx, field) case "members": return ec.fieldContext_Group_members(ctx, field) } @@ -218762,6 +220244,8 @@ func (ec *executionContext) fieldContext_User_organizations(_ context.Context, f return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -222612,6 +224096,8 @@ func (ec *executionContext) fieldContext_UserSetting_defaultOrg(_ context.Contex return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -225309,6 +226795,8 @@ func (ec *executionContext) fieldContext_Webhook_owner(_ context.Context, field return ec.fieldContext_Organization_risks(ctx, field) case "controlobjectives": return ec.fieldContext_Organization_controlobjectives(ctx, field) + case "narratives": + return ec.fieldContext_Organization_narratives(ctx, field) case "members": return ec.fieldContext_Organization_members(ctx, field) } @@ -245082,7 +246570,7 @@ func (ec *executionContext) unmarshalInputCreateGroupInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"tags", "name", "description", "gravatarLogoURL", "logoURL", "displayName", "ownerID", "settingID", "userIDs", "eventIDs", "integrationIDs", "fileIDs", "taskIDs", "procedureEditorIDs", "procedureBlockedGroupIDs", "internalpolicyEditorIDs", "internalpolicyBlockedGroupIDs", "programViewerIDs", "programEditorIDs", "programBlockedGroupIDs", "riskViewerIDs", "riskEditorIDs", "riskBlockedGroupIDs", "controlobjectiveViewerIDs", "controlobjectiveEditorIDs", "controlobjectiveBlockedGroupIDs", "createGroupSettings"} + fieldsInOrder := [...]string{"tags", "name", "description", "gravatarLogoURL", "logoURL", "displayName", "ownerID", "settingID", "userIDs", "eventIDs", "integrationIDs", "fileIDs", "taskIDs", "procedureEditorIDs", "procedureBlockedGroupIDs", "internalpolicyEditorIDs", "internalpolicyBlockedGroupIDs", "programViewerIDs", "programEditorIDs", "programBlockedGroupIDs", "riskViewerIDs", "riskEditorIDs", "riskBlockedGroupIDs", "controlobjectiveViewerIDs", "controlobjectiveEditorIDs", "controlobjectiveBlockedGroupIDs", "narrativeViewerIDs", "narrativeEditorIDs", "narrativeBlockedGroupIDs", "createGroupSettings"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -245271,6 +246759,27 @@ func (ec *executionContext) unmarshalInputCreateGroupInput(ctx context.Context, return it, err } it.ControlobjectiveBlockedGroupIDs = data + case "narrativeViewerIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("narrativeViewerIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NarrativeViewerIDs = data + case "narrativeEditorIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("narrativeEditorIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NarrativeEditorIDs = data + case "narrativeBlockedGroupIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("narrativeBlockedGroupIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NarrativeBlockedGroupIDs = data case "createGroupSettings": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createGroupSettings")) data, err := ec.unmarshalOCreateGroupSettingInput2ᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐCreateGroupSettingInput(ctx, v) @@ -245784,7 +247293,7 @@ func (ec *executionContext) unmarshalInputCreateNarrativeInput(ctx context.Conte asMap[k] = v } - fieldsInOrder := [...]string{"tags", "name", "description", "satisfies", "details", "policyIDs", "controlIDs", "procedureIDs", "controlobjectiveIDs", "programIDs"} + fieldsInOrder := [...]string{"tags", "name", "description", "satisfies", "details", "ownerID", "blockedGroupIDs", "editorIDs", "viewerIDs", "policyIDs", "controlIDs", "procedureIDs", "controlobjectiveIDs", "programIDs"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -245826,6 +247335,34 @@ func (ec *executionContext) unmarshalInputCreateNarrativeInput(ctx context.Conte return it, err } it.Details = data + case "ownerID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) + data, err := ec.unmarshalNID2string(ctx, v) + if err != nil { + return it, err + } + it.OwnerID = data + case "blockedGroupIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockedGroupIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.BlockedGroupIDs = data + case "editorIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("editorIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.EditorIDs = data + case "viewerIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("viewerIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ViewerIDs = data case "policyIDs": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("policyIDs")) data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) @@ -246206,7 +247743,7 @@ func (ec *executionContext) unmarshalInputCreateOrganizationInput(ctx context.Co asMap[k] = v } - fieldsInOrder := [...]string{"tags", "name", "displayName", "description", "personalOrg", "avatarRemoteURL", "dedicatedDb", "parentID", "groupIDs", "templateIDs", "integrationIDs", "settingID", "documentdatumIDs", "entitlementIDs", "organizationEntitlementIDs", "personalAccessTokenIDs", "apiTokenIDs", "oauthproviderIDs", "userIDs", "inviteIDs", "subscriberIDs", "webhookIDs", "eventIDs", "secretIDs", "featureIDs", "fileIDs", "entitlementplanIDs", "entityIDs", "entitytypeIDs", "contactIDs", "noteIDs", "taskIDs", "programIDs", "procedureIDs", "internalpolicyIDs", "riskIDs", "controlobjectiveIDs", "createOrgSettings"} + fieldsInOrder := [...]string{"tags", "name", "displayName", "description", "personalOrg", "avatarRemoteURL", "dedicatedDb", "parentID", "groupIDs", "templateIDs", "integrationIDs", "settingID", "documentdatumIDs", "entitlementIDs", "organizationEntitlementIDs", "personalAccessTokenIDs", "apiTokenIDs", "oauthproviderIDs", "userIDs", "inviteIDs", "subscriberIDs", "webhookIDs", "eventIDs", "secretIDs", "featureIDs", "fileIDs", "entitlementplanIDs", "entityIDs", "entitytypeIDs", "contactIDs", "noteIDs", "taskIDs", "programIDs", "procedureIDs", "internalpolicyIDs", "riskIDs", "controlobjectiveIDs", "narrativeIDs", "createOrgSettings"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -246472,6 +248009,13 @@ func (ec *executionContext) unmarshalInputCreateOrganizationInput(ctx context.Co return it, err } it.ControlobjectiveIDs = data + case "narrativeIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("narrativeIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NarrativeIDs = data case "createOrgSettings": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createOrgSettings")) data, err := ec.unmarshalOCreateOrganizationSettingInput2ᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐCreateOrganizationSettingInput(ctx, v) @@ -276350,7 +277894,7 @@ func (ec *executionContext) unmarshalInputGroupWhereInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "idEqualFold", "idContainsFold", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "createdAtIsNil", "createdAtNotNil", "updatedAt", "updatedAtNEQ", "updatedAtIn", "updatedAtNotIn", "updatedAtGT", "updatedAtGTE", "updatedAtLT", "updatedAtLTE", "updatedAtIsNil", "updatedAtNotNil", "createdBy", "createdByNEQ", "createdByIn", "createdByNotIn", "createdByGT", "createdByGTE", "createdByLT", "createdByLTE", "createdByContains", "createdByHasPrefix", "createdByHasSuffix", "createdByIsNil", "createdByNotNil", "createdByEqualFold", "createdByContainsFold", "updatedBy", "updatedByNEQ", "updatedByIn", "updatedByNotIn", "updatedByGT", "updatedByGTE", "updatedByLT", "updatedByLTE", "updatedByContains", "updatedByHasPrefix", "updatedByHasSuffix", "updatedByIsNil", "updatedByNotNil", "updatedByEqualFold", "updatedByContainsFold", "deletedAt", "deletedAtNEQ", "deletedAtIn", "deletedAtNotIn", "deletedAtGT", "deletedAtGTE", "deletedAtLT", "deletedAtLTE", "deletedAtIsNil", "deletedAtNotNil", "deletedBy", "deletedByNEQ", "deletedByIn", "deletedByNotIn", "deletedByGT", "deletedByGTE", "deletedByLT", "deletedByLTE", "deletedByContains", "deletedByHasPrefix", "deletedByHasSuffix", "deletedByIsNil", "deletedByNotNil", "deletedByEqualFold", "deletedByContainsFold", "ownerID", "ownerIDNEQ", "ownerIDIn", "ownerIDNotIn", "ownerIDGT", "ownerIDGTE", "ownerIDLT", "ownerIDLTE", "ownerIDContains", "ownerIDHasPrefix", "ownerIDHasSuffix", "ownerIDIsNil", "ownerIDNotNil", "ownerIDEqualFold", "ownerIDContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "displayName", "displayNameNEQ", "displayNameIn", "displayNameNotIn", "displayNameGT", "displayNameGTE", "displayNameLT", "displayNameLTE", "displayNameContains", "displayNameHasPrefix", "displayNameHasSuffix", "displayNameEqualFold", "displayNameContainsFold", "hasOwner", "hasOwnerWith", "hasSetting", "hasSettingWith", "hasUsers", "hasUsersWith", "hasEvents", "hasEventsWith", "hasIntegrations", "hasIntegrationsWith", "hasFiles", "hasFilesWith", "hasTasks", "hasTasksWith", "hasProcedureEditors", "hasProcedureEditorsWith", "hasProcedureBlockedGroups", "hasProcedureBlockedGroupsWith", "hasInternalpolicyEditors", "hasInternalpolicyEditorsWith", "hasInternalpolicyBlockedGroups", "hasInternalpolicyBlockedGroupsWith", "hasProgramViewers", "hasProgramViewersWith", "hasProgramEditors", "hasProgramEditorsWith", "hasProgramBlockedGroups", "hasProgramBlockedGroupsWith", "hasRiskViewers", "hasRiskViewersWith", "hasRiskEditors", "hasRiskEditorsWith", "hasRiskBlockedGroups", "hasRiskBlockedGroupsWith", "hasControlobjectiveViewers", "hasControlobjectiveViewersWith", "hasControlobjectiveEditors", "hasControlobjectiveEditorsWith", "hasControlobjectiveBlockedGroups", "hasControlobjectiveBlockedGroupsWith", "hasMembers", "hasMembersWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "idEqualFold", "idContainsFold", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "createdAtIsNil", "createdAtNotNil", "updatedAt", "updatedAtNEQ", "updatedAtIn", "updatedAtNotIn", "updatedAtGT", "updatedAtGTE", "updatedAtLT", "updatedAtLTE", "updatedAtIsNil", "updatedAtNotNil", "createdBy", "createdByNEQ", "createdByIn", "createdByNotIn", "createdByGT", "createdByGTE", "createdByLT", "createdByLTE", "createdByContains", "createdByHasPrefix", "createdByHasSuffix", "createdByIsNil", "createdByNotNil", "createdByEqualFold", "createdByContainsFold", "updatedBy", "updatedByNEQ", "updatedByIn", "updatedByNotIn", "updatedByGT", "updatedByGTE", "updatedByLT", "updatedByLTE", "updatedByContains", "updatedByHasPrefix", "updatedByHasSuffix", "updatedByIsNil", "updatedByNotNil", "updatedByEqualFold", "updatedByContainsFold", "deletedAt", "deletedAtNEQ", "deletedAtIn", "deletedAtNotIn", "deletedAtGT", "deletedAtGTE", "deletedAtLT", "deletedAtLTE", "deletedAtIsNil", "deletedAtNotNil", "deletedBy", "deletedByNEQ", "deletedByIn", "deletedByNotIn", "deletedByGT", "deletedByGTE", "deletedByLT", "deletedByLTE", "deletedByContains", "deletedByHasPrefix", "deletedByHasSuffix", "deletedByIsNil", "deletedByNotNil", "deletedByEqualFold", "deletedByContainsFold", "ownerID", "ownerIDNEQ", "ownerIDIn", "ownerIDNotIn", "ownerIDGT", "ownerIDGTE", "ownerIDLT", "ownerIDLTE", "ownerIDContains", "ownerIDHasPrefix", "ownerIDHasSuffix", "ownerIDIsNil", "ownerIDNotNil", "ownerIDEqualFold", "ownerIDContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "displayName", "displayNameNEQ", "displayNameIn", "displayNameNotIn", "displayNameGT", "displayNameGTE", "displayNameLT", "displayNameLTE", "displayNameContains", "displayNameHasPrefix", "displayNameHasSuffix", "displayNameEqualFold", "displayNameContainsFold", "hasOwner", "hasOwnerWith", "hasSetting", "hasSettingWith", "hasUsers", "hasUsersWith", "hasEvents", "hasEventsWith", "hasIntegrations", "hasIntegrationsWith", "hasFiles", "hasFilesWith", "hasTasks", "hasTasksWith", "hasProcedureEditors", "hasProcedureEditorsWith", "hasProcedureBlockedGroups", "hasProcedureBlockedGroupsWith", "hasInternalpolicyEditors", "hasInternalpolicyEditorsWith", "hasInternalpolicyBlockedGroups", "hasInternalpolicyBlockedGroupsWith", "hasProgramViewers", "hasProgramViewersWith", "hasProgramEditors", "hasProgramEditorsWith", "hasProgramBlockedGroups", "hasProgramBlockedGroupsWith", "hasRiskViewers", "hasRiskViewersWith", "hasRiskEditors", "hasRiskEditorsWith", "hasRiskBlockedGroups", "hasRiskBlockedGroupsWith", "hasControlobjectiveViewers", "hasControlobjectiveViewersWith", "hasControlobjectiveEditors", "hasControlobjectiveEditorsWith", "hasControlobjectiveBlockedGroups", "hasControlobjectiveBlockedGroupsWith", "hasNarrativeViewers", "hasNarrativeViewersWith", "hasNarrativeEditors", "hasNarrativeEditorsWith", "hasNarrativeBlockedGroups", "hasNarrativeBlockedGroupsWith", "hasMembers", "hasMembersWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -277540,6 +279084,48 @@ func (ec *executionContext) unmarshalInputGroupWhereInput(ctx context.Context, o return it, err } it.HasControlobjectiveBlockedGroupsWith = data + case "hasNarrativeViewers": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasNarrativeViewers")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasNarrativeViewers = data + case "hasNarrativeViewersWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasNarrativeViewersWith")) + data, err := ec.unmarshalONarrativeWhereInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐNarrativeWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasNarrativeViewersWith = data + case "hasNarrativeEditors": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasNarrativeEditors")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasNarrativeEditors = data + case "hasNarrativeEditorsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasNarrativeEditorsWith")) + data, err := ec.unmarshalONarrativeWhereInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐNarrativeWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasNarrativeEditorsWith = data + case "hasNarrativeBlockedGroups": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasNarrativeBlockedGroups")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasNarrativeBlockedGroups = data + case "hasNarrativeBlockedGroupsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasNarrativeBlockedGroupsWith")) + data, err := ec.unmarshalONarrativeWhereInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐNarrativeWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasNarrativeBlockedGroupsWith = data case "hasMembers": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasMembers")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) @@ -286343,7 +287929,7 @@ func (ec *executionContext) unmarshalInputNarrativeHistoryWhereInput(ctx context asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "idEqualFold", "idContainsFold", "historyTime", "historyTimeNEQ", "historyTimeIn", "historyTimeNotIn", "historyTimeGT", "historyTimeGTE", "historyTimeLT", "historyTimeLTE", "ref", "refNEQ", "refIn", "refNotIn", "refGT", "refGTE", "refLT", "refLTE", "refContains", "refHasPrefix", "refHasSuffix", "refIsNil", "refNotNil", "refEqualFold", "refContainsFold", "operation", "operationNEQ", "operationIn", "operationNotIn", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "createdAtIsNil", "createdAtNotNil", "updatedAt", "updatedAtNEQ", "updatedAtIn", "updatedAtNotIn", "updatedAtGT", "updatedAtGTE", "updatedAtLT", "updatedAtLTE", "updatedAtIsNil", "updatedAtNotNil", "createdBy", "createdByNEQ", "createdByIn", "createdByNotIn", "createdByGT", "createdByGTE", "createdByLT", "createdByLTE", "createdByContains", "createdByHasPrefix", "createdByHasSuffix", "createdByIsNil", "createdByNotNil", "createdByEqualFold", "createdByContainsFold", "updatedBy", "updatedByNEQ", "updatedByIn", "updatedByNotIn", "updatedByGT", "updatedByGTE", "updatedByLT", "updatedByLTE", "updatedByContains", "updatedByHasPrefix", "updatedByHasSuffix", "updatedByIsNil", "updatedByNotNil", "updatedByEqualFold", "updatedByContainsFold", "deletedAt", "deletedAtNEQ", "deletedAtIn", "deletedAtNotIn", "deletedAtGT", "deletedAtGTE", "deletedAtLT", "deletedAtLTE", "deletedAtIsNil", "deletedAtNotNil", "deletedBy", "deletedByNEQ", "deletedByIn", "deletedByNotIn", "deletedByGT", "deletedByGTE", "deletedByLT", "deletedByLTE", "deletedByContains", "deletedByHasPrefix", "deletedByHasSuffix", "deletedByIsNil", "deletedByNotNil", "deletedByEqualFold", "deletedByContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionIsNil", "descriptionNotNil", "descriptionEqualFold", "descriptionContainsFold", "satisfies", "satisfiesNEQ", "satisfiesIn", "satisfiesNotIn", "satisfiesGT", "satisfiesGTE", "satisfiesLT", "satisfiesLTE", "satisfiesContains", "satisfiesHasPrefix", "satisfiesHasSuffix", "satisfiesIsNil", "satisfiesNotNil", "satisfiesEqualFold", "satisfiesContainsFold"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "idEqualFold", "idContainsFold", "historyTime", "historyTimeNEQ", "historyTimeIn", "historyTimeNotIn", "historyTimeGT", "historyTimeGTE", "historyTimeLT", "historyTimeLTE", "ref", "refNEQ", "refIn", "refNotIn", "refGT", "refGTE", "refLT", "refLTE", "refContains", "refHasPrefix", "refHasSuffix", "refIsNil", "refNotNil", "refEqualFold", "refContainsFold", "operation", "operationNEQ", "operationIn", "operationNotIn", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "createdAtIsNil", "createdAtNotNil", "updatedAt", "updatedAtNEQ", "updatedAtIn", "updatedAtNotIn", "updatedAtGT", "updatedAtGTE", "updatedAtLT", "updatedAtLTE", "updatedAtIsNil", "updatedAtNotNil", "createdBy", "createdByNEQ", "createdByIn", "createdByNotIn", "createdByGT", "createdByGTE", "createdByLT", "createdByLTE", "createdByContains", "createdByHasPrefix", "createdByHasSuffix", "createdByIsNil", "createdByNotNil", "createdByEqualFold", "createdByContainsFold", "updatedBy", "updatedByNEQ", "updatedByIn", "updatedByNotIn", "updatedByGT", "updatedByGTE", "updatedByLT", "updatedByLTE", "updatedByContains", "updatedByHasPrefix", "updatedByHasSuffix", "updatedByIsNil", "updatedByNotNil", "updatedByEqualFold", "updatedByContainsFold", "deletedAt", "deletedAtNEQ", "deletedAtIn", "deletedAtNotIn", "deletedAtGT", "deletedAtGTE", "deletedAtLT", "deletedAtLTE", "deletedAtIsNil", "deletedAtNotNil", "deletedBy", "deletedByNEQ", "deletedByIn", "deletedByNotIn", "deletedByGT", "deletedByGTE", "deletedByLT", "deletedByLTE", "deletedByContains", "deletedByHasPrefix", "deletedByHasSuffix", "deletedByIsNil", "deletedByNotNil", "deletedByEqualFold", "deletedByContainsFold", "ownerID", "ownerIDNEQ", "ownerIDIn", "ownerIDNotIn", "ownerIDGT", "ownerIDGTE", "ownerIDLT", "ownerIDLTE", "ownerIDContains", "ownerIDHasPrefix", "ownerIDHasSuffix", "ownerIDEqualFold", "ownerIDContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionIsNil", "descriptionNotNil", "descriptionEqualFold", "descriptionContainsFold", "satisfies", "satisfiesNEQ", "satisfiesIn", "satisfiesNotIn", "satisfiesGT", "satisfiesGTE", "satisfiesLT", "satisfiesLTE", "satisfiesContains", "satisfiesHasPrefix", "satisfiesHasSuffix", "satisfiesIsNil", "satisfiesNotNil", "satisfiesEqualFold", "satisfiesContainsFold"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -287155,6 +288741,97 @@ func (ec *executionContext) unmarshalInputNarrativeHistoryWhereInput(ctx context return it, err } it.DeletedByContainsFold = data + case "ownerID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerID = data + case "ownerIDNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDNEQ = data + case "ownerIDIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDIn = data + case "ownerIDNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDNotIn = data + case "ownerIDGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDGT = data + case "ownerIDGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDGTE = data + case "ownerIDLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDLT = data + case "ownerIDLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDLTE = data + case "ownerIDContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDContains = data + case "ownerIDHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDHasPrefix = data + case "ownerIDHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDHasSuffix = data + case "ownerIDEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDEqualFold = data + case "ownerIDContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDContainsFold = data case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -287469,7 +289146,7 @@ func (ec *executionContext) unmarshalInputNarrativeWhereInput(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "idEqualFold", "idContainsFold", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "createdAtIsNil", "createdAtNotNil", "updatedAt", "updatedAtNEQ", "updatedAtIn", "updatedAtNotIn", "updatedAtGT", "updatedAtGTE", "updatedAtLT", "updatedAtLTE", "updatedAtIsNil", "updatedAtNotNil", "createdBy", "createdByNEQ", "createdByIn", "createdByNotIn", "createdByGT", "createdByGTE", "createdByLT", "createdByLTE", "createdByContains", "createdByHasPrefix", "createdByHasSuffix", "createdByIsNil", "createdByNotNil", "createdByEqualFold", "createdByContainsFold", "updatedBy", "updatedByNEQ", "updatedByIn", "updatedByNotIn", "updatedByGT", "updatedByGTE", "updatedByLT", "updatedByLTE", "updatedByContains", "updatedByHasPrefix", "updatedByHasSuffix", "updatedByIsNil", "updatedByNotNil", "updatedByEqualFold", "updatedByContainsFold", "deletedAt", "deletedAtNEQ", "deletedAtIn", "deletedAtNotIn", "deletedAtGT", "deletedAtGTE", "deletedAtLT", "deletedAtLTE", "deletedAtIsNil", "deletedAtNotNil", "deletedBy", "deletedByNEQ", "deletedByIn", "deletedByNotIn", "deletedByGT", "deletedByGTE", "deletedByLT", "deletedByLTE", "deletedByContains", "deletedByHasPrefix", "deletedByHasSuffix", "deletedByIsNil", "deletedByNotNil", "deletedByEqualFold", "deletedByContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionIsNil", "descriptionNotNil", "descriptionEqualFold", "descriptionContainsFold", "satisfies", "satisfiesNEQ", "satisfiesIn", "satisfiesNotIn", "satisfiesGT", "satisfiesGTE", "satisfiesLT", "satisfiesLTE", "satisfiesContains", "satisfiesHasPrefix", "satisfiesHasSuffix", "satisfiesIsNil", "satisfiesNotNil", "satisfiesEqualFold", "satisfiesContainsFold", "hasPolicy", "hasPolicyWith", "hasControl", "hasControlWith", "hasProcedure", "hasProcedureWith", "hasControlobjective", "hasControlobjectiveWith", "hasProgram", "hasProgramWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "idEqualFold", "idContainsFold", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "createdAtIsNil", "createdAtNotNil", "updatedAt", "updatedAtNEQ", "updatedAtIn", "updatedAtNotIn", "updatedAtGT", "updatedAtGTE", "updatedAtLT", "updatedAtLTE", "updatedAtIsNil", "updatedAtNotNil", "createdBy", "createdByNEQ", "createdByIn", "createdByNotIn", "createdByGT", "createdByGTE", "createdByLT", "createdByLTE", "createdByContains", "createdByHasPrefix", "createdByHasSuffix", "createdByIsNil", "createdByNotNil", "createdByEqualFold", "createdByContainsFold", "updatedBy", "updatedByNEQ", "updatedByIn", "updatedByNotIn", "updatedByGT", "updatedByGTE", "updatedByLT", "updatedByLTE", "updatedByContains", "updatedByHasPrefix", "updatedByHasSuffix", "updatedByIsNil", "updatedByNotNil", "updatedByEqualFold", "updatedByContainsFold", "deletedAt", "deletedAtNEQ", "deletedAtIn", "deletedAtNotIn", "deletedAtGT", "deletedAtGTE", "deletedAtLT", "deletedAtLTE", "deletedAtIsNil", "deletedAtNotNil", "deletedBy", "deletedByNEQ", "deletedByIn", "deletedByNotIn", "deletedByGT", "deletedByGTE", "deletedByLT", "deletedByLTE", "deletedByContains", "deletedByHasPrefix", "deletedByHasSuffix", "deletedByIsNil", "deletedByNotNil", "deletedByEqualFold", "deletedByContainsFold", "ownerID", "ownerIDNEQ", "ownerIDIn", "ownerIDNotIn", "ownerIDGT", "ownerIDGTE", "ownerIDLT", "ownerIDLTE", "ownerIDContains", "ownerIDHasPrefix", "ownerIDHasSuffix", "ownerIDEqualFold", "ownerIDContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionIsNil", "descriptionNotNil", "descriptionEqualFold", "descriptionContainsFold", "satisfies", "satisfiesNEQ", "satisfiesIn", "satisfiesNotIn", "satisfiesGT", "satisfiesGTE", "satisfiesLT", "satisfiesLTE", "satisfiesContains", "satisfiesHasPrefix", "satisfiesHasSuffix", "satisfiesIsNil", "satisfiesNotNil", "satisfiesEqualFold", "satisfiesContainsFold", "hasOwner", "hasOwnerWith", "hasBlockedGroups", "hasBlockedGroupsWith", "hasEditors", "hasEditorsWith", "hasViewers", "hasViewersWith", "hasPolicy", "hasPolicyWith", "hasControl", "hasControlWith", "hasProcedure", "hasProcedureWith", "hasControlobjective", "hasControlobjectiveWith", "hasPrograms", "hasProgramsWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -288092,6 +289769,97 @@ func (ec *executionContext) unmarshalInputNarrativeWhereInput(ctx context.Contex return it, err } it.DeletedByContainsFold = data + case "ownerID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerID = data + case "ownerIDNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDNEQ")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDNEQ = data + case "ownerIDIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDIn")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDIn = data + case "ownerIDNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDNotIn")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDNotIn = data + case "ownerIDGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDGT")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDGT = data + case "ownerIDGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDGTE")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDGTE = data + case "ownerIDLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDLT")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDLT = data + case "ownerIDLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDLTE")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDLTE = data + case "ownerIDContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDContains")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDContains = data + case "ownerIDHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDHasPrefix")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDHasPrefix = data + case "ownerIDHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDHasSuffix")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDHasSuffix = data + case "ownerIDEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDEqualFold")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDEqualFold = data + case "ownerIDContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIDContainsFold")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerIDContainsFold = data case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -288393,6 +290161,62 @@ func (ec *executionContext) unmarshalInputNarrativeWhereInput(ctx context.Contex return it, err } it.SatisfiesContainsFold = data + case "hasOwner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwner")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasOwner = data + case "hasOwnerWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwnerWith")) + data, err := ec.unmarshalOOrganizationWhereInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐOrganizationWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasOwnerWith = data + case "hasBlockedGroups": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBlockedGroups")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasBlockedGroups = data + case "hasBlockedGroupsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBlockedGroupsWith")) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐGroupWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasBlockedGroupsWith = data + case "hasEditors": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasEditors")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasEditors = data + case "hasEditorsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasEditorsWith")) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐGroupWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasEditorsWith = data + case "hasViewers": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasViewers")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasViewers = data + case "hasViewersWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasViewersWith")) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐGroupWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasViewersWith = data case "hasPolicy": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasPolicy")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) @@ -288449,20 +290273,20 @@ func (ec *executionContext) unmarshalInputNarrativeWhereInput(ctx context.Contex return it, err } it.HasControlobjectiveWith = data - case "hasProgram": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProgram")) + case "hasPrograms": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasPrograms")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasProgram = data - case "hasProgramWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProgramWith")) + it.HasPrograms = data + case "hasProgramsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProgramsWith")) data, err := ec.unmarshalOProgramWhereInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐProgramWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasProgramWith = data + it.HasProgramsWith = data } } @@ -300470,7 +302294,7 @@ func (ec *executionContext) unmarshalInputOrganizationWhereInput(ctx context.Con asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "idEqualFold", "idContainsFold", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "createdAtIsNil", "createdAtNotNil", "updatedAt", "updatedAtNEQ", "updatedAtIn", "updatedAtNotIn", "updatedAtGT", "updatedAtGTE", "updatedAtLT", "updatedAtLTE", "updatedAtIsNil", "updatedAtNotNil", "createdBy", "createdByNEQ", "createdByIn", "createdByNotIn", "createdByGT", "createdByGTE", "createdByLT", "createdByLTE", "createdByContains", "createdByHasPrefix", "createdByHasSuffix", "createdByIsNil", "createdByNotNil", "createdByEqualFold", "createdByContainsFold", "updatedBy", "updatedByNEQ", "updatedByIn", "updatedByNotIn", "updatedByGT", "updatedByGTE", "updatedByLT", "updatedByLTE", "updatedByContains", "updatedByHasPrefix", "updatedByHasSuffix", "updatedByIsNil", "updatedByNotNil", "updatedByEqualFold", "updatedByContainsFold", "deletedAt", "deletedAtNEQ", "deletedAtIn", "deletedAtNotIn", "deletedAtGT", "deletedAtGTE", "deletedAtLT", "deletedAtLTE", "deletedAtIsNil", "deletedAtNotNil", "deletedBy", "deletedByNEQ", "deletedByIn", "deletedByNotIn", "deletedByGT", "deletedByGTE", "deletedByLT", "deletedByLTE", "deletedByContains", "deletedByHasPrefix", "deletedByHasSuffix", "deletedByIsNil", "deletedByNotNil", "deletedByEqualFold", "deletedByContainsFold", "displayName", "displayNameNEQ", "displayNameIn", "displayNameNotIn", "displayNameGT", "displayNameGTE", "displayNameLT", "displayNameLTE", "displayNameContains", "displayNameHasPrefix", "displayNameHasSuffix", "displayNameEqualFold", "displayNameContainsFold", "parentOrganizationID", "parentOrganizationIDNEQ", "parentOrganizationIDIn", "parentOrganizationIDNotIn", "parentOrganizationIDGT", "parentOrganizationIDGTE", "parentOrganizationIDLT", "parentOrganizationIDLTE", "parentOrganizationIDContains", "parentOrganizationIDHasPrefix", "parentOrganizationIDHasSuffix", "parentOrganizationIDIsNil", "parentOrganizationIDNotNil", "parentOrganizationIDEqualFold", "parentOrganizationIDContainsFold", "personalOrg", "personalOrgNEQ", "personalOrgIsNil", "personalOrgNotNil", "avatarRemoteURL", "avatarRemoteURLNEQ", "avatarRemoteURLIn", "avatarRemoteURLNotIn", "avatarRemoteURLGT", "avatarRemoteURLGTE", "avatarRemoteURLLT", "avatarRemoteURLLTE", "avatarRemoteURLContains", "avatarRemoteURLHasPrefix", "avatarRemoteURLHasSuffix", "avatarRemoteURLIsNil", "avatarRemoteURLNotNil", "avatarRemoteURLEqualFold", "avatarRemoteURLContainsFold", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith", "hasGroups", "hasGroupsWith", "hasTemplates", "hasTemplatesWith", "hasIntegrations", "hasIntegrationsWith", "hasSetting", "hasSettingWith", "hasDocumentdata", "hasDocumentdataWith", "hasEntitlements", "hasEntitlementsWith", "hasOrganizationEntitlement", "hasOrganizationEntitlementWith", "hasPersonalAccessTokens", "hasPersonalAccessTokensWith", "hasAPITokens", "hasAPITokensWith", "hasOauthprovider", "hasOauthproviderWith", "hasUsers", "hasUsersWith", "hasInvites", "hasInvitesWith", "hasSubscribers", "hasSubscribersWith", "hasWebhooks", "hasWebhooksWith", "hasEvents", "hasEventsWith", "hasSecrets", "hasSecretsWith", "hasFeatures", "hasFeaturesWith", "hasFiles", "hasFilesWith", "hasEntitlementplans", "hasEntitlementplansWith", "hasEntitlementplanfeatures", "hasEntitlementplanfeaturesWith", "hasEntities", "hasEntitiesWith", "hasEntitytypes", "hasEntitytypesWith", "hasContacts", "hasContactsWith", "hasNotes", "hasNotesWith", "hasTasks", "hasTasksWith", "hasPrograms", "hasProgramsWith", "hasProcedures", "hasProceduresWith", "hasInternalpolicies", "hasInternalpoliciesWith", "hasRisks", "hasRisksWith", "hasControlobjectives", "hasControlobjectivesWith", "hasMembers", "hasMembersWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "idEqualFold", "idContainsFold", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "createdAtIsNil", "createdAtNotNil", "updatedAt", "updatedAtNEQ", "updatedAtIn", "updatedAtNotIn", "updatedAtGT", "updatedAtGTE", "updatedAtLT", "updatedAtLTE", "updatedAtIsNil", "updatedAtNotNil", "createdBy", "createdByNEQ", "createdByIn", "createdByNotIn", "createdByGT", "createdByGTE", "createdByLT", "createdByLTE", "createdByContains", "createdByHasPrefix", "createdByHasSuffix", "createdByIsNil", "createdByNotNil", "createdByEqualFold", "createdByContainsFold", "updatedBy", "updatedByNEQ", "updatedByIn", "updatedByNotIn", "updatedByGT", "updatedByGTE", "updatedByLT", "updatedByLTE", "updatedByContains", "updatedByHasPrefix", "updatedByHasSuffix", "updatedByIsNil", "updatedByNotNil", "updatedByEqualFold", "updatedByContainsFold", "deletedAt", "deletedAtNEQ", "deletedAtIn", "deletedAtNotIn", "deletedAtGT", "deletedAtGTE", "deletedAtLT", "deletedAtLTE", "deletedAtIsNil", "deletedAtNotNil", "deletedBy", "deletedByNEQ", "deletedByIn", "deletedByNotIn", "deletedByGT", "deletedByGTE", "deletedByLT", "deletedByLTE", "deletedByContains", "deletedByHasPrefix", "deletedByHasSuffix", "deletedByIsNil", "deletedByNotNil", "deletedByEqualFold", "deletedByContainsFold", "displayName", "displayNameNEQ", "displayNameIn", "displayNameNotIn", "displayNameGT", "displayNameGTE", "displayNameLT", "displayNameLTE", "displayNameContains", "displayNameHasPrefix", "displayNameHasSuffix", "displayNameEqualFold", "displayNameContainsFold", "parentOrganizationID", "parentOrganizationIDNEQ", "parentOrganizationIDIn", "parentOrganizationIDNotIn", "parentOrganizationIDGT", "parentOrganizationIDGTE", "parentOrganizationIDLT", "parentOrganizationIDLTE", "parentOrganizationIDContains", "parentOrganizationIDHasPrefix", "parentOrganizationIDHasSuffix", "parentOrganizationIDIsNil", "parentOrganizationIDNotNil", "parentOrganizationIDEqualFold", "parentOrganizationIDContainsFold", "personalOrg", "personalOrgNEQ", "personalOrgIsNil", "personalOrgNotNil", "avatarRemoteURL", "avatarRemoteURLNEQ", "avatarRemoteURLIn", "avatarRemoteURLNotIn", "avatarRemoteURLGT", "avatarRemoteURLGTE", "avatarRemoteURLLT", "avatarRemoteURLLTE", "avatarRemoteURLContains", "avatarRemoteURLHasPrefix", "avatarRemoteURLHasSuffix", "avatarRemoteURLIsNil", "avatarRemoteURLNotNil", "avatarRemoteURLEqualFold", "avatarRemoteURLContainsFold", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith", "hasGroups", "hasGroupsWith", "hasTemplates", "hasTemplatesWith", "hasIntegrations", "hasIntegrationsWith", "hasSetting", "hasSettingWith", "hasDocumentdata", "hasDocumentdataWith", "hasEntitlements", "hasEntitlementsWith", "hasOrganizationEntitlement", "hasOrganizationEntitlementWith", "hasPersonalAccessTokens", "hasPersonalAccessTokensWith", "hasAPITokens", "hasAPITokensWith", "hasOauthprovider", "hasOauthproviderWith", "hasUsers", "hasUsersWith", "hasInvites", "hasInvitesWith", "hasSubscribers", "hasSubscribersWith", "hasWebhooks", "hasWebhooksWith", "hasEvents", "hasEventsWith", "hasSecrets", "hasSecretsWith", "hasFeatures", "hasFeaturesWith", "hasFiles", "hasFilesWith", "hasEntitlementplans", "hasEntitlementplansWith", "hasEntitlementplanfeatures", "hasEntitlementplanfeaturesWith", "hasEntities", "hasEntitiesWith", "hasEntitytypes", "hasEntitytypesWith", "hasContacts", "hasContactsWith", "hasNotes", "hasNotesWith", "hasTasks", "hasTasksWith", "hasPrograms", "hasProgramsWith", "hasProcedures", "hasProceduresWith", "hasInternalpolicies", "hasInternalpoliciesWith", "hasRisks", "hasRisksWith", "hasControlobjectives", "hasControlobjectivesWith", "hasNarratives", "hasNarrativesWith", "hasMembers", "hasMembersWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -301870,6 +303694,20 @@ func (ec *executionContext) unmarshalInputOrganizationWhereInput(ctx context.Con return it, err } it.HasControlobjectivesWith = data + case "hasNarratives": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasNarratives")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasNarratives = data + case "hasNarrativesWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasNarrativesWith")) + data, err := ec.unmarshalONarrativeWhereInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐNarrativeWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasNarrativesWith = data case "hasMembers": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasMembers")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) @@ -331580,7 +333418,7 @@ func (ec *executionContext) unmarshalInputUpdateGroupInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"tags", "appendTags", "clearTags", "name", "description", "clearDescription", "gravatarLogoURL", "clearGravatarLogoURL", "logoURL", "clearLogoURL", "displayName", "ownerID", "clearOwner", "settingID", "addUserIDs", "removeUserIDs", "clearUsers", "addEventIDs", "removeEventIDs", "clearEvents", "addIntegrationIDs", "removeIntegrationIDs", "clearIntegrations", "addFileIDs", "removeFileIDs", "clearFiles", "addTaskIDs", "removeTaskIDs", "clearTasks", "addProcedureEditorIDs", "removeProcedureEditorIDs", "clearProcedureEditors", "addProcedureBlockedGroupIDs", "removeProcedureBlockedGroupIDs", "clearProcedureBlockedGroups", "addInternalpolicyEditorIDs", "removeInternalpolicyEditorIDs", "clearInternalpolicyEditors", "addInternalpolicyBlockedGroupIDs", "removeInternalpolicyBlockedGroupIDs", "clearInternalpolicyBlockedGroups", "addProgramViewerIDs", "removeProgramViewerIDs", "clearProgramViewers", "addProgramEditorIDs", "removeProgramEditorIDs", "clearProgramEditors", "addProgramBlockedGroupIDs", "removeProgramBlockedGroupIDs", "clearProgramBlockedGroups", "addRiskViewerIDs", "removeRiskViewerIDs", "clearRiskViewers", "addRiskEditorIDs", "removeRiskEditorIDs", "clearRiskEditors", "addRiskBlockedGroupIDs", "removeRiskBlockedGroupIDs", "clearRiskBlockedGroups", "addControlobjectiveViewerIDs", "removeControlobjectiveViewerIDs", "clearControlobjectiveViewers", "addControlobjectiveEditorIDs", "removeControlobjectiveEditorIDs", "clearControlobjectiveEditors", "addControlobjectiveBlockedGroupIDs", "removeControlobjectiveBlockedGroupIDs", "clearControlobjectiveBlockedGroups", "addGroupMembers", "updateGroupSettings"} + fieldsInOrder := [...]string{"tags", "appendTags", "clearTags", "name", "description", "clearDescription", "gravatarLogoURL", "clearGravatarLogoURL", "logoURL", "clearLogoURL", "displayName", "ownerID", "clearOwner", "settingID", "addUserIDs", "removeUserIDs", "clearUsers", "addEventIDs", "removeEventIDs", "clearEvents", "addIntegrationIDs", "removeIntegrationIDs", "clearIntegrations", "addFileIDs", "removeFileIDs", "clearFiles", "addTaskIDs", "removeTaskIDs", "clearTasks", "addProcedureEditorIDs", "removeProcedureEditorIDs", "clearProcedureEditors", "addProcedureBlockedGroupIDs", "removeProcedureBlockedGroupIDs", "clearProcedureBlockedGroups", "addInternalpolicyEditorIDs", "removeInternalpolicyEditorIDs", "clearInternalpolicyEditors", "addInternalpolicyBlockedGroupIDs", "removeInternalpolicyBlockedGroupIDs", "clearInternalpolicyBlockedGroups", "addProgramViewerIDs", "removeProgramViewerIDs", "clearProgramViewers", "addProgramEditorIDs", "removeProgramEditorIDs", "clearProgramEditors", "addProgramBlockedGroupIDs", "removeProgramBlockedGroupIDs", "clearProgramBlockedGroups", "addRiskViewerIDs", "removeRiskViewerIDs", "clearRiskViewers", "addRiskEditorIDs", "removeRiskEditorIDs", "clearRiskEditors", "addRiskBlockedGroupIDs", "removeRiskBlockedGroupIDs", "clearRiskBlockedGroups", "addControlobjectiveViewerIDs", "removeControlobjectiveViewerIDs", "clearControlobjectiveViewers", "addControlobjectiveEditorIDs", "removeControlobjectiveEditorIDs", "clearControlobjectiveEditors", "addControlobjectiveBlockedGroupIDs", "removeControlobjectiveBlockedGroupIDs", "clearControlobjectiveBlockedGroups", "addNarrativeViewerIDs", "removeNarrativeViewerIDs", "clearNarrativeViewers", "addNarrativeEditorIDs", "removeNarrativeEditorIDs", "clearNarrativeEditors", "addNarrativeBlockedGroupIDs", "removeNarrativeBlockedGroupIDs", "clearNarrativeBlockedGroups", "addGroupMembers", "updateGroupSettings"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -332063,6 +333901,69 @@ func (ec *executionContext) unmarshalInputUpdateGroupInput(ctx context.Context, return it, err } it.ClearControlobjectiveBlockedGroups = data + case "addNarrativeViewerIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addNarrativeViewerIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddNarrativeViewerIDs = data + case "removeNarrativeViewerIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeNarrativeViewerIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveNarrativeViewerIDs = data + case "clearNarrativeViewers": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearNarrativeViewers")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearNarrativeViewers = data + case "addNarrativeEditorIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addNarrativeEditorIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddNarrativeEditorIDs = data + case "removeNarrativeEditorIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeNarrativeEditorIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveNarrativeEditorIDs = data + case "clearNarrativeEditors": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearNarrativeEditors")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearNarrativeEditors = data + case "addNarrativeBlockedGroupIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addNarrativeBlockedGroupIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddNarrativeBlockedGroupIDs = data + case "removeNarrativeBlockedGroupIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeNarrativeBlockedGroupIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveNarrativeBlockedGroupIDs = data + case "clearNarrativeBlockedGroups": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearNarrativeBlockedGroups")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearNarrativeBlockedGroups = data case "addGroupMembers": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addGroupMembers")) data, err := ec.unmarshalOCreateGroupMembershipInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐCreateGroupMembershipInputᚄ(ctx, v) @@ -332852,291 +334753,361 @@ func (ec *executionContext) unmarshalInputUpdateInternalPolicyInput(ctx context. return it, nil } -func (ec *executionContext) unmarshalInputUpdateInviteInput(ctx context.Context, obj interface{}) (generated.UpdateInviteInput, error) { - var it generated.UpdateInviteInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"expires", "clearExpires", "status", "role", "sendAttempts", "ownerID", "clearOwner", "addEventIDs", "removeEventIDs", "clearEvents"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "expires": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expires")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.Expires = data - case "clearExpires": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearExpires")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearExpires = data - case "status": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - data, err := ec.unmarshalOInviteInviteStatus2ᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋpkgᚋenumsᚐInviteStatus(ctx, v) - if err != nil { - return it, err - } - it.Status = data - case "role": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("role")) - data, err := ec.unmarshalOInviteRole2ᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋpkgᚋenumsᚐRole(ctx, v) - if err != nil { - return it, err - } - it.Role = data - case "sendAttempts": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sendAttempts")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SendAttempts = data - case "ownerID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) - data, err := ec.unmarshalOID2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.OwnerID = data - case "clearOwner": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearOwner")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearOwner = data - case "addEventIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addEventIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddEventIDs = data - case "removeEventIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeEventIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.RemoveEventIDs = data - case "clearEvents": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearEvents")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearEvents = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputUpdateNarrativeInput(ctx context.Context, obj interface{}) (generated.UpdateNarrativeInput, error) { - var it generated.UpdateNarrativeInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"tags", "appendTags", "clearTags", "name", "description", "clearDescription", "satisfies", "clearSatisfies", "details", "clearDetails", "addPolicyIDs", "removePolicyIDs", "clearPolicy", "addControlIDs", "removeControlIDs", "clearControl", "addProcedureIDs", "removeProcedureIDs", "clearProcedure", "addControlobjectiveIDs", "removeControlobjectiveIDs", "clearControlobjective", "addProgramIDs", "removeProgramIDs", "clearProgram"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "tags": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tags")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.Tags = data - case "appendTags": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("appendTags")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AppendTags = data - case "clearTags": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTags")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearTags = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Name = data - case "description": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Description = data - case "clearDescription": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearDescription")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearDescription = data - case "satisfies": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("satisfies")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Satisfies = data - case "clearSatisfies": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSatisfies")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearSatisfies = data - case "details": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("details")) - data, err := ec.unmarshalOMap2map(ctx, v) - if err != nil { - return it, err - } - it.Details = data - case "clearDetails": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearDetails")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearDetails = data - case "addPolicyIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addPolicyIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddPolicyIDs = data - case "removePolicyIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removePolicyIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.RemovePolicyIDs = data - case "clearPolicy": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearPolicy")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearPolicy = data - case "addControlIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addControlIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddControlIDs = data - case "removeControlIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeControlIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.RemoveControlIDs = data - case "clearControl": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearControl")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearControl = data - case "addProcedureIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addProcedureIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddProcedureIDs = data - case "removeProcedureIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeProcedureIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.RemoveProcedureIDs = data - case "clearProcedure": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearProcedure")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearProcedure = data - case "addControlobjectiveIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addControlobjectiveIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddControlobjectiveIDs = data - case "removeControlobjectiveIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeControlobjectiveIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.RemoveControlobjectiveIDs = data - case "clearControlobjective": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearControlobjective")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearControlobjective = data - case "addProgramIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addProgramIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddProgramIDs = data - case "removeProgramIDs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeProgramIDs")) - data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.RemoveProgramIDs = data - case "clearProgram": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearProgram")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ClearProgram = data - } - } - - return it, nil -} - +func (ec *executionContext) unmarshalInputUpdateInviteInput(ctx context.Context, obj interface{}) (generated.UpdateInviteInput, error) { + var it generated.UpdateInviteInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"expires", "clearExpires", "status", "role", "sendAttempts", "ownerID", "clearOwner", "addEventIDs", "removeEventIDs", "clearEvents"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "expires": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expires")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.Expires = data + case "clearExpires": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearExpires")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearExpires = data + case "status": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOInviteInviteStatus2ᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋpkgᚋenumsᚐInviteStatus(ctx, v) + if err != nil { + return it, err + } + it.Status = data + case "role": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("role")) + data, err := ec.unmarshalOInviteRole2ᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋpkgᚋenumsᚐRole(ctx, v) + if err != nil { + return it, err + } + it.Role = data + case "sendAttempts": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sendAttempts")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SendAttempts = data + case "ownerID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerID = data + case "clearOwner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearOwner")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearOwner = data + case "addEventIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addEventIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddEventIDs = data + case "removeEventIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeEventIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveEventIDs = data + case "clearEvents": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearEvents")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearEvents = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUpdateNarrativeInput(ctx context.Context, obj interface{}) (generated.UpdateNarrativeInput, error) { + var it generated.UpdateNarrativeInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"tags", "appendTags", "clearTags", "name", "description", "clearDescription", "satisfies", "clearSatisfies", "details", "clearDetails", "ownerID", "addBlockedGroupIDs", "removeBlockedGroupIDs", "clearBlockedGroups", "addEditorIDs", "removeEditorIDs", "clearEditors", "addViewerIDs", "removeViewerIDs", "clearViewers", "addPolicyIDs", "removePolicyIDs", "clearPolicy", "addControlIDs", "removeControlIDs", "clearControl", "addProcedureIDs", "removeProcedureIDs", "clearProcedure", "addControlobjectiveIDs", "removeControlobjectiveIDs", "clearControlobjective", "addProgramIDs", "removeProgramIDs", "clearPrograms"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "tags": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tags")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Tags = data + case "appendTags": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("appendTags")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AppendTags = data + case "clearTags": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTags")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearTags = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Description = data + case "clearDescription": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearDescription")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearDescription = data + case "satisfies": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("satisfies")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Satisfies = data + case "clearSatisfies": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSatisfies")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearSatisfies = data + case "details": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("details")) + data, err := ec.unmarshalOMap2map(ctx, v) + if err != nil { + return it, err + } + it.Details = data + case "clearDetails": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearDetails")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearDetails = data + case "ownerID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerID = data + case "addBlockedGroupIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addBlockedGroupIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddBlockedGroupIDs = data + case "removeBlockedGroupIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeBlockedGroupIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveBlockedGroupIDs = data + case "clearBlockedGroups": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearBlockedGroups")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearBlockedGroups = data + case "addEditorIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addEditorIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddEditorIDs = data + case "removeEditorIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeEditorIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveEditorIDs = data + case "clearEditors": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearEditors")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearEditors = data + case "addViewerIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addViewerIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddViewerIDs = data + case "removeViewerIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeViewerIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveViewerIDs = data + case "clearViewers": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearViewers")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearViewers = data + case "addPolicyIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addPolicyIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddPolicyIDs = data + case "removePolicyIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removePolicyIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemovePolicyIDs = data + case "clearPolicy": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearPolicy")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearPolicy = data + case "addControlIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addControlIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddControlIDs = data + case "removeControlIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeControlIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveControlIDs = data + case "clearControl": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearControl")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearControl = data + case "addProcedureIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addProcedureIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddProcedureIDs = data + case "removeProcedureIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeProcedureIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveProcedureIDs = data + case "clearProcedure": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearProcedure")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearProcedure = data + case "addControlobjectiveIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addControlobjectiveIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddControlobjectiveIDs = data + case "removeControlobjectiveIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeControlobjectiveIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveControlobjectiveIDs = data + case "clearControlobjective": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearControlobjective")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearControlobjective = data + case "addProgramIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addProgramIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddProgramIDs = data + case "removeProgramIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeProgramIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveProgramIDs = data + case "clearPrograms": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearPrograms")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearPrograms = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputUpdateNoteInput(ctx context.Context, obj interface{}) (generated.UpdateNoteInput, error) { var it generated.UpdateNoteInput asMap := map[string]interface{}{} @@ -333637,7 +335608,7 @@ func (ec *executionContext) unmarshalInputUpdateOrganizationInput(ctx context.Co asMap[k] = v } - fieldsInOrder := [...]string{"tags", "appendTags", "clearTags", "name", "displayName", "description", "clearDescription", "avatarRemoteURL", "clearAvatarRemoteURL", "addGroupIDs", "removeGroupIDs", "clearGroups", "addTemplateIDs", "removeTemplateIDs", "clearTemplates", "addIntegrationIDs", "removeIntegrationIDs", "clearIntegrations", "settingID", "clearSetting", "addDocumentdatumIDs", "removeDocumentdatumIDs", "clearDocumentdata", "addEntitlementIDs", "removeEntitlementIDs", "clearEntitlements", "addOrganizationEntitlementIDs", "removeOrganizationEntitlementIDs", "clearOrganizationEntitlement", "addPersonalAccessTokenIDs", "removePersonalAccessTokenIDs", "clearPersonalAccessTokens", "addAPITokenIDs", "removeAPITokenIDs", "clearAPITokens", "addOauthproviderIDs", "removeOauthproviderIDs", "clearOauthprovider", "addUserIDs", "removeUserIDs", "clearUsers", "addInviteIDs", "removeInviteIDs", "clearInvites", "addSubscriberIDs", "removeSubscriberIDs", "clearSubscribers", "addWebhookIDs", "removeWebhookIDs", "clearWebhooks", "addEventIDs", "removeEventIDs", "clearEvents", "addSecretIDs", "removeSecretIDs", "clearSecrets", "addFeatureIDs", "removeFeatureIDs", "clearFeatures", "addFileIDs", "removeFileIDs", "clearFiles", "addEntitlementplanIDs", "removeEntitlementplanIDs", "clearEntitlementplans", "addEntityIDs", "removeEntityIDs", "clearEntities", "addEntitytypeIDs", "removeEntitytypeIDs", "clearEntitytypes", "addContactIDs", "removeContactIDs", "clearContacts", "addNoteIDs", "removeNoteIDs", "clearNotes", "addTaskIDs", "removeTaskIDs", "clearTasks", "addProgramIDs", "removeProgramIDs", "clearPrograms", "addProcedureIDs", "removeProcedureIDs", "clearProcedures", "addInternalpolicyIDs", "removeInternalpolicyIDs", "clearInternalpolicies", "addRiskIDs", "removeRiskIDs", "clearRisks", "addControlobjectiveIDs", "removeControlobjectiveIDs", "clearControlobjectives", "addOrgMembers", "updateOrgSettings"} + fieldsInOrder := [...]string{"tags", "appendTags", "clearTags", "name", "displayName", "description", "clearDescription", "avatarRemoteURL", "clearAvatarRemoteURL", "addGroupIDs", "removeGroupIDs", "clearGroups", "addTemplateIDs", "removeTemplateIDs", "clearTemplates", "addIntegrationIDs", "removeIntegrationIDs", "clearIntegrations", "settingID", "clearSetting", "addDocumentdatumIDs", "removeDocumentdatumIDs", "clearDocumentdata", "addEntitlementIDs", "removeEntitlementIDs", "clearEntitlements", "addOrganizationEntitlementIDs", "removeOrganizationEntitlementIDs", "clearOrganizationEntitlement", "addPersonalAccessTokenIDs", "removePersonalAccessTokenIDs", "clearPersonalAccessTokens", "addAPITokenIDs", "removeAPITokenIDs", "clearAPITokens", "addOauthproviderIDs", "removeOauthproviderIDs", "clearOauthprovider", "addUserIDs", "removeUserIDs", "clearUsers", "addInviteIDs", "removeInviteIDs", "clearInvites", "addSubscriberIDs", "removeSubscriberIDs", "clearSubscribers", "addWebhookIDs", "removeWebhookIDs", "clearWebhooks", "addEventIDs", "removeEventIDs", "clearEvents", "addSecretIDs", "removeSecretIDs", "clearSecrets", "addFeatureIDs", "removeFeatureIDs", "clearFeatures", "addFileIDs", "removeFileIDs", "clearFiles", "addEntitlementplanIDs", "removeEntitlementplanIDs", "clearEntitlementplans", "addEntityIDs", "removeEntityIDs", "clearEntities", "addEntitytypeIDs", "removeEntitytypeIDs", "clearEntitytypes", "addContactIDs", "removeContactIDs", "clearContacts", "addNoteIDs", "removeNoteIDs", "clearNotes", "addTaskIDs", "removeTaskIDs", "clearTasks", "addProgramIDs", "removeProgramIDs", "clearPrograms", "addProcedureIDs", "removeProcedureIDs", "clearProcedures", "addInternalpolicyIDs", "removeInternalpolicyIDs", "clearInternalpolicies", "addRiskIDs", "removeRiskIDs", "clearRisks", "addControlobjectiveIDs", "removeControlobjectiveIDs", "clearControlobjectives", "addNarrativeIDs", "removeNarrativeIDs", "clearNarratives", "addOrgMembers", "updateOrgSettings"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -334309,6 +336280,27 @@ func (ec *executionContext) unmarshalInputUpdateOrganizationInput(ctx context.Co return it, err } it.ClearControlobjectives = data + case "addNarrativeIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addNarrativeIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddNarrativeIDs = data + case "removeNarrativeIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeNarrativeIDs")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveNarrativeIDs = data + case "clearNarratives": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearNarratives")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearNarratives = data case "addOrgMembers": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addOrgMembers")) data, err := ec.unmarshalOCreateOrgMembershipInput2ᚕᚖgithubᚗcomᚋtheopenlaneᚋcoreᚋinternalᚋentᚋgeneratedᚐCreateOrgMembershipInputᚄ(ctx, v) @@ -358170,6 +360162,105 @@ func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, ob continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "narrativeViewers": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Group_narrativeViewers(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "narrativeEditors": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Group_narrativeEditors(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "narrativeBlockedGroups": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Group_narrativeBlockedGroups(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "members": field := field @@ -363665,6 +365756,11 @@ func (ec *executionContext) _Narrative(ctx context.Context, sel ast.SelectionSet out.Values[i] = ec._Narrative_deletedBy(ctx, field, obj) case "tags": out.Values[i] = ec._Narrative_tags(ctx, field, obj) + case "ownerID": + out.Values[i] = ec._Narrative_ownerID(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "name": out.Values[i] = ec._Narrative_name(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -363676,6 +365772,141 @@ func (ec *executionContext) _Narrative(ctx context.Context, sel ast.SelectionSet out.Values[i] = ec._Narrative_satisfies(ctx, field, obj) case "details": out.Values[i] = ec._Narrative_details(ctx, field, obj) + case "owner": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Narrative_owner(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "blockedGroups": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Narrative_blockedGroups(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "editors": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Narrative_editors(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "viewers": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Narrative_viewers(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "policy": field := field @@ -363808,7 +366039,7 @@ func (ec *executionContext) _Narrative(ctx context.Context, sel ast.SelectionSet } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "program": + case "programs": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { @@ -363817,7 +366048,7 @@ func (ec *executionContext) _Narrative(ctx context.Context, sel ast.SelectionSet ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Narrative_program(ctx, field, obj) + res = ec._Narrative_programs(ctx, field, obj) return res } @@ -364107,6 +366338,11 @@ func (ec *executionContext) _NarrativeHistory(ctx context.Context, sel ast.Selec out.Values[i] = ec._NarrativeHistory_deletedBy(ctx, field, obj) case "tags": out.Values[i] = ec._NarrativeHistory_tags(ctx, field, obj) + case "ownerID": + out.Values[i] = ec._NarrativeHistory_ownerID(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "name": out.Values[i] = ec._NarrativeHistory_name(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -367468,6 +369704,39 @@ func (ec *executionContext) _Organization(ctx context.Context, sel ast.Selection continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "narratives": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Organization_narratives(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "members": field := field diff --git a/internal/graphapi/models_test.go b/internal/graphapi/models_test.go index 3a9ee3c3..e3feefb7 100644 --- a/internal/graphapi/models_test.go +++ b/internal/graphapi/models_test.go @@ -305,6 +305,14 @@ type ControlObjectiveBuilder struct { ProgramID string } +type NarrativeBuilder struct { + client *client + + // Fields + Name string + ProgramID string +} + // MustNew organization builder is used to create, without authz checks, orgs in the database func (o *OrganizationBuilder) MustNew(ctx context.Context, t *testing.T) *ent.Organization { // no auth, so allow policy @@ -1015,3 +1023,27 @@ func (c *ControlObjectiveBuilder) MustNew(ctx context.Context, t *testing.T) *en return co } + +// MustNew narrative builder is used to create, without authz checks, narratives in the database +func (n *NarrativeBuilder) MustNew(ctx context.Context, t *testing.T) *ent.Narrative { + ctx = privacy.DecisionContext(ctx, privacy.Allow) + + // add client to context + ctx = ent.NewContext(ctx, n.client.db) + + if n.Name == "" { + n.Name = gofakeit.AppName() + } + + mutation := n.client.db.Narrative.Create(). + SetName(n.Name) + + if n.ProgramID != "" { + mutation.AddProgramIDs(n.ProgramID) + } + + narrative := mutation. + SaveX(ctx) + + return narrative +} diff --git a/internal/graphapi/narrative.resolvers.go b/internal/graphapi/narrative.resolvers.go index 5c7d4d5a..4d9e308a 100644 --- a/internal/graphapi/narrative.resolvers.go +++ b/internal/graphapi/narrative.resolvers.go @@ -10,10 +10,18 @@ import ( "github.com/99designs/gqlgen/graphql" "github.com/rs/zerolog/log" "github.com/theopenlane/core/internal/ent/generated" + "github.com/theopenlane/utils/rout" ) // CreateNarrative is the resolver for the createNarrative field. func (r *mutationResolver) CreateNarrative(ctx context.Context, input generated.CreateNarrativeInput) (*NarrativeCreatePayload, error) { + // set the organization in the auth context if its not done for us + if err := setOrganizationInAuthContext(ctx, &input.OwnerID); err != nil { + log.Error().Err(err).Msg("failed to set organization in auth context") + + return nil, rout.NewMissingRequiredFieldError("organization_id") + } + res, err := withTransactionalMutation(ctx).Narrative.Create().SetInput(input).Save(ctx) if err != nil { return nil, parseRequestError(err, action{action: ActionCreate, object: "narrative"}) @@ -48,6 +56,13 @@ func (r *mutationResolver) UpdateNarrative(ctx context.Context, id string, input return nil, parseRequestError(err, action{action: ActionUpdate, object: "narrative"}) } + // set the organization in the auth context if its not done for us + if err := setOrganizationInAuthContext(ctx, &res.OwnerID); err != nil { + log.Error().Err(err).Msg("failed to set organization in auth context") + + return nil, rout.ErrPermissionDenied + } + // setup update request req := res.Update().SetInput(input).AppendTags(input.AppendTags) diff --git a/internal/graphapi/narrative_test.go b/internal/graphapi/narrative_test.go new file mode 100644 index 00000000..d8fad286 --- /dev/null +++ b/internal/graphapi/narrative_test.go @@ -0,0 +1,536 @@ +package graphapi_test + +import ( + "context" + "testing" + + "github.com/samber/lo" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/theopenlane/core/pkg/enums" + "github.com/theopenlane/core/pkg/openlaneclient" + "github.com/theopenlane/utils/ulids" +) + +func (suite *GraphTestSuite) TestQueryNarrative() { + t := suite.T() + + program := (&ProgramBuilder{client: suite.client}).MustNew(testUser1.UserCtx, t) + + // add adminUser to the program so that they can create a Narrative + (&ProgramMemberBuilder{client: suite.client, ProgramID: program.ID, + UserID: adminUser.ID, Role: enums.RoleAdmin.String()}). + MustNew(testUser1.UserCtx, t) + + // add test cases for querying the Narrative + testCases := []struct { + name string + queryID string + client *openlaneclient.OpenlaneClient + ctx context.Context + errorMsg string + }{ + { + name: "happy path", + client: suite.client.api, + ctx: testUser1.UserCtx, + }, + { + name: "read only user, same org, no access to the program", + client: suite.client.api, + ctx: viewOnlyUser.UserCtx, + errorMsg: notFoundErrorMsg, + }, + { + name: "admin user, access to the program", + client: suite.client.api, + ctx: adminUser.UserCtx, + }, + { + name: "happy path using personal access token", + client: suite.client.apiWithPAT, + ctx: context.Background(), + }, + { + name: "narrative not found, invalid ID", + queryID: "invalid", + client: suite.client.api, + ctx: testUser1.UserCtx, + errorMsg: notFoundErrorMsg, + }, + { + name: "narrative not found, using not authorized user", + client: suite.client.api, + ctx: testUser2.UserCtx, + errorMsg: notFoundErrorMsg, + }, + } + + for _, tc := range testCases { + t.Run("Get "+tc.name, func(t *testing.T) { + // setup the narrative if it is not already created + if tc.queryID == "" { + resp, err := suite.client.api.CreateNarrative(testUser1.UserCtx, + openlaneclient.CreateNarrativeInput{ + Name: "Narrative", + ProgramIDs: []string{program.ID}, + }) + + require.NoError(t, err) + require.NotNil(t, resp) + + tc.queryID = resp.CreateNarrative.Narrative.ID + } + + resp, err := tc.client.GetNarrativeByID(tc.ctx, tc.queryID) + + if tc.errorMsg != "" { + require.Error(t, err) + assert.ErrorContains(t, err, tc.errorMsg) + assert.Nil(t, resp) + + return + } + + require.NoError(t, err) + require.NotNil(t, resp) + + require.NotEmpty(t, resp.Narrative) + + assert.Equal(t, tc.queryID, resp.Narrative.ID) + assert.NotEmpty(t, resp.Narrative.Name) + + require.Len(t, resp.Narrative.Programs, 1) + assert.NotEmpty(t, resp.Narrative.Programs[0].ID) + }) + } +} + +func (suite *GraphTestSuite) TestQueryNarratives() { + t := suite.T() + + // create multiple objects to be queried using testUser1 + (&NarrativeBuilder{client: suite.client}).MustNew(testUser1.UserCtx, t) + (&NarrativeBuilder{client: suite.client}).MustNew(testUser1.UserCtx, t) + + testCases := []struct { + name string + client *openlaneclient.OpenlaneClient + ctx context.Context + expectedResults int + }{ + { + name: "happy path", + client: suite.client.api, + ctx: testUser1.UserCtx, + expectedResults: 2, + }, + { + name: "happy path, using read only user of the same org, no programs or groups associated", + client: suite.client.api, + ctx: viewOnlyUser.UserCtx, + expectedResults: 0, + }, + { + name: "happy path, no access to the program or group", + client: suite.client.apiWithToken, + ctx: context.Background(), + expectedResults: 0, + }, + { + name: "happy path, using pat", + client: suite.client.apiWithPAT, + ctx: context.Background(), + expectedResults: 2, + }, + { + name: "another user, no narratives should be returned", + client: suite.client.api, + ctx: testUser2.UserCtx, + expectedResults: 0, + }, + } + + for _, tc := range testCases { + t.Run("List "+tc.name, func(t *testing.T) { + resp, err := tc.client.GetAllNarratives(tc.ctx) + require.NoError(t, err) + require.NotNil(t, resp) + + assert.Len(t, resp.Narratives.Edges, tc.expectedResults) + }) + } +} + +func (suite *GraphTestSuite) TestMutationCreateNarrative() { + t := suite.T() + + program1 := (&ProgramBuilder{client: suite.client}).MustNew(testUser1.UserCtx, t) + program2 := (&ProgramBuilder{client: suite.client}).MustNew(testUser1.UserCtx, t) + programAnotherUser := (&ProgramBuilder{client: suite.client}).MustNew(testUser2.UserCtx, t) + + // add adminUser to the program so that they can create a narrative associated with the program1 + (&ProgramMemberBuilder{client: suite.client, ProgramID: program1.ID, + UserID: adminUser.ID, Role: enums.RoleAdmin.String()}). + MustNew(testUser1.UserCtx, t) + + // create groups to be associated with the narrative + blockedGroup := (&GroupBuilder{client: suite.client}).MustNew(testUser1.UserCtx, t) + viewerGroup := (&GroupBuilder{client: suite.client}).MustNew(testUser1.UserCtx, t) + + testCases := []struct { + name string + request openlaneclient.CreateNarrativeInput + client *openlaneclient.OpenlaneClient + ctx context.Context + expectedErr string + }{ + { + name: "happy path, minimal input", + request: openlaneclient.CreateNarrativeInput{ + Name: "Narrative", + }, + client: suite.client.api, + ctx: testUser1.UserCtx, + }, + { + name: "happy path, all input", + request: openlaneclient.CreateNarrativeInput{ + Name: "Another Narrative", + Description: lo.ToPtr("A description of the Narrative"), + Satisfies: lo.ToPtr("controls"), + Details: map[string]interface{}{"stuff": "things"}, + ProgramIDs: []string{program1.ID, program2.ID}, // multiple programs + }, + client: suite.client.api, + ctx: testUser1.UserCtx, + }, + { + name: "add groups", + request: openlaneclient.CreateNarrativeInput{ + Name: "Test Procedure", + EditorIDs: []string{testUser1.GroupID}, + BlockedGroupIDs: []string{blockedGroup.ID}, + ViewerIDs: []string{viewerGroup.ID}, + }, + client: suite.client.api, + ctx: testUser1.UserCtx, + }, + { + name: "happy path, using pat", + request: openlaneclient.CreateNarrativeInput{ + Name: "Narrative", + OwnerID: testUser1.OrganizationID, + }, + client: suite.client.apiWithPAT, + ctx: context.Background(), + }, + { + name: "using api token", + request: openlaneclient.CreateNarrativeInput{ + Name: "Narrative", + }, + client: suite.client.apiWithToken, + ctx: context.Background(), + }, + { + name: "user not authorized, not enough permissions", + request: openlaneclient.CreateNarrativeInput{ + Name: "Narrative", + }, + client: suite.client.api, + ctx: viewOnlyUser.UserCtx, + expectedErr: notAuthorizedErrorMsg, + }, + { + name: "user authorized, they were added to the program", + request: openlaneclient.CreateNarrativeInput{ + Name: "Narrative", + ProgramIDs: []string{program1.ID}, + }, + client: suite.client.api, + ctx: adminUser.UserCtx, + }, + { + name: "user authorized, user not authorized to one of the programs", + request: openlaneclient.CreateNarrativeInput{ + Name: "Narrative", + ProgramIDs: []string{program1.ID, program2.ID}, + }, + client: suite.client.api, + ctx: adminUser.UserCtx, + expectedErr: notAuthorizedErrorMsg, + }, + { + name: "missing required name", + request: openlaneclient.CreateNarrativeInput{}, + client: suite.client.api, + ctx: testUser1.UserCtx, + expectedErr: "value is less than the required length", + }, + { + name: "user not authorized, no permissions to one of the programs", + request: openlaneclient.CreateNarrativeInput{ + Name: "Narrative", + ProgramIDs: []string{programAnotherUser.ID, program1.ID}, + }, + client: suite.client.api, + ctx: testUser1.UserCtx, + expectedErr: notAuthorizedErrorMsg, + }, + } + + for _, tc := range testCases { + t.Run("Create "+tc.name, func(t *testing.T) { + resp, err := tc.client.CreateNarrative(tc.ctx, tc.request) + if tc.expectedErr != "" { + require.Error(t, err) + assert.ErrorContains(t, err, tc.expectedErr) + assert.Nil(t, resp) + + return + } + + require.NoError(t, err) + require.NotNil(t, resp) + + // check required fields + require.NotEmpty(t, resp.CreateNarrative.Narrative.ID) + assert.Equal(t, tc.request.Name, resp.CreateNarrative.Narrative.Name) + + // ensure the program is set + if len(tc.request.ProgramIDs) > 0 { + require.NotEmpty(t, resp.CreateNarrative.Narrative.Programs) + require.Len(t, resp.CreateNarrative.Narrative.Programs, len(tc.request.ProgramIDs)) + + for i, p := range resp.CreateNarrative.Narrative.Programs { + assert.Equal(t, tc.request.ProgramIDs[i], p.ID) + } + } else { + assert.Empty(t, resp.CreateNarrative.Narrative.Programs) + } + + if tc.request.Description != nil { + assert.Equal(t, *tc.request.Description, *resp.CreateNarrative.Narrative.Description) + } else { + assert.Empty(t, resp.CreateNarrative.Narrative.Description) + } + + if tc.request.Satisfies != nil { + assert.Equal(t, *tc.request.Satisfies, *resp.CreateNarrative.Narrative.Satisfies) + } else { + assert.Empty(t, resp.CreateNarrative.Narrative.Satisfies) + } + + if tc.request.Details != nil { + assert.Equal(t, tc.request.Details, resp.CreateNarrative.Narrative.Details) + } else { + assert.Empty(t, resp.CreateNarrative.Narrative.Details) + } + + if len(tc.request.EditorIDs) > 0 { + require.Len(t, resp.CreateNarrative.Narrative.Editors, 1) + for _, edge := range resp.CreateNarrative.Narrative.Editors { + assert.Equal(t, testUser1.GroupID, edge.ID) + } + } + + if len(tc.request.BlockedGroupIDs) > 0 { + require.Len(t, resp.CreateNarrative.Narrative.BlockedGroups, 1) + for _, edge := range resp.CreateNarrative.Narrative.BlockedGroups { + assert.Equal(t, blockedGroup.ID, edge.ID) + } + } + + if len(tc.request.ViewerIDs) > 0 { + require.Len(t, resp.CreateNarrative.Narrative.Viewers, 1) + for _, edge := range resp.CreateNarrative.Narrative.Viewers { + assert.Equal(t, viewerGroup.ID, edge.ID) + } + } + }) + } +} + +func (suite *GraphTestSuite) TestMutationUpdateNarrative() { + t := suite.T() + + program := (&ProgramBuilder{client: suite.client, EditorIDs: testUser1.GroupID}).MustNew(testUser1.UserCtx, t) + narrative := (&NarrativeBuilder{client: suite.client, ProgramID: program.ID}).MustNew(testUser1.UserCtx, t) + + // create another admin user and add them to the same organization and group as testUser1 + // this will allow us to test the group editor/viewer permissions + anotherAdminUser := suite.userBuilder(context.Background()) + suite.addUserToOrganization(&anotherAdminUser, enums.RoleAdmin, testUser1.OrganizationID) + + (&GroupMemberBuilder{client: suite.client, UserID: anotherAdminUser.ID, GroupID: testUser1.GroupID}).MustNew(testUser1.UserCtx, t) + + // ensure the user does not currently have access to the narrative + res, err := suite.client.api.GetNarrativeByID(anotherAdminUser.UserCtx, narrative.ID) + require.Error(t, err) + require.Nil(t, res) + + testCases := []struct { + name string + request openlaneclient.UpdateNarrativeInput + client *openlaneclient.OpenlaneClient + ctx context.Context + expectedErr string + }{ + { + name: "happy path, update field", + request: openlaneclient.UpdateNarrativeInput{ + Description: lo.ToPtr("Updated description"), + AddViewerIDs: []string{testUser1.GroupID}, + }, + client: suite.client.api, + ctx: testUser1.UserCtx, + }, + { + name: "happy path, update multiple fields", + request: openlaneclient.UpdateNarrativeInput{ + Satisfies: lo.ToPtr("Updated controls"), + Tags: []string{"tag1", "tag2"}, + Name: lo.ToPtr("Updated Name"), + Details: map[string]interface{}{"key": "value"}, + }, + client: suite.client.apiWithPAT, + ctx: context.Background(), + }, + { + name: "update not allowed, not permissions in same org", + request: openlaneclient.UpdateNarrativeInput{ + AppendTags: []string{"tag3"}, + }, + client: suite.client.api, + ctx: viewOnlyUser.UserCtx, + expectedErr: notFoundErrorMsg, + }, + { + name: "update not allowed, no permissions", + request: openlaneclient.UpdateNarrativeInput{ + AppendTags: []string{"tag3"}, + }, + client: suite.client.api, + ctx: testUser2.UserCtx, + expectedErr: notFoundErrorMsg, + }, + } + + for _, tc := range testCases { + t.Run("Update "+tc.name, func(t *testing.T) { + resp, err := tc.client.UpdateNarrative(tc.ctx, narrative.ID, tc.request) + if tc.expectedErr != "" { + require.Error(t, err) + assert.ErrorContains(t, err, tc.expectedErr) + assert.Nil(t, resp) + + return + } + + require.NoError(t, err) + require.NotNil(t, resp) + + if tc.request.Description != nil { + assert.Equal(t, *tc.request.Description, *resp.UpdateNarrative.Narrative.Description) + } + + if tc.request.Satisfies != nil { + assert.Equal(t, *tc.request.Satisfies, *resp.UpdateNarrative.Narrative.Satisfies) + } + + if tc.request.Tags != nil { + assert.ElementsMatch(t, tc.request.Tags, resp.UpdateNarrative.Narrative.Tags) + } + + if tc.request.AppendTags != nil { + assert.Contains(t, resp.UpdateNarrative.Narrative.Tags, tc.request.AppendTags[0]) + } + + if tc.request.Details != nil { + assert.Equal(t, tc.request.Details, resp.UpdateNarrative.Narrative.Details) + } + + if len(tc.request.AddViewerIDs) > 0 { + require.Len(t, resp.UpdateNarrative.Narrative.Viewers, 1) + for _, edge := range resp.UpdateNarrative.Narrative.Viewers { + assert.Equal(t, testUser1.GroupID, edge.ID) + } + + // ensure the user has access to the narrative now + res, err := suite.client.api.GetNarrativeByID(anotherAdminUser.UserCtx, narrative.ID) + require.NoError(t, err) + require.NotEmpty(t, res) + assert.Equal(t, narrative.ID, res.Narrative.ID) + } + }) + } +} + +func (suite *GraphTestSuite) TestMutationDeleteNarrative() { + t := suite.T() + + // create objects to be deleted + Narrative1 := (&NarrativeBuilder{client: suite.client}).MustNew(testUser1.UserCtx, t) + Narrative2 := (&NarrativeBuilder{client: suite.client}).MustNew(testUser1.UserCtx, t) + + testCases := []struct { + name string + idToDelete string + client *openlaneclient.OpenlaneClient + ctx context.Context + expectedErr string + }{ + { + name: "not authorized, delete", + idToDelete: Narrative1.ID, + client: suite.client.api, + ctx: testUser2.UserCtx, + expectedErr: notFoundErrorMsg, + }, + { + name: "happy path, delete", + idToDelete: Narrative1.ID, + client: suite.client.api, + ctx: testUser1.UserCtx, + }, + { + name: "already deleted, not found", + idToDelete: Narrative1.ID, + client: suite.client.api, + ctx: testUser1.UserCtx, + expectedErr: "not found", + }, + { + name: "happy path, delete using personal access token", + idToDelete: Narrative2.ID, + client: suite.client.apiWithPAT, + ctx: context.Background(), + }, + { + name: "unknown id, not found", + idToDelete: ulids.New().String(), + client: suite.client.api, + ctx: testUser1.UserCtx, + expectedErr: notFoundErrorMsg, + }, + } + + for _, tc := range testCases { + t.Run("Delete "+tc.name, func(t *testing.T) { + resp, err := tc.client.DeleteNarrative(tc.ctx, tc.idToDelete) + if tc.expectedErr != "" { + require.Error(t, err) + assert.ErrorContains(t, err, tc.expectedErr) + assert.Nil(t, resp) + + return + } + + require.NoError(t, err) + require.NotNil(t, resp) + assert.Equal(t, tc.idToDelete, resp.DeleteNarrative.DeletedID) + }) + } +} diff --git a/internal/graphapi/search.go b/internal/graphapi/search.go index 36cae3d1..16519ae8 100644 --- a/internal/graphapi/search.go +++ b/internal/graphapi/search.go @@ -712,12 +712,13 @@ func adminSearchNarratives(ctx context.Context, query string) ([]*generated.Narr likeQuery := "%" + query + "%" s.Where(sql.ExprP("(tags)::text LIKE $3", likeQuery)) // search by Tags }, + narrative.OwnerIDContainsFold(query), // search by OwnerID narrative.NameContainsFold(query), // search by Name narrative.DescriptionContainsFold(query), // search by Description narrative.SatisfiesContainsFold(query), // search by Satisfies func(s *sql.Selector) { likeQuery := "%" + query + "%" - s.Where(sql.ExprP("(details)::text LIKE $7", likeQuery)) // search by Details + s.Where(sql.ExprP("(details)::text LIKE $8", likeQuery)) // search by Details }, ), ).All(ctx) diff --git a/pkg/openlaneclient/graphclient.go b/pkg/openlaneclient/graphclient.go index 5fbdba72..2afa5165 100644 --- a/pkg/openlaneclient/graphclient.go +++ b/pkg/openlaneclient/graphclient.go @@ -2824,6 +2824,7 @@ type AdminSearch_AdminSearch_Nodes_NarrativeSearchResult_Narratives struct { DeletedBy *string "json:\"deletedBy,omitempty\" graphql:\"deletedBy\"" ID string "json:\"id\" graphql:\"id\"" Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" + OwnerID string "json:\"ownerID\" graphql:\"ownerID\"" Name string "json:\"name\" graphql:\"name\"" Description *string "json:\"description,omitempty\" graphql:\"description\"" Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" @@ -2848,6 +2849,12 @@ func (t *AdminSearch_AdminSearch_Nodes_NarrativeSearchResult_Narratives) GetTags } return t.Tags } +func (t *AdminSearch_AdminSearch_Nodes_NarrativeSearchResult_Narratives) GetOwnerID() string { + if t == nil { + t = &AdminSearch_AdminSearch_Nodes_NarrativeSearchResult_Narratives{} + } + return t.OwnerID +} func (t *AdminSearch_AdminSearch_Nodes_NarrativeSearchResult_Narratives) GetName() string { if t == nil { t = &AdminSearch_AdminSearch_Nodes_NarrativeSearchResult_Narratives{} @@ -27524,17 +27531,93 @@ func (t *CreateBulkNarrative_CreateBulkNarrative) GetNarratives() []*CreateBulkN return t.Narratives } +type CreateNarrative_CreateNarrative_Narrative_Programs struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *CreateNarrative_CreateNarrative_Narrative_Programs) GetID() string { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative_Programs{} + } + return t.ID +} +func (t *CreateNarrative_CreateNarrative_Narrative_Programs) GetName() string { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative_Programs{} + } + return t.Name +} + +type CreateNarrative_CreateNarrative_Narrative_Editors struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *CreateNarrative_CreateNarrative_Narrative_Editors) GetID() string { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative_Editors{} + } + return t.ID +} +func (t *CreateNarrative_CreateNarrative_Narrative_Editors) GetName() string { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative_Editors{} + } + return t.Name +} + +type CreateNarrative_CreateNarrative_Narrative_Viewers struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *CreateNarrative_CreateNarrative_Narrative_Viewers) GetID() string { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative_Viewers{} + } + return t.ID +} +func (t *CreateNarrative_CreateNarrative_Narrative_Viewers) GetName() string { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative_Viewers{} + } + return t.Name +} + +type CreateNarrative_CreateNarrative_Narrative_BlockedGroups struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *CreateNarrative_CreateNarrative_Narrative_BlockedGroups) GetID() string { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative_BlockedGroups{} + } + return t.ID +} +func (t *CreateNarrative_CreateNarrative_Narrative_BlockedGroups) GetName() string { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative_BlockedGroups{} + } + return t.Name +} + type CreateNarrative_CreateNarrative_Narrative struct { - CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" - CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" - Description *string "json:\"description,omitempty\" graphql:\"description\"" - Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" - ID string "json:\"id\" graphql:\"id\"" - Name string "json:\"name\" graphql:\"name\"" - Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" - Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" - UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" - UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" + CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" + Description *string "json:\"description,omitempty\" graphql:\"description\"" + Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" + Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" + Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" + UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" + UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + Programs []*CreateNarrative_CreateNarrative_Narrative_Programs "json:\"programs,omitempty\" graphql:\"programs\"" + Editors []*CreateNarrative_CreateNarrative_Narrative_Editors "json:\"editors,omitempty\" graphql:\"editors\"" + Viewers []*CreateNarrative_CreateNarrative_Narrative_Viewers "json:\"viewers,omitempty\" graphql:\"viewers\"" + BlockedGroups []*CreateNarrative_CreateNarrative_Narrative_BlockedGroups "json:\"blockedGroups,omitempty\" graphql:\"blockedGroups\"" } func (t *CreateNarrative_CreateNarrative_Narrative) GetCreatedAt() *time.Time { @@ -27597,6 +27680,30 @@ func (t *CreateNarrative_CreateNarrative_Narrative) GetUpdatedBy() *string { } return t.UpdatedBy } +func (t *CreateNarrative_CreateNarrative_Narrative) GetPrograms() []*CreateNarrative_CreateNarrative_Narrative_Programs { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative{} + } + return t.Programs +} +func (t *CreateNarrative_CreateNarrative_Narrative) GetEditors() []*CreateNarrative_CreateNarrative_Narrative_Editors { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative{} + } + return t.Editors +} +func (t *CreateNarrative_CreateNarrative_Narrative) GetViewers() []*CreateNarrative_CreateNarrative_Narrative_Viewers { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative{} + } + return t.Viewers +} +func (t *CreateNarrative_CreateNarrative_Narrative) GetBlockedGroups() []*CreateNarrative_CreateNarrative_Narrative_BlockedGroups { + if t == nil { + t = &CreateNarrative_CreateNarrative_Narrative{} + } + return t.BlockedGroups +} type CreateNarrative_CreateNarrative struct { Narrative CreateNarrative_CreateNarrative_Narrative "json:\"narrative\" graphql:\"narrative\"" @@ -27620,17 +27727,93 @@ func (t *DeleteNarrative_DeleteNarrative) GetDeletedID() string { return t.DeletedID } +type GetAllNarratives_Narratives_Edges_Node_Programs struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetAllNarratives_Narratives_Edges_Node_Programs) GetID() string { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node_Programs{} + } + return t.ID +} +func (t *GetAllNarratives_Narratives_Edges_Node_Programs) GetName() string { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node_Programs{} + } + return t.Name +} + +type GetAllNarratives_Narratives_Edges_Node_Editors struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetAllNarratives_Narratives_Edges_Node_Editors) GetID() string { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node_Editors{} + } + return t.ID +} +func (t *GetAllNarratives_Narratives_Edges_Node_Editors) GetName() string { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node_Editors{} + } + return t.Name +} + +type GetAllNarratives_Narratives_Edges_Node_Viewers struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetAllNarratives_Narratives_Edges_Node_Viewers) GetID() string { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node_Viewers{} + } + return t.ID +} +func (t *GetAllNarratives_Narratives_Edges_Node_Viewers) GetName() string { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node_Viewers{} + } + return t.Name +} + +type GetAllNarratives_Narratives_Edges_Node_BlockedGroups struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetAllNarratives_Narratives_Edges_Node_BlockedGroups) GetID() string { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node_BlockedGroups{} + } + return t.ID +} +func (t *GetAllNarratives_Narratives_Edges_Node_BlockedGroups) GetName() string { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node_BlockedGroups{} + } + return t.Name +} + type GetAllNarratives_Narratives_Edges_Node struct { - CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" - CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" - Description *string "json:\"description,omitempty\" graphql:\"description\"" - Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" - ID string "json:\"id\" graphql:\"id\"" - Name string "json:\"name\" graphql:\"name\"" - Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" - Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" - UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" - UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" + CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" + Description *string "json:\"description,omitempty\" graphql:\"description\"" + Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" + Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" + Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" + UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" + UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + Programs []*GetAllNarratives_Narratives_Edges_Node_Programs "json:\"programs,omitempty\" graphql:\"programs\"" + Editors []*GetAllNarratives_Narratives_Edges_Node_Editors "json:\"editors,omitempty\" graphql:\"editors\"" + Viewers []*GetAllNarratives_Narratives_Edges_Node_Viewers "json:\"viewers,omitempty\" graphql:\"viewers\"" + BlockedGroups []*GetAllNarratives_Narratives_Edges_Node_BlockedGroups "json:\"blockedGroups,omitempty\" graphql:\"blockedGroups\"" } func (t *GetAllNarratives_Narratives_Edges_Node) GetCreatedAt() *time.Time { @@ -27693,6 +27876,30 @@ func (t *GetAllNarratives_Narratives_Edges_Node) GetUpdatedBy() *string { } return t.UpdatedBy } +func (t *GetAllNarratives_Narratives_Edges_Node) GetPrograms() []*GetAllNarratives_Narratives_Edges_Node_Programs { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node{} + } + return t.Programs +} +func (t *GetAllNarratives_Narratives_Edges_Node) GetEditors() []*GetAllNarratives_Narratives_Edges_Node_Editors { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node{} + } + return t.Editors +} +func (t *GetAllNarratives_Narratives_Edges_Node) GetViewers() []*GetAllNarratives_Narratives_Edges_Node_Viewers { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node{} + } + return t.Viewers +} +func (t *GetAllNarratives_Narratives_Edges_Node) GetBlockedGroups() []*GetAllNarratives_Narratives_Edges_Node_BlockedGroups { + if t == nil { + t = &GetAllNarratives_Narratives_Edges_Node{} + } + return t.BlockedGroups +} type GetAllNarratives_Narratives_Edges struct { Node *GetAllNarratives_Narratives_Edges_Node "json:\"node,omitempty\" graphql:\"node\"" @@ -27716,17 +27923,93 @@ func (t *GetAllNarratives_Narratives) GetEdges() []*GetAllNarratives_Narratives_ return t.Edges } +type GetNarrativeByID_Narrative_Programs struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetNarrativeByID_Narrative_Programs) GetID() string { + if t == nil { + t = &GetNarrativeByID_Narrative_Programs{} + } + return t.ID +} +func (t *GetNarrativeByID_Narrative_Programs) GetName() string { + if t == nil { + t = &GetNarrativeByID_Narrative_Programs{} + } + return t.Name +} + +type GetNarrativeByID_Narrative_Editors struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetNarrativeByID_Narrative_Editors) GetID() string { + if t == nil { + t = &GetNarrativeByID_Narrative_Editors{} + } + return t.ID +} +func (t *GetNarrativeByID_Narrative_Editors) GetName() string { + if t == nil { + t = &GetNarrativeByID_Narrative_Editors{} + } + return t.Name +} + +type GetNarrativeByID_Narrative_Viewers struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetNarrativeByID_Narrative_Viewers) GetID() string { + if t == nil { + t = &GetNarrativeByID_Narrative_Viewers{} + } + return t.ID +} +func (t *GetNarrativeByID_Narrative_Viewers) GetName() string { + if t == nil { + t = &GetNarrativeByID_Narrative_Viewers{} + } + return t.Name +} + +type GetNarrativeByID_Narrative_BlockedGroups struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetNarrativeByID_Narrative_BlockedGroups) GetID() string { + if t == nil { + t = &GetNarrativeByID_Narrative_BlockedGroups{} + } + return t.ID +} +func (t *GetNarrativeByID_Narrative_BlockedGroups) GetName() string { + if t == nil { + t = &GetNarrativeByID_Narrative_BlockedGroups{} + } + return t.Name +} + type GetNarrativeByID_Narrative struct { - CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" - CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" - Description *string "json:\"description,omitempty\" graphql:\"description\"" - Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" - ID string "json:\"id\" graphql:\"id\"" - Name string "json:\"name\" graphql:\"name\"" - Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" - Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" - UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" - UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" + CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" + Description *string "json:\"description,omitempty\" graphql:\"description\"" + Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" + Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" + Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" + UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" + UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + Programs []*GetNarrativeByID_Narrative_Programs "json:\"programs,omitempty\" graphql:\"programs\"" + Editors []*GetNarrativeByID_Narrative_Editors "json:\"editors,omitempty\" graphql:\"editors\"" + Viewers []*GetNarrativeByID_Narrative_Viewers "json:\"viewers,omitempty\" graphql:\"viewers\"" + BlockedGroups []*GetNarrativeByID_Narrative_BlockedGroups "json:\"blockedGroups,omitempty\" graphql:\"blockedGroups\"" } func (t *GetNarrativeByID_Narrative) GetCreatedAt() *time.Time { @@ -27789,18 +28072,118 @@ func (t *GetNarrativeByID_Narrative) GetUpdatedBy() *string { } return t.UpdatedBy } +func (t *GetNarrativeByID_Narrative) GetPrograms() []*GetNarrativeByID_Narrative_Programs { + if t == nil { + t = &GetNarrativeByID_Narrative{} + } + return t.Programs +} +func (t *GetNarrativeByID_Narrative) GetEditors() []*GetNarrativeByID_Narrative_Editors { + if t == nil { + t = &GetNarrativeByID_Narrative{} + } + return t.Editors +} +func (t *GetNarrativeByID_Narrative) GetViewers() []*GetNarrativeByID_Narrative_Viewers { + if t == nil { + t = &GetNarrativeByID_Narrative{} + } + return t.Viewers +} +func (t *GetNarrativeByID_Narrative) GetBlockedGroups() []*GetNarrativeByID_Narrative_BlockedGroups { + if t == nil { + t = &GetNarrativeByID_Narrative{} + } + return t.BlockedGroups +} + +type GetNarratives_Narratives_Edges_Node_Programs struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetNarratives_Narratives_Edges_Node_Programs) GetID() string { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node_Programs{} + } + return t.ID +} +func (t *GetNarratives_Narratives_Edges_Node_Programs) GetName() string { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node_Programs{} + } + return t.Name +} + +type GetNarratives_Narratives_Edges_Node_Editors struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetNarratives_Narratives_Edges_Node_Editors) GetID() string { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node_Editors{} + } + return t.ID +} +func (t *GetNarratives_Narratives_Edges_Node_Editors) GetName() string { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node_Editors{} + } + return t.Name +} + +type GetNarratives_Narratives_Edges_Node_Viewers struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetNarratives_Narratives_Edges_Node_Viewers) GetID() string { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node_Viewers{} + } + return t.ID +} +func (t *GetNarratives_Narratives_Edges_Node_Viewers) GetName() string { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node_Viewers{} + } + return t.Name +} + +type GetNarratives_Narratives_Edges_Node_BlockedGroups struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *GetNarratives_Narratives_Edges_Node_BlockedGroups) GetID() string { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node_BlockedGroups{} + } + return t.ID +} +func (t *GetNarratives_Narratives_Edges_Node_BlockedGroups) GetName() string { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node_BlockedGroups{} + } + return t.Name +} type GetNarratives_Narratives_Edges_Node struct { - CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" - CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" - Description *string "json:\"description,omitempty\" graphql:\"description\"" - Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" - ID string "json:\"id\" graphql:\"id\"" - Name string "json:\"name\" graphql:\"name\"" - Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" - Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" - UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" - UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" + CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" + Description *string "json:\"description,omitempty\" graphql:\"description\"" + Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" + Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" + Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" + UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" + UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + Programs []*GetNarratives_Narratives_Edges_Node_Programs "json:\"programs,omitempty\" graphql:\"programs\"" + Editors []*GetNarratives_Narratives_Edges_Node_Editors "json:\"editors,omitempty\" graphql:\"editors\"" + Viewers []*GetNarratives_Narratives_Edges_Node_Viewers "json:\"viewers,omitempty\" graphql:\"viewers\"" + BlockedGroups []*GetNarratives_Narratives_Edges_Node_BlockedGroups "json:\"blockedGroups,omitempty\" graphql:\"blockedGroups\"" } func (t *GetNarratives_Narratives_Edges_Node) GetCreatedAt() *time.Time { @@ -27863,6 +28246,30 @@ func (t *GetNarratives_Narratives_Edges_Node) GetUpdatedBy() *string { } return t.UpdatedBy } +func (t *GetNarratives_Narratives_Edges_Node) GetPrograms() []*GetNarratives_Narratives_Edges_Node_Programs { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node{} + } + return t.Programs +} +func (t *GetNarratives_Narratives_Edges_Node) GetEditors() []*GetNarratives_Narratives_Edges_Node_Editors { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node{} + } + return t.Editors +} +func (t *GetNarratives_Narratives_Edges_Node) GetViewers() []*GetNarratives_Narratives_Edges_Node_Viewers { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node{} + } + return t.Viewers +} +func (t *GetNarratives_Narratives_Edges_Node) GetBlockedGroups() []*GetNarratives_Narratives_Edges_Node_BlockedGroups { + if t == nil { + t = &GetNarratives_Narratives_Edges_Node{} + } + return t.BlockedGroups +} type GetNarratives_Narratives_Edges struct { Node *GetNarratives_Narratives_Edges_Node "json:\"node,omitempty\" graphql:\"node\"" @@ -27886,17 +28293,93 @@ func (t *GetNarratives_Narratives) GetEdges() []*GetNarratives_Narratives_Edges return t.Edges } +type UpdateNarrative_UpdateNarrative_Narrative_Programs struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *UpdateNarrative_UpdateNarrative_Narrative_Programs) GetID() string { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative_Programs{} + } + return t.ID +} +func (t *UpdateNarrative_UpdateNarrative_Narrative_Programs) GetName() string { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative_Programs{} + } + return t.Name +} + +type UpdateNarrative_UpdateNarrative_Narrative_Editors struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *UpdateNarrative_UpdateNarrative_Narrative_Editors) GetID() string { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative_Editors{} + } + return t.ID +} +func (t *UpdateNarrative_UpdateNarrative_Narrative_Editors) GetName() string { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative_Editors{} + } + return t.Name +} + +type UpdateNarrative_UpdateNarrative_Narrative_Viewers struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *UpdateNarrative_UpdateNarrative_Narrative_Viewers) GetID() string { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative_Viewers{} + } + return t.ID +} +func (t *UpdateNarrative_UpdateNarrative_Narrative_Viewers) GetName() string { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative_Viewers{} + } + return t.Name +} + +type UpdateNarrative_UpdateNarrative_Narrative_BlockedGroups struct { + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" +} + +func (t *UpdateNarrative_UpdateNarrative_Narrative_BlockedGroups) GetID() string { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative_BlockedGroups{} + } + return t.ID +} +func (t *UpdateNarrative_UpdateNarrative_Narrative_BlockedGroups) GetName() string { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative_BlockedGroups{} + } + return t.Name +} + type UpdateNarrative_UpdateNarrative_Narrative struct { - CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" - CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" - Description *string "json:\"description,omitempty\" graphql:\"description\"" - Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" - ID string "json:\"id\" graphql:\"id\"" - Name string "json:\"name\" graphql:\"name\"" - Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" - Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" - UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" - UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + CreatedAt *time.Time "json:\"createdAt,omitempty\" graphql:\"createdAt\"" + CreatedBy *string "json:\"createdBy,omitempty\" graphql:\"createdBy\"" + Description *string "json:\"description,omitempty\" graphql:\"description\"" + Details map[string]interface{} "json:\"details,omitempty\" graphql:\"details\"" + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" + Satisfies *string "json:\"satisfies,omitempty\" graphql:\"satisfies\"" + Tags []string "json:\"tags,omitempty\" graphql:\"tags\"" + UpdatedAt *time.Time "json:\"updatedAt,omitempty\" graphql:\"updatedAt\"" + UpdatedBy *string "json:\"updatedBy,omitempty\" graphql:\"updatedBy\"" + Programs []*UpdateNarrative_UpdateNarrative_Narrative_Programs "json:\"programs,omitempty\" graphql:\"programs\"" + Editors []*UpdateNarrative_UpdateNarrative_Narrative_Editors "json:\"editors,omitempty\" graphql:\"editors\"" + Viewers []*UpdateNarrative_UpdateNarrative_Narrative_Viewers "json:\"viewers,omitempty\" graphql:\"viewers\"" + BlockedGroups []*UpdateNarrative_UpdateNarrative_Narrative_BlockedGroups "json:\"blockedGroups,omitempty\" graphql:\"blockedGroups\"" } func (t *UpdateNarrative_UpdateNarrative_Narrative) GetCreatedAt() *time.Time { @@ -27959,6 +28442,30 @@ func (t *UpdateNarrative_UpdateNarrative_Narrative) GetUpdatedBy() *string { } return t.UpdatedBy } +func (t *UpdateNarrative_UpdateNarrative_Narrative) GetPrograms() []*UpdateNarrative_UpdateNarrative_Narrative_Programs { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative{} + } + return t.Programs +} +func (t *UpdateNarrative_UpdateNarrative_Narrative) GetEditors() []*UpdateNarrative_UpdateNarrative_Narrative_Editors { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative{} + } + return t.Editors +} +func (t *UpdateNarrative_UpdateNarrative_Narrative) GetViewers() []*UpdateNarrative_UpdateNarrative_Narrative_Viewers { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative{} + } + return t.Viewers +} +func (t *UpdateNarrative_UpdateNarrative_Narrative) GetBlockedGroups() []*UpdateNarrative_UpdateNarrative_Narrative_BlockedGroups { + if t == nil { + t = &UpdateNarrative_UpdateNarrative_Narrative{} + } + return t.BlockedGroups +} type UpdateNarrative_UpdateNarrative struct { Narrative UpdateNarrative_UpdateNarrative_Narrative "json:\"narrative\" graphql:\"narrative\"" @@ -55504,6 +56011,7 @@ const AdminSearchDocument = `query AdminSearch ($query: String!) { deletedBy id tags + ownerID name description satisfies @@ -63224,6 +63732,22 @@ const CreateNarrativeDocument = `mutation CreateNarrative ($input: CreateNarrati tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } } @@ -63284,6 +63808,22 @@ const GetAllNarrativesDocument = `query GetAllNarratives { tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } } @@ -63317,6 +63857,22 @@ const GetNarrativeByIDDocument = `query GetNarrativeByID ($narrativeId: ID!) { tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } ` @@ -63352,6 +63908,22 @@ const GetNarrativesDocument = `query GetNarratives ($where: NarrativeWhereInput) tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } } @@ -63388,6 +63960,22 @@ const UpdateNarrativeDocument = `mutation UpdateNarrative ($updateNarrativeId: I tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } } diff --git a/pkg/openlaneclient/models.go b/pkg/openlaneclient/models.go index 50d9c485..afcf30e5 100644 --- a/pkg/openlaneclient/models.go +++ b/pkg/openlaneclient/models.go @@ -3359,6 +3359,9 @@ type CreateGroupInput struct { ControlobjectiveViewerIDs []string `json:"controlobjectiveViewerIDs,omitempty"` ControlobjectiveEditorIDs []string `json:"controlobjectiveEditorIDs,omitempty"` ControlobjectiveBlockedGroupIDs []string `json:"controlobjectiveBlockedGroupIDs,omitempty"` + NarrativeViewerIDs []string `json:"narrativeViewerIDs,omitempty"` + NarrativeEditorIDs []string `json:"narrativeEditorIDs,omitempty"` + NarrativeBlockedGroupIDs []string `json:"narrativeBlockedGroupIDs,omitempty"` CreateGroupSettings *CreateGroupSettingInput `json:"createGroupSettings,omitempty"` } @@ -3485,6 +3488,10 @@ type CreateNarrativeInput struct { Satisfies *string `json:"satisfies,omitempty"` // json data for the narrative document Details map[string]interface{} `json:"details,omitempty"` + OwnerID string `json:"ownerID"` + BlockedGroupIDs []string `json:"blockedGroupIDs,omitempty"` + EditorIDs []string `json:"editorIDs,omitempty"` + ViewerIDs []string `json:"viewerIDs,omitempty"` PolicyIDs []string `json:"policyIDs,omitempty"` ControlIDs []string `json:"controlIDs,omitempty"` ProcedureIDs []string `json:"procedureIDs,omitempty"` @@ -3608,6 +3615,7 @@ type CreateOrganizationInput struct { InternalpolicyIDs []string `json:"internalpolicyIDs,omitempty"` RiskIDs []string `json:"riskIDs,omitempty"` ControlobjectiveIDs []string `json:"controlobjectiveIDs,omitempty"` + NarrativeIDs []string `json:"narrativeIDs,omitempty"` CreateOrgSettings *CreateOrganizationSettingInput `json:"createOrgSettings,omitempty"` } @@ -8872,6 +8880,9 @@ type Group struct { ControlobjectiveViewers []*ControlObjective `json:"controlobjectiveViewers,omitempty"` ControlobjectiveEditors []*ControlObjective `json:"controlobjectiveEditors,omitempty"` ControlobjectiveBlockedGroups []*ControlObjective `json:"controlobjectiveBlockedGroups,omitempty"` + NarrativeViewers []*Narrative `json:"narrativeViewers,omitempty"` + NarrativeEditors []*Narrative `json:"narrativeEditors,omitempty"` + NarrativeBlockedGroups []*Narrative `json:"narrativeBlockedGroups,omitempty"` Members []*GroupMembership `json:"members,omitempty"` } @@ -10153,6 +10164,15 @@ type GroupWhereInput struct { // controlobjective_blocked_groups edge predicates HasControlobjectiveBlockedGroups *bool `json:"hasControlobjectiveBlockedGroups,omitempty"` HasControlobjectiveBlockedGroupsWith []*ControlObjectiveWhereInput `json:"hasControlobjectiveBlockedGroupsWith,omitempty"` + // narrative_viewers edge predicates + HasNarrativeViewers *bool `json:"hasNarrativeViewers,omitempty"` + HasNarrativeViewersWith []*NarrativeWhereInput `json:"hasNarrativeViewersWith,omitempty"` + // narrative_editors edge predicates + HasNarrativeEditors *bool `json:"hasNarrativeEditors,omitempty"` + HasNarrativeEditorsWith []*NarrativeWhereInput `json:"hasNarrativeEditorsWith,omitempty"` + // narrative_blocked_groups edge predicates + HasNarrativeBlockedGroups *bool `json:"hasNarrativeBlockedGroups,omitempty"` + HasNarrativeBlockedGroupsWith []*NarrativeWhereInput `json:"hasNarrativeBlockedGroupsWith,omitempty"` // members edge predicates HasMembers *bool `json:"hasMembers,omitempty"` HasMembersWith []*GroupMembershipWhereInput `json:"hasMembersWith,omitempty"` @@ -12000,6 +12020,8 @@ type Narrative struct { DeletedBy *string `json:"deletedBy,omitempty"` // tags associated with the object Tags []string `json:"tags,omitempty"` + // the ID of the organization owner of the object + OwnerID string `json:"ownerID"` // the name of the narrative Name string `json:"name"` // the description of the narrative @@ -12007,12 +12029,19 @@ type Narrative struct { // which controls are satisfied by the narrative Satisfies *string `json:"satisfies,omitempty"` // json data for the narrative document - Details map[string]interface{} `json:"details,omitempty"` - Policy []*InternalPolicy `json:"policy,omitempty"` - Control []*Control `json:"control,omitempty"` - Procedure []*Procedure `json:"procedure,omitempty"` - Controlobjective []*ControlObjective `json:"controlobjective,omitempty"` - Program []*Program `json:"program,omitempty"` + Details map[string]interface{} `json:"details,omitempty"` + Owner *Organization `json:"owner"` + // groups that are blocked from viewing or editing the risk + BlockedGroups []*Group `json:"blockedGroups,omitempty"` + // provides edit access to the risk to members of the group + Editors []*Group `json:"editors,omitempty"` + // provides view access to the risk to members of the group + Viewers []*Group `json:"viewers,omitempty"` + Policy []*InternalPolicy `json:"policy,omitempty"` + Control []*Control `json:"control,omitempty"` + Procedure []*Procedure `json:"procedure,omitempty"` + Controlobjective []*ControlObjective `json:"controlobjective,omitempty"` + Programs []*Program `json:"programs,omitempty"` } func (Narrative) IsNode() {} @@ -12066,6 +12095,8 @@ type NarrativeHistory struct { DeletedBy *string `json:"deletedBy,omitempty"` // tags associated with the object Tags []string `json:"tags,omitempty"` + // the ID of the organization owner of the object + OwnerID string `json:"ownerID"` // the name of the narrative Name string `json:"name"` // the description of the narrative @@ -12224,6 +12255,20 @@ type NarrativeHistoryWhereInput struct { DeletedByNotNil *bool `json:"deletedByNotNil,omitempty"` DeletedByEqualFold *string `json:"deletedByEqualFold,omitempty"` DeletedByContainsFold *string `json:"deletedByContainsFold,omitempty"` + // owner_id field predicates + OwnerID *string `json:"ownerID,omitempty"` + OwnerIdneq *string `json:"ownerIDNEQ,omitempty"` + OwnerIDIn []string `json:"ownerIDIn,omitempty"` + OwnerIDNotIn []string `json:"ownerIDNotIn,omitempty"` + OwnerIdgt *string `json:"ownerIDGT,omitempty"` + OwnerIdgte *string `json:"ownerIDGTE,omitempty"` + OwnerIdlt *string `json:"ownerIDLT,omitempty"` + OwnerIdlte *string `json:"ownerIDLTE,omitempty"` + OwnerIDContains *string `json:"ownerIDContains,omitempty"` + OwnerIDHasPrefix *string `json:"ownerIDHasPrefix,omitempty"` + OwnerIDHasSuffix *string `json:"ownerIDHasSuffix,omitempty"` + OwnerIDEqualFold *string `json:"ownerIDEqualFold,omitempty"` + OwnerIDContainsFold *string `json:"ownerIDContainsFold,omitempty"` // name field predicates Name *string `json:"name,omitempty"` NameNeq *string `json:"nameNEQ,omitempty"` @@ -12382,6 +12427,20 @@ type NarrativeWhereInput struct { DeletedByNotNil *bool `json:"deletedByNotNil,omitempty"` DeletedByEqualFold *string `json:"deletedByEqualFold,omitempty"` DeletedByContainsFold *string `json:"deletedByContainsFold,omitempty"` + // owner_id field predicates + OwnerID *string `json:"ownerID,omitempty"` + OwnerIdneq *string `json:"ownerIDNEQ,omitempty"` + OwnerIDIn []string `json:"ownerIDIn,omitempty"` + OwnerIDNotIn []string `json:"ownerIDNotIn,omitempty"` + OwnerIdgt *string `json:"ownerIDGT,omitempty"` + OwnerIdgte *string `json:"ownerIDGTE,omitempty"` + OwnerIdlt *string `json:"ownerIDLT,omitempty"` + OwnerIdlte *string `json:"ownerIDLTE,omitempty"` + OwnerIDContains *string `json:"ownerIDContains,omitempty"` + OwnerIDHasPrefix *string `json:"ownerIDHasPrefix,omitempty"` + OwnerIDHasSuffix *string `json:"ownerIDHasSuffix,omitempty"` + OwnerIDEqualFold *string `json:"ownerIDEqualFold,omitempty"` + OwnerIDContainsFold *string `json:"ownerIDContainsFold,omitempty"` // name field predicates Name *string `json:"name,omitempty"` NameNeq *string `json:"nameNEQ,omitempty"` @@ -12428,6 +12487,18 @@ type NarrativeWhereInput struct { SatisfiesNotNil *bool `json:"satisfiesNotNil,omitempty"` SatisfiesEqualFold *string `json:"satisfiesEqualFold,omitempty"` SatisfiesContainsFold *string `json:"satisfiesContainsFold,omitempty"` + // owner edge predicates + HasOwner *bool `json:"hasOwner,omitempty"` + HasOwnerWith []*OrganizationWhereInput `json:"hasOwnerWith,omitempty"` + // blocked_groups edge predicates + HasBlockedGroups *bool `json:"hasBlockedGroups,omitempty"` + HasBlockedGroupsWith []*GroupWhereInput `json:"hasBlockedGroupsWith,omitempty"` + // editors edge predicates + HasEditors *bool `json:"hasEditors,omitempty"` + HasEditorsWith []*GroupWhereInput `json:"hasEditorsWith,omitempty"` + // viewers edge predicates + HasViewers *bool `json:"hasViewers,omitempty"` + HasViewersWith []*GroupWhereInput `json:"hasViewersWith,omitempty"` // policy edge predicates HasPolicy *bool `json:"hasPolicy,omitempty"` HasPolicyWith []*InternalPolicyWhereInput `json:"hasPolicyWith,omitempty"` @@ -12440,9 +12511,9 @@ type NarrativeWhereInput struct { // controlobjective edge predicates HasControlobjective *bool `json:"hasControlobjective,omitempty"` HasControlobjectiveWith []*ControlObjectiveWhereInput `json:"hasControlobjectiveWith,omitempty"` - // program edge predicates - HasProgram *bool `json:"hasProgram,omitempty"` - HasProgramWith []*ProgramWhereInput `json:"hasProgramWith,omitempty"` + // programs edge predicates + HasPrograms *bool `json:"hasPrograms,omitempty"` + HasProgramsWith []*ProgramWhereInput `json:"hasProgramsWith,omitempty"` } type Note struct { @@ -14096,6 +14167,7 @@ type Organization struct { Internalpolicies []*InternalPolicy `json:"internalpolicies,omitempty"` Risks []*Risk `json:"risks,omitempty"` Controlobjectives []*ControlObjective `json:"controlobjectives,omitempty"` + Narratives []*Narrative `json:"narratives,omitempty"` Members []*OrgMembership `json:"members,omitempty"` } @@ -15247,6 +15319,9 @@ type OrganizationWhereInput struct { // controlobjectives edge predicates HasControlobjectives *bool `json:"hasControlobjectives,omitempty"` HasControlobjectivesWith []*ControlObjectiveWhereInput `json:"hasControlobjectivesWith,omitempty"` + // narratives edge predicates + HasNarratives *bool `json:"hasNarratives,omitempty"` + HasNarrativesWith []*NarrativeWhereInput `json:"hasNarrativesWith,omitempty"` // members edge predicates HasMembers *bool `json:"hasMembers,omitempty"` HasMembersWith []*OrgMembershipWhereInput `json:"hasMembersWith,omitempty"` @@ -21440,6 +21515,15 @@ type UpdateGroupInput struct { AddControlobjectiveBlockedGroupIDs []string `json:"addControlobjectiveBlockedGroupIDs,omitempty"` RemoveControlobjectiveBlockedGroupIDs []string `json:"removeControlobjectiveBlockedGroupIDs,omitempty"` ClearControlobjectiveBlockedGroups *bool `json:"clearControlobjectiveBlockedGroups,omitempty"` + AddNarrativeViewerIDs []string `json:"addNarrativeViewerIDs,omitempty"` + RemoveNarrativeViewerIDs []string `json:"removeNarrativeViewerIDs,omitempty"` + ClearNarrativeViewers *bool `json:"clearNarrativeViewers,omitempty"` + AddNarrativeEditorIDs []string `json:"addNarrativeEditorIDs,omitempty"` + RemoveNarrativeEditorIDs []string `json:"removeNarrativeEditorIDs,omitempty"` + ClearNarrativeEditors *bool `json:"clearNarrativeEditors,omitempty"` + AddNarrativeBlockedGroupIDs []string `json:"addNarrativeBlockedGroupIDs,omitempty"` + RemoveNarrativeBlockedGroupIDs []string `json:"removeNarrativeBlockedGroupIDs,omitempty"` + ClearNarrativeBlockedGroups *bool `json:"clearNarrativeBlockedGroups,omitempty"` AddGroupMembers []*CreateGroupMembershipInput `json:"addGroupMembers,omitempty"` UpdateGroupSettings *UpdateGroupSettingInput `json:"updateGroupSettings,omitempty"` } @@ -21620,6 +21704,16 @@ type UpdateNarrativeInput struct { // json data for the narrative document Details map[string]interface{} `json:"details,omitempty"` ClearDetails *bool `json:"clearDetails,omitempty"` + OwnerID *string `json:"ownerID,omitempty"` + AddBlockedGroupIDs []string `json:"addBlockedGroupIDs,omitempty"` + RemoveBlockedGroupIDs []string `json:"removeBlockedGroupIDs,omitempty"` + ClearBlockedGroups *bool `json:"clearBlockedGroups,omitempty"` + AddEditorIDs []string `json:"addEditorIDs,omitempty"` + RemoveEditorIDs []string `json:"removeEditorIDs,omitempty"` + ClearEditors *bool `json:"clearEditors,omitempty"` + AddViewerIDs []string `json:"addViewerIDs,omitempty"` + RemoveViewerIDs []string `json:"removeViewerIDs,omitempty"` + ClearViewers *bool `json:"clearViewers,omitempty"` AddPolicyIDs []string `json:"addPolicyIDs,omitempty"` RemovePolicyIDs []string `json:"removePolicyIDs,omitempty"` ClearPolicy *bool `json:"clearPolicy,omitempty"` @@ -21634,7 +21728,7 @@ type UpdateNarrativeInput struct { ClearControlobjective *bool `json:"clearControlobjective,omitempty"` AddProgramIDs []string `json:"addProgramIDs,omitempty"` RemoveProgramIDs []string `json:"removeProgramIDs,omitempty"` - ClearProgram *bool `json:"clearProgram,omitempty"` + ClearPrograms *bool `json:"clearPrograms,omitempty"` } // UpdateNoteInput is used for update Note object. @@ -21832,6 +21926,9 @@ type UpdateOrganizationInput struct { AddControlobjectiveIDs []string `json:"addControlobjectiveIDs,omitempty"` RemoveControlobjectiveIDs []string `json:"removeControlobjectiveIDs,omitempty"` ClearControlobjectives *bool `json:"clearControlobjectives,omitempty"` + AddNarrativeIDs []string `json:"addNarrativeIDs,omitempty"` + RemoveNarrativeIDs []string `json:"removeNarrativeIDs,omitempty"` + ClearNarratives *bool `json:"clearNarratives,omitempty"` AddOrgMembers []*CreateOrgMembershipInput `json:"addOrgMembers,omitempty"` UpdateOrgSettings *UpdateOrganizationSettingInput `json:"updateOrgSettings,omitempty"` } diff --git a/query/adminsearch.graphql b/query/adminsearch.graphql index c6c555f4..42c51d6f 100644 --- a/query/adminsearch.graphql +++ b/query/adminsearch.graphql @@ -239,6 +239,7 @@ query AdminSearch($query: String!) { deletedBy id tags + ownerID name description satisfies diff --git a/query/narrative.graphql b/query/narrative.graphql index 436492b4..2d1b27e0 100644 --- a/query/narrative.graphql +++ b/query/narrative.graphql @@ -46,6 +46,22 @@ mutation CreateNarrative($input: CreateNarrativeInput!) { tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } } @@ -70,6 +86,22 @@ query GetAllNarratives { tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } } @@ -86,6 +118,22 @@ query GetNarrativeByID($narrativeId: ID!) { tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } @@ -103,6 +151,22 @@ query GetNarratives($where: NarrativeWhereInput) { tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } } @@ -120,6 +184,22 @@ mutation UpdateNarrative($updateNarrativeId: ID!, $input: UpdateNarrativeInput!) tags updatedAt updatedBy + programs { + id + name + } + editors { + id + name + } + viewers { + id + name + } + blockedGroups { + id + name + } } } } diff --git a/schema.graphql b/schema.graphql index 3d0b8126..ef36f4ce 100644 --- a/schema.graphql +++ b/schema.graphql @@ -4309,6 +4309,9 @@ input CreateGroupInput { controlobjectiveViewerIDs: [ID!] controlobjectiveEditorIDs: [ID!] controlobjectiveBlockedGroupIDs: [ID!] + narrativeViewerIDs: [ID!] + narrativeEditorIDs: [ID!] + narrativeBlockedGroupIDs: [ID!] createGroupSettings: CreateGroupSettingInput } """ @@ -4506,6 +4509,10 @@ input CreateNarrativeInput { json data for the narrative document """ details: Map + ownerID: ID! + blockedGroupIDs: [ID!] + editorIDs: [ID!] + viewerIDs: [ID!] policyIDs: [ID!] controlIDs: [ID!] procedureIDs: [ID!] @@ -4674,6 +4681,7 @@ input CreateOrganizationInput { internalpolicyIDs: [ID!] riskIDs: [ID!] controlobjectiveIDs: [ID!] + narrativeIDs: [ID!] createOrgSettings: CreateOrganizationSettingInput } """ @@ -11437,6 +11445,9 @@ type Group implements Node { controlobjectiveViewers: [ControlObjective!] controlobjectiveEditors: [ControlObjective!] controlobjectiveBlockedGroups: [ControlObjective!] + narrativeViewers: [Narrative!] + narrativeEditors: [Narrative!] + narrativeBlockedGroups: [Narrative!] members: [GroupMembership!] } """ @@ -13126,6 +13137,21 @@ input GroupWhereInput { hasControlobjectiveBlockedGroups: Boolean hasControlobjectiveBlockedGroupsWith: [ControlObjectiveWhereInput!] """ + narrative_viewers edge predicates + """ + hasNarrativeViewers: Boolean + hasNarrativeViewersWith: [NarrativeWhereInput!] + """ + narrative_editors edge predicates + """ + hasNarrativeEditors: Boolean + hasNarrativeEditorsWith: [NarrativeWhereInput!] + """ + narrative_blocked_groups edge predicates + """ + hasNarrativeBlockedGroups: Boolean + hasNarrativeBlockedGroupsWith: [NarrativeWhereInput!] + """ members edge predicates """ hasMembers: Boolean @@ -17456,6 +17482,10 @@ type Narrative implements Node { """ tags: [String!] """ + the ID of the organization owner of the object + """ + ownerID: ID! + """ the name of the narrative """ name: String! @@ -17471,11 +17501,24 @@ type Narrative implements Node { json data for the narrative document """ details: Map + owner: Organization! + """ + groups that are blocked from viewing or editing the risk + """ + blockedGroups: [Group!] + """ + provides edit access to the risk to members of the group + """ + editors: [Group!] + """ + provides view access to the risk to members of the group + """ + viewers: [Group!] policy: [InternalPolicy!] control: [Control!] procedure: [Procedure!] controlobjective: [ControlObjective!] - program: [Program!] + programs: [Program!] } """ Return response for createBulkNarrative mutation @@ -17550,6 +17593,10 @@ type NarrativeHistory implements Node { """ tags: [String!] """ + the ID of the organization owner of the object + """ + ownerID: String! + """ the name of the narrative """ name: String! @@ -17755,6 +17802,22 @@ input NarrativeHistoryWhereInput { deletedByEqualFold: String deletedByContainsFold: String """ + owner_id field predicates + """ + ownerID: String + ownerIDNEQ: String + ownerIDIn: [String!] + ownerIDNotIn: [String!] + ownerIDGT: String + ownerIDGTE: String + ownerIDLT: String + ownerIDLTE: String + ownerIDContains: String + ownerIDHasPrefix: String + ownerIDHasSuffix: String + ownerIDEqualFold: String + ownerIDContainsFold: String + """ name field predicates """ name: String @@ -17934,6 +17997,22 @@ input NarrativeWhereInput { deletedByEqualFold: String deletedByContainsFold: String """ + owner_id field predicates + """ + ownerID: ID + ownerIDNEQ: ID + ownerIDIn: [ID!] + ownerIDNotIn: [ID!] + ownerIDGT: ID + ownerIDGTE: ID + ownerIDLT: ID + ownerIDLTE: ID + ownerIDContains: ID + ownerIDHasPrefix: ID + ownerIDHasSuffix: ID + ownerIDEqualFold: ID + ownerIDContainsFold: ID + """ name field predicates """ name: String @@ -17986,6 +18065,26 @@ input NarrativeWhereInput { satisfiesEqualFold: String satisfiesContainsFold: String """ + owner edge predicates + """ + hasOwner: Boolean + hasOwnerWith: [OrganizationWhereInput!] + """ + blocked_groups edge predicates + """ + hasBlockedGroups: Boolean + hasBlockedGroupsWith: [GroupWhereInput!] + """ + editors edge predicates + """ + hasEditors: Boolean + hasEditorsWith: [GroupWhereInput!] + """ + viewers edge predicates + """ + hasViewers: Boolean + hasViewersWith: [GroupWhereInput!] + """ policy edge predicates """ hasPolicy: Boolean @@ -18006,10 +18105,10 @@ input NarrativeWhereInput { hasControlobjective: Boolean hasControlobjectiveWith: [ControlObjectiveWhereInput!] """ - program edge predicates + programs edge predicates """ - hasProgram: Boolean - hasProgramWith: [ProgramWhereInput!] + hasPrograms: Boolean + hasProgramsWith: [ProgramWhereInput!] } """ An object with an ID. @@ -20119,6 +20218,7 @@ type Organization implements Node { internalpolicies: [InternalPolicy!] risks: [Risk!] controlobjectives: [ControlObjective!] + narratives: [Narrative!] members: [OrgMembership!] } """ @@ -21624,6 +21724,11 @@ input OrganizationWhereInput { hasControlobjectives: Boolean hasControlobjectivesWith: [ControlObjectiveWhereInput!] """ + narratives edge predicates + """ + hasNarratives: Boolean + hasNarrativesWith: [NarrativeWhereInput!] + """ members edge predicates """ hasMembers: Boolean @@ -32784,6 +32889,15 @@ input UpdateGroupInput { addControlobjectiveBlockedGroupIDs: [ID!] removeControlobjectiveBlockedGroupIDs: [ID!] clearControlobjectiveBlockedGroups: Boolean + addNarrativeViewerIDs: [ID!] + removeNarrativeViewerIDs: [ID!] + clearNarrativeViewers: Boolean + addNarrativeEditorIDs: [ID!] + removeNarrativeEditorIDs: [ID!] + clearNarrativeEditors: Boolean + addNarrativeBlockedGroupIDs: [ID!] + removeNarrativeBlockedGroupIDs: [ID!] + clearNarrativeBlockedGroups: Boolean addGroupMembers: [CreateGroupMembershipInput!] updateGroupSettings: UpdateGroupSettingInput } @@ -33027,6 +33141,16 @@ input UpdateNarrativeInput { """ details: Map clearDetails: Boolean + ownerID: ID + addBlockedGroupIDs: [ID!] + removeBlockedGroupIDs: [ID!] + clearBlockedGroups: Boolean + addEditorIDs: [ID!] + removeEditorIDs: [ID!] + clearEditors: Boolean + addViewerIDs: [ID!] + removeViewerIDs: [ID!] + clearViewers: Boolean addPolicyIDs: [ID!] removePolicyIDs: [ID!] clearPolicy: Boolean @@ -33041,7 +33165,7 @@ input UpdateNarrativeInput { clearControlobjective: Boolean addProgramIDs: [ID!] removeProgramIDs: [ID!] - clearProgram: Boolean + clearPrograms: Boolean } """ UpdateNoteInput is used for update Note object. @@ -33280,6 +33404,9 @@ input UpdateOrganizationInput { addControlobjectiveIDs: [ID!] removeControlobjectiveIDs: [ID!] clearControlobjectives: Boolean + addNarrativeIDs: [ID!] + removeNarrativeIDs: [ID!] + clearNarratives: Boolean addOrgMembers: [CreateOrgMembershipInput!] updateOrgSettings: UpdateOrganizationSettingInput } diff --git a/schema/ent.graphql b/schema/ent.graphql index 87509276..ce857d18 100644 --- a/schema/ent.graphql +++ b/schema/ent.graphql @@ -4067,6 +4067,9 @@ input CreateGroupInput { controlobjectiveViewerIDs: [ID!] controlobjectiveEditorIDs: [ID!] controlobjectiveBlockedGroupIDs: [ID!] + narrativeViewerIDs: [ID!] + narrativeEditorIDs: [ID!] + narrativeBlockedGroupIDs: [ID!] } """ CreateGroupMembershipInput is used for create GroupMembership object. @@ -4263,6 +4266,10 @@ input CreateNarrativeInput { json data for the narrative document """ details: Map + ownerID: ID! + blockedGroupIDs: [ID!] + editorIDs: [ID!] + viewerIDs: [ID!] policyIDs: [ID!] controlIDs: [ID!] procedureIDs: [ID!] @@ -4431,6 +4438,7 @@ input CreateOrganizationInput { internalpolicyIDs: [ID!] riskIDs: [ID!] controlobjectiveIDs: [ID!] + narrativeIDs: [ID!] } """ CreateOrganizationSettingInput is used for create OrganizationSetting object. @@ -10869,6 +10877,9 @@ type Group implements Node { controlobjectiveViewers: [ControlObjective!] controlobjectiveEditors: [ControlObjective!] controlobjectiveBlockedGroups: [ControlObjective!] + narrativeViewers: [Narrative!] + narrativeEditors: [Narrative!] + narrativeBlockedGroups: [Narrative!] members: [GroupMembership!] } """ @@ -12442,6 +12453,21 @@ input GroupWhereInput { hasControlobjectiveBlockedGroups: Boolean hasControlobjectiveBlockedGroupsWith: [ControlObjectiveWhereInput!] """ + narrative_viewers edge predicates + """ + hasNarrativeViewers: Boolean + hasNarrativeViewersWith: [NarrativeWhereInput!] + """ + narrative_editors edge predicates + """ + hasNarrativeEditors: Boolean + hasNarrativeEditorsWith: [NarrativeWhereInput!] + """ + narrative_blocked_groups edge predicates + """ + hasNarrativeBlockedGroups: Boolean + hasNarrativeBlockedGroupsWith: [NarrativeWhereInput!] + """ members edge predicates """ hasMembers: Boolean @@ -14665,6 +14691,10 @@ type Narrative implements Node { """ tags: [String!] """ + the ID of the organization owner of the object + """ + ownerID: ID! + """ the name of the narrative """ name: String! @@ -14680,11 +14710,24 @@ type Narrative implements Node { json data for the narrative document """ details: Map + owner: Organization! + """ + groups that are blocked from viewing or editing the risk + """ + blockedGroups: [Group!] + """ + provides edit access to the risk to members of the group + """ + editors: [Group!] + """ + provides view access to the risk to members of the group + """ + viewers: [Group!] policy: [InternalPolicy!] control: [Control!] procedure: [Procedure!] controlobjective: [ControlObjective!] - program: [Program!] + programs: [Program!] } """ A connection to a list of items. @@ -14732,6 +14775,10 @@ type NarrativeHistory implements Node { """ tags: [String!] """ + the ID of the organization owner of the object + """ + ownerID: String! + """ the name of the narrative """ name: String! @@ -14937,6 +14984,22 @@ input NarrativeHistoryWhereInput { deletedByEqualFold: String deletedByContainsFold: String """ + owner_id field predicates + """ + ownerID: String + ownerIDNEQ: String + ownerIDIn: [String!] + ownerIDNotIn: [String!] + ownerIDGT: String + ownerIDGTE: String + ownerIDLT: String + ownerIDLTE: String + ownerIDContains: String + ownerIDHasPrefix: String + ownerIDHasSuffix: String + ownerIDEqualFold: String + ownerIDContainsFold: String + """ name field predicates """ name: String @@ -15104,6 +15167,22 @@ input NarrativeWhereInput { deletedByEqualFold: String deletedByContainsFold: String """ + owner_id field predicates + """ + ownerID: ID + ownerIDNEQ: ID + ownerIDIn: [ID!] + ownerIDNotIn: [ID!] + ownerIDGT: ID + ownerIDGTE: ID + ownerIDLT: ID + ownerIDLTE: ID + ownerIDContains: ID + ownerIDHasPrefix: ID + ownerIDHasSuffix: ID + ownerIDEqualFold: ID + ownerIDContainsFold: ID + """ name field predicates """ name: String @@ -15156,6 +15235,26 @@ input NarrativeWhereInput { satisfiesEqualFold: String satisfiesContainsFold: String """ + owner edge predicates + """ + hasOwner: Boolean + hasOwnerWith: [OrganizationWhereInput!] + """ + blocked_groups edge predicates + """ + hasBlockedGroups: Boolean + hasBlockedGroupsWith: [GroupWhereInput!] + """ + editors edge predicates + """ + hasEditors: Boolean + hasEditorsWith: [GroupWhereInput!] + """ + viewers edge predicates + """ + hasViewers: Boolean + hasViewersWith: [GroupWhereInput!] + """ policy edge predicates """ hasPolicy: Boolean @@ -15176,10 +15275,10 @@ input NarrativeWhereInput { hasControlobjective: Boolean hasControlobjectiveWith: [ControlObjectiveWhereInput!] """ - program edge predicates + programs edge predicates """ - hasProgram: Boolean - hasProgramWith: [ProgramWhereInput!] + hasPrograms: Boolean + hasProgramsWith: [ProgramWhereInput!] } """ An object with an ID. @@ -17173,6 +17272,7 @@ type Organization implements Node { internalpolicies: [InternalPolicy!] risks: [Risk!] controlobjectives: [ControlObjective!] + narratives: [Narrative!] members: [OrgMembership!] } """ @@ -18600,6 +18700,11 @@ input OrganizationWhereInput { hasControlobjectives: Boolean hasControlobjectivesWith: [ControlObjectiveWhereInput!] """ + narratives edge predicates + """ + hasNarratives: Boolean + hasNarrativesWith: [NarrativeWhereInput!] + """ members edge predicates """ hasMembers: Boolean @@ -28283,6 +28388,15 @@ input UpdateGroupInput { addControlobjectiveBlockedGroupIDs: [ID!] removeControlobjectiveBlockedGroupIDs: [ID!] clearControlobjectiveBlockedGroups: Boolean + addNarrativeViewerIDs: [ID!] + removeNarrativeViewerIDs: [ID!] + clearNarrativeViewers: Boolean + addNarrativeEditorIDs: [ID!] + removeNarrativeEditorIDs: [ID!] + clearNarrativeEditors: Boolean + addNarrativeBlockedGroupIDs: [ID!] + removeNarrativeBlockedGroupIDs: [ID!] + clearNarrativeBlockedGroups: Boolean } """ UpdateGroupMembershipInput is used for update GroupMembership object. @@ -28524,6 +28638,16 @@ input UpdateNarrativeInput { """ details: Map clearDetails: Boolean + ownerID: ID + addBlockedGroupIDs: [ID!] + removeBlockedGroupIDs: [ID!] + clearBlockedGroups: Boolean + addEditorIDs: [ID!] + removeEditorIDs: [ID!] + clearEditors: Boolean + addViewerIDs: [ID!] + removeViewerIDs: [ID!] + clearViewers: Boolean addPolicyIDs: [ID!] removePolicyIDs: [ID!] clearPolicy: Boolean @@ -28538,7 +28662,7 @@ input UpdateNarrativeInput { clearControlobjective: Boolean addProgramIDs: [ID!] removeProgramIDs: [ID!] - clearProgram: Boolean + clearPrograms: Boolean } """ UpdateNoteInput is used for update Note object. @@ -28777,6 +28901,9 @@ input UpdateOrganizationInput { addControlobjectiveIDs: [ID!] removeControlobjectiveIDs: [ID!] clearControlobjectives: Boolean + addNarrativeIDs: [ID!] + removeNarrativeIDs: [ID!] + clearNarratives: Boolean } """ UpdateOrganizationSettingInput is used for update OrganizationSetting object. diff --git a/sonar-project.properties b/sonar-project.properties index be9f7059..fde4c111 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -6,7 +6,7 @@ sonar.projectVersion=1.0 sonar.sources=. -sonar.exclusions=**/*_test.go,**/vendor/**,internal/ent/generated/**,query/**,schema/**,scripts/**,gen_schema.go,generate.go,tools.go,docker/**,db/**,db/backup/**,internal/graphapi/gen_server.go,internal/ent/entc.go,pkg/testutils/**,pkg/events/soiree/examples/**,pkg/middleware/ratelimiter/examples/**,pkg/objects/mocks/** +sonar.exclusions=**/*_test.go,**/vendor/**,internal/ent/generated/**,query/**,schema/**,scripts/**,gen_schema.go,generate.go,tools.go,docker/**,db/**,db/backup/**,internal/graphapi/gen_server.go,internal/ent/entc.go,pkg/testutils/**,pkg/events/soiree/examples/**,pkg/middleware/ratelimiter/examples/**,pkg/objects/mocks/**,cmd/** sonar.tests=. sonar.test.inclusions=**/*_test.go sonar.test.exclusions=**/vendor/**