Add settins connector view
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
useMutation,
|
||||
} from "react-relay";
|
||||
import { useParams } from "react-router";
|
||||
import { Link } from "react-router";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
@@ -41,6 +42,21 @@ import type { SettingsViewRemoveUserMutation as SettingsViewRemoveUserMutationTy
|
||||
import { PageTemplate } from "@/components/PageTemplate";
|
||||
import { SettingsViewSkeleton } from "./SettingsPage";
|
||||
|
||||
// Define the connector type until the generated type is available
|
||||
interface Connector {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
interface AvailableConnector {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
const settingsViewQuery = graphql`
|
||||
query SettingsViewQuery($organizationID: ID!) {
|
||||
organization: node(id: $organizationID) {
|
||||
@@ -58,6 +74,16 @@ const settingsViewQuery = graphql`
|
||||
}
|
||||
}
|
||||
}
|
||||
connectors(first: 100) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
type
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,6 +127,7 @@ function SettingsViewContent({
|
||||
const data = usePreloadedQuery(settingsViewQuery, queryRef);
|
||||
const organization = data.organization;
|
||||
const users = organization.users?.edges.map((edge) => edge.node) || [];
|
||||
const connectors = (organization as any).connectors?.edges.map((edge: any) => edge.node) || [];
|
||||
const { toast } = useToast();
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
@@ -115,6 +142,18 @@ function SettingsViewContent({
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
const [isRemoving, setIsRemoving] = useState(false);
|
||||
|
||||
// Available connectors
|
||||
const availableConnectors: AvailableConnector[] = [
|
||||
{ id: "github", name: "GitHub", type: "oauth2", description: "Connect to GitHub repositories and issues" },
|
||||
{ id: "slack", name: "Slack", type: "oauth2", description: "Connect to Slack workspace and channels" },
|
||||
];
|
||||
|
||||
// Filter out connectors that are already connected
|
||||
const connectedConnectorIds = connectors.map((connector: Connector) => connector.name);
|
||||
const notConnectedConnectors = availableConnectors.filter(
|
||||
connector => !connectedConnectorIds.includes(connector.id)
|
||||
);
|
||||
|
||||
const [updateOrganization] =
|
||||
useMutation<SettingsViewUpdateOrganizationMutationType>(
|
||||
updateOrganizationMutation
|
||||
@@ -129,7 +168,7 @@ function SettingsViewContent({
|
||||
const { organizationId } = useParams();
|
||||
const [, loadQuery] =
|
||||
useQueryLoader<SettingsViewQueryType>(settingsViewQuery);
|
||||
|
||||
|
||||
const handleUpdateName = () => {
|
||||
updateOrganization({
|
||||
variables: {
|
||||
@@ -444,6 +483,96 @@ function SettingsViewContent({
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between">
|
||||
<div>
|
||||
<CardTitle>Integrations</CardTitle>
|
||||
<CardDescription>
|
||||
Connect to third-party services to enhance your workflow
|
||||
</CardDescription>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-6">
|
||||
{connectors.length > 0 && (
|
||||
<div>
|
||||
<h3 className="mb-4 text-sm font-medium">Connected services</h3>
|
||||
<div className="space-y-4">
|
||||
{connectors.map((connector: Connector) => (
|
||||
<div
|
||||
key={connector.id}
|
||||
className="flex items-center justify-between rounded-lg border p-3 shadow-xs"
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-lg border bg-subtle-bg">
|
||||
<Building2 className="h-5 w-5 text-tertiary" />
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">
|
||||
{connector.name}
|
||||
</span>
|
||||
<span className="text-sm text-tertiary">
|
||||
{connector.type} · Connected on {new Date(connector.createdAt).toLocaleDateString()}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{notConnectedConnectors.length > 0 && (
|
||||
<div>
|
||||
<h3 className="mb-4 text-sm font-medium">Available services</h3>
|
||||
<div className="space-y-4">
|
||||
{notConnectedConnectors.map((connector) => (
|
||||
<div
|
||||
key={connector.id}
|
||||
className="flex items-center justify-between rounded-lg border p-3 shadow-xs"
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-lg border bg-subtle-bg">
|
||||
<Building2 className="h-5 w-5 text-tertiary" />
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">
|
||||
{connector.name}
|
||||
</span>
|
||||
<span className="text-sm text-tertiary">
|
||||
{connector.description}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<a
|
||||
href={`${process.env.API_SERVER_HOST}/api/console/v1/connectors/initiate?organization_id=${encodeURIComponent(organization.id)}&connector_id=${encodeURIComponent(connector.id)}&continue=${encodeURIComponent(window.location.href)}`}
|
||||
className="inline-flex items-center justify-center h-9 px-3 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground"
|
||||
>
|
||||
Connect
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{connectors.length === 0 && notConnectedConnectors.length === 0 && (
|
||||
<div className="flex flex-col items-center justify-center p-8 text-center">
|
||||
<div className="rounded-full bg-subtle-bg p-3">
|
||||
<Building2 className="h-6 w-6 text-tertiary" />
|
||||
</div>
|
||||
<h3 className="mt-4 text-lg font-medium">No integrations available</h3>
|
||||
<p className="mt-2 text-sm text-tertiary">
|
||||
There are currently no integrations available for your workspace.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<Dialog open={isEditNameOpen} onOpenChange={setIsEditNameOpen}>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<d22ffd34989ddeb523e19aab24261e58>>
|
||||
* @generated SignedSource<<302c6e908c1aea64db4820b83e5e2bcd>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -14,6 +14,16 @@ export type SettingsViewQuery$variables = {
|
||||
};
|
||||
export type SettingsViewQuery$data = {
|
||||
readonly organization: {
|
||||
readonly connectors?: {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly createdAt: string;
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly type: string;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
readonly id: string;
|
||||
readonly logoUrl?: string | null | undefined;
|
||||
readonly name?: string;
|
||||
@@ -57,15 +67,30 @@ v2 = {
|
||||
"storageKey": null
|
||||
},
|
||||
v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
"value": 100
|
||||
}
|
||||
],
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
v6 = {
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -75,13 +100,7 @@ v3 = {
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
"value": 100
|
||||
}
|
||||
],
|
||||
"args": (v4/*: any*/),
|
||||
"concreteType": "UserConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "users",
|
||||
@@ -118,13 +137,7 @@ v3 = {
|
||||
"name": "email",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
}
|
||||
(v5/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -133,6 +146,49 @@ v3 = {
|
||||
}
|
||||
],
|
||||
"storageKey": "users(first:100)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v4/*: any*/),
|
||||
"concreteType": "ConnectorConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "connectors",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ConnectorEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Connector",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "type",
|
||||
"storageKey": null
|
||||
},
|
||||
(v5/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": "connectors(first:100)"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
@@ -154,7 +210,7 @@ return {
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/)
|
||||
(v6/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -184,23 +240,23 @@ return {
|
||||
"storageKey": null
|
||||
},
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/)
|
||||
(v6/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "1749c3e17b6efd13be678a0e968b7ac4",
|
||||
"cacheID": "e243498081f3875e74172abba80a88e8",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "SettingsViewQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query SettingsViewQuery(\n $organizationID: ID!\n) {\n organization: node(id: $organizationID) {\n __typename\n id\n ... on Organization {\n name\n logoUrl\n users(first: 100) {\n edges {\n node {\n id\n fullName\n email\n createdAt\n }\n }\n }\n }\n }\n}\n"
|
||||
"text": "query SettingsViewQuery(\n $organizationID: ID!\n) {\n organization: node(id: $organizationID) {\n __typename\n id\n ... on Organization {\n name\n logoUrl\n users(first: 100) {\n edges {\n node {\n id\n fullName\n email\n createdAt\n }\n }\n }\n connectors(first: 100) {\n edges {\n node {\n id\n name\n type\n createdAt\n }\n }\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "147757d21500b3eb42848ebe8a43bd9f";
|
||||
(node as any).hash = "52b24e3845bb31016ddad6f815be1cdb";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -19,14 +19,16 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
)
|
||||
|
||||
type (
|
||||
ProtocolType string
|
||||
|
||||
Connector interface {
|
||||
Initiate(ctx context.Context, connectorID string, organizationID string, r *http.Request) (string, error)
|
||||
Complete(ctx context.Context, connectorID string, organizationID string, r *http.Request) (Connection, error)
|
||||
Initiate(ctx context.Context, connectorID string, organizationID gid.GID, r *http.Request) (string, error)
|
||||
Complete(ctx context.Context, connectorID string, organizationID gid.GID, r *http.Request) (Connection, error)
|
||||
}
|
||||
|
||||
Connection interface {
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/statelesstoken"
|
||||
)
|
||||
|
||||
@@ -65,8 +66,8 @@ var (
|
||||
OAuth2TokenTTL = 10 * time.Minute
|
||||
)
|
||||
|
||||
func (c *OAuth2Connector) Initiate(ctx context.Context, connectorID string, organizationID string, r *http.Request) (string, error) {
|
||||
stateData := OAuth2State{OrganizationID: organizationID, ConnectorID: connectorID}
|
||||
func (c *OAuth2Connector) Initiate(ctx context.Context, connectorID string, organizationID gid.GID, r *http.Request) (string, error) {
|
||||
stateData := OAuth2State{OrganizationID: organizationID.String(), ConnectorID: connectorID}
|
||||
state, err := statelesstoken.NewToken(c.ClientSecret, OAuth2TokenType, OAuth2TokenTTL, stateData)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot create state token: %w", err)
|
||||
@@ -78,7 +79,7 @@ func (c *OAuth2Connector) Initiate(ctx context.Context, connectorID string, orga
|
||||
}
|
||||
|
||||
redirectQuery := url.Values{}
|
||||
redirectQuery.Set("organization_id", organizationID)
|
||||
redirectQuery.Set("organization_id", organizationID.String())
|
||||
redirectQuery.Set("connector_id", connectorID)
|
||||
|
||||
redirectURI.RawQuery = redirectQuery.Encode()
|
||||
@@ -100,7 +101,7 @@ func (c *OAuth2Connector) Initiate(ctx context.Context, connectorID string, orga
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
func (c *OAuth2Connector) Complete(ctx context.Context, connectorID string, organizationID string, r *http.Request) (Connection, error) {
|
||||
func (c *OAuth2Connector) Complete(ctx context.Context, connectorID string, organizationID gid.GID, r *http.Request) (Connection, error) {
|
||||
code := r.URL.Query().Get("code")
|
||||
if code == "" {
|
||||
return nil, fmt.Errorf("no code in request")
|
||||
@@ -116,7 +117,7 @@ func (c *OAuth2Connector) Complete(ctx context.Context, connectorID string, orga
|
||||
return nil, fmt.Errorf("cannot validate state token: %w", err)
|
||||
}
|
||||
|
||||
if payload.Data.OrganizationID != organizationID {
|
||||
if payload.Data.OrganizationID != organizationID.String() {
|
||||
return nil, fmt.Errorf("invalid organization ID")
|
||||
}
|
||||
|
||||
@@ -130,7 +131,7 @@ func (c *OAuth2Connector) Complete(ctx context.Context, connectorID string, orga
|
||||
}
|
||||
|
||||
redirectQuery := url.Values{}
|
||||
redirectQuery.Set("organization_id", organizationID)
|
||||
redirectQuery.Set("organization_id", organizationID.String())
|
||||
redirectQuery.Set("connector_id", connectorID)
|
||||
|
||||
redirectURI.RawQuery = redirectQuery.Encode()
|
||||
|
||||
@@ -19,6 +19,8 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -54,7 +56,7 @@ func (cr *ConnectorRegistry) Get(connectorID string) (Connector, error) {
|
||||
return connector, nil
|
||||
}
|
||||
|
||||
func (cr *ConnectorRegistry) Initiate(ctx context.Context, connectorID string, organizationID string, r *http.Request) (string, error) {
|
||||
func (cr *ConnectorRegistry) Initiate(ctx context.Context, connectorID string, organizationID gid.GID, r *http.Request) (string, error) {
|
||||
connector, err := cr.Get(connectorID)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot initiate connector: %w", err)
|
||||
@@ -63,7 +65,7 @@ func (cr *ConnectorRegistry) Initiate(ctx context.Context, connectorID string, o
|
||||
return connector.Initiate(ctx, connectorID, organizationID, r)
|
||||
}
|
||||
|
||||
func (cr *ConnectorRegistry) Complete(ctx context.Context, connectorID string, organizationID string, r *http.Request) (Connection, error) {
|
||||
func (cr *ConnectorRegistry) Complete(ctx context.Context, connectorID string, organizationID gid.GID, r *http.Request) (Connection, error) {
|
||||
connector, err := cr.Get(connectorID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot complete connector: %w", err)
|
||||
|
||||
@@ -18,11 +18,13 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"github.com/getprobo/probo/pkg/connector"
|
||||
"github.com/getprobo/probo/pkg/crypto/cipher"
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
@@ -38,8 +40,65 @@ type (
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
Connectors []*Connector
|
||||
)
|
||||
|
||||
func (c *Connectors) LoadWithoutDecryptedConnectionByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[ConnectorOrderField],
|
||||
encryptionKey cipher.EncryptionKey,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
name,
|
||||
type,
|
||||
encrypted_connection,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
connectors
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
AND %s
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query connectors: %w", err)
|
||||
}
|
||||
|
||||
connectors, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Connector])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect connectors: %w", err)
|
||||
}
|
||||
|
||||
*c = connectors
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Connector) CursorKey(orderBy ConnectorOrderField) page.CursorKey {
|
||||
switch orderBy {
|
||||
case ConnectorOrderFieldCreatedAt:
|
||||
return page.CursorKey{ID: c.ID, Value: c.CreatedAt}
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||
}
|
||||
|
||||
func (c *Connector) Upsert(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
|
||||
41
pkg/coredata/connector_order_field.go
Normal file
41
pkg/coredata/connector_order_field.go
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// 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
|
||||
|
||||
type (
|
||||
ConnectorOrderField string
|
||||
)
|
||||
|
||||
const (
|
||||
ConnectorOrderFieldCreatedAt ConnectorOrderField = "CREATED_AT"
|
||||
ConnectorOrderFieldName ConnectorOrderField = "NAME"
|
||||
)
|
||||
|
||||
func (p ConnectorOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ConnectorOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ConnectorOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *ConnectorOrderField) UnmarshalText(text []byte) error {
|
||||
*p = ConnectorOrderField(text)
|
||||
return nil
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/getprobo/probo/pkg/connector"
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
@@ -38,7 +39,38 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (s *ConnectorService) CreateOrUpdate(ctx context.Context, req CreateOrUpdateConnectorRequest) (*coredata.Connector, error) {
|
||||
func (s *ConnectorService) ListForOrganizationID(
|
||||
ctx context.Context,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[coredata.ConnectorOrderField],
|
||||
) (*page.Page[*coredata.Connector, coredata.ConnectorOrderField], error) {
|
||||
var connectors coredata.Connectors
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
return connectors.LoadWithoutDecryptedConnectionByOrganizationID(
|
||||
ctx,
|
||||
conn,
|
||||
s.svc.scope,
|
||||
organizationID,
|
||||
cursor,
|
||||
s.svc.encryptionKey,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot list connectors: %w", err)
|
||||
}
|
||||
|
||||
return page.NewPage(connectors, cursor), nil
|
||||
}
|
||||
|
||||
func (s *ConnectorService) CreateOrUpdate(
|
||||
ctx context.Context,
|
||||
req CreateOrUpdateConnectorRequest,
|
||||
) (*coredata.Connector, error) {
|
||||
if req.OrganizationID == gid.Nil {
|
||||
return nil, fmt.Errorf("organization ID is required")
|
||||
}
|
||||
|
||||
@@ -85,15 +85,13 @@ func NewMux(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg AuthConf
|
||||
r.Post("/auth/reset-password", ResetPasswordHandler(usrmgrSvc, authCfg))
|
||||
|
||||
r.Get("/connectors/initiate", WithSession(usrmgrSvc, authCfg, func(w http.ResponseWriter, r *http.Request) {
|
||||
session := SessionFromContext(r.Context())
|
||||
if session == nil {
|
||||
panic(fmt.Errorf("session not found"))
|
||||
connectorID := r.URL.Query().Get("connector_id")
|
||||
organizationID, err := gid.ParseGID(r.URL.Query().Get("organization_id"))
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to parse organization id: %w", err))
|
||||
}
|
||||
|
||||
// TODO: check if current user has access to the organization
|
||||
|
||||
connectorID := r.URL.Query().Get("connector_id")
|
||||
organizationID := r.URL.Query().Get("organization_id")
|
||||
_ = GetTenantService(r.Context(), proboSvc, organizationID.TenantID())
|
||||
|
||||
redirectURL, err := connectorRegistry.Initiate(r.Context(), connectorID, organizationID, r)
|
||||
if err != nil {
|
||||
@@ -104,28 +102,20 @@ func NewMux(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg AuthConf
|
||||
}))
|
||||
|
||||
r.Get("/connectors/complete", WithSession(usrmgrSvc, authCfg, func(w http.ResponseWriter, r *http.Request) {
|
||||
session := SessionFromContext(r.Context())
|
||||
if session == nil {
|
||||
panic(fmt.Errorf("session not found"))
|
||||
}
|
||||
|
||||
// TODO: check if current user has access to the organization
|
||||
|
||||
connectorID := r.URL.Query().Get("connector_id")
|
||||
organizationIDString := r.URL.Query().Get("organization_id")
|
||||
|
||||
connection, err := connectorRegistry.Complete(r.Context(), connectorID, organizationIDString, r)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to complete connector: %w", err))
|
||||
}
|
||||
|
||||
organizationID, err := gid.ParseGID(organizationIDString)
|
||||
organizationID, err := gid.ParseGID(r.URL.Query().Get("organization_id"))
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to parse organization id: %w", err))
|
||||
}
|
||||
|
||||
tenantID := session.ID.TenantID()
|
||||
_, err = proboSvc.WithTenant(tenantID).Connectors.CreateOrUpdate(
|
||||
connection, err := connectorRegistry.Complete(r.Context(), connectorID, organizationID, r)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to complete connector: %w", err))
|
||||
}
|
||||
|
||||
svc := GetTenantService(r.Context(), proboSvc, organizationID.TenantID())
|
||||
|
||||
_, err = svc.Connectors.CreateOrUpdate(
|
||||
r.Context(),
|
||||
probo.CreateOrUpdateConnectorRequest{
|
||||
OrganizationID: organizationID,
|
||||
@@ -282,7 +272,7 @@ func WithSession(usrmgrSvc *usrmgr.Service, authCfg AuthConfig, next http.Handle
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Resolver) GetTenantServiceIfAuthorized(ctx context.Context, tenantID gid.TenantID) *probo.TenantService {
|
||||
func GetTenantService(ctx context.Context, svc *probo.Service, tenantID gid.TenantID) *probo.TenantService {
|
||||
tenantIDs, _ := ctx.Value(userTenantContextKey).(*[]gid.TenantID)
|
||||
|
||||
if tenantIDs == nil {
|
||||
@@ -291,7 +281,7 @@ func (r *Resolver) GetTenantServiceIfAuthorized(ctx context.Context, tenantID gi
|
||||
|
||||
for _, id := range *tenantIDs {
|
||||
if id == tenantID {
|
||||
return r.proboSvc.WithTenant(tenantID)
|
||||
return svc.WithTenant(tenantID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -262,6 +262,20 @@ enum OrganizationOrderField {
|
||||
UPDATED_AT
|
||||
}
|
||||
|
||||
enum ConnectorOrderField
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/coredata.ConnectorOrderField"
|
||||
) {
|
||||
CREATED_AT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ConnectorOrderFieldCreatedAt"
|
||||
)
|
||||
NAME
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ConnectorOrderFieldName"
|
||||
)
|
||||
}
|
||||
|
||||
# Order Input Types
|
||||
input UserOrder
|
||||
@goModel(
|
||||
@@ -356,6 +370,11 @@ input OrganizationOrder {
|
||||
field: OrganizationOrderField!
|
||||
}
|
||||
|
||||
input ConnectorOrder {
|
||||
field: ConnectorOrderField!
|
||||
direction: OrderDirection!
|
||||
}
|
||||
|
||||
# Core Types
|
||||
type Organization implements Node {
|
||||
id: ID!
|
||||
@@ -370,6 +389,14 @@ type Organization implements Node {
|
||||
orderBy: UserOrder
|
||||
): UserConnection! @goField(forceResolver: true)
|
||||
|
||||
connectors(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: ConnectorOrder
|
||||
): ConnectorConnection! @goField(forceResolver: true)
|
||||
|
||||
frameworks(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
@@ -430,6 +457,14 @@ type User implements Node {
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type Connector implements Node {
|
||||
id: ID!
|
||||
name: String!
|
||||
type: String!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type People implements Node {
|
||||
id: ID!
|
||||
fullName: String!
|
||||
@@ -805,6 +840,16 @@ type VendorComplianceReportEdge {
|
||||
node: VendorComplianceReport!
|
||||
}
|
||||
|
||||
type ConnectorConnection {
|
||||
edges: [ConnectorEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
|
||||
type ConnectorEdge {
|
||||
cursor: CursorKey!
|
||||
node: Connector!
|
||||
}
|
||||
|
||||
# Root Types
|
||||
type Query {
|
||||
node(id: ID!): Node!
|
||||
@@ -1213,6 +1258,12 @@ input RemoveUserInput {
|
||||
userId: ID!
|
||||
}
|
||||
|
||||
input InitiateConnectorInput {
|
||||
organizationId: ID!
|
||||
connectorId: String!
|
||||
continueUrl: String!
|
||||
}
|
||||
|
||||
# Payload Types
|
||||
type CreateOrganizationPayload {
|
||||
organizationEdge: OrganizationEdge!
|
||||
@@ -1389,3 +1440,7 @@ type InviteUserPayload {
|
||||
type RemoveUserPayload {
|
||||
success: Boolean!
|
||||
}
|
||||
|
||||
type InitiateConnectorPayload {
|
||||
redirectUrl: String!
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
54
pkg/server/api/console/v1/types/connector.go
Normal file
54
pkg/server/api/console/v1/types/connector.go
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// 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/coredata"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
ConnectorOrderBy OrderBy[coredata.ConnectorOrderField]
|
||||
)
|
||||
|
||||
func NewConnectorConnection(p *page.Page[*coredata.Connector, coredata.ConnectorOrderField]) *ConnectorConnection {
|
||||
var edges = make([]*ConnectorEdge, len(p.Data))
|
||||
|
||||
for i := range edges {
|
||||
edges[i] = NewConnectorEdge(p.Data[i], p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &ConnectorConnection{
|
||||
Edges: edges,
|
||||
PageInfo: NewPageInfo(p),
|
||||
}
|
||||
}
|
||||
|
||||
func NewConnectorEdge(c *coredata.Connector, orderBy coredata.ConnectorOrderField) *ConnectorEdge {
|
||||
return &ConnectorEdge{
|
||||
Cursor: c.CursorKey(orderBy),
|
||||
Node: NewConnector(c),
|
||||
}
|
||||
}
|
||||
|
||||
func NewConnector(c *coredata.Connector) *Connector {
|
||||
return &Connector{
|
||||
ID: c.ID,
|
||||
Name: c.Name,
|
||||
Type: string(c.Type),
|
||||
CreatedAt: c.CreatedAt,
|
||||
UpdatedAt: c.UpdatedAt,
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,32 @@ type ConfirmEmailPayload struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
type Connector struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Connector) IsNode() {}
|
||||
func (this Connector) GetID() gid.GID { return this.ID }
|
||||
|
||||
type ConnectorConnection struct {
|
||||
Edges []*ConnectorEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type ConnectorEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *Connector `json:"node"`
|
||||
}
|
||||
|
||||
type ConnectorOrder struct {
|
||||
Field coredata.ConnectorOrderField `json:"field"`
|
||||
Direction page.OrderDirection `json:"direction"`
|
||||
}
|
||||
|
||||
type Control struct {
|
||||
ID gid.GID `json:"id"`
|
||||
ReferenceID string `json:"referenceId"`
|
||||
@@ -407,6 +433,16 @@ type ImportMesurePayload struct {
|
||||
MesureEdges []*MesureEdge `json:"mesureEdges"`
|
||||
}
|
||||
|
||||
type InitiateConnectorInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
ConnectorID string `json:"connectorId"`
|
||||
ContinueURL string `json:"continueUrl"`
|
||||
}
|
||||
|
||||
type InitiateConnectorPayload struct {
|
||||
RedirectURL string `json:"redirectUrl"`
|
||||
}
|
||||
|
||||
type InviteUserInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Email string `json:"email"`
|
||||
@@ -452,6 +488,7 @@ type Organization struct {
|
||||
Name string `json:"name"`
|
||||
LogoURL *string `json:"logoUrl,omitempty"`
|
||||
Users *UserConnection `json:"users"`
|
||||
Connectors *ConnectorConnection `json:"connectors"`
|
||||
Frameworks *FrameworkConnection `json:"frameworks"`
|
||||
Vendors *VendorConnection `json:"vendors"`
|
||||
Peoples *PeopleConnection `json:"peoples"`
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
// Mesures is the resolver for the mesures field.
|
||||
func (r *controlResolver) Mesures(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MesureOrderBy) (*types.MesureConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.MesureOrderField]{
|
||||
Field: coredata.MesureOrderFieldCreatedAt,
|
||||
@@ -47,7 +47,7 @@ func (r *controlResolver) Mesures(ctx context.Context, obj *types.Control, first
|
||||
|
||||
// Policies is the resolver for the policies field.
|
||||
func (r *controlResolver) Policies(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.PolicyOrderBy) (*types.PolicyConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.PolicyOrderField]{
|
||||
Field: coredata.PolicyOrderFieldCreatedAt,
|
||||
@@ -72,7 +72,7 @@ func (r *controlResolver) Policies(ctx context.Context, obj *types.Control, firs
|
||||
|
||||
// FileURL is the resolver for the fileUrl field.
|
||||
func (r *evidenceResolver) FileURL(ctx context.Context, obj *types.Evidence) (*string, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
if obj.Type == coredata.EvidenceTypeLink {
|
||||
return obj.URL, nil
|
||||
@@ -89,7 +89,7 @@ func (r *evidenceResolver) FileURL(ctx context.Context, obj *types.Evidence) (*s
|
||||
|
||||
// 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, orderBy *types.ControlOrderBy) (*types.ControlConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -114,7 +114,7 @@ func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework,
|
||||
|
||||
// Tasks is the resolver for the tasks field.
|
||||
func (r *mesureResolver) Tasks(ctx context.Context, obj *types.Mesure, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.TaskOrderBy) (*types.TaskConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.TaskOrderField]{
|
||||
Field: coredata.TaskOrderFieldCreatedAt,
|
||||
@@ -139,7 +139,7 @@ func (r *mesureResolver) Tasks(ctx context.Context, obj *types.Mesure, first *in
|
||||
|
||||
// Risks is the resolver for the risks field.
|
||||
func (r *mesureResolver) Risks(ctx context.Context, obj *types.Mesure, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.RiskOrderBy) (*types.RiskConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.RiskOrderField]{
|
||||
Field: coredata.RiskOrderFieldCreatedAt,
|
||||
@@ -164,7 +164,7 @@ func (r *mesureResolver) Risks(ctx context.Context, obj *types.Mesure, first *in
|
||||
|
||||
// Controls is the resolver for the controls field.
|
||||
func (r *mesureResolver) Controls(ctx context.Context, obj *types.Mesure, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy) (*types.ControlConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -213,7 +213,7 @@ func (r *mutationResolver) CreateOrganization(ctx context.Context, input types.C
|
||||
|
||||
// UpdateOrganization is the resolver for the updateOrganization field.
|
||||
func (r *mutationResolver) UpdateOrganization(ctx context.Context, input types.UpdateOrganizationInput) (*types.UpdateOrganizationPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
req := probo.UpdateOrganizationRequest{
|
||||
ID: input.OrganizationID,
|
||||
@@ -298,7 +298,7 @@ func (r *mutationResolver) RemoveUser(ctx context.Context, input types.RemoveUse
|
||||
|
||||
// CreatePeople is the resolver for the createPeople field.
|
||||
func (r *mutationResolver) CreatePeople(ctx context.Context, input types.CreatePeopleInput) (*types.CreatePeoplePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
people, err := svc.Peoples.Create(ctx, probo.CreatePeopleRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -319,7 +319,7 @@ func (r *mutationResolver) CreatePeople(ctx context.Context, input types.CreateP
|
||||
|
||||
// UpdatePeople is the resolver for the updatePeople field.
|
||||
func (r *mutationResolver) UpdatePeople(ctx context.Context, input types.UpdatePeopleInput) (*types.UpdatePeoplePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.ID.TenantID())
|
||||
|
||||
people, err := svc.Peoples.Update(ctx, probo.UpdatePeopleRequest{
|
||||
ID: input.ID,
|
||||
@@ -339,7 +339,7 @@ func (r *mutationResolver) UpdatePeople(ctx context.Context, input types.UpdateP
|
||||
|
||||
// DeletePeople is the resolver for the deletePeople field.
|
||||
func (r *mutationResolver) DeletePeople(ctx context.Context, input types.DeletePeopleInput) (*types.DeletePeoplePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.PeopleID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.PeopleID.TenantID())
|
||||
|
||||
err := svc.Peoples.Delete(ctx, input.PeopleID)
|
||||
if err != nil {
|
||||
@@ -353,7 +353,7 @@ func (r *mutationResolver) DeletePeople(ctx context.Context, input types.DeleteP
|
||||
|
||||
// CreateVendor is the resolver for the createVendor field.
|
||||
func (r *mutationResolver) CreateVendor(ctx context.Context, input types.CreateVendorInput) (*types.CreateVendorPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
vendor, err := svc.Vendors.Create(
|
||||
ctx,
|
||||
@@ -391,7 +391,7 @@ func (r *mutationResolver) CreateVendor(ctx context.Context, input types.CreateV
|
||||
|
||||
// UpdateVendor is the resolver for the updateVendor field.
|
||||
func (r *mutationResolver) UpdateVendor(ctx context.Context, input types.UpdateVendorInput) (*types.UpdateVendorPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.ID.TenantID())
|
||||
|
||||
vendor, err := svc.Vendors.Update(ctx, probo.UpdateVendorRequest{
|
||||
ID: input.ID,
|
||||
@@ -427,7 +427,7 @@ func (r *mutationResolver) UpdateVendor(ctx context.Context, input types.UpdateV
|
||||
|
||||
// DeleteVendor is the resolver for the deleteVendor field.
|
||||
func (r *mutationResolver) DeleteVendor(ctx context.Context, input types.DeleteVendorInput) (*types.DeleteVendorPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.VendorID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.VendorID.TenantID())
|
||||
|
||||
err := svc.Vendors.Delete(ctx, input.VendorID)
|
||||
if err != nil {
|
||||
@@ -441,7 +441,7 @@ func (r *mutationResolver) DeleteVendor(ctx context.Context, input types.DeleteV
|
||||
|
||||
// CreateFramework is the resolver for the createFramework field.
|
||||
func (r *mutationResolver) CreateFramework(ctx context.Context, input types.CreateFrameworkInput) (*types.CreateFrameworkPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
framework, err := svc.Frameworks.Create(ctx, probo.CreateFrameworkRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -458,7 +458,7 @@ func (r *mutationResolver) CreateFramework(ctx context.Context, input types.Crea
|
||||
|
||||
// UpdateFramework is the resolver for the updateFramework field.
|
||||
func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.UpdateFrameworkInput) (*types.UpdateFrameworkPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.ID.TenantID())
|
||||
|
||||
framework, err := svc.Frameworks.Update(ctx, probo.UpdateFrameworkRequest{
|
||||
ID: input.ID,
|
||||
@@ -476,7 +476,7 @@ func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.Upda
|
||||
|
||||
// ImportFramework is the resolver for the importFramework field.
|
||||
func (r *mutationResolver) ImportFramework(ctx context.Context, input types.ImportFrameworkInput) (*types.ImportFrameworkPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
req := probo.ImportFrameworkRequest{}
|
||||
if err := json.NewDecoder(input.File.File).Decode(&req.Framework); err != nil {
|
||||
@@ -506,7 +506,7 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo
|
||||
|
||||
// DeleteFramework is the resolver for the deleteFramework field.
|
||||
func (r *mutationResolver) DeleteFramework(ctx context.Context, input types.DeleteFrameworkInput) (*types.DeleteFrameworkPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.FrameworkID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.FrameworkID.TenantID())
|
||||
|
||||
err := svc.Frameworks.Delete(ctx, input.FrameworkID)
|
||||
if err != nil {
|
||||
@@ -520,7 +520,7 @@ func (r *mutationResolver) DeleteFramework(ctx context.Context, input types.Dele
|
||||
|
||||
// // CreateMesure is the resolver for the createMesure field.
|
||||
func (r *mutationResolver) CreateMesure(ctx context.Context, input types.CreateMesureInput) (*types.CreateMesurePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
mesure, err := svc.Mesures.Create(ctx, probo.CreateMesureRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -540,7 +540,7 @@ func (r *mutationResolver) CreateMesure(ctx context.Context, input types.CreateM
|
||||
|
||||
// UpdateMesure is the resolver for the updateMesure field.
|
||||
func (r *mutationResolver) UpdateMesure(ctx context.Context, input types.UpdateMesureInput) (*types.UpdateMesurePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.ID.TenantID())
|
||||
|
||||
mesure, err := svc.Mesures.Update(ctx, probo.UpdateMesureRequest{
|
||||
ID: input.ID,
|
||||
@@ -561,7 +561,7 @@ func (r *mutationResolver) UpdateMesure(ctx context.Context, input types.UpdateM
|
||||
|
||||
// ImportMesure is the resolver for the importMesure field.
|
||||
func (r *mutationResolver) ImportMesure(ctx context.Context, input types.ImportMesureInput) (*types.ImportMesurePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
var req probo.ImportMesureRequest
|
||||
if err := json.NewDecoder(input.File.File).Decode(&req.Mesures); err != nil {
|
||||
@@ -585,7 +585,7 @@ func (r *mutationResolver) ImportMesure(ctx context.Context, input types.ImportM
|
||||
|
||||
// CreateControlMesureMapping is the resolver for the createControlMesureMapping field.
|
||||
func (r *mutationResolver) CreateControlMesureMapping(ctx context.Context, input types.CreateControlMesureMappingInput) (*types.CreateControlMesureMappingPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.MesureID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.MesureID.TenantID())
|
||||
|
||||
err := svc.Controls.CreateMesureMapping(ctx, input.ControlID, input.MesureID)
|
||||
if err != nil {
|
||||
@@ -599,7 +599,7 @@ func (r *mutationResolver) CreateControlMesureMapping(ctx context.Context, input
|
||||
|
||||
// CreateControlPolicyMapping is the resolver for the createControlPolicyMapping field.
|
||||
func (r *mutationResolver) CreateControlPolicyMapping(ctx context.Context, input types.CreateControlPolicyMappingInput) (*types.CreateControlPolicyMappingPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.PolicyID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.PolicyID.TenantID())
|
||||
|
||||
err := svc.Controls.CreatePolicyMapping(ctx, input.ControlID, input.PolicyID)
|
||||
if err != nil {
|
||||
@@ -613,7 +613,7 @@ func (r *mutationResolver) CreateControlPolicyMapping(ctx context.Context, input
|
||||
|
||||
// DeleteControlMesureMapping is the resolver for the deleteControlMesureMapping field.
|
||||
func (r *mutationResolver) DeleteControlMesureMapping(ctx context.Context, input types.DeleteControlMesureMappingInput) (*types.DeleteControlMesureMappingPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.MesureID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.MesureID.TenantID())
|
||||
|
||||
err := svc.Controls.DeleteMesureMapping(ctx, input.ControlID, input.MesureID)
|
||||
if err != nil {
|
||||
@@ -627,7 +627,7 @@ func (r *mutationResolver) DeleteControlMesureMapping(ctx context.Context, input
|
||||
|
||||
// DeleteControlPolicyMapping is the resolver for the deleteControlPolicyMapping field.
|
||||
func (r *mutationResolver) DeleteControlPolicyMapping(ctx context.Context, input types.DeleteControlPolicyMappingInput) (*types.DeleteControlPolicyMappingPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.PolicyID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.PolicyID.TenantID())
|
||||
|
||||
err := svc.Controls.DeletePolicyMapping(ctx, input.ControlID, input.PolicyID)
|
||||
if err != nil {
|
||||
@@ -641,7 +641,7 @@ func (r *mutationResolver) DeleteControlPolicyMapping(ctx context.Context, input
|
||||
|
||||
// CreateTask is the resolver for the createTask field.
|
||||
func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTaskInput) (*types.CreateTaskPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.MesureID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.MesureID.TenantID())
|
||||
|
||||
task, err := svc.Tasks.Create(ctx, probo.CreateTaskRequest{
|
||||
MesureID: input.MesureID,
|
||||
@@ -660,7 +660,7 @@ func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTas
|
||||
|
||||
// UpdateTask is the resolver for the updateTask field.
|
||||
func (r *mutationResolver) UpdateTask(ctx context.Context, input types.UpdateTaskInput) (*types.UpdateTaskPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.TaskID.TenantID())
|
||||
|
||||
task, err := svc.Tasks.Update(ctx, probo.UpdateTaskRequest{
|
||||
TaskID: input.TaskID,
|
||||
@@ -680,7 +680,7 @@ func (r *mutationResolver) UpdateTask(ctx context.Context, input types.UpdateTas
|
||||
|
||||
// DeleteTask is the resolver for the deleteTask field.
|
||||
func (r *mutationResolver) DeleteTask(ctx context.Context, input types.DeleteTaskInput) (*types.DeleteTaskPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.TaskID.TenantID())
|
||||
|
||||
err := svc.Tasks.Delete(ctx, input.TaskID)
|
||||
if err != nil {
|
||||
@@ -694,7 +694,7 @@ func (r *mutationResolver) DeleteTask(ctx context.Context, input types.DeleteTas
|
||||
|
||||
// AssignTask is the resolver for the assignTask field.
|
||||
func (r *mutationResolver) AssignTask(ctx context.Context, input types.AssignTaskInput) (*types.AssignTaskPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.TaskID.TenantID())
|
||||
|
||||
task, err := svc.Tasks.Assign(ctx, input.TaskID, input.AssignedToID)
|
||||
if err != nil {
|
||||
@@ -708,7 +708,7 @@ func (r *mutationResolver) AssignTask(ctx context.Context, input types.AssignTas
|
||||
|
||||
// UnassignTask is the resolver for the unassignTask field.
|
||||
func (r *mutationResolver) UnassignTask(ctx context.Context, input types.UnassignTaskInput) (*types.UnassignTaskPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.TaskID.TenantID())
|
||||
|
||||
task, err := svc.Tasks.Unassign(ctx, input.TaskID)
|
||||
if err != nil {
|
||||
@@ -722,7 +722,7 @@ func (r *mutationResolver) UnassignTask(ctx context.Context, input types.Unassig
|
||||
|
||||
// CreateRisk is the resolver for the createRisk field.
|
||||
func (r *mutationResolver) CreateRisk(ctx context.Context, input types.CreateRiskInput) (*types.CreateRiskPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
risk, err := svc.Risks.Create(
|
||||
ctx,
|
||||
@@ -750,7 +750,7 @@ func (r *mutationResolver) CreateRisk(ctx context.Context, input types.CreateRis
|
||||
|
||||
// UpdateRisk is the resolver for the updateRisk field.
|
||||
func (r *mutationResolver) UpdateRisk(ctx context.Context, input types.UpdateRiskInput) (*types.UpdateRiskPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.ID.TenantID())
|
||||
|
||||
risk, err := svc.Risks.Update(
|
||||
ctx,
|
||||
@@ -778,7 +778,7 @@ func (r *mutationResolver) UpdateRisk(ctx context.Context, input types.UpdateRis
|
||||
|
||||
// DeleteRisk is the resolver for the deleteRisk field.
|
||||
func (r *mutationResolver) DeleteRisk(ctx context.Context, input types.DeleteRiskInput) (*types.DeleteRiskPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.RiskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.RiskID.TenantID())
|
||||
|
||||
err := svc.Risks.Delete(ctx, input.RiskID)
|
||||
if err != nil {
|
||||
@@ -792,7 +792,7 @@ func (r *mutationResolver) DeleteRisk(ctx context.Context, input types.DeleteRis
|
||||
|
||||
// CreateRiskMesureMapping is the resolver for the createRiskMesureMapping field.
|
||||
func (r *mutationResolver) CreateRiskMesureMapping(ctx context.Context, input types.CreateRiskMesureMappingInput) (*types.CreateRiskMesureMappingPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.RiskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.RiskID.TenantID())
|
||||
|
||||
err := svc.Risks.CreateMesureMapping(ctx, input.RiskID, input.MesureID)
|
||||
if err != nil {
|
||||
@@ -806,7 +806,7 @@ func (r *mutationResolver) CreateRiskMesureMapping(ctx context.Context, input ty
|
||||
|
||||
// DeleteRiskMesureMapping is the resolver for the deleteRiskMesureMapping field.
|
||||
func (r *mutationResolver) DeleteRiskMesureMapping(ctx context.Context, input types.DeleteRiskMesureMappingInput) (*types.DeleteRiskMesureMappingPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.RiskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.RiskID.TenantID())
|
||||
|
||||
err := svc.Risks.DeleteMesureMapping(ctx, input.RiskID, input.MesureID)
|
||||
if err != nil {
|
||||
@@ -820,7 +820,7 @@ func (r *mutationResolver) DeleteRiskMesureMapping(ctx context.Context, input ty
|
||||
|
||||
// CreateRiskPolicyMapping is the resolver for the createRiskPolicyMapping field.
|
||||
func (r *mutationResolver) CreateRiskPolicyMapping(ctx context.Context, input types.CreateRiskPolicyMappingInput) (*types.CreateRiskPolicyMappingPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.RiskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.RiskID.TenantID())
|
||||
|
||||
err := svc.Risks.CreatePolicyMapping(ctx, input.RiskID, input.PolicyID)
|
||||
if err != nil {
|
||||
@@ -834,7 +834,7 @@ func (r *mutationResolver) CreateRiskPolicyMapping(ctx context.Context, input ty
|
||||
|
||||
// DeleteRiskPolicyMapping is the resolver for the deleteRiskPolicyMapping field.
|
||||
func (r *mutationResolver) DeleteRiskPolicyMapping(ctx context.Context, input types.DeleteRiskPolicyMappingInput) (*types.DeleteRiskPolicyMappingPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.RiskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.RiskID.TenantID())
|
||||
|
||||
err := svc.Risks.DeletePolicyMapping(ctx, input.RiskID, input.PolicyID)
|
||||
if err != nil {
|
||||
@@ -848,7 +848,7 @@ func (r *mutationResolver) DeleteRiskPolicyMapping(ctx context.Context, input ty
|
||||
|
||||
// RequestEvidence is the resolver for the requestEvidence field.
|
||||
func (r *mutationResolver) RequestEvidence(ctx context.Context, input types.RequestEvidenceInput) (*types.RequestEvidencePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.TaskID.TenantID())
|
||||
|
||||
evidence, err := svc.Evidences.Request(
|
||||
ctx,
|
||||
@@ -870,7 +870,7 @@ func (r *mutationResolver) RequestEvidence(ctx context.Context, input types.Requ
|
||||
|
||||
// FulfillEvidence is the resolver for the fulfillEvidence field.
|
||||
func (r *mutationResolver) FulfillEvidence(ctx context.Context, input types.FulfillEvidenceInput) (*types.FulfillEvidencePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.EvidenceID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.EvidenceID.TenantID())
|
||||
|
||||
req := probo.FulfilledEvidenceRequest{
|
||||
EvidenceID: input.EvidenceID,
|
||||
@@ -897,7 +897,7 @@ func (r *mutationResolver) FulfillEvidence(ctx context.Context, input types.Fulf
|
||||
|
||||
// CreateEvidence is the resolver for the createEvidence field.
|
||||
func (r *mutationResolver) CreateEvidence(ctx context.Context, input types.CreateEvidenceInput) (*types.CreateEvidencePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.TaskID.TenantID())
|
||||
|
||||
req := probo.CreateEvidenceRequest{
|
||||
TaskID: input.TaskID,
|
||||
@@ -929,7 +929,7 @@ func (r *mutationResolver) CreateEvidence(ctx context.Context, input types.Creat
|
||||
|
||||
// DeleteEvidence is the resolver for the deleteEvidence field.
|
||||
func (r *mutationResolver) DeleteEvidence(ctx context.Context, input types.DeleteEvidenceInput) (*types.DeleteEvidencePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.EvidenceID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.EvidenceID.TenantID())
|
||||
|
||||
err := svc.Evidences.Delete(ctx, input.EvidenceID)
|
||||
if err != nil {
|
||||
@@ -943,7 +943,7 @@ func (r *mutationResolver) DeleteEvidence(ctx context.Context, input types.Delet
|
||||
|
||||
// UploadVendorComplianceReport is the resolver for the uploadVendorComplianceReport field.
|
||||
func (r *mutationResolver) UploadVendorComplianceReport(ctx context.Context, input types.UploadVendorComplianceReportInput) (*types.UploadVendorComplianceReportPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.VendorID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.VendorID.TenantID())
|
||||
|
||||
vendorComplianceReport, err := svc.VendorComplianceReports.Upload(
|
||||
ctx,
|
||||
@@ -966,7 +966,7 @@ func (r *mutationResolver) UploadVendorComplianceReport(ctx context.Context, inp
|
||||
|
||||
// DeleteVendorComplianceReport is the resolver for the deleteVendorComplianceReport field.
|
||||
func (r *mutationResolver) DeleteVendorComplianceReport(ctx context.Context, input types.DeleteVendorComplianceReportInput) (*types.DeleteVendorComplianceReportPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ReportID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.ReportID.TenantID())
|
||||
|
||||
err := svc.VendorComplianceReports.Delete(ctx, input.ReportID)
|
||||
if err != nil {
|
||||
@@ -980,7 +980,7 @@ func (r *mutationResolver) DeleteVendorComplianceReport(ctx context.Context, inp
|
||||
|
||||
// CreatePolicy is the resolver for the createPolicy field.
|
||||
func (r *mutationResolver) CreatePolicy(ctx context.Context, input types.CreatePolicyInput) (*types.CreatePolicyPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
policy, err := svc.Policies.Create(ctx, probo.CreatePolicyRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -1001,7 +1001,7 @@ func (r *mutationResolver) CreatePolicy(ctx context.Context, input types.CreateP
|
||||
|
||||
// UpdatePolicy is the resolver for the updatePolicy field.
|
||||
func (r *mutationResolver) UpdatePolicy(ctx context.Context, input types.UpdatePolicyInput) (*types.UpdatePolicyPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.ID.TenantID())
|
||||
|
||||
policy, err := svc.Policies.Update(ctx, probo.UpdatePolicyRequest{
|
||||
ID: input.ID,
|
||||
@@ -1022,7 +1022,7 @@ func (r *mutationResolver) UpdatePolicy(ctx context.Context, input types.UpdateP
|
||||
|
||||
// DeletePolicy is the resolver for the deletePolicy field.
|
||||
func (r *mutationResolver) DeletePolicy(ctx context.Context, input types.DeletePolicyInput) (*types.DeletePolicyPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.PolicyID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.PolicyID.TenantID())
|
||||
|
||||
err := svc.Policies.Delete(ctx, input.PolicyID)
|
||||
if err != nil {
|
||||
@@ -1036,7 +1036,7 @@ func (r *mutationResolver) DeletePolicy(ctx context.Context, input types.DeleteP
|
||||
|
||||
// LogoURL is the resolver for the logoUrl field.
|
||||
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
return svc.Organizations.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
}
|
||||
@@ -1064,9 +1064,34 @@ func (r *organizationResolver) Users(ctx context.Context, obj *types.Organizatio
|
||||
return types.NewUserConnection(page), nil
|
||||
}
|
||||
|
||||
// Connectors is the resolver for the connectors field.
|
||||
func (r *organizationResolver) Connectors(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ConnectorOrder) (*types.ConnectorConnection, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ConnectorOrderField]{
|
||||
Field: coredata.ConnectorOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.ConnectorOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.Connectors.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization connectors: %w", err))
|
||||
}
|
||||
|
||||
return types.NewConnectorConnection(page), nil
|
||||
}
|
||||
|
||||
// Frameworks is the resolver for the frameworks field.
|
||||
func (r *organizationResolver) Frameworks(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.FrameworkOrderBy) (*types.FrameworkConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.FrameworkOrderField]{
|
||||
Field: coredata.FrameworkOrderFieldCreatedAt,
|
||||
@@ -1091,7 +1116,7 @@ func (r *organizationResolver) Frameworks(ctx context.Context, obj *types.Organi
|
||||
|
||||
// Vendors is the resolver for the vendors field.
|
||||
func (r *organizationResolver) Vendors(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorOrderBy) (*types.VendorConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.VendorOrderField]{
|
||||
Field: coredata.VendorOrderFieldCreatedAt,
|
||||
@@ -1116,7 +1141,7 @@ func (r *organizationResolver) Vendors(ctx context.Context, obj *types.Organizat
|
||||
|
||||
// Peoples is the resolver for the peoples field.
|
||||
func (r *organizationResolver) Peoples(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.PeopleOrderBy) (*types.PeopleConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.PeopleOrderField]{
|
||||
Field: coredata.PeopleOrderFieldCreatedAt,
|
||||
@@ -1141,7 +1166,7 @@ func (r *organizationResolver) Peoples(ctx context.Context, obj *types.Organizat
|
||||
|
||||
// Policies is the resolver for the policies field.
|
||||
func (r *organizationResolver) Policies(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.PolicyOrderBy) (*types.PolicyConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.PolicyOrderField]{
|
||||
Field: coredata.PolicyOrderFieldName,
|
||||
@@ -1166,7 +1191,7 @@ func (r *organizationResolver) Policies(ctx context.Context, obj *types.Organiza
|
||||
|
||||
// Mesures is the resolver for the mesures field.
|
||||
func (r *organizationResolver) Mesures(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MesureOrderBy) (*types.MesureConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.MesureOrderField]{
|
||||
Field: coredata.MesureOrderFieldCreatedAt,
|
||||
@@ -1191,7 +1216,7 @@ func (r *organizationResolver) Mesures(ctx context.Context, obj *types.Organizat
|
||||
|
||||
// Risks is the resolver for the risks field.
|
||||
func (r *organizationResolver) Risks(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.RiskOrderBy) (*types.RiskConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.RiskOrderField]{
|
||||
Field: coredata.RiskOrderFieldCreatedAt,
|
||||
@@ -1216,7 +1241,7 @@ func (r *organizationResolver) Risks(ctx context.Context, obj *types.Organizatio
|
||||
|
||||
// Owner is the resolver for the owner field.
|
||||
func (r *policyResolver) Owner(ctx context.Context, obj *types.Policy) (*types.People, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
policy, err := svc.Policies.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
@@ -1234,7 +1259,7 @@ func (r *policyResolver) Owner(ctx context.Context, obj *types.Policy) (*types.P
|
||||
|
||||
// Controls is the resolver for the controls field.
|
||||
func (r *policyResolver) Controls(ctx context.Context, obj *types.Policy, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy) (*types.ControlConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -1259,7 +1284,7 @@ func (r *policyResolver) Controls(ctx context.Context, obj *types.Policy, first
|
||||
|
||||
// Node is the resolver for the node field.
|
||||
func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, id.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, id.TenantID())
|
||||
|
||||
switch id.EntityType() {
|
||||
case coredata.OrganizationEntityType:
|
||||
@@ -1355,7 +1380,7 @@ func (r *queryResolver) Viewer(ctx context.Context) (*types.Viewer, error) {
|
||||
|
||||
// Owner is the resolver for the owner field.
|
||||
func (r *riskResolver) Owner(ctx context.Context, obj *types.Risk) (*types.People, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
risk, err := svc.Risks.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
@@ -1376,7 +1401,7 @@ func (r *riskResolver) Owner(ctx context.Context, obj *types.Risk) (*types.Peopl
|
||||
|
||||
// Mesures is the resolver for the mesures field.
|
||||
func (r *riskResolver) Mesures(ctx context.Context, obj *types.Risk, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MesureOrderBy) (*types.MesureConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.MesureOrderField]{
|
||||
Field: coredata.MesureOrderFieldCreatedAt,
|
||||
@@ -1401,7 +1426,7 @@ func (r *riskResolver) Mesures(ctx context.Context, obj *types.Risk, first *int,
|
||||
|
||||
// Policies is the resolver for the policies field.
|
||||
func (r *riskResolver) Policies(ctx context.Context, obj *types.Risk, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.PolicyOrderBy) (*types.PolicyConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.PolicyOrderField]{
|
||||
Field: coredata.PolicyOrderFieldCreatedAt,
|
||||
@@ -1426,7 +1451,7 @@ func (r *riskResolver) Policies(ctx context.Context, obj *types.Risk, first *int
|
||||
|
||||
// Controls is the resolver for the controls field.
|
||||
func (r *riskResolver) Controls(ctx context.Context, obj *types.Risk, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy) (*types.ControlConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -1451,7 +1476,7 @@ func (r *riskResolver) Controls(ctx context.Context, obj *types.Risk, first *int
|
||||
|
||||
// AssignedTo is the resolver for the assignedTo field.
|
||||
func (r *taskResolver) AssignedTo(ctx context.Context, obj *types.Task) (*types.People, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
task, err := svc.Tasks.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
@@ -1472,7 +1497,7 @@ func (r *taskResolver) AssignedTo(ctx context.Context, obj *types.Task) (*types.
|
||||
|
||||
// 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, orderBy *types.EvidenceOrderBy) (*types.EvidenceConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.EvidenceOrderField]{
|
||||
Field: coredata.EvidenceOrderFieldCreatedAt,
|
||||
@@ -1496,7 +1521,7 @@ func (r *taskResolver) Evidences(ctx context.Context, obj *types.Task, first *in
|
||||
|
||||
// ComplianceReports is the resolver for the complianceReports field.
|
||||
func (r *vendorResolver) ComplianceReports(ctx context.Context, obj *types.Vendor, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorComplianceReportOrderBy) (*types.VendorComplianceReportConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.VendorComplianceReportOrderField]{
|
||||
Field: coredata.VendorComplianceReportOrderFieldReportDate,
|
||||
@@ -1521,7 +1546,7 @@ func (r *vendorResolver) ComplianceReports(ctx context.Context, obj *types.Vendo
|
||||
|
||||
// BusinessOwner is the resolver for the businessOwner field.
|
||||
func (r *vendorResolver) BusinessOwner(ctx context.Context, obj *types.Vendor) (*types.People, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
vendor, err := svc.Vendors.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
@@ -1542,7 +1567,7 @@ func (r *vendorResolver) BusinessOwner(ctx context.Context, obj *types.Vendor) (
|
||||
|
||||
// SecurityOwner is the resolver for the securityOwner field.
|
||||
func (r *vendorResolver) SecurityOwner(ctx context.Context, obj *types.Vendor) (*types.People, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
vendor, err := svc.Vendors.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
@@ -1563,7 +1588,7 @@ func (r *vendorResolver) SecurityOwner(ctx context.Context, obj *types.Vendor) (
|
||||
|
||||
// Vendor is the resolver for the vendor field.
|
||||
func (r *vendorComplianceReportResolver) Vendor(ctx context.Context, obj *types.VendorComplianceReport) (*types.Vendor, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
vendor, err := svc.Vendors.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
@@ -1575,7 +1600,7 @@ func (r *vendorComplianceReportResolver) Vendor(ctx context.Context, obj *types.
|
||||
|
||||
// FileURL is the resolver for the fileUrl field.
|
||||
func (r *vendorComplianceReportResolver) FileURL(ctx context.Context, obj *types.VendorComplianceReport) (string, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
fileURL, err := svc.VendorComplianceReports.GenerateFileURL(ctx, obj.ID, 1*time.Hour)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user