From c2bf3a42ed7b4f3cc7611b40dc4b8890a462a02a Mon Sep 17 00:00:00 2001 From: gearnode Date: Tue, 11 Mar 2025 09:03:13 +0100 Subject: [PATCH] Simplify database schema Signed-off-by: gearnode --- pkg/probo/coredata/control.go | 55 +- .../coredata/control_state_transition.go | 128 - pkg/probo/coredata/evidence.go | 17 +- .../coredata/evidence_state_transition.go | 150 - .../coredata/migrations/20250310T161900Z.sql | 17 + .../coredata/migrations/20250310T164900Z.sql | 3 + .../coredata/migrations/20250310T181100Z.sql | 1 + pkg/probo/coredata/state_transition.go | 31 - pkg/probo/coredata/task.go | 193 +- pkg/probo/coredata/task_state_transition.go | 126 - pkg/probo/create_control.go | 21 - pkg/probo/create_evidence.go | 21 - pkg/probo/create_task.go | 23 +- pkg/probo/delete_evidence.go | 5 - pkg/probo/list_control_state_transitions.go | 51 - pkg/probo/list_task_state_transitions.go | 51 - ...ce_state_transitions.go => update_task.go} | 43 +- pkg/probo/update_task_state.go | 88 - pkg/server/api/console/v1/schema.graphql | 102 +- pkg/server/api/console/v1/schema/schema.go | 3183 ++--------------- .../v1/types/control_state_transition.go | 58 - .../v1/types/evidence_state_transition.go | 58 - pkg/server/api/console/v1/types/task.go | 1 + .../console/v1/types/task_state_transition.go | 58 - pkg/server/api/console/v1/types/types.go | 121 +- pkg/server/api/console/v1/v1_resolver.go | 77 +- 26 files changed, 538 insertions(+), 4144 deletions(-) delete mode 100644 pkg/probo/coredata/control_state_transition.go delete mode 100644 pkg/probo/coredata/evidence_state_transition.go create mode 100644 pkg/probo/coredata/migrations/20250310T161900Z.sql create mode 100644 pkg/probo/coredata/migrations/20250310T164900Z.sql create mode 100644 pkg/probo/coredata/migrations/20250310T181100Z.sql delete mode 100644 pkg/probo/coredata/state_transition.go delete mode 100644 pkg/probo/coredata/task_state_transition.go delete mode 100644 pkg/probo/list_control_state_transitions.go delete mode 100644 pkg/probo/list_task_state_transitions.go rename pkg/probo/{list_evidence_state_transitions.go => update_task.go} (65%) delete mode 100644 pkg/probo/update_task_state.go delete mode 100644 pkg/server/api/console/v1/types/control_state_transition.go delete mode 100644 pkg/server/api/console/v1/types/evidence_state_transition.go delete mode 100644 pkg/server/api/console/v1/types/task_state_transition.go diff --git a/pkg/probo/coredata/control.go b/pkg/probo/coredata/control.go index d7ab2e846..bc30eb799 100644 --- a/pkg/probo/coredata/control.go +++ b/pkg/probo/coredata/control.go @@ -63,38 +63,22 @@ func (c *Control) LoadByID( controlID gid.GID, ) error { q := ` -WITH control_states AS ( - SELECT - control_id, - to_state, - reason, - RANK() OVER w - FROM - control_state_transitions - WHERE - control_id = @control_id - WINDOW - w AS (PARTITION BY control_id ORDER BY created_at DESC) -) SELECT id, framework_id, category, name, description, - cs.to_state AS state, + state, content_ref, created_at, updated_at, version FROM controls -INNER JOIN - control_states cs ON cs.control_id = controls.id WHERE %s AND id = @control_id - AND cs.rank = 1 LIMIT 1; ` @@ -131,6 +115,7 @@ INSERT INTO framework_id, category, name, + state, description, content_ref, created_at, @@ -143,6 +128,7 @@ VALUES ( @framework_id, @category, @name, + @state, @description, @content_ref, @created_at, @@ -162,6 +148,7 @@ VALUES ( "content_ref": c.ContentRef, "created_at": c.CreatedAt, "updated_at": c.UpdatedAt, + "state": c.State, } _, err := conn.Exec(ctx, q, args) return err @@ -175,36 +162,22 @@ func (c *Controls) LoadByFrameworkID( cursor *page.Cursor, ) error { q := ` -WITH control_states AS ( - SELECT - control_id, - to_state, - reason, - RANK() OVER w - FROM - control_state_transitions - WINDOW - w AS (PARTITION BY control_id ORDER BY created_at DESC) -) SELECT id, framework_id, category, name, description, - cs.to_state AS state, + state, content_ref, created_at, updated_at, version FROM controls -INNER JOIN - control_states cs ON cs.control_id = controls.id WHERE %s AND framework_id = @framework_id - AND cs.rank = 1 AND %s ` q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) @@ -235,21 +208,11 @@ func (c *Control) Update( params UpdateControlParams, ) error { q := ` -WITH control_states AS ( - SELECT - control_id, - to_state, - reason, - RANK() OVER w - FROM - control_state_transitions - WINDOW - w AS (PARTITION BY control_id ORDER BY created_at DESC) -) UPDATE controls SET name = COALESCE(@name, name), description = COALESCE(@description, description), category = COALESCE(@category, category), + state = COALESCE(@state, state), updated_at = @updated_at, version = version + 1 WHERE %s @@ -261,7 +224,7 @@ RETURNING category, name, description, - (SELECT to_state FROM control_states WHERE control_id = controls.id AND rank = 1) AS state, + state, content_ref, created_at, updated_at, @@ -269,12 +232,14 @@ RETURNING ` q = fmt.Sprintf(q, scope.SQLFragment()) - args := pgx.StrictNamedArgs{ + args := pgx.NamedArgs{ "control_id": c.ID, "expected_version": params.ExpectedVersion, "updated_at": time.Now(), } + maps.Copy(args, scope.SQLArguments()) + if params.Name != nil { args["name"] = *params.Name } diff --git a/pkg/probo/coredata/control_state_transition.go b/pkg/probo/coredata/control_state_transition.go deleted file mode 100644 index 1533ff1c4..000000000 --- a/pkg/probo/coredata/control_state_transition.go +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) 2025 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package coredata - -import ( - "context" - "fmt" - "maps" - - "github.com/getprobo/probo/pkg/gid" - "github.com/getprobo/probo/pkg/page" - "github.com/jackc/pgx/v5" - "go.gearno.de/kit/pg" -) - -type ( - ControlStateTransition struct { - StateTransition[ControlState] - - ControlID gid.GID `db:"control_id"` - } - - ControlStateTransitions []*ControlStateTransition -) - -func (cst ControlStateTransition) CursorKey() page.CursorKey { - return page.NewCursorKey(cst.ID, cst.CreatedAt) -} - -func (cst ControlStateTransition) Insert( - ctx context.Context, - conn pg.Conn, - scope Scoper, -) error { - q := ` -INSERT INTO - control_state_transitions ( - tenant_id, - id, - control_id, - from_state, - to_state, - reason, - created_at, - updated_at - ) -VALUES ( - @tenant_id, - @control_state_transition_id, - @control_id, - @from_state, - @to_state, - @reason, - @created_at, - @updated_at -); -` - - args := pgx.StrictNamedArgs{ - "tenant_id": scope.GetTenantID(), - "control_state_transition_id": cst.ID, - "control_id": cst.ControlID, - "from_state": cst.FromState, - "to_state": cst.ToState, - "reason": cst.Reason, - "created_at": cst.CreatedAt, - "updated_at": cst.UpdatedAt, - } - _, err := conn.Exec(ctx, q, args) - return err -} - -func (cst *ControlStateTransitions) LoadByControlID( - ctx context.Context, - conn pg.Conn, - scope Scoper, - controlID gid.GID, - cursor *page.Cursor, -) error { - q := ` -SELECT - id, - tenant_id, - control_id, - from_state, - to_state, - reason, - created_at, - updated_at -FROM - control_state_transitions -WHERE - %s - AND control_id = @control_id - AND %s -` - - q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) - - args := pgx.StrictNamedArgs{"control_id": controlID} - maps.Copy(args, scope.SQLArguments()) - - rows, err := conn.Query(ctx, q, args) - if err != nil { - return fmt.Errorf("cannot query control state transitions: %w", err) - } - - controlStateTransitions, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[ControlStateTransition]) - if err != nil { - return fmt.Errorf("cannot collect control state transitions: %w", err) - } - - *cst = controlStateTransitions - - return nil -} diff --git a/pkg/probo/coredata/evidence.go b/pkg/probo/coredata/evidence.go index 1fdcd1b1a..0a9b7e9d4 100644 --- a/pkg/probo/coredata/evidence.go +++ b/pkg/probo/coredata/evidence.go @@ -162,22 +162,10 @@ func (e *Evidences) LoadByTaskID( cursor *page.Cursor, ) error { q := ` -WITH - evidence_states AS ( - SELECT - evidence_id, - to_state AS state, - reason, - RANK() OVER w - FROM - evidence_state_transitions - WINDOW - w AS (PARTITION BY evidence_id ORDER BY created_at DESC) - ) SELECT id, task_id, - es.state, + state, object_key, mime_type, size, @@ -186,12 +174,9 @@ SELECT updated_at FROM evidences -INNER JOIN - evidence_states es ON es.evidence_id = evidences.id WHERE %s AND task_id = @task_id - AND es.rank = 1 AND %s ` diff --git a/pkg/probo/coredata/evidence_state_transition.go b/pkg/probo/coredata/evidence_state_transition.go deleted file mode 100644 index e4acce68e..000000000 --- a/pkg/probo/coredata/evidence_state_transition.go +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) 2025 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package coredata - -import ( - "context" - "fmt" - "maps" - - "github.com/getprobo/probo/pkg/gid" - "github.com/getprobo/probo/pkg/page" - "github.com/jackc/pgx/v5" - "go.gearno.de/kit/pg" -) - -type ( - EvidenceStateTransition struct { - StateTransition[EvidenceState] - - EvidenceID gid.GID `db:"evidence_id"` - } - - EvidenceStateTransitions []*EvidenceStateTransition -) - -func (cst EvidenceStateTransition) CursorKey() page.CursorKey { - return page.NewCursorKey(cst.ID, cst.CreatedAt) -} - -func (est EvidenceStateTransition) Insert( - ctx context.Context, - conn pg.Conn, - scope Scoper, -) error { - q := ` -INSERT INTO - evidence_state_transitions ( - tenant_id, - id, - evidence_id, - from_state, - to_state, - reason, - created_at, - updated_at - ) -VALUES ( - @tenant_id, - @evidence_state_transition_id, - @evidence_id, - @from_state, - @to_state, - @reason, - @created_at, - @updated_at -); -` - - args := pgx.StrictNamedArgs{ - "tenant_id": scope.GetTenantID(), - "evidence_state_transition_id": est.ID, - "evidence_id": est.EvidenceID, - "from_state": est.FromState, - "to_state": est.ToState, - "reason": est.Reason, - "created_at": est.CreatedAt, - "updated_at": est.UpdatedAt, - } - _, err := conn.Exec(ctx, q, args) - return err -} - -func (cst *EvidenceStateTransitions) LoadByEvidenceID( - ctx context.Context, - conn pg.Conn, - scope Scoper, - evidenceID gid.GID, - cursor *page.Cursor, -) error { - q := ` -SELECT - id, - evidence_id, - from_state, - to_state, - reason, - created_at, - updated_at -FROM - evidence_state_transitions -WHERE - %s - AND evidence_id = @evidence_id - AND %s -` - - q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) - - args := pgx.StrictNamedArgs{"evidence_id": evidenceID} - maps.Copy(args, scope.SQLArguments()) - - rows, err := conn.Query(ctx, q, args) - if err != nil { - return fmt.Errorf("cannot query evidence state transitions: %w", err) - } - - evidenceStateTransitions, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[EvidenceStateTransition]) - if err != nil { - return fmt.Errorf("cannot collect evidence state transitions: %w", err) - } - - *cst = evidenceStateTransitions - - return nil -} - -func (cst *EvidenceStateTransitions) DeleteForEvidenceID( - ctx context.Context, - conn pg.Conn, - scope Scoper, - evidenceID gid.GID, -) error { - q := ` -DELETE FROM - evidence_state_transitions -WHERE - %s - AND evidence_id = @evidence_id -` - - q = fmt.Sprintf(q, scope.SQLFragment()) - - args := pgx.StrictNamedArgs{"evidence_id": evidenceID} - maps.Copy(args, scope.SQLArguments()) - - _, err := conn.Exec(ctx, q, args) - return err -} diff --git a/pkg/probo/coredata/migrations/20250310T161900Z.sql b/pkg/probo/coredata/migrations/20250310T161900Z.sql new file mode 100644 index 000000000..8ee03cda0 --- /dev/null +++ b/pkg/probo/coredata/migrations/20250310T161900Z.sql @@ -0,0 +1,17 @@ +DROP TABLE control_state_transitions; +DROP TABLE evidence_state_transitions; +DROP TABLE task_state_transitions; + +ALTER TABLE tasks ADD COLUMN control_id TEXT; + +UPDATE tasks +SET control_id = controls_tasks.control_id +FROM controls_tasks +WHERE tasks.id = controls_tasks.task_id; + +ALTER TABLE tasks ALTER COLUMN control_id SET NOT NULL; + +ALTER TABLE tasks ADD CONSTRAINT fk_tasks_control_id + FOREIGN KEY (control_id) REFERENCES controls(id) ON DELETE CASCADE; + +DROP TABLE controls_tasks; diff --git a/pkg/probo/coredata/migrations/20250310T164900Z.sql b/pkg/probo/coredata/migrations/20250310T164900Z.sql new file mode 100644 index 000000000..52555be1c --- /dev/null +++ b/pkg/probo/coredata/migrations/20250310T164900Z.sql @@ -0,0 +1,3 @@ +ALTER TABLE controls ADD COLUMN state control_state; +ALTER TABLE evidences ADD COLUMN state evidence_state; +ALTER TABLE tasks ADD COLUMN state task_state; diff --git a/pkg/probo/coredata/migrations/20250310T181100Z.sql b/pkg/probo/coredata/migrations/20250310T181100Z.sql new file mode 100644 index 000000000..4be07a300 --- /dev/null +++ b/pkg/probo/coredata/migrations/20250310T181100Z.sql @@ -0,0 +1 @@ +ALTER TABLE tasks ADD COLUMN version INTEGER NOT NULL DEFAULT 1; diff --git a/pkg/probo/coredata/state_transition.go b/pkg/probo/coredata/state_transition.go deleted file mode 100644 index 1317ce1c4..000000000 --- a/pkg/probo/coredata/state_transition.go +++ /dev/null @@ -1,31 +0,0 @@ -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package coredata - -import ( - "time" - - "github.com/getprobo/probo/pkg/gid" -) - -type ( - StateTransition[T any] struct { - ID gid.GID `db:"id"` - ToState T `db:"to_state"` - FromState *T `db:"from_state"` - Reason *string `db:"reason"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` - } -) diff --git a/pkg/probo/coredata/task.go b/pkg/probo/coredata/task.go index b346874fc..e592b9f6b 100644 --- a/pkg/probo/coredata/task.go +++ b/pkg/probo/coredata/task.go @@ -37,9 +37,17 @@ type ( ContentRef string `db:"content_ref"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` + Version int `db:"version"` } Tasks []*Task + + UpdateTaskParams struct { + ExpectedVersion int + Name *string + Description *string + State *TaskState + } ) func (t Task) CursorKey() page.CursorKey { @@ -53,58 +61,27 @@ func (t *Task) LoadByID( taskID gid.GID, ) error { q := ` -WITH - control_tasks AS ( - SELECT - t.id, - ct.control_id AS control_id, - t.name, - t.description, - t.content_ref, - t.created_at, - t.updated_at - FROM - tasks t - INNER JOIN - controls_tasks ct ON - ct.task_id = t.id - WHERE - t.tenant_id = @tenant_id - AND id = @task_id - ), - task_states AS ( - SELECT - task_id, - to_state AS state, - reason, - RANK() OVER w - FROM - task_state_transitions - WHERE - task_id = @task_id - WINDOW - w AS (PARTITION BY task_id ORDER BY created_at DESC) - ) SELECT id, control_id, name, description, - ts.state AS state, + state, content_ref, created_at, - updated_at + updated_at, + version FROM - control_tasks -INNER JOIN - task_states ts ON ts.task_id = control_tasks.id + tasks WHERE - ts.rank = 1 - AND id = @task_id + %s + AND task_id = @task_id LIMIT 1; ` - args := pgx.StrictNamedArgs{"tenant_id": scope.GetTenantID(), "task_id": taskID} + q = fmt.Sprintf(q, scope.SQLFragment()) + + args := pgx.StrictNamedArgs{"task_id": taskID} maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) @@ -128,38 +105,29 @@ func (t Task) Insert( scope Scoper, ) error { q := ` -WITH task_insert AS ( - INSERT INTO tasks ( - tenant_id, - id, - name, - description, - content_ref, - created_at, - updated_at - ) - VALUES ( - @tenant_id, - @task_id, - @name, - @description, - @content_ref, - @created_at, - @updated_at - ) - RETURNING id -) -INSERT INTO controls_tasks ( - task_id, - tenant_id, - control_id, - created_at +INSERT INTO tasks ( + tenant_id, + id, + name, + control_id, + description, + content_ref, + created_at, + updated_at, + version, + state ) VALUES ( - (SELECT id FROM task_insert), - @tenant_id, - @control_id, - @created_at + @tenant_id, + @task_id, + @name, + @control_id, + @description, + @content_ref, + @created_at, + @updated_at, + @version, + @state ); ` @@ -172,6 +140,8 @@ VALUES ( "content_ref": t.ContentRef, "created_at": t.CreatedAt, "updated_at": t.UpdatedAt, + "version": t.Version, + "state": t.State, } _, err := conn.Exec(ctx, q, args) return err @@ -185,57 +155,27 @@ func (t *Tasks) LoadByControlID( cursor *page.Cursor, ) error { q := ` -WITH - control_tasks AS ( - SELECT - t.id, - @control_id AS control_id, - t.name, - t.description, - t.content_ref, - t.created_at, - t.updated_at - FROM - tasks t - INNER JOIN - controls_tasks ct ON - ct.task_id = t.id - AND ct.control_id = @control_id - WHERE - t.tenant_id = @tenant_id - ), - task_states AS ( - SELECT - task_id, - to_state AS state, - reason, - RANK() OVER w - FROM - task_state_transitions - WINDOW - w AS (PARTITION BY task_id ORDER BY created_at DESC) - ) SELECT id, control_id, name, description, - ts.state AS state, + state, content_ref, created_at, - updated_at + updated_at, + version FROM - control_tasks -INNER JOIN - task_states ts ON ts.task_id = control_tasks.id + tasks WHERE - ts.rank = 1 + %s + AND control_id = @control_id AND %s ` - q = fmt.Sprintf(q, cursor.SQLFragment()) + q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) - args := pgx.StrictNamedArgs{"tenant_id": scope.GetTenantID(), "control_id": controlID} + args := pgx.StrictNamedArgs{"control_id": controlID} maps.Copy(args, scope.SQLArguments()) maps.Copy(args, cursor.SQLArguments()) @@ -254,6 +194,43 @@ WHERE return nil } +func (t *Task) Update( + ctx context.Context, + conn pg.Conn, + scope Scoper, + params UpdateTaskParams, +) error { + q := ` +UPDATE tasks +SET + name = COALESCE(@name, name), + description = COALESCE(@description, description), + state = COALESCE(@state, state), + updated_at = @updated_at, + version = version + 1 +WHERE + %s + AND id = @task_id + AND version = @expected_version +RETURNING + version; +` + q = fmt.Sprintf(q, scope.SQLFragment()) + + args := pgx.StrictNamedArgs{ + "task_id": t.ID, + "expected_version": params.ExpectedVersion, + "name": params.Name, + "description": params.Description, + "state": params.State, + "updated_at": time.Now(), + } + maps.Copy(args, scope.SQLArguments()) + + err := conn.QueryRow(ctx, q, args).Scan(&t.Version) + return err +} + func (t *Task) Delete( ctx context.Context, conn pg.Conn, diff --git a/pkg/probo/coredata/task_state_transition.go b/pkg/probo/coredata/task_state_transition.go deleted file mode 100644 index e84cf1643..000000000 --- a/pkg/probo/coredata/task_state_transition.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) 2025 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package coredata - -import ( - "context" - "fmt" - "maps" - - "github.com/getprobo/probo/pkg/gid" - "github.com/getprobo/probo/pkg/page" - "github.com/jackc/pgx/v5" - "go.gearno.de/kit/pg" -) - -type ( - TaskStateTransition struct { - StateTransition[TaskState] - TaskID gid.GID `db:"task_id"` - } - - TaskStateTransitions []*TaskStateTransition -) - -func (tst TaskStateTransition) CursorKey() page.CursorKey { - return page.NewCursorKey(tst.ID, tst.CreatedAt) -} - -func (tst TaskStateTransition) Insert( - ctx context.Context, - conn pg.Conn, - scope Scoper, -) error { - q := ` -INSERT INTO - task_state_transitions ( - tenant_id, - id, - task_id, - from_state, - to_state, - reason, - created_at, - updated_at - ) -VALUES ( - @tenant_id, - @task_state_transition_id, - @task_id, - @from_state, - @to_state, - @reason, - @created_at, - @updated_at -); -` - - args := pgx.StrictNamedArgs{ - "tenant_id": scope.GetTenantID(), - "task_state_transition_id": tst.ID, - "task_id": tst.TaskID, - "from_state": tst.FromState, - "to_state": tst.ToState, - "reason": tst.Reason, - "created_at": tst.CreatedAt, - "updated_at": tst.UpdatedAt, - } - _, err := conn.Exec(ctx, q, args) - return err -} - -func (tst *TaskStateTransitions) LoadByTaskID( - ctx context.Context, - conn pg.Conn, - scope Scoper, - taskID gid.GID, - cursor *page.Cursor, -) error { - q := ` -SELECT - id, - task_id, - from_state, - to_state, - reason, - created_at, - updated_at -FROM - task_state_transitions -WHERE - %s - AND task_id = @task_id - AND %s -` - - q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) - - args := pgx.StrictNamedArgs{"task_id": taskID} - maps.Copy(args, scope.SQLArguments()) - - rows, err := conn.Query(ctx, q, args) - if err != nil { - return fmt.Errorf("cannot query task state transitions: %w", err) - } - - taskStateTransitions, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TaskStateTransition]) - if err != nil { - return fmt.Errorf("cannot collect task state transitions: %w", err) - } - - *tst = taskStateTransitions - - return nil -} diff --git a/pkg/probo/create_control.go b/pkg/probo/create_control.go index 550b76987..d0b0ed3b9 100644 --- a/pkg/probo/create_control.go +++ b/pkg/probo/create_control.go @@ -19,7 +19,6 @@ import ( "fmt" "time" - "gearno.de/ref" "github.com/getprobo/probo/pkg/gid" "github.com/getprobo/probo/pkg/probo/coredata" "go.gearno.de/kit/pg" @@ -44,10 +43,6 @@ func (s Service) CreateControl( if err != nil { return nil, fmt.Errorf("cannot create control global id: %w", err) } - controlStateTransitionID, err := gid.NewGID(s.scope.GetTenantID(), coredata.ControlStateTransitionEntityType) - if err != nil { - return nil, fmt.Errorf("cannot create control state transition global id: %w", err) - } framework := &coredata.Framework{} control := &coredata.Control{ @@ -62,18 +57,6 @@ func (s Service) CreateControl( UpdatedAt: now, } - controlStateTransition := coredata.ControlStateTransition{ - StateTransition: coredata.StateTransition[coredata.ControlState]{ - ID: controlStateTransitionID, - FromState: nil, - ToState: control.State, - Reason: ref.Ref("Initial state"), - CreatedAt: now, - UpdatedAt: now, - }, - ControlID: control.ID, - } - err = s.pg.WithTx( ctx, func(conn pg.Conn) error { @@ -85,10 +68,6 @@ func (s Service) CreateControl( return fmt.Errorf("cannot insert control: %w", err) } - if err := controlStateTransition.Insert(ctx, conn, s.scope); err != nil { - return fmt.Errorf("cannot insert control state transition: %w", err) - } - return nil }, ) diff --git a/pkg/probo/create_evidence.go b/pkg/probo/create_evidence.go index 118613a38..a24866f5a 100644 --- a/pkg/probo/create_evidence.go +++ b/pkg/probo/create_evidence.go @@ -22,7 +22,6 @@ import ( "path/filepath" "time" - "gearno.de/ref" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/getprobo/probo/pkg/gid" @@ -48,10 +47,6 @@ func (s Service) CreateEvidence( if err != nil { return nil, fmt.Errorf("cannot create evidence global id: %w", err) } - evidenceStateTransitionID, err := gid.NewGID(s.scope.GetTenantID(), coredata.EvidenceStateTransitionEntityType) - if err != nil { - return nil, fmt.Errorf("cannot create evidence state transition: %w", err) - } contentType := "application/octet-stream" if req.Name != "" { @@ -98,18 +93,6 @@ func (s Service) CreateEvidence( UpdatedAt: now, } - evidenceStateTransition := coredata.EvidenceStateTransition{ - StateTransition: coredata.StateTransition[coredata.EvidenceState]{ - ID: evidenceStateTransitionID, - FromState: nil, - ToState: evidence.State, - Reason: ref.Ref("Initial state"), - CreatedAt: now, - UpdatedAt: now, - }, - EvidenceID: evidence.ID, - } - err = s.pg.WithTx( ctx, func(conn pg.Conn) error { @@ -121,10 +104,6 @@ func (s Service) CreateEvidence( return fmt.Errorf("cannot insert evidence: %w", err) } - if err := evidenceStateTransition.Insert(ctx, conn, s.scope); err != nil { - return fmt.Errorf("cannot insert evidence state transition: %w", err) - } - return nil }, ) diff --git a/pkg/probo/create_task.go b/pkg/probo/create_task.go index 89edae03e..7f1f7b9a4 100644 --- a/pkg/probo/create_task.go +++ b/pkg/probo/create_task.go @@ -19,7 +19,6 @@ import ( "fmt" "time" - "gearno.de/ref" "github.com/getprobo/probo/pkg/gid" "github.com/getprobo/probo/pkg/probo/coredata" "go.gearno.de/kit/pg" @@ -43,10 +42,6 @@ func (s Service) CreateTask( if err != nil { return nil, fmt.Errorf("cannot create task global id: %w", err) } - taskStateTransitionID, err := gid.NewGID(s.scope.GetTenantID(), coredata.TaskStateTransitionEntityType) - if err != nil { - return nil, fmt.Errorf("cannot create task state transition global id: %w", err) - } control := &coredata.Control{} task := &coredata.Task{ @@ -54,24 +49,12 @@ func (s Service) CreateTask( ControlID: req.ControlID, Name: req.Name, ContentRef: req.ContentRef, - Description: req.Description, State: coredata.TaskStateTodo, + Description: req.Description, CreatedAt: now, UpdatedAt: now, } - taskStateTransition := coredata.TaskStateTransition{ - StateTransition: coredata.StateTransition[coredata.TaskState]{ - ID: taskStateTransitionID, - FromState: nil, - ToState: task.State, - Reason: ref.Ref("Initial state"), - CreatedAt: now, - UpdatedAt: now, - }, - TaskID: task.ID, - } - err = s.pg.WithTx( ctx, func(conn pg.Conn) error { @@ -83,10 +66,6 @@ func (s Service) CreateTask( return fmt.Errorf("cannot insert task: %w", err) } - if err := taskStateTransition.Insert(ctx, conn, s.scope); err != nil { - return fmt.Errorf("cannot insert task state transition: %w", err) - } - return nil }, ) diff --git a/pkg/probo/delete_evidence.go b/pkg/probo/delete_evidence.go index 9ac5963d4..9fc514c58 100644 --- a/pkg/probo/delete_evidence.go +++ b/pkg/probo/delete_evidence.go @@ -27,16 +27,11 @@ func (s *Service) DeleteEvidence( ctx context.Context, evidenceID gid.GID, ) error { - evidenceStateTransitions := &coredata.EvidenceStateTransitions{} evidence := &coredata.Evidence{ID: evidenceID} return s.pg.WithTx( ctx, func(conn pg.Conn) error { - if err := evidenceStateTransitions.DeleteForEvidenceID(ctx, conn, s.scope, evidenceID); err != nil { - return fmt.Errorf("cannot delete evidence state transitions: %w", err) - } - if err := evidence.Delete(ctx, conn, s.scope); err != nil { return fmt.Errorf("cannot delete evidence: %w", err) } diff --git a/pkg/probo/list_control_state_transitions.go b/pkg/probo/list_control_state_transitions.go deleted file mode 100644 index c270348db..000000000 --- a/pkg/probo/list_control_state_transitions.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2025 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package probo - -import ( - "context" - - "github.com/getprobo/probo/pkg/gid" - "github.com/getprobo/probo/pkg/page" - "github.com/getprobo/probo/pkg/probo/coredata" - "go.gearno.de/kit/pg" -) - -func (s Service) ListControlStateTransitions( - ctx context.Context, - controlID gid.GID, - cursor *page.Cursor, -) (*page.Page[*coredata.ControlStateTransition], error) { - var controlStateTransitions coredata.ControlStateTransitions - - err := s.pg.WithConn( - ctx, - func(conn pg.Conn) error { - return controlStateTransitions.LoadByControlID( - ctx, - conn, - s.scope, - controlID, - cursor, - ) - }, - ) - - if err != nil { - return nil, err - } - - return page.NewPage(controlStateTransitions, cursor), nil -} diff --git a/pkg/probo/list_task_state_transitions.go b/pkg/probo/list_task_state_transitions.go deleted file mode 100644 index a96b64e59..000000000 --- a/pkg/probo/list_task_state_transitions.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2025 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package probo - -import ( - "context" - - "github.com/getprobo/probo/pkg/gid" - "github.com/getprobo/probo/pkg/page" - "github.com/getprobo/probo/pkg/probo/coredata" - "go.gearno.de/kit/pg" -) - -func (s Service) ListTaskStateTransitions( - ctx context.Context, - taskID gid.GID, - cursor *page.Cursor, -) (*page.Page[*coredata.TaskStateTransition], error) { - var taskStateTransitions coredata.TaskStateTransitions - - err := s.pg.WithConn( - ctx, - func(conn pg.Conn) error { - return taskStateTransitions.LoadByTaskID( - ctx, - conn, - s.scope, - taskID, - cursor, - ) - }, - ) - - if err != nil { - return nil, err - } - - return page.NewPage(taskStateTransitions, cursor), nil -} diff --git a/pkg/probo/list_evidence_state_transitions.go b/pkg/probo/update_task.go similarity index 65% rename from pkg/probo/list_evidence_state_transitions.go rename to pkg/probo/update_task.go index cbfa8900a..9eaa0931a 100644 --- a/pkg/probo/list_evidence_state_transitions.go +++ b/pkg/probo/update_task.go @@ -18,34 +18,39 @@ import ( "context" "github.com/getprobo/probo/pkg/gid" - "github.com/getprobo/probo/pkg/page" "github.com/getprobo/probo/pkg/probo/coredata" "go.gearno.de/kit/pg" ) -func (s Service) ListEvidenceStateTransitions( - ctx context.Context, - evidenceID gid.GID, - cursor *page.Cursor, -) (*page.Page[*coredata.EvidenceStateTransition], error) { - var evidenceStateTransitions coredata.EvidenceStateTransitions +type UpdateTaskRequest struct { + ID gid.GID + ExpectedVersion int + Name *string + Description *string + State *coredata.TaskState +} - err := s.pg.WithConn( +func (s Service) UpdateTask( + ctx context.Context, + req UpdateTaskRequest, +) (*coredata.Task, error) { + params := coredata.UpdateTaskParams{ + ExpectedVersion: req.ExpectedVersion, + Name: req.Name, + Description: req.Description, + State: req.State, + } + + task := &coredata.Task{ID: req.ID} + + err := s.pg.WithTx( ctx, func(conn pg.Conn) error { - return evidenceStateTransitions.LoadByEvidenceID( - ctx, - conn, - s.scope, - evidenceID, - cursor, - ) - }, - ) - + return task.Update(ctx, conn, s.scope, params) + }) if err != nil { return nil, err } - return page.NewPage(evidenceStateTransitions, cursor), nil + return task, nil } diff --git a/pkg/probo/update_task_state.go b/pkg/probo/update_task_state.go deleted file mode 100644 index fd8412826..000000000 --- a/pkg/probo/update_task_state.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2025 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package probo - -import ( - "context" - "fmt" - "time" - - "github.com/getprobo/probo/pkg/gid" - "github.com/getprobo/probo/pkg/probo/coredata" - "go.gearno.de/kit/pg" -) - -type UpdateTaskStateRequest struct { - TaskID gid.GID - State coredata.TaskState - Reason *string -} - -func (s Service) UpdateTaskState( - ctx context.Context, - req UpdateTaskStateRequest, -) (*coredata.Task, error) { - - // TODO: lock the task for update to ensure that only one update can happen at a time - - task, err := s.GetTask(ctx, req.TaskID) - if err != nil { - return nil, fmt.Errorf("cannot get task: %w", err) - } - - if task.State == req.State { - return task, nil - } - - taskStateTransitionID, err := gid.NewGID(s.scope.GetTenantID(), coredata.TaskStateTransitionEntityType) - if err != nil { - return nil, fmt.Errorf("cannot create task state transition global id: %w", err) - } - - now := time.Now() - currentState := task.State - - taskStateTransition := coredata.TaskStateTransition{ - StateTransition: coredata.StateTransition[coredata.TaskState]{ - ID: taskStateTransitionID, - FromState: ¤tState, - ToState: req.State, - Reason: req.Reason, - CreatedAt: now, - UpdatedAt: now, - }, - TaskID: task.ID, - } - - task.State = req.State - task.UpdatedAt = now - - err = s.pg.WithConn( - ctx, - func(conn pg.Conn) error { - if err := taskStateTransition.Insert(ctx, conn, s.scope); err != nil { - return fmt.Errorf("cannot insert task state transition: %w", err) - } - - return nil - }, - ) - - if err != nil { - return nil, err - } - - return task, nil -} diff --git a/pkg/server/api/console/v1/schema.graphql b/pkg/server/api/console/v1/schema.graphql index 7f0dbe37f..207264630 100644 --- a/pkg/server/api/console/v1/schema.graphql +++ b/pkg/server/api/console/v1/schema.graphql @@ -225,13 +225,6 @@ type Control implements Node { description: String! state: ControlState! - stateTransisions( - first: Int - after: CursorKey - last: Int - before: CursorKey - ): ControlStateTransitionConnection! @goField(forceResolver: true) - tasks( first: Int after: CursorKey @@ -243,25 +236,6 @@ type Control implements Node { updatedAt: Datetime! } -type ControlStateTransitionConnection { - edges: [ControlStateTransitionEdge!]! - pageInfo: PageInfo! -} - -type ControlStateTransitionEdge { - cursor: CursorKey! - node: ControlStateTransition! -} - -type ControlStateTransition { - id: ID! - fromState: ControlState - toState: ControlState! - reason: String - createdAt: Datetime! - updatedAt: Datetime! -} - type TaskConnection { edges: [TaskEdge!]! pageInfo: PageInfo! @@ -274,17 +248,11 @@ type TaskEdge { type Task implements Node { id: ID! + version: Int! name: String! description: String! state: TaskState! - stateTransisions( - first: Int - after: CursorKey - last: Int - before: CursorKey - ): TaskStateTransitionConnection! @goField(forceResolver: true) - evidences( first: Int after: CursorKey @@ -296,25 +264,6 @@ type Task implements Node { updatedAt: Datetime! } -type TaskStateTransitionConnection { - edges: [TaskStateTransitionEdge!]! - pageInfo: PageInfo! -} - -type TaskStateTransitionEdge { - cursor: CursorKey! - node: TaskStateTransition! -} - -type TaskStateTransition { - id: ID! - fromState: TaskState - toState: TaskState! - reason: String - createdAt: Datetime! - updatedAt: Datetime! -} - type EvidenceConnection { edges: [EvidenceEdge!]! pageInfo: PageInfo! @@ -333,32 +282,6 @@ type Evidence implements Node { state: EvidenceState! filename: String! - stateTransisions( - first: Int - after: CursorKey - last: Int - before: CursorKey - ): EvidenceStateTransitionConnection! @goField(forceResolver: true) - - createdAt: Datetime! - updatedAt: Datetime! -} - -type EvidenceStateTransitionConnection { - edges: [EvidenceStateTransitionEdge!]! - pageInfo: PageInfo! -} - -type EvidenceStateTransitionEdge { - cursor: CursorKey! - node: EvidenceStateTransition! -} - -type EvidenceStateTransition { - id: ID! - fromState: EvidenceState - toState: EvidenceState! - reason: String createdAt: Datetime! updatedAt: Datetime! } @@ -402,8 +325,8 @@ type Mutation { deleteOrganization( input: DeleteOrganizationInput! ): DeleteOrganizationPayload! - updateTaskState(input: UpdateTaskStateInput!): UpdateTaskStatePayload! createTask(input: CreateTaskInput!): CreateTaskPayload! + updateTask(input: UpdateTaskInput!): UpdateTaskPayload! deleteTask(input: DeleteTaskInput!): DeleteTaskPayload! createFramework(input: CreateFrameworkInput!): CreateFrameworkPayload! createControl(input: CreateControlInput!): CreateControlPayload! @@ -534,15 +457,6 @@ type DeleteOrganizationPayload { deletedOrganizationId: ID! } -input UpdateTaskStateInput { - taskId: ID! - state: TaskState! -} - -type UpdateTaskStatePayload { - task: Task! -} - input CreateTaskInput { controlId: ID! name: String! @@ -700,3 +614,15 @@ type PolicyEdge { cursor: CursorKey! node: Policy! } + +input UpdateTaskInput { + taskId: ID! + expectedVersion: Int! + name: String + description: String + state: TaskState +} + +type UpdateTaskPayload { + task: Task! +} diff --git a/pkg/server/api/console/v1/schema/schema.go b/pkg/server/api/console/v1/schema/schema.go index 40c3fabd9..1f6753f11 100644 --- a/pkg/server/api/console/v1/schema/schema.go +++ b/pkg/server/api/console/v1/schema/schema.go @@ -58,16 +58,15 @@ type DirectiveRoot struct { type ComplexityRoot struct { Control struct { - Category func(childComplexity int) int - CreatedAt func(childComplexity int) int - Description func(childComplexity int) int - ID func(childComplexity int) int - Name func(childComplexity int) int - State func(childComplexity int) int - StateTransisions func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int - Tasks func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int - UpdatedAt func(childComplexity int) int - Version func(childComplexity int) int + Category func(childComplexity int) int + CreatedAt func(childComplexity int) int + Description func(childComplexity int) int + ID func(childComplexity int) int + Name func(childComplexity int) int + State func(childComplexity int) int + Tasks func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int + UpdatedAt func(childComplexity int) int + Version func(childComplexity int) int } ControlConnection struct { @@ -80,25 +79,6 @@ type ComplexityRoot struct { Node func(childComplexity int) int } - ControlStateTransition struct { - CreatedAt func(childComplexity int) int - FromState func(childComplexity int) int - ID func(childComplexity int) int - Reason func(childComplexity int) int - ToState func(childComplexity int) int - UpdatedAt func(childComplexity int) int - } - - ControlStateTransitionConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - } - - ControlStateTransitionEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - CreateControlPayload struct { ControlEdge func(childComplexity int) int } @@ -152,15 +132,14 @@ type ComplexityRoot struct { } Evidence struct { - CreatedAt func(childComplexity int) int - FileURL func(childComplexity int) int - Filename func(childComplexity int) int - ID func(childComplexity int) int - MimeType func(childComplexity int) int - Size func(childComplexity int) int - State func(childComplexity int) int - StateTransisions func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int - UpdatedAt func(childComplexity int) int + CreatedAt func(childComplexity int) int + FileURL func(childComplexity int) int + Filename func(childComplexity int) int + ID func(childComplexity int) int + MimeType func(childComplexity int) int + Size func(childComplexity int) int + State func(childComplexity int) int + UpdatedAt func(childComplexity int) int } EvidenceConnection struct { @@ -173,25 +152,6 @@ type ComplexityRoot struct { Node func(childComplexity int) int } - EvidenceStateTransition struct { - CreatedAt func(childComplexity int) int - FromState func(childComplexity int) int - ID func(childComplexity int) int - Reason func(childComplexity int) int - ToState func(childComplexity int) int - UpdatedAt func(childComplexity int) int - } - - EvidenceStateTransitionConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - } - - EvidenceStateTransitionEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - Framework struct { Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int CreatedAt func(childComplexity int) int @@ -230,7 +190,7 @@ type ComplexityRoot struct { UpdateFramework func(childComplexity int, input types.UpdateFrameworkInput) int UpdatePeople func(childComplexity int, input types.UpdatePeopleInput) int UpdatePolicy func(childComplexity int, input types.UpdatePolicyInput) int - UpdateTaskState func(childComplexity int, input types.UpdateTaskStateInput) int + UpdateTask func(childComplexity int, input types.UpdateTaskInput) int UpdateVendor func(childComplexity int, input types.UpdateVendorInput) int UploadEvidence func(childComplexity int, input types.UploadEvidenceInput) int } @@ -318,14 +278,14 @@ type ComplexityRoot struct { } Task struct { - CreatedAt func(childComplexity int) int - Description func(childComplexity int) int - Evidences func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int - ID func(childComplexity int) int - Name func(childComplexity int) int - State func(childComplexity int) int - StateTransisions func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int - UpdatedAt func(childComplexity int) int + CreatedAt func(childComplexity int) int + Description func(childComplexity int) int + Evidences func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int + ID func(childComplexity int) int + Name func(childComplexity int) int + State func(childComplexity int) int + UpdatedAt func(childComplexity int) int + Version func(childComplexity int) int } TaskConnection struct { @@ -338,25 +298,6 @@ type ComplexityRoot struct { Node func(childComplexity int) int } - TaskStateTransition struct { - CreatedAt func(childComplexity int) int - FromState func(childComplexity int) int - ID func(childComplexity int) int - Reason func(childComplexity int) int - ToState func(childComplexity int) int - UpdatedAt func(childComplexity int) int - } - - TaskStateTransitionConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - } - - TaskStateTransitionEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - UpdateControlPayload struct { Control func(childComplexity int) int } @@ -373,6 +314,10 @@ type ComplexityRoot struct { Policy func(childComplexity int) int } + UpdateTaskPayload struct { + Task func(childComplexity int) int + } + UpdateTaskStatePayload struct { Task func(childComplexity int) int } @@ -422,13 +367,10 @@ type ComplexityRoot struct { } type ControlResolver interface { - StateTransisions(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.ControlStateTransitionConnection, error) Tasks(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TaskConnection, error) } type EvidenceResolver interface { FileURL(ctx context.Context, obj *types.Evidence) (string, error) - - StateTransisions(ctx context.Context, obj *types.Evidence, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.EvidenceStateTransitionConnection, error) } type FrameworkResolver interface { Controls(ctx context.Context, obj *types.Framework, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.ControlConnection, error) @@ -442,8 +384,8 @@ type MutationResolver interface { DeletePeople(ctx context.Context, input types.DeletePeopleInput) (*types.DeletePeoplePayload, error) CreateOrganization(ctx context.Context, input types.CreateOrganizationInput) (*types.CreateOrganizationPayload, error) DeleteOrganization(ctx context.Context, input types.DeleteOrganizationInput) (*types.DeleteOrganizationPayload, error) - UpdateTaskState(ctx context.Context, input types.UpdateTaskStateInput) (*types.UpdateTaskStatePayload, error) CreateTask(ctx context.Context, input types.CreateTaskInput) (*types.CreateTaskPayload, error) + UpdateTask(ctx context.Context, input types.UpdateTaskInput) (*types.UpdateTaskPayload, error) DeleteTask(ctx context.Context, input types.DeleteTaskInput) (*types.DeleteTaskPayload, error) CreateFramework(ctx context.Context, input types.CreateFrameworkInput) (*types.CreateFrameworkPayload, error) CreateControl(ctx context.Context, input types.CreateControlInput) (*types.CreateControlPayload, error) @@ -469,7 +411,6 @@ type QueryResolver interface { Viewer(ctx context.Context) (*types.User, error) } type TaskResolver interface { - StateTransisions(ctx context.Context, obj *types.Task, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TaskStateTransitionConnection, error) Evidences(ctx context.Context, obj *types.Task, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.EvidenceConnection, error) } type UserResolver interface { @@ -537,18 +478,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Control.State(childComplexity), true - case "Control.stateTransisions": - if e.complexity.Control.StateTransisions == nil { - break - } - - args, err := ec.field_Control_stateTransisions_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Control.StateTransisions(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey)), true - case "Control.tasks": if e.complexity.Control.Tasks == nil { break @@ -603,76 +532,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ControlEdge.Node(childComplexity), true - case "ControlStateTransition.createdAt": - if e.complexity.ControlStateTransition.CreatedAt == nil { - break - } - - return e.complexity.ControlStateTransition.CreatedAt(childComplexity), true - - case "ControlStateTransition.fromState": - if e.complexity.ControlStateTransition.FromState == nil { - break - } - - return e.complexity.ControlStateTransition.FromState(childComplexity), true - - case "ControlStateTransition.id": - if e.complexity.ControlStateTransition.ID == nil { - break - } - - return e.complexity.ControlStateTransition.ID(childComplexity), true - - case "ControlStateTransition.reason": - if e.complexity.ControlStateTransition.Reason == nil { - break - } - - return e.complexity.ControlStateTransition.Reason(childComplexity), true - - case "ControlStateTransition.toState": - if e.complexity.ControlStateTransition.ToState == nil { - break - } - - return e.complexity.ControlStateTransition.ToState(childComplexity), true - - case "ControlStateTransition.updatedAt": - if e.complexity.ControlStateTransition.UpdatedAt == nil { - break - } - - return e.complexity.ControlStateTransition.UpdatedAt(childComplexity), true - - case "ControlStateTransitionConnection.edges": - if e.complexity.ControlStateTransitionConnection.Edges == nil { - break - } - - return e.complexity.ControlStateTransitionConnection.Edges(childComplexity), true - - case "ControlStateTransitionConnection.pageInfo": - if e.complexity.ControlStateTransitionConnection.PageInfo == nil { - break - } - - return e.complexity.ControlStateTransitionConnection.PageInfo(childComplexity), true - - case "ControlStateTransitionEdge.cursor": - if e.complexity.ControlStateTransitionEdge.Cursor == nil { - break - } - - return e.complexity.ControlStateTransitionEdge.Cursor(childComplexity), true - - case "ControlStateTransitionEdge.node": - if e.complexity.ControlStateTransitionEdge.Node == nil { - break - } - - return e.complexity.ControlStateTransitionEdge.Node(childComplexity), true - case "CreateControlPayload.controlEdge": if e.complexity.CreateControlPayload.ControlEdge == nil { break @@ -813,18 +672,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Evidence.State(childComplexity), true - case "Evidence.stateTransisions": - if e.complexity.Evidence.StateTransisions == nil { - break - } - - args, err := ec.field_Evidence_stateTransisions_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Evidence.StateTransisions(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey)), true - case "Evidence.updatedAt": if e.complexity.Evidence.UpdatedAt == nil { break @@ -860,76 +707,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.EvidenceEdge.Node(childComplexity), true - case "EvidenceStateTransition.createdAt": - if e.complexity.EvidenceStateTransition.CreatedAt == nil { - break - } - - return e.complexity.EvidenceStateTransition.CreatedAt(childComplexity), true - - case "EvidenceStateTransition.fromState": - if e.complexity.EvidenceStateTransition.FromState == nil { - break - } - - return e.complexity.EvidenceStateTransition.FromState(childComplexity), true - - case "EvidenceStateTransition.id": - if e.complexity.EvidenceStateTransition.ID == nil { - break - } - - return e.complexity.EvidenceStateTransition.ID(childComplexity), true - - case "EvidenceStateTransition.reason": - if e.complexity.EvidenceStateTransition.Reason == nil { - break - } - - return e.complexity.EvidenceStateTransition.Reason(childComplexity), true - - case "EvidenceStateTransition.toState": - if e.complexity.EvidenceStateTransition.ToState == nil { - break - } - - return e.complexity.EvidenceStateTransition.ToState(childComplexity), true - - case "EvidenceStateTransition.updatedAt": - if e.complexity.EvidenceStateTransition.UpdatedAt == nil { - break - } - - return e.complexity.EvidenceStateTransition.UpdatedAt(childComplexity), true - - case "EvidenceStateTransitionConnection.edges": - if e.complexity.EvidenceStateTransitionConnection.Edges == nil { - break - } - - return e.complexity.EvidenceStateTransitionConnection.Edges(childComplexity), true - - case "EvidenceStateTransitionConnection.pageInfo": - if e.complexity.EvidenceStateTransitionConnection.PageInfo == nil { - break - } - - return e.complexity.EvidenceStateTransitionConnection.PageInfo(childComplexity), true - - case "EvidenceStateTransitionEdge.cursor": - if e.complexity.EvidenceStateTransitionEdge.Cursor == nil { - break - } - - return e.complexity.EvidenceStateTransitionEdge.Cursor(childComplexity), true - - case "EvidenceStateTransitionEdge.node": - if e.complexity.EvidenceStateTransitionEdge.Node == nil { - break - } - - return e.complexity.EvidenceStateTransitionEdge.Node(childComplexity), true - case "Framework.controls": if e.complexity.Framework.Controls == nil { break @@ -1216,17 +993,17 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.UpdatePolicy(childComplexity, args["input"].(types.UpdatePolicyInput)), true - case "Mutation.updateTaskState": - if e.complexity.Mutation.UpdateTaskState == nil { + case "Mutation.updateTask": + if e.complexity.Mutation.UpdateTask == nil { break } - args, err := ec.field_Mutation_updateTaskState_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_updateTask_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.UpdateTaskState(childComplexity, args["input"].(types.UpdateTaskStateInput)), true + return e.complexity.Mutation.UpdateTask(childComplexity, args["input"].(types.UpdateTaskInput)), true case "Mutation.updateVendor": if e.complexity.Mutation.UpdateVendor == nil { @@ -1646,18 +1423,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Task.State(childComplexity), true - case "Task.stateTransisions": - if e.complexity.Task.StateTransisions == nil { - break - } - - args, err := ec.field_Task_stateTransisions_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Task.StateTransisions(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey)), true - case "Task.updatedAt": if e.complexity.Task.UpdatedAt == nil { break @@ -1665,6 +1430,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Task.UpdatedAt(childComplexity), true + case "Task.version": + if e.complexity.Task.Version == nil { + break + } + + return e.complexity.Task.Version(childComplexity), true + case "TaskConnection.edges": if e.complexity.TaskConnection.Edges == nil { break @@ -1693,76 +1465,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.TaskEdge.Node(childComplexity), true - case "TaskStateTransition.createdAt": - if e.complexity.TaskStateTransition.CreatedAt == nil { - break - } - - return e.complexity.TaskStateTransition.CreatedAt(childComplexity), true - - case "TaskStateTransition.fromState": - if e.complexity.TaskStateTransition.FromState == nil { - break - } - - return e.complexity.TaskStateTransition.FromState(childComplexity), true - - case "TaskStateTransition.id": - if e.complexity.TaskStateTransition.ID == nil { - break - } - - return e.complexity.TaskStateTransition.ID(childComplexity), true - - case "TaskStateTransition.reason": - if e.complexity.TaskStateTransition.Reason == nil { - break - } - - return e.complexity.TaskStateTransition.Reason(childComplexity), true - - case "TaskStateTransition.toState": - if e.complexity.TaskStateTransition.ToState == nil { - break - } - - return e.complexity.TaskStateTransition.ToState(childComplexity), true - - case "TaskStateTransition.updatedAt": - if e.complexity.TaskStateTransition.UpdatedAt == nil { - break - } - - return e.complexity.TaskStateTransition.UpdatedAt(childComplexity), true - - case "TaskStateTransitionConnection.edges": - if e.complexity.TaskStateTransitionConnection.Edges == nil { - break - } - - return e.complexity.TaskStateTransitionConnection.Edges(childComplexity), true - - case "TaskStateTransitionConnection.pageInfo": - if e.complexity.TaskStateTransitionConnection.PageInfo == nil { - break - } - - return e.complexity.TaskStateTransitionConnection.PageInfo(childComplexity), true - - case "TaskStateTransitionEdge.cursor": - if e.complexity.TaskStateTransitionEdge.Cursor == nil { - break - } - - return e.complexity.TaskStateTransitionEdge.Cursor(childComplexity), true - - case "TaskStateTransitionEdge.node": - if e.complexity.TaskStateTransitionEdge.Node == nil { - break - } - - return e.complexity.TaskStateTransitionEdge.Node(childComplexity), true - case "UpdateControlPayload.control": if e.complexity.UpdateControlPayload.Control == nil { break @@ -1791,6 +1493,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.UpdatePolicyPayload.Policy(childComplexity), true + case "UpdateTaskPayload.task": + if e.complexity.UpdateTaskPayload.Task == nil { + break + } + + return e.complexity.UpdateTaskPayload.Task(childComplexity), true + case "UpdateTaskStatePayload.task": if e.complexity.UpdateTaskStatePayload.Task == nil { break @@ -2003,6 +1712,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputUpdateFrameworkInput, ec.unmarshalInputUpdatePeopleInput, ec.unmarshalInputUpdatePolicyInput, + ec.unmarshalInputUpdateTaskInput, ec.unmarshalInputUpdateTaskStateInput, ec.unmarshalInputUpdateVendorInput, ec.unmarshalInputUploadEvidenceInput, @@ -2330,13 +2040,6 @@ type Control implements Node { description: String! state: ControlState! - stateTransisions( - first: Int - after: CursorKey - last: Int - before: CursorKey - ): ControlStateTransitionConnection! @goField(forceResolver: true) - tasks( first: Int after: CursorKey @@ -2348,25 +2051,6 @@ type Control implements Node { updatedAt: Datetime! } -type ControlStateTransitionConnection { - edges: [ControlStateTransitionEdge!]! - pageInfo: PageInfo! -} - -type ControlStateTransitionEdge { - cursor: CursorKey! - node: ControlStateTransition! -} - -type ControlStateTransition { - id: ID! - fromState: ControlState - toState: ControlState! - reason: String - createdAt: Datetime! - updatedAt: Datetime! -} - type TaskConnection { edges: [TaskEdge!]! pageInfo: PageInfo! @@ -2379,17 +2063,11 @@ type TaskEdge { type Task implements Node { id: ID! + version: Int! name: String! description: String! state: TaskState! - stateTransisions( - first: Int - after: CursorKey - last: Int - before: CursorKey - ): TaskStateTransitionConnection! @goField(forceResolver: true) - evidences( first: Int after: CursorKey @@ -2401,25 +2079,6 @@ type Task implements Node { updatedAt: Datetime! } -type TaskStateTransitionConnection { - edges: [TaskStateTransitionEdge!]! - pageInfo: PageInfo! -} - -type TaskStateTransitionEdge { - cursor: CursorKey! - node: TaskStateTransition! -} - -type TaskStateTransition { - id: ID! - fromState: TaskState - toState: TaskState! - reason: String - createdAt: Datetime! - updatedAt: Datetime! -} - type EvidenceConnection { edges: [EvidenceEdge!]! pageInfo: PageInfo! @@ -2438,32 +2097,6 @@ type Evidence implements Node { state: EvidenceState! filename: String! - stateTransisions( - first: Int - after: CursorKey - last: Int - before: CursorKey - ): EvidenceStateTransitionConnection! @goField(forceResolver: true) - - createdAt: Datetime! - updatedAt: Datetime! -} - -type EvidenceStateTransitionConnection { - edges: [EvidenceStateTransitionEdge!]! - pageInfo: PageInfo! -} - -type EvidenceStateTransitionEdge { - cursor: CursorKey! - node: EvidenceStateTransition! -} - -type EvidenceStateTransition { - id: ID! - fromState: EvidenceState - toState: EvidenceState! - reason: String createdAt: Datetime! updatedAt: Datetime! } @@ -2507,8 +2140,8 @@ type Mutation { deleteOrganization( input: DeleteOrganizationInput! ): DeleteOrganizationPayload! - updateTaskState(input: UpdateTaskStateInput!): UpdateTaskStatePayload! createTask(input: CreateTaskInput!): CreateTaskPayload! + updateTask(input: UpdateTaskInput!): UpdateTaskPayload! deleteTask(input: DeleteTaskInput!): DeleteTaskPayload! createFramework(input: CreateFrameworkInput!): CreateFrameworkPayload! createControl(input: CreateControlInput!): CreateControlPayload! @@ -2805,6 +2438,18 @@ type PolicyEdge { cursor: CursorKey! node: Policy! } + +input UpdateTaskInput { + taskId: ID! + expectedVersion: Int! + name: String + description: String + state: TaskState +} + +type UpdateTaskPayload { + task: Task! +} `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) @@ -2813,83 +2458,6 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...) // region ***************************** args.gotpl ***************************** -func (ec *executionContext) field_Control_stateTransisions_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := ec.field_Control_stateTransisions_argsFirst(ctx, rawArgs) - if err != nil { - return nil, err - } - args["first"] = arg0 - arg1, err := ec.field_Control_stateTransisions_argsAfter(ctx, rawArgs) - if err != nil { - return nil, err - } - args["after"] = arg1 - arg2, err := ec.field_Control_stateTransisions_argsLast(ctx, rawArgs) - if err != nil { - return nil, err - } - args["last"] = arg2 - arg3, err := ec.field_Control_stateTransisions_argsBefore(ctx, rawArgs) - if err != nil { - return nil, err - } - args["before"] = arg3 - return args, nil -} -func (ec *executionContext) field_Control_stateTransisions_argsFirst( - ctx context.Context, - rawArgs map[string]any, -) (*int, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - if tmp, ok := rawArgs["first"]; ok { - return ec.unmarshalOInt2ᚖint(ctx, tmp) - } - - var zeroVal *int - return zeroVal, nil -} - -func (ec *executionContext) field_Control_stateTransisions_argsAfter( - ctx context.Context, - rawArgs map[string]any, -) (*page.CursorKey, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - if tmp, ok := rawArgs["after"]; ok { - return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) - } - - var zeroVal *page.CursorKey - return zeroVal, nil -} - -func (ec *executionContext) field_Control_stateTransisions_argsLast( - ctx context.Context, - rawArgs map[string]any, -) (*int, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - if tmp, ok := rawArgs["last"]; ok { - return ec.unmarshalOInt2ᚖint(ctx, tmp) - } - - var zeroVal *int - return zeroVal, nil -} - -func (ec *executionContext) field_Control_stateTransisions_argsBefore( - ctx context.Context, - rawArgs map[string]any, -) (*page.CursorKey, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - if tmp, ok := rawArgs["before"]; ok { - return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) - } - - var zeroVal *page.CursorKey - return zeroVal, nil -} - func (ec *executionContext) field_Control_tasks_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -2967,83 +2535,6 @@ func (ec *executionContext) field_Control_tasks_argsBefore( return zeroVal, nil } -func (ec *executionContext) field_Evidence_stateTransisions_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := ec.field_Evidence_stateTransisions_argsFirst(ctx, rawArgs) - if err != nil { - return nil, err - } - args["first"] = arg0 - arg1, err := ec.field_Evidence_stateTransisions_argsAfter(ctx, rawArgs) - if err != nil { - return nil, err - } - args["after"] = arg1 - arg2, err := ec.field_Evidence_stateTransisions_argsLast(ctx, rawArgs) - if err != nil { - return nil, err - } - args["last"] = arg2 - arg3, err := ec.field_Evidence_stateTransisions_argsBefore(ctx, rawArgs) - if err != nil { - return nil, err - } - args["before"] = arg3 - return args, nil -} -func (ec *executionContext) field_Evidence_stateTransisions_argsFirst( - ctx context.Context, - rawArgs map[string]any, -) (*int, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - if tmp, ok := rawArgs["first"]; ok { - return ec.unmarshalOInt2ᚖint(ctx, tmp) - } - - var zeroVal *int - return zeroVal, nil -} - -func (ec *executionContext) field_Evidence_stateTransisions_argsAfter( - ctx context.Context, - rawArgs map[string]any, -) (*page.CursorKey, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - if tmp, ok := rawArgs["after"]; ok { - return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) - } - - var zeroVal *page.CursorKey - return zeroVal, nil -} - -func (ec *executionContext) field_Evidence_stateTransisions_argsLast( - ctx context.Context, - rawArgs map[string]any, -) (*int, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - if tmp, ok := rawArgs["last"]; ok { - return ec.unmarshalOInt2ᚖint(ctx, tmp) - } - - var zeroVal *int - return zeroVal, nil -} - -func (ec *executionContext) field_Evidence_stateTransisions_argsBefore( - ctx context.Context, - rawArgs map[string]any, -) (*page.CursorKey, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - if tmp, ok := rawArgs["before"]; ok { - return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) - } - - var zeroVal *page.CursorKey - return zeroVal, nil -} - func (ec *executionContext) field_Framework_controls_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -3512,26 +3003,26 @@ func (ec *executionContext) field_Mutation_updatePolicy_argsInput( return zeroVal, nil } -func (ec *executionContext) field_Mutation_updateTaskState_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Mutation_updateTask_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := ec.field_Mutation_updateTaskState_argsInput(ctx, rawArgs) + arg0, err := ec.field_Mutation_updateTask_argsInput(ctx, rawArgs) if err != nil { return nil, err } args["input"] = arg0 return args, nil } -func (ec *executionContext) field_Mutation_updateTaskState_argsInput( +func (ec *executionContext) field_Mutation_updateTask_argsInput( ctx context.Context, rawArgs map[string]any, -) (types.UpdateTaskStateInput, error) { +) (types.UpdateTaskInput, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) if tmp, ok := rawArgs["input"]; ok { - return ec.unmarshalNUpdateTaskStateInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskStateInput(ctx, tmp) + return ec.unmarshalNUpdateTaskInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskInput(ctx, tmp) } - var zeroVal types.UpdateTaskStateInput + var zeroVal types.UpdateTaskInput return zeroVal, nil } @@ -4012,83 +3503,6 @@ func (ec *executionContext) field_Task_evidences_argsBefore( return zeroVal, nil } -func (ec *executionContext) field_Task_stateTransisions_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := ec.field_Task_stateTransisions_argsFirst(ctx, rawArgs) - if err != nil { - return nil, err - } - args["first"] = arg0 - arg1, err := ec.field_Task_stateTransisions_argsAfter(ctx, rawArgs) - if err != nil { - return nil, err - } - args["after"] = arg1 - arg2, err := ec.field_Task_stateTransisions_argsLast(ctx, rawArgs) - if err != nil { - return nil, err - } - args["last"] = arg2 - arg3, err := ec.field_Task_stateTransisions_argsBefore(ctx, rawArgs) - if err != nil { - return nil, err - } - args["before"] = arg3 - return args, nil -} -func (ec *executionContext) field_Task_stateTransisions_argsFirst( - ctx context.Context, - rawArgs map[string]any, -) (*int, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - if tmp, ok := rawArgs["first"]; ok { - return ec.unmarshalOInt2ᚖint(ctx, tmp) - } - - var zeroVal *int - return zeroVal, nil -} - -func (ec *executionContext) field_Task_stateTransisions_argsAfter( - ctx context.Context, - rawArgs map[string]any, -) (*page.CursorKey, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - if tmp, ok := rawArgs["after"]; ok { - return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) - } - - var zeroVal *page.CursorKey - return zeroVal, nil -} - -func (ec *executionContext) field_Task_stateTransisions_argsLast( - ctx context.Context, - rawArgs map[string]any, -) (*int, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - if tmp, ok := rawArgs["last"]; ok { - return ec.unmarshalOInt2ᚖint(ctx, tmp) - } - - var zeroVal *int - return zeroVal, nil -} - -func (ec *executionContext) field_Task_stateTransisions_argsBefore( - ctx context.Context, - rawArgs map[string]any, -) (*page.CursorKey, error) { - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - if tmp, ok := rawArgs["before"]; ok { - return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) - } - - var zeroVal *page.CursorKey - return zeroVal, nil -} - func (ec *executionContext) field_User_organizations_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -4494,55 +3908,6 @@ func (ec *executionContext) fieldContext_Control_state(_ context.Context, field return fc, nil } -func (ec *executionContext) _Control_stateTransisions(ctx context.Context, field graphql.CollectedField, obj *types.Control) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Control_stateTransisions(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Control().StateTransisions(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey)) - }) - 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.(*types.ControlStateTransitionConnection) - fc.Result = res - return ec.marshalNControlStateTransitionConnection2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlStateTransitionConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Control_stateTransisions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Control", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_ControlStateTransitionConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_ControlStateTransitionConnection_pageInfo(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ControlStateTransitionConnection", field.Name) - }, - } - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Control_stateTransisions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - func (ec *executionContext) _Control_tasks(ctx context.Context, field graphql.CollectedField, obj *types.Control) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Control_tasks(ctx, field) if err != nil { @@ -4843,8 +4208,6 @@ func (ec *executionContext) fieldContext_ControlEdge_node(_ context.Context, fie return ec.fieldContext_Control_description(ctx, field) case "state": return ec.fieldContext_Control_state(ctx, field) - case "stateTransisions": - return ec.fieldContext_Control_stateTransisions(ctx, field) case "tasks": return ec.fieldContext_Control_tasks(ctx, field) case "createdAt": @@ -4858,410 +4221,6 @@ func (ec *executionContext) fieldContext_ControlEdge_node(_ context.Context, fie return fc, nil } -func (ec *executionContext) _ControlStateTransition_id(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransition_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, 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.(gid.GID) - fc.Result = res - return ec.marshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransition_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransition", - 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) _ControlStateTransition_fromState(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransition_fromState(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.FromState, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*coredata.ControlState) - fc.Result = res - return ec.marshalOControlState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐControlState(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransition_fromState(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ControlState does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _ControlStateTransition_toState(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransition_toState(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ToState, 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.(coredata.ControlState) - fc.Result = res - return ec.marshalNControlState2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐControlState(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransition_toState(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ControlState does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _ControlStateTransition_reason(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransition_reason(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Reason, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransition_reason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransition", - 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) _ControlStateTransition_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransition_createdAt(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, 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.(time.Time) - fc.Result = res - return ec.marshalNDatetime2timeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransition_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Datetime does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _ControlStateTransition_updatedAt(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransition_updatedAt(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.UpdatedAt, 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.(time.Time) - fc.Result = res - return ec.marshalNDatetime2timeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransition_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Datetime does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _ControlStateTransitionConnection_edges(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransitionConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransitionConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, 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.([]*types.ControlStateTransitionEdge) - fc.Result = res - return ec.marshalNControlStateTransitionEdge2ᚕᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlStateTransitionEdgeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransitionConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransitionConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "cursor": - return ec.fieldContext_ControlStateTransitionEdge_cursor(ctx, field) - case "node": - return ec.fieldContext_ControlStateTransitionEdge_node(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ControlStateTransitionEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _ControlStateTransitionConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransitionConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransitionConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, 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.(*types.PageInfo) - fc.Result = res - return ec.marshalNPageInfo2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransitionConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransitionConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _ControlStateTransitionEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransitionEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransitionEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, 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.(page.CursorKey) - fc.Result = res - return ec.marshalNCursorKey2githubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransitionEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransitionEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type CursorKey does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _ControlStateTransitionEdge_node(ctx context.Context, field graphql.CollectedField, obj *types.ControlStateTransitionEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ControlStateTransitionEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, 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.(*types.ControlStateTransition) - fc.Result = res - return ec.marshalNControlStateTransition2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlStateTransition(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ControlStateTransitionEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ControlStateTransitionEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_ControlStateTransition_id(ctx, field) - case "fromState": - return ec.fieldContext_ControlStateTransition_fromState(ctx, field) - case "toState": - return ec.fieldContext_ControlStateTransition_toState(ctx, field) - case "reason": - return ec.fieldContext_ControlStateTransition_reason(ctx, field) - case "createdAt": - return ec.fieldContext_ControlStateTransition_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_ControlStateTransition_updatedAt(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ControlStateTransition", field.Name) - }, - } - return fc, nil -} - func (ec *executionContext) _CreateControlPayload_controlEdge(ctx context.Context, field graphql.CollectedField, obj *types.CreateControlPayload) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CreateControlPayload_controlEdge(ctx, field) if err != nil { @@ -6026,55 +4985,6 @@ func (ec *executionContext) fieldContext_Evidence_filename(_ context.Context, fi return fc, nil } -func (ec *executionContext) _Evidence_stateTransisions(ctx context.Context, field graphql.CollectedField, obj *types.Evidence) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Evidence_stateTransisions(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Evidence().StateTransisions(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey)) - }) - 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.(*types.EvidenceStateTransitionConnection) - fc.Result = res - return ec.marshalNEvidenceStateTransitionConnection2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceStateTransitionConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Evidence_stateTransisions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Evidence", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_EvidenceStateTransitionConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_EvidenceStateTransitionConnection_pageInfo(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EvidenceStateTransitionConnection", field.Name) - }, - } - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Evidence_stateTransisions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - func (ec *executionContext) _Evidence_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.Evidence) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Evidence_createdAt(ctx, field) if err != nil { @@ -6326,8 +5236,6 @@ func (ec *executionContext) fieldContext_EvidenceEdge_node(_ context.Context, fi return ec.fieldContext_Evidence_state(ctx, field) case "filename": return ec.fieldContext_Evidence_filename(ctx, field) - case "stateTransisions": - return ec.fieldContext_Evidence_stateTransisions(ctx, field) case "createdAt": return ec.fieldContext_Evidence_createdAt(ctx, field) case "updatedAt": @@ -6339,410 +5247,6 @@ func (ec *executionContext) fieldContext_EvidenceEdge_node(_ context.Context, fi return fc, nil } -func (ec *executionContext) _EvidenceStateTransition_id(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransition_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, 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.(gid.GID) - fc.Result = res - return ec.marshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransition_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransition", - 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) _EvidenceStateTransition_fromState(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransition_fromState(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.FromState, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*coredata.EvidenceState) - fc.Result = res - return ec.marshalOEvidenceState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐEvidenceState(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransition_fromState(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type EvidenceState does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EvidenceStateTransition_toState(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransition_toState(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ToState, 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.(coredata.EvidenceState) - fc.Result = res - return ec.marshalNEvidenceState2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐEvidenceState(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransition_toState(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type EvidenceState does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EvidenceStateTransition_reason(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransition_reason(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Reason, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransition_reason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransition", - 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) _EvidenceStateTransition_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransition_createdAt(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, 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.(time.Time) - fc.Result = res - return ec.marshalNDatetime2timeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransition_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Datetime does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EvidenceStateTransition_updatedAt(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransition_updatedAt(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.UpdatedAt, 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.(time.Time) - fc.Result = res - return ec.marshalNDatetime2timeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransition_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Datetime does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EvidenceStateTransitionConnection_edges(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransitionConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransitionConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, 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.([]*types.EvidenceStateTransitionEdge) - fc.Result = res - return ec.marshalNEvidenceStateTransitionEdge2ᚕᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceStateTransitionEdgeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransitionConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransitionConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "cursor": - return ec.fieldContext_EvidenceStateTransitionEdge_cursor(ctx, field) - case "node": - return ec.fieldContext_EvidenceStateTransitionEdge_node(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EvidenceStateTransitionEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EvidenceStateTransitionConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransitionConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransitionConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, 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.(*types.PageInfo) - fc.Result = res - return ec.marshalNPageInfo2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransitionConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransitionConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EvidenceStateTransitionEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransitionEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransitionEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, 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.(page.CursorKey) - fc.Result = res - return ec.marshalNCursorKey2githubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransitionEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransitionEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type CursorKey does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EvidenceStateTransitionEdge_node(ctx context.Context, field graphql.CollectedField, obj *types.EvidenceStateTransitionEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EvidenceStateTransitionEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, 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.(*types.EvidenceStateTransition) - fc.Result = res - return ec.marshalNEvidenceStateTransition2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceStateTransition(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EvidenceStateTransitionEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EvidenceStateTransitionEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_EvidenceStateTransition_id(ctx, field) - case "fromState": - return ec.fieldContext_EvidenceStateTransition_fromState(ctx, field) - case "toState": - return ec.fieldContext_EvidenceStateTransition_toState(ctx, field) - case "reason": - return ec.fieldContext_EvidenceStateTransition_reason(ctx, field) - case "createdAt": - return ec.fieldContext_EvidenceStateTransition_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_EvidenceStateTransition_updatedAt(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EvidenceStateTransition", field.Name) - }, - } - return fc, nil -} - func (ec *executionContext) _Framework_id(ctx context.Context, field graphql.CollectedField, obj *types.Framework) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Framework_id(ctx, field) if err != nil { @@ -7580,53 +6084,6 @@ func (ec *executionContext) fieldContext_Mutation_deleteOrganization(ctx context return fc, nil } -func (ec *executionContext) _Mutation_updateTaskState(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateTaskState(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateTaskState(rctx, fc.Args["input"].(types.UpdateTaskStateInput)) - }) - 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.(*types.UpdateTaskStatePayload) - fc.Result = res - return ec.marshalNUpdateTaskStatePayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskStatePayload(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_updateTaskState(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "task": - return ec.fieldContext_UpdateTaskStatePayload_task(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UpdateTaskStatePayload", field.Name) - }, - } - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateTaskState_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - func (ec *executionContext) _Mutation_createTask(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_createTask(ctx, field) if err != nil { @@ -7674,6 +6131,53 @@ func (ec *executionContext) fieldContext_Mutation_createTask(ctx context.Context return fc, nil } +func (ec *executionContext) _Mutation_updateTask(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateTask(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateTask(rctx, fc.Args["input"].(types.UpdateTaskInput)) + }) + 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.(*types.UpdateTaskPayload) + fc.Result = res + return ec.marshalNUpdateTaskPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskPayload(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateTask(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "task": + return ec.fieldContext_UpdateTaskPayload_task(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UpdateTaskPayload", field.Name) + }, + } + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateTask_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Mutation_deleteTask(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_deleteTask(ctx, field) if err != nil { @@ -10221,6 +8725,44 @@ func (ec *executionContext) fieldContext_Task_id(_ context.Context, field graphq return fc, nil } +func (ec *executionContext) _Task_version(ctx context.Context, field graphql.CollectedField, obj *types.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_version(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Version, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Task_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Task", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Task_name(ctx context.Context, field graphql.CollectedField, obj *types.Task) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Task_name(ctx, field) if err != nil { @@ -10335,55 +8877,6 @@ func (ec *executionContext) fieldContext_Task_state(_ context.Context, field gra return fc, nil } -func (ec *executionContext) _Task_stateTransisions(ctx context.Context, field graphql.CollectedField, obj *types.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_stateTransisions(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Task().StateTransisions(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey)) - }) - 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.(*types.TaskStateTransitionConnection) - fc.Result = res - return ec.marshalNTaskStateTransitionConnection2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTaskStateTransitionConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Task_stateTransisions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Task", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TaskStateTransitionConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TaskStateTransitionConnection_pageInfo(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskStateTransitionConnection", field.Name) - }, - } - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_stateTransisions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - func (ec *executionContext) _Task_evidences(ctx context.Context, field graphql.CollectedField, obj *types.Task) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Task_evidences(ctx, field) if err != nil { @@ -10674,14 +9167,14 @@ func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field switch field.Name { case "id": return ec.fieldContext_Task_id(ctx, field) + case "version": + return ec.fieldContext_Task_version(ctx, field) case "name": return ec.fieldContext_Task_name(ctx, field) case "description": return ec.fieldContext_Task_description(ctx, field) case "state": return ec.fieldContext_Task_state(ctx, field) - case "stateTransisions": - return ec.fieldContext_Task_stateTransisions(ctx, field) case "evidences": return ec.fieldContext_Task_evidences(ctx, field) case "createdAt": @@ -10695,410 +9188,6 @@ func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field return fc, nil } -func (ec *executionContext) _TaskStateTransition_id(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransition_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, 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.(gid.GID) - fc.Result = res - return ec.marshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransition_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransition", - 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) _TaskStateTransition_fromState(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransition_fromState(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.FromState, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*coredata.TaskState) - fc.Result = res - return ec.marshalOTaskState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐTaskState(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransition_fromState(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TaskState does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _TaskStateTransition_toState(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransition_toState(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ToState, 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.(coredata.TaskState) - fc.Result = res - return ec.marshalNTaskState2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐTaskState(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransition_toState(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TaskState does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _TaskStateTransition_reason(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransition_reason(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Reason, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransition_reason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransition", - 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) _TaskStateTransition_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransition_createdAt(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, 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.(time.Time) - fc.Result = res - return ec.marshalNDatetime2timeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransition_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Datetime does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _TaskStateTransition_updatedAt(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransition) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransition_updatedAt(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.UpdatedAt, 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.(time.Time) - fc.Result = res - return ec.marshalNDatetime2timeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransition_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransition", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Datetime does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _TaskStateTransitionConnection_edges(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransitionConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransitionConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, 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.([]*types.TaskStateTransitionEdge) - fc.Result = res - return ec.marshalNTaskStateTransitionEdge2ᚕᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTaskStateTransitionEdgeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransitionConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransitionConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "cursor": - return ec.fieldContext_TaskStateTransitionEdge_cursor(ctx, field) - case "node": - return ec.fieldContext_TaskStateTransitionEdge_node(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskStateTransitionEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _TaskStateTransitionConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransitionConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransitionConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, 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.(*types.PageInfo) - fc.Result = res - return ec.marshalNPageInfo2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransitionConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransitionConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _TaskStateTransitionEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransitionEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransitionEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, 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.(page.CursorKey) - fc.Result = res - return ec.marshalNCursorKey2githubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransitionEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransitionEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type CursorKey does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _TaskStateTransitionEdge_node(ctx context.Context, field graphql.CollectedField, obj *types.TaskStateTransitionEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskStateTransitionEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, 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.(*types.TaskStateTransition) - fc.Result = res - return ec.marshalNTaskStateTransition2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTaskStateTransition(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_TaskStateTransitionEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskStateTransitionEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_TaskStateTransition_id(ctx, field) - case "fromState": - return ec.fieldContext_TaskStateTransition_fromState(ctx, field) - case "toState": - return ec.fieldContext_TaskStateTransition_toState(ctx, field) - case "reason": - return ec.fieldContext_TaskStateTransition_reason(ctx, field) - case "createdAt": - return ec.fieldContext_TaskStateTransition_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_TaskStateTransition_updatedAt(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskStateTransition", field.Name) - }, - } - return fc, nil -} - func (ec *executionContext) _UpdateControlPayload_control(ctx context.Context, field graphql.CollectedField, obj *types.UpdateControlPayload) (ret graphql.Marshaler) { fc, err := ec.fieldContext_UpdateControlPayload_control(ctx, field) if err != nil { @@ -11144,8 +9233,6 @@ func (ec *executionContext) fieldContext_UpdateControlPayload_control(_ context. return ec.fieldContext_Control_description(ctx, field) case "state": return ec.fieldContext_Control_state(ctx, field) - case "stateTransisions": - return ec.fieldContext_Control_stateTransisions(ctx, field) case "tasks": return ec.fieldContext_Control_tasks(ctx, field) case "createdAt": @@ -11327,6 +9414,62 @@ func (ec *executionContext) fieldContext_UpdatePolicyPayload_policy(_ context.Co return fc, nil } +func (ec *executionContext) _UpdateTaskPayload_task(ctx context.Context, field graphql.CollectedField, obj *types.UpdateTaskPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UpdateTaskPayload_task(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Task, 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.(*types.Task) + fc.Result = res + return ec.marshalNTask2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTask(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UpdateTaskPayload_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UpdateTaskPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "version": + return ec.fieldContext_Task_version(ctx, field) + case "name": + return ec.fieldContext_Task_name(ctx, field) + case "description": + return ec.fieldContext_Task_description(ctx, field) + case "state": + return ec.fieldContext_Task_state(ctx, field) + case "evidences": + return ec.fieldContext_Task_evidences(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Task_updatedAt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _UpdateTaskStatePayload_task(ctx context.Context, field graphql.CollectedField, obj *types.UpdateTaskStatePayload) (ret graphql.Marshaler) { fc, err := ec.fieldContext_UpdateTaskStatePayload_task(ctx, field) if err != nil { @@ -11362,14 +9505,14 @@ func (ec *executionContext) fieldContext_UpdateTaskStatePayload_task(_ context.C switch field.Name { case "id": return ec.fieldContext_Task_id(ctx, field) + case "version": + return ec.fieldContext_Task_version(ctx, field) case "name": return ec.fieldContext_Task_name(ctx, field) case "description": return ec.fieldContext_Task_description(ctx, field) case "state": return ec.fieldContext_Task_state(ctx, field) - case "stateTransisions": - return ec.fieldContext_Task_stateTransisions(ctx, field) case "evidences": return ec.fieldContext_Task_evidences(ctx, field) case "createdAt": @@ -14876,6 +13019,61 @@ func (ec *executionContext) unmarshalInputUpdatePolicyInput(ctx context.Context, return it, nil } +func (ec *executionContext) unmarshalInputUpdateTaskInput(ctx context.Context, obj any) (types.UpdateTaskInput, error) { + var it types.UpdateTaskInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"taskId", "expectedVersion", "name", "description", "state"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "taskId": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("taskId")) + data, err := ec.unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v) + if err != nil { + return it, err + } + it.TaskID = data + case "expectedVersion": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expectedVersion")) + data, err := ec.unmarshalNInt2int(ctx, v) + if err != nil { + return it, err + } + it.ExpectedVersion = 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 "state": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) + data, err := ec.unmarshalOTaskState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐTaskState(ctx, v) + if err != nil { + return it, err + } + it.State = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputUpdateTaskStateInput(ctx context.Context, obj any) (types.UpdateTaskStateInput, error) { var it types.UpdateTaskStateInput asMap := map[string]any{} @@ -15169,37 +13367,6 @@ func (ec *executionContext) _Control(ctx context.Context, sel ast.SelectionSet, if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "stateTransisions": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - res = ec._Control_stateTransisions(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 "tasks": field := field @@ -15352,152 +13519,6 @@ func (ec *executionContext) _ControlEdge(ctx context.Context, sel ast.SelectionS return out } -var controlStateTransitionImplementors = []string{"ControlStateTransition"} - -func (ec *executionContext) _ControlStateTransition(ctx context.Context, sel ast.SelectionSet, obj *types.ControlStateTransition) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, controlStateTransitionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ControlStateTransition") - case "id": - out.Values[i] = ec._ControlStateTransition_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "fromState": - out.Values[i] = ec._ControlStateTransition_fromState(ctx, field, obj) - case "toState": - out.Values[i] = ec._ControlStateTransition_toState(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "reason": - out.Values[i] = ec._ControlStateTransition_reason(ctx, field, obj) - case "createdAt": - out.Values[i] = ec._ControlStateTransition_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updatedAt": - out.Values[i] = ec._ControlStateTransition_updatedAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var controlStateTransitionConnectionImplementors = []string{"ControlStateTransitionConnection"} - -func (ec *executionContext) _ControlStateTransitionConnection(ctx context.Context, sel ast.SelectionSet, obj *types.ControlStateTransitionConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, controlStateTransitionConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ControlStateTransitionConnection") - case "edges": - out.Values[i] = ec._ControlStateTransitionConnection_edges(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "pageInfo": - out.Values[i] = ec._ControlStateTransitionConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var controlStateTransitionEdgeImplementors = []string{"ControlStateTransitionEdge"} - -func (ec *executionContext) _ControlStateTransitionEdge(ctx context.Context, sel ast.SelectionSet, obj *types.ControlStateTransitionEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, controlStateTransitionEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ControlStateTransitionEdge") - case "cursor": - out.Values[i] = ec._ControlStateTransitionEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "node": - out.Values[i] = ec._ControlStateTransitionEdge_node(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - var createControlPayloadImplementors = []string{"CreateControlPayload"} func (ec *executionContext) _CreateControlPayload(ctx context.Context, sel ast.SelectionSet, obj *types.CreateControlPayload) graphql.Marshaler { @@ -16072,37 +14093,6 @@ func (ec *executionContext) _Evidence(ctx context.Context, sel ast.SelectionSet, if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "stateTransisions": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - res = ec._Evidence_stateTransisions(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 "createdAt": out.Values[i] = ec._Evidence_createdAt(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16224,152 +14214,6 @@ func (ec *executionContext) _EvidenceEdge(ctx context.Context, sel ast.Selection return out } -var evidenceStateTransitionImplementors = []string{"EvidenceStateTransition"} - -func (ec *executionContext) _EvidenceStateTransition(ctx context.Context, sel ast.SelectionSet, obj *types.EvidenceStateTransition) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, evidenceStateTransitionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EvidenceStateTransition") - case "id": - out.Values[i] = ec._EvidenceStateTransition_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "fromState": - out.Values[i] = ec._EvidenceStateTransition_fromState(ctx, field, obj) - case "toState": - out.Values[i] = ec._EvidenceStateTransition_toState(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "reason": - out.Values[i] = ec._EvidenceStateTransition_reason(ctx, field, obj) - case "createdAt": - out.Values[i] = ec._EvidenceStateTransition_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updatedAt": - out.Values[i] = ec._EvidenceStateTransition_updatedAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var evidenceStateTransitionConnectionImplementors = []string{"EvidenceStateTransitionConnection"} - -func (ec *executionContext) _EvidenceStateTransitionConnection(ctx context.Context, sel ast.SelectionSet, obj *types.EvidenceStateTransitionConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, evidenceStateTransitionConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EvidenceStateTransitionConnection") - case "edges": - out.Values[i] = ec._EvidenceStateTransitionConnection_edges(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "pageInfo": - out.Values[i] = ec._EvidenceStateTransitionConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var evidenceStateTransitionEdgeImplementors = []string{"EvidenceStateTransitionEdge"} - -func (ec *executionContext) _EvidenceStateTransitionEdge(ctx context.Context, sel ast.SelectionSet, obj *types.EvidenceStateTransitionEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, evidenceStateTransitionEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EvidenceStateTransitionEdge") - case "cursor": - out.Values[i] = ec._EvidenceStateTransitionEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "node": - out.Values[i] = ec._EvidenceStateTransitionEdge_node(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - var frameworkImplementors = []string{"Framework", "Node"} func (ec *executionContext) _Framework(ctx context.Context, sel ast.SelectionSet, obj *types.Framework) graphql.Marshaler { @@ -16628,16 +14472,16 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateTaskState": + case "createTask": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateTaskState(ctx, field) + return ec._Mutation_createTask(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "createTask": + case "updateTask": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createTask(ctx, field) + return ec._Mutation_updateTask(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ @@ -17550,6 +15394,11 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "version": + out.Values[i] = ec._Task_version(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "name": out.Values[i] = ec._Task_name(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -17565,37 +15414,6 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "stateTransisions": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - res = ec._Task_stateTransisions(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 "evidences": field := field @@ -17748,152 +15566,6 @@ func (ec *executionContext) _TaskEdge(ctx context.Context, sel ast.SelectionSet, return out } -var taskStateTransitionImplementors = []string{"TaskStateTransition"} - -func (ec *executionContext) _TaskStateTransition(ctx context.Context, sel ast.SelectionSet, obj *types.TaskStateTransition) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, taskStateTransitionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("TaskStateTransition") - case "id": - out.Values[i] = ec._TaskStateTransition_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "fromState": - out.Values[i] = ec._TaskStateTransition_fromState(ctx, field, obj) - case "toState": - out.Values[i] = ec._TaskStateTransition_toState(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "reason": - out.Values[i] = ec._TaskStateTransition_reason(ctx, field, obj) - case "createdAt": - out.Values[i] = ec._TaskStateTransition_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updatedAt": - out.Values[i] = ec._TaskStateTransition_updatedAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var taskStateTransitionConnectionImplementors = []string{"TaskStateTransitionConnection"} - -func (ec *executionContext) _TaskStateTransitionConnection(ctx context.Context, sel ast.SelectionSet, obj *types.TaskStateTransitionConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, taskStateTransitionConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("TaskStateTransitionConnection") - case "edges": - out.Values[i] = ec._TaskStateTransitionConnection_edges(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "pageInfo": - out.Values[i] = ec._TaskStateTransitionConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var taskStateTransitionEdgeImplementors = []string{"TaskStateTransitionEdge"} - -func (ec *executionContext) _TaskStateTransitionEdge(ctx context.Context, sel ast.SelectionSet, obj *types.TaskStateTransitionEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, taskStateTransitionEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("TaskStateTransitionEdge") - case "cursor": - out.Values[i] = ec._TaskStateTransitionEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "node": - out.Values[i] = ec._TaskStateTransitionEdge_node(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - var updateControlPayloadImplementors = []string{"UpdateControlPayload"} func (ec *executionContext) _UpdateControlPayload(ctx context.Context, sel ast.SelectionSet, obj *types.UpdateControlPayload) graphql.Marshaler { @@ -18050,6 +15722,45 @@ func (ec *executionContext) _UpdatePolicyPayload(ctx context.Context, sel ast.Se return out } +var updateTaskPayloadImplementors = []string{"UpdateTaskPayload"} + +func (ec *executionContext) _UpdateTaskPayload(ctx context.Context, sel ast.SelectionSet, obj *types.UpdateTaskPayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, updateTaskPayloadImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("UpdateTaskPayload") + case "task": + out.Values[i] = ec._UpdateTaskPayload_task(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var updateTaskStatePayloadImplementors = []string{"UpdateTaskStatePayload"} func (ec *executionContext) _UpdateTaskStatePayload(ctx context.Context, sel ast.SelectionSet, obj *types.UpdateTaskStatePayload) graphql.Marshaler { @@ -18885,78 +16596,6 @@ var ( } ) -func (ec *executionContext) marshalNControlStateTransition2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlStateTransition(ctx context.Context, sel ast.SelectionSet, v *types.ControlStateTransition) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._ControlStateTransition(ctx, sel, v) -} - -func (ec *executionContext) marshalNControlStateTransitionConnection2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlStateTransitionConnection(ctx context.Context, sel ast.SelectionSet, v types.ControlStateTransitionConnection) graphql.Marshaler { - return ec._ControlStateTransitionConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNControlStateTransitionConnection2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlStateTransitionConnection(ctx context.Context, sel ast.SelectionSet, v *types.ControlStateTransitionConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._ControlStateTransitionConnection(ctx, sel, v) -} - -func (ec *executionContext) marshalNControlStateTransitionEdge2ᚕᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlStateTransitionEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*types.ControlStateTransitionEdge) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNControlStateTransitionEdge2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlStateTransitionEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNControlStateTransitionEdge2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlStateTransitionEdge(ctx context.Context, sel ast.SelectionSet, v *types.ControlStateTransitionEdge) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._ControlStateTransitionEdge(ctx, sel, v) -} - func (ec *executionContext) unmarshalNCreateControlInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlInput(ctx context.Context, v any) (types.CreateControlInput, error) { res, err := ec.unmarshalInputCreateControlInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -19335,78 +16974,6 @@ var ( } ) -func (ec *executionContext) marshalNEvidenceStateTransition2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceStateTransition(ctx context.Context, sel ast.SelectionSet, v *types.EvidenceStateTransition) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._EvidenceStateTransition(ctx, sel, v) -} - -func (ec *executionContext) marshalNEvidenceStateTransitionConnection2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceStateTransitionConnection(ctx context.Context, sel ast.SelectionSet, v types.EvidenceStateTransitionConnection) graphql.Marshaler { - return ec._EvidenceStateTransitionConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNEvidenceStateTransitionConnection2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceStateTransitionConnection(ctx context.Context, sel ast.SelectionSet, v *types.EvidenceStateTransitionConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._EvidenceStateTransitionConnection(ctx, sel, v) -} - -func (ec *executionContext) marshalNEvidenceStateTransitionEdge2ᚕᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceStateTransitionEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*types.EvidenceStateTransitionEdge) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNEvidenceStateTransitionEdge2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceStateTransitionEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNEvidenceStateTransitionEdge2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceStateTransitionEdge(ctx context.Context, sel ast.SelectionSet, v *types.EvidenceStateTransitionEdge) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._EvidenceStateTransitionEdge(ctx, sel, v) -} - func (ec *executionContext) marshalNFramework2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐFramework(ctx context.Context, sel ast.SelectionSet, v *types.Framework) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -20007,78 +17574,6 @@ var ( } ) -func (ec *executionContext) marshalNTaskStateTransition2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTaskStateTransition(ctx context.Context, sel ast.SelectionSet, v *types.TaskStateTransition) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._TaskStateTransition(ctx, sel, v) -} - -func (ec *executionContext) marshalNTaskStateTransitionConnection2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTaskStateTransitionConnection(ctx context.Context, sel ast.SelectionSet, v types.TaskStateTransitionConnection) graphql.Marshaler { - return ec._TaskStateTransitionConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNTaskStateTransitionConnection2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTaskStateTransitionConnection(ctx context.Context, sel ast.SelectionSet, v *types.TaskStateTransitionConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._TaskStateTransitionConnection(ctx, sel, v) -} - -func (ec *executionContext) marshalNTaskStateTransitionEdge2ᚕᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTaskStateTransitionEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*types.TaskStateTransitionEdge) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNTaskStateTransitionEdge2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTaskStateTransitionEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNTaskStateTransitionEdge2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTaskStateTransitionEdge(ctx context.Context, sel ast.SelectionSet, v *types.TaskStateTransitionEdge) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._TaskStateTransitionEdge(ctx, sel, v) -} - func (ec *executionContext) unmarshalNUpdateControlInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateControlInput(ctx context.Context, v any) (types.UpdateControlInput, error) { res, err := ec.unmarshalInputUpdateControlInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -20155,23 +17650,23 @@ func (ec *executionContext) marshalNUpdatePolicyPayload2ᚖgithubᚗcomᚋgetpro return ec._UpdatePolicyPayload(ctx, sel, v) } -func (ec *executionContext) unmarshalNUpdateTaskStateInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskStateInput(ctx context.Context, v any) (types.UpdateTaskStateInput, error) { - res, err := ec.unmarshalInputUpdateTaskStateInput(ctx, v) +func (ec *executionContext) unmarshalNUpdateTaskInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskInput(ctx context.Context, v any) (types.UpdateTaskInput, error) { + res, err := ec.unmarshalInputUpdateTaskInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNUpdateTaskStatePayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskStatePayload(ctx context.Context, sel ast.SelectionSet, v types.UpdateTaskStatePayload) graphql.Marshaler { - return ec._UpdateTaskStatePayload(ctx, sel, &v) +func (ec *executionContext) marshalNUpdateTaskPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskPayload(ctx context.Context, sel ast.SelectionSet, v types.UpdateTaskPayload) graphql.Marshaler { + return ec._UpdateTaskPayload(ctx, sel, &v) } -func (ec *executionContext) marshalNUpdateTaskStatePayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskStatePayload(ctx context.Context, sel ast.SelectionSet, v *types.UpdateTaskStatePayload) graphql.Marshaler { +func (ec *executionContext) marshalNUpdateTaskPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateTaskPayload(ctx context.Context, sel ast.SelectionSet, v *types.UpdateTaskPayload) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._UpdateTaskStatePayload(ctx, sel, v) + return ec._UpdateTaskPayload(ctx, sel, v) } func (ec *executionContext) unmarshalNUpdateVendorInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUpdateVendorInput(ctx context.Context, v any) (types.UpdateVendorInput, error) { @@ -20632,36 +18127,6 @@ func (ec *executionContext) marshalODatetime2ᚖtimeᚐTime(ctx context.Context, return res } -func (ec *executionContext) unmarshalOEvidenceState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐEvidenceState(ctx context.Context, v any) (*coredata.EvidenceState, error) { - if v == nil { - return nil, nil - } - tmp, err := graphql.UnmarshalString(v) - res := unmarshalOEvidenceState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐEvidenceState[tmp] - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOEvidenceState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐEvidenceState(ctx context.Context, sel ast.SelectionSet, v *coredata.EvidenceState) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalString(marshalOEvidenceState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐEvidenceState[*v]) - return res -} - -var ( - unmarshalOEvidenceState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐEvidenceState = map[string]coredata.EvidenceState{ - "VALID": coredata.EvidenceStateValid, - "INVALID": coredata.EvidenceStateInvalid, - "EXPIRED": coredata.EvidenceStateExpired, - } - marshalOEvidenceState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐEvidenceState = map[coredata.EvidenceState]string{ - coredata.EvidenceStateValid: "VALID", - coredata.EvidenceStateInvalid: "INVALID", - coredata.EvidenceStateExpired: "EXPIRED", - } -) - func (ec *executionContext) unmarshalOID2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx context.Context, v any) (*gid.GID, error) { if v == nil { return nil, nil diff --git a/pkg/server/api/console/v1/types/control_state_transition.go b/pkg/server/api/console/v1/types/control_state_transition.go deleted file mode 100644 index 250c982c2..000000000 --- a/pkg/server/api/console/v1/types/control_state_transition.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2025 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package types - -import ( - "github.com/getprobo/probo/pkg/page" - "github.com/getprobo/probo/pkg/probo/coredata" -) - -func NewControlStateTransitionConnection( - p *page.Page[*coredata.ControlStateTransition], -) *ControlStateTransitionConnection { - var edges = make([]*ControlStateTransitionEdge, len(p.Data)) - - for i := range edges { - edges[i] = NewControlStateTransitionEdge(p.Data[i]) - } - - return &ControlStateTransitionConnection{ - Edges: edges, - PageInfo: NewPageInfo(p), - } -} - -func NewControlStateTransitionEdge(cst *coredata.ControlStateTransition) *ControlStateTransitionEdge { - return &ControlStateTransitionEdge{ - Cursor: cst.CursorKey(), - Node: NewControlStateTransition(cst), - } -} - -func NewControlStateTransition(cst *coredata.ControlStateTransition) *ControlStateTransition { - var fromState *coredata.ControlState - if cst.FromState != nil { - fromState = cst.FromState - } - - return &ControlStateTransition{ - ID: cst.ID, - FromState: fromState, - ToState: cst.ToState, - Reason: cst.Reason, - CreatedAt: cst.CreatedAt, - UpdatedAt: cst.UpdatedAt, - } -} diff --git a/pkg/server/api/console/v1/types/evidence_state_transition.go b/pkg/server/api/console/v1/types/evidence_state_transition.go deleted file mode 100644 index 4a43738f9..000000000 --- a/pkg/server/api/console/v1/types/evidence_state_transition.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2025 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package types - -import ( - "github.com/getprobo/probo/pkg/page" - "github.com/getprobo/probo/pkg/probo/coredata" -) - -func NewEvidenceStateTransitionConnection( - p *page.Page[*coredata.EvidenceStateTransition], -) *EvidenceStateTransitionConnection { - var edges = make([]*EvidenceStateTransitionEdge, len(p.Data)) - - for i := range edges { - edges[i] = NewEvidenceStateTransitionEdge(p.Data[i]) - } - - return &EvidenceStateTransitionConnection{ - Edges: edges, - PageInfo: NewPageInfo(p), - } -} - -func NewEvidenceStateTransitionEdge(est *coredata.EvidenceStateTransition) *EvidenceStateTransitionEdge { - return &EvidenceStateTransitionEdge{ - Cursor: est.CursorKey(), - Node: NewEvidenceStateTransition(est), - } -} - -func NewEvidenceStateTransition(est *coredata.EvidenceStateTransition) *EvidenceStateTransition { - var fromState *coredata.EvidenceState - if est.FromState != nil { - fromState = est.FromState - } - - return &EvidenceStateTransition{ - ID: est.ID, - FromState: fromState, - ToState: est.ToState, - Reason: est.Reason, - CreatedAt: est.CreatedAt, - UpdatedAt: est.UpdatedAt, - } -} diff --git a/pkg/server/api/console/v1/types/task.go b/pkg/server/api/console/v1/types/task.go index 01e8f0ffc..f51fb725d 100644 --- a/pkg/server/api/console/v1/types/task.go +++ b/pkg/server/api/console/v1/types/task.go @@ -47,5 +47,6 @@ func NewTask(t *coredata.Task) *Task { State: t.State, CreatedAt: t.CreatedAt, UpdatedAt: t.UpdatedAt, + Version: t.Version, } } diff --git a/pkg/server/api/console/v1/types/task_state_transition.go b/pkg/server/api/console/v1/types/task_state_transition.go deleted file mode 100644 index 673403034..000000000 --- a/pkg/server/api/console/v1/types/task_state_transition.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2025 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -package types - -import ( - "github.com/getprobo/probo/pkg/page" - "github.com/getprobo/probo/pkg/probo/coredata" -) - -func NewTaskStateTransitionConnection( - p *page.Page[*coredata.TaskStateTransition], -) *TaskStateTransitionConnection { - var edges = make([]*TaskStateTransitionEdge, len(p.Data)) - - for i := range edges { - edges[i] = NewTaskStateTransitionEdge(p.Data[i]) - } - - return &TaskStateTransitionConnection{ - Edges: edges, - PageInfo: NewPageInfo(p), - } -} - -func NewTaskStateTransitionEdge(tst *coredata.TaskStateTransition) *TaskStateTransitionEdge { - return &TaskStateTransitionEdge{ - Cursor: tst.CursorKey(), - Node: NewTaskStateTransition(tst), - } -} - -func NewTaskStateTransition(tst *coredata.TaskStateTransition) *TaskStateTransition { - var fromState *coredata.TaskState - if tst.FromState != nil { - fromState = tst.FromState - } - - return &TaskStateTransition{ - ID: tst.ID, - FromState: fromState, - ToState: tst.ToState, - Reason: tst.Reason, - CreatedAt: tst.CreatedAt, - UpdatedAt: tst.UpdatedAt, - } -} diff --git a/pkg/server/api/console/v1/types/types.go b/pkg/server/api/console/v1/types/types.go index aa9307a22..b0a8da9dc 100644 --- a/pkg/server/api/console/v1/types/types.go +++ b/pkg/server/api/console/v1/types/types.go @@ -17,16 +17,15 @@ type Node interface { } type Control struct { - ID gid.GID `json:"id"` - Version int `json:"version"` - Category string `json:"category"` - Name string `json:"name"` - Description string `json:"description"` - State coredata.ControlState `json:"state"` - StateTransisions *ControlStateTransitionConnection `json:"stateTransisions"` - Tasks *TaskConnection `json:"tasks"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + ID gid.GID `json:"id"` + Version int `json:"version"` + Category string `json:"category"` + Name string `json:"name"` + Description string `json:"description"` + State coredata.ControlState `json:"state"` + Tasks *TaskConnection `json:"tasks"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` } func (Control) IsNode() {} @@ -42,25 +41,6 @@ type ControlEdge struct { Node *Control `json:"node"` } -type ControlStateTransition struct { - ID gid.GID `json:"id"` - FromState *coredata.ControlState `json:"fromState,omitempty"` - ToState coredata.ControlState `json:"toState"` - Reason *string `json:"reason,omitempty"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -type ControlStateTransitionConnection struct { - Edges []*ControlStateTransitionEdge `json:"edges"` - PageInfo *PageInfo `json:"pageInfo"` -} - -type ControlStateTransitionEdge struct { - Cursor page.CursorKey `json:"cursor"` - Node *ControlStateTransition `json:"node"` -} - type CreateControlInput struct { FrameworkID gid.GID `json:"frameworkId"` Name string `json:"name"` @@ -191,15 +171,14 @@ type DeleteVendorPayload struct { } type Evidence struct { - ID gid.GID `json:"id"` - FileURL string `json:"fileUrl"` - MimeType string `json:"mimeType"` - Size int `json:"size"` - State coredata.EvidenceState `json:"state"` - Filename string `json:"filename"` - StateTransisions *EvidenceStateTransitionConnection `json:"stateTransisions"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + ID gid.GID `json:"id"` + FileURL string `json:"fileUrl"` + MimeType string `json:"mimeType"` + Size int `json:"size"` + State coredata.EvidenceState `json:"state"` + Filename string `json:"filename"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` } func (Evidence) IsNode() {} @@ -215,25 +194,6 @@ type EvidenceEdge struct { Node *Evidence `json:"node"` } -type EvidenceStateTransition struct { - ID gid.GID `json:"id"` - FromState *coredata.EvidenceState `json:"fromState,omitempty"` - ToState coredata.EvidenceState `json:"toState"` - Reason *string `json:"reason,omitempty"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -type EvidenceStateTransitionConnection struct { - Edges []*EvidenceStateTransitionEdge `json:"edges"` - PageInfo *PageInfo `json:"pageInfo"` -} - -type EvidenceStateTransitionEdge struct { - Cursor page.CursorKey `json:"cursor"` - Node *EvidenceStateTransition `json:"node"` -} - type Framework struct { ID gid.GID `json:"id"` Version int `json:"version"` @@ -350,14 +310,14 @@ type Session struct { } type Task struct { - ID gid.GID `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - State coredata.TaskState `json:"state"` - StateTransisions *TaskStateTransitionConnection `json:"stateTransisions"` - Evidences *EvidenceConnection `json:"evidences"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + ID gid.GID `json:"id"` + Version int `json:"version"` + Name string `json:"name"` + Description string `json:"description"` + State coredata.TaskState `json:"state"` + Evidences *EvidenceConnection `json:"evidences"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` } func (Task) IsNode() {} @@ -373,25 +333,6 @@ type TaskEdge struct { Node *Task `json:"node"` } -type TaskStateTransition struct { - ID gid.GID `json:"id"` - FromState *coredata.TaskState `json:"fromState,omitempty"` - ToState coredata.TaskState `json:"toState"` - Reason *string `json:"reason,omitempty"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -type TaskStateTransitionConnection struct { - Edges []*TaskStateTransitionEdge `json:"edges"` - PageInfo *PageInfo `json:"pageInfo"` -} - -type TaskStateTransitionEdge struct { - Cursor page.CursorKey `json:"cursor"` - Node *TaskStateTransition `json:"node"` -} - type UpdateControlInput struct { ID gid.GID `json:"id"` ExpectedVersion int `json:"expectedVersion"` @@ -443,6 +384,18 @@ type UpdatePolicyPayload struct { Policy *Policy `json:"policy"` } +type UpdateTaskInput struct { + TaskID gid.GID `json:"taskId"` + ExpectedVersion int `json:"expectedVersion"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + State *coredata.TaskState `json:"state,omitempty"` +} + +type UpdateTaskPayload struct { + Task *Task `json:"task"` +} + type UpdateTaskStateInput struct { TaskID gid.GID `json:"taskId"` State coredata.TaskState `json:"state"` diff --git a/pkg/server/api/console/v1/v1_resolver.go b/pkg/server/api/console/v1/v1_resolver.go index f4a120a95..e69857123 100644 --- a/pkg/server/api/console/v1/v1_resolver.go +++ b/pkg/server/api/console/v1/v1_resolver.go @@ -18,19 +18,6 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -// StateTransisions is the resolver for the stateTransisions field. -func (r *controlResolver) StateTransisions(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.ControlStateTransitionConnection, error) { - svc := r.proboSvc.WithTenant(obj.ID.TenantID()) - cursor := types.NewCursor(first, after, last, before) - - page, err := svc.ListControlStateTransitions(ctx, obj.ID, cursor) - if err != nil { - return nil, fmt.Errorf("cannot list control tasks: %w", err) - } - - return types.NewControlStateTransitionConnection(page), nil -} - // Tasks is the resolver for the tasks field. func (r *controlResolver) Tasks(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TaskConnection, error) { svc := r.proboSvc.WithTenant(obj.ID.TenantID()) @@ -56,19 +43,6 @@ func (r *evidenceResolver) FileURL(ctx context.Context, obj *types.Evidence) (st return *fileURL, nil } -// StateTransisions is the resolver for the stateTransisions field. -func (r *evidenceResolver) StateTransisions(ctx context.Context, obj *types.Evidence, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.EvidenceStateTransitionConnection, error) { - svc := r.proboSvc.WithTenant(obj.ID.TenantID()) - cursor := types.NewCursor(first, after, last, before) - - page, err := svc.ListEvidenceStateTransitions(ctx, obj.ID, cursor) - if err != nil { - return nil, fmt.Errorf("cannot list evidence state transitions: %w", err) - } - - return types.NewEvidenceStateTransitionConnection(page), nil -} - // Controls is the resolver for the controls field. func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.ControlConnection, error) { svc := r.proboSvc.WithTenant(obj.ID.TenantID()) @@ -226,24 +200,6 @@ func (r *mutationResolver) DeleteOrganization(ctx context.Context, input types.D panic(fmt.Errorf("not implemented: DeleteOrganization - deleteOrganization")) } -// UpdateTaskState is the resolver for the updateTaskState field. -func (r *mutationResolver) UpdateTaskState(ctx context.Context, input types.UpdateTaskStateInput) (*types.UpdateTaskStatePayload, error) { - svc := r.proboSvc.WithTenant(input.TaskID.TenantID()) - - task, err := svc.UpdateTaskState(ctx, probo.UpdateTaskStateRequest{ - TaskID: input.TaskID, - State: input.State, - Reason: nil, - }) - if err != nil { - return nil, fmt.Errorf("cannot update task state: %w", err) - } - - return &types.UpdateTaskStatePayload{ - Task: types.NewTask(task), - }, nil -} - // CreateTask is the resolver for the createTask field. func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTaskInput) (*types.CreateTaskPayload, error) { svc := r.proboSvc.WithTenant(input.ControlID.TenantID()) @@ -262,6 +218,26 @@ func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTas }, nil } +// UpdateTask is the resolver for the updateTask field. +func (r *mutationResolver) UpdateTask(ctx context.Context, input types.UpdateTaskInput) (*types.UpdateTaskPayload, error) { + svc := r.proboSvc.WithTenant(input.TaskID.TenantID()) + + task, err := svc.UpdateTask(ctx, probo.UpdateTaskRequest{ + ID: input.TaskID, + ExpectedVersion: input.ExpectedVersion, + Name: input.Name, + Description: input.Description, + State: input.State, + }) + if err != nil { + return nil, fmt.Errorf("cannot update task: %w", err) + } + + return &types.UpdateTaskPayload{ + Task: types.NewTask(task), + }, nil +} + // DeleteTask is the resolver for the deleteTask field. func (r *mutationResolver) DeleteTask(ctx context.Context, input types.DeleteTaskInput) (*types.DeleteTaskPayload, error) { svc := r.proboSvc.WithTenant(input.TaskID.TenantID()) @@ -589,19 +565,6 @@ func (r *queryResolver) Viewer(ctx context.Context) (*types.User, error) { return types.NewUser(user), nil } -// StateTransisions is the resolver for the stateTransisions field. -func (r *taskResolver) StateTransisions(ctx context.Context, obj *types.Task, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TaskStateTransitionConnection, error) { - svc := r.proboSvc.WithTenant(obj.ID.TenantID()) - cursor := types.NewCursor(first, after, last, before) - - page, err := svc.ListTaskStateTransitions(ctx, obj.ID, cursor) - if err != nil { - return nil, fmt.Errorf("cannot list control tasks: %w", err) - } - - return types.NewTaskStateTransitionConnection(page), nil -} - // Evidences is the resolver for the evidences field. func (r *taskResolver) Evidences(ctx context.Context, obj *types.Task, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.EvidenceConnection, error) { svc := r.proboSvc.WithTenant(obj.ID.TenantID())