Add webhooks

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-02-11 09:34:06 +01:00
parent 4945c022a1
commit f9de9c4834
34 changed files with 5932 additions and 4 deletions

View File

@@ -2654,6 +2654,7 @@ type Mutation {
updateSCIMBridge(
input: UpdateSCIMBridgeInput!
): UpdateSCIMBridgePayload @session(required: PRESENT)
}
type Identity implements Node {
@@ -3499,6 +3500,8 @@ type RegenerateSCIMTokenPayload {
type UpdateSCIMBridgePayload {
scimBridge: SCIMBridge!
}
`, BuiltIn: false},
{Name: "../../../../gqlutils/directives/session/schema.graphql", Input: `# Session directive for GraphQL APIs
# Include this schema in your gqlgen configuration to enable session-based access control.

View File

@@ -488,6 +488,16 @@ enum MeetingOrderField
)
}
enum WebhookConfigurationOrderField
@goModel(
model: "go.probo.inc/probo/pkg/coredata.WebhookConfigurationOrderField"
) {
CREATED_AT
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.WebhookConfigurationOrderFieldCreatedAt"
)
}
enum RiskOrderField
@goModel(model: "go.probo.inc/probo/pkg/coredata.RiskOrderField") {
CREATED_AT
@@ -1345,6 +1355,14 @@ input MeetingOrder
field: MeetingOrderField!
}
input WebhookConfigurationOrder
@goModel(
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookConfigurationOrderBy"
) {
direction: OrderDirection!
field: WebhookConfigurationOrderField!
}
input RiskOrder
@goModel(
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.RiskOrderBy"
@@ -1817,6 +1835,14 @@ type Organization implements Node {
customDomain: CustomDomain @goField(forceResolver: true)
webhookConfigurations(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: WebhookConfigurationOrder
): WebhookConfigurationConnection! @goField(forceResolver: true)
createdAt: Datetime!
updatedAt: Datetime!
@@ -2242,6 +2268,48 @@ type Meeting implements Node {
permission(action: String!): Boolean! @goField(forceResolver: true)
}
enum WebhookEventType
@goModel(model: "go.probo.inc/probo/pkg/coredata.WebhookEventType") {
MEETING_CREATED
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventTypeMeetingCreated")
MEETING_UPDATED
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventTypeMeetingUpdated")
MEETING_DELETED
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventTypeMeetingDeleted")
VENDOR_CREATED
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventTypeVendorCreated")
VENDOR_UPDATED
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventTypeVendorUpdated")
VENDOR_DELETED
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventTypeVendorDeleted")
}
type WebhookConfiguration implements Node {
id: ID!
organization: Organization @goField(forceResolver: true)
endpointUrl: String!
signingSecret: String! @goField(forceResolver: true)
selectedEvents: [WebhookEventType!]!
createdAt: Datetime!
updatedAt: Datetime!
permission(action: String!): Boolean! @goField(forceResolver: true)
}
type WebhookConfigurationConnection
@goModel(
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookConfigurationConnection"
) {
edges: [WebhookConfigurationEdge!]!
pageInfo: PageInfo!
totalCount: Int! @goField(forceResolver: true)
}
type WebhookConfigurationEdge {
cursor: CursorKey!
node: WebhookConfiguration!
}
type StateOfApplicability implements Node {
id: ID!
name: String!
@@ -3270,6 +3338,16 @@ type Mutation {
createMeeting(input: CreateMeetingInput!): CreateMeetingPayload!
updateMeeting(input: UpdateMeetingInput!): UpdateMeetingPayload!
deleteMeeting(input: DeleteMeetingInput!): DeleteMeetingPayload!
# WebhookConfiguration mutations
createWebhookConfiguration(
input: CreateWebhookConfigurationInput!
): CreateWebhookConfigurationPayload!
updateWebhookConfiguration(
input: UpdateWebhookConfigurationInput!
): UpdateWebhookConfigurationPayload!
deleteWebhookConfiguration(
input: DeleteWebhookConfigurationInput!
): DeleteWebhookConfigurationPayload!
# StateOfApplicability mutations
createStateOfApplicability(
input: CreateStateOfApplicabilityInput!
@@ -4621,6 +4699,34 @@ type DeleteMeetingPayload {
deletedMeetingId: ID!
}
input CreateWebhookConfigurationInput {
organizationId: ID!
endpointUrl: String!
selectedEvents: [WebhookEventType!]!
}
input UpdateWebhookConfigurationInput {
id: ID!
endpointUrl: String
selectedEvents: [WebhookEventType!]
}
input DeleteWebhookConfigurationInput {
webhookConfigurationId: ID!
}
type CreateWebhookConfigurationPayload {
webhookConfigurationEdge: WebhookConfigurationEdge!
}
type UpdateWebhookConfigurationPayload {
webhookConfiguration: WebhookConfiguration!
}
type DeleteWebhookConfigurationPayload {
deletedWebhookConfigurationId: ID!
}
type CreateStateOfApplicabilityPayload {
stateOfApplicabilityEdge: StateOfApplicabilityEdge!
}

File diff suppressed because it is too large Load Diff

View File

@@ -693,6 +693,16 @@ type CreateVendorServicePayload struct {
VendorServiceEdge *VendorServiceEdge `json:"vendorServiceEdge"`
}
type CreateWebhookConfigurationInput struct {
OrganizationID gid.GID `json:"organizationId"`
EndpointURL string `json:"endpointUrl"`
SelectedEvents []coredata.WebhookEventType `json:"selectedEvents"`
}
type CreateWebhookConfigurationPayload struct {
WebhookConfigurationEdge *WebhookConfigurationEdge `json:"webhookConfigurationEdge"`
}
type CustomDomain struct {
ID gid.GID `json:"id"`
Organization *Organization `json:"organization"`
@@ -1103,6 +1113,14 @@ type DeleteVendorServicePayload struct {
DeletedVendorServiceID gid.GID `json:"deletedVendorServiceId"`
}
type DeleteWebhookConfigurationInput struct {
WebhookConfigurationID gid.GID `json:"webhookConfigurationId"`
}
type DeleteWebhookConfigurationPayload struct {
DeletedWebhookConfigurationID gid.GID `json:"deletedWebhookConfigurationId"`
}
type Document struct {
ID gid.GID `json:"id"`
Title string `json:"title"`
@@ -1499,6 +1517,7 @@ type Organization struct {
TrustCenterFiles *TrustCenterFileConnection `json:"trustCenterFiles"`
TrustCenter *TrustCenter `json:"trustCenter,omitempty"`
CustomDomain *CustomDomain `json:"customDomain,omitempty"`
WebhookConfigurations *WebhookConfigurationConnection `json:"webhookConfigurations"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Permission bool `json:"permission"`
@@ -2342,6 +2361,16 @@ type UpdateVendorServicePayload struct {
VendorService *VendorService `json:"vendorService"`
}
type UpdateWebhookConfigurationInput struct {
ID gid.GID `json:"id"`
EndpointURL *string `json:"endpointUrl,omitempty"`
SelectedEvents []coredata.WebhookEventType `json:"selectedEvents,omitempty"`
}
type UpdateWebhookConfigurationPayload struct {
WebhookConfiguration *WebhookConfiguration `json:"webhookConfiguration"`
}
type UploadAuditReportInput struct {
AuditID gid.GID `json:"auditId"`
File graphql.Upload `json:"file"`
@@ -2593,3 +2622,22 @@ type Viewer struct {
SignableDocuments *SignableDocumentConnection `json:"signableDocuments"`
SignableDocument *SignableDocument `json:"signableDocument,omitempty"`
}
type WebhookConfiguration struct {
ID gid.GID `json:"id"`
Organization *Organization `json:"organization,omitempty"`
EndpointURL string `json:"endpointUrl"`
SigningSecret string `json:"signingSecret"`
SelectedEvents []coredata.WebhookEventType `json:"selectedEvents"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Permission bool `json:"permission"`
}
func (WebhookConfiguration) IsNode() {}
func (this WebhookConfiguration) GetID() gid.GID { return this.ID }
type WebhookConfigurationEdge struct {
Cursor page.CursorKey `json:"cursor"`
Node *WebhookConfiguration `json:"node"`
}

View File

@@ -0,0 +1,74 @@
// 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 (
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/page"
)
type (
WebhookConfigurationOrderBy OrderBy[coredata.WebhookConfigurationOrderField]
WebhookConfigurationConnection struct {
TotalCount int
Edges []*WebhookConfigurationEdge
PageInfo PageInfo
Resolver any
ParentID gid.GID
}
)
func NewWebhookConfigurationConnection(
p *page.Page[*coredata.WebhookConfiguration, coredata.WebhookConfigurationOrderField],
parentType any,
parentID gid.GID,
) *WebhookConfigurationConnection {
var edges = make([]*WebhookConfigurationEdge, len(p.Data))
for i := range edges {
edges[i] = NewWebhookConfigurationEdge(p.Data[i], p.Cursor.OrderBy.Field)
}
return &WebhookConfigurationConnection{
Edges: edges,
PageInfo: *NewPageInfo(p),
Resolver: parentType,
ParentID: parentID,
}
}
func NewWebhookConfigurationEdge(wc *coredata.WebhookConfiguration, orderBy coredata.WebhookConfigurationOrderField) *WebhookConfigurationEdge {
return &WebhookConfigurationEdge{
Cursor: wc.CursorKey(orderBy),
Node: NewWebhookConfiguration(wc),
}
}
func NewWebhookConfiguration(wc *coredata.WebhookConfiguration) *WebhookConfiguration {
return &WebhookConfiguration{
ID: wc.ID,
Organization: &Organization{
ID: wc.OrganizationID,
},
EndpointURL: wc.EndpointURL,
SelectedEvents: wc.SelectedEvents,
CreatedAt: wc.CreatedAt,
UpdatedAt: wc.UpdatedAt,
}
}

View File

@@ -3678,6 +3678,77 @@ func (r *mutationResolver) DeleteMeeting(ctx context.Context, input types.Delete
}, nil
}
// CreateWebhookConfiguration is the resolver for the createWebhookConfiguration field.
func (r *mutationResolver) CreateWebhookConfiguration(ctx context.Context, input types.CreateWebhookConfigurationInput) (*types.CreateWebhookConfigurationPayload, error) {
if err := r.authorize(ctx, input.OrganizationID, probo.ActionWebhookConfigurationCreate); err != nil {
return nil, err
}
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
wc, err := prb.WebhookConfigurations.Create(
ctx,
probo.CreateWebhookConfigurationRequest{
OrganizationID: input.OrganizationID,
EndpointURL: input.EndpointURL,
SelectedEvents: input.SelectedEvents,
},
)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot create webhook configuration", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return &types.CreateWebhookConfigurationPayload{
WebhookConfigurationEdge: types.NewWebhookConfigurationEdge(wc, coredata.WebhookConfigurationOrderFieldCreatedAt),
}, nil
}
// UpdateWebhookConfiguration is the resolver for the updateWebhookConfiguration field.
func (r *mutationResolver) UpdateWebhookConfiguration(ctx context.Context, input types.UpdateWebhookConfigurationInput) (*types.UpdateWebhookConfigurationPayload, error) {
if err := r.authorize(ctx, input.ID, probo.ActionWebhookConfigurationUpdate); err != nil {
return nil, err
}
prb := r.ProboService(ctx, input.ID.TenantID())
wc, err := prb.WebhookConfigurations.Update(
ctx,
probo.UpdateWebhookConfigurationRequest{
WebhookConfigurationID: input.ID,
EndpointURL: input.EndpointURL,
SelectedEvents: input.SelectedEvents,
},
)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot update webhook configuration", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return &types.UpdateWebhookConfigurationPayload{
WebhookConfiguration: types.NewWebhookConfiguration(wc),
}, nil
}
// DeleteWebhookConfiguration is the resolver for the deleteWebhookConfiguration field.
func (r *mutationResolver) DeleteWebhookConfiguration(ctx context.Context, input types.DeleteWebhookConfigurationInput) (*types.DeleteWebhookConfigurationPayload, error) {
if err := r.authorize(ctx, input.WebhookConfigurationID, probo.ActionWebhookConfigurationDelete); err != nil {
return nil, err
}
prb := r.ProboService(ctx, input.WebhookConfigurationID.TenantID())
err := prb.WebhookConfigurations.Delete(ctx, input.WebhookConfigurationID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot delete webhook configuration", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return &types.DeleteWebhookConfigurationPayload{
DeletedWebhookConfigurationID: input.WebhookConfigurationID,
}, nil
}
// CreateStateOfApplicability is the resolver for the createStateOfApplicability field.
func (r *mutationResolver) CreateStateOfApplicability(ctx context.Context, input types.CreateStateOfApplicabilityInput) (*types.CreateStateOfApplicabilityPayload, error) {
if err := r.authorize(ctx, input.OrganizationID, probo.ActionStateOfApplicabilityCreate); err != nil {
@@ -6313,6 +6384,36 @@ func (r *organizationResolver) CustomDomain(ctx context.Context, obj *types.Orga
return types.NewCustomDomain(domain, r.customDomainCname), nil
}
// WebhookConfigurations is the resolver for the webhookConfigurations field.
func (r *organizationResolver) WebhookConfigurations(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.WebhookConfigurationOrderBy) (*types.WebhookConfigurationConnection, error) {
if err := r.authorize(ctx, obj.ID, probo.ActionWebhookConfigurationList); err != nil {
return nil, err
}
prb := r.ProboService(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.WebhookConfigurationOrderField]{
Field: coredata.WebhookConfigurationOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
}
if orderBy != nil {
pageOrderBy = page.OrderBy[coredata.WebhookConfigurationOrderField]{
Field: orderBy.Field,
Direction: orderBy.Direction,
}
}
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := prb.WebhookConfigurations.ListForOrganizationID(ctx, obj.ID, cursor)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list organization webhook configurations", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewWebhookConfigurationConnection(page, r, obj.ID), nil
}
// Permission is the resolver for the permission field.
func (r *organizationResolver) Permission(ctx context.Context, obj *types.Organization, action string) (bool, error) {
return r.Resolver.Permission(ctx, obj, action)
@@ -6761,6 +6862,15 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
}
return types.NewStateOfApplicability(stateOfApplicability), nil
}
case coredata.WebhookConfigurationEntityType:
action = probo.ActionWebhookConfigurationGet
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
wc, err := prb.WebhookConfigurations.Get(ctx, id)
if err != nil {
return nil, err
}
return types.NewWebhookConfiguration(wc), nil
}
default:
}
@@ -8449,6 +8559,67 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer
}, nil
}
// Organization is the resolver for the organization field.
func (r *webhookConfigurationResolver) Organization(ctx context.Context, obj *types.WebhookConfiguration) (*types.Organization, error) {
if err := r.authorize(ctx, obj.ID, probo.ActionOrganizationGet); err != nil {
return nil, err
}
prb := r.ProboService(ctx, obj.ID.TenantID())
organization, err := prb.Organizations.Get(ctx, obj.Organization.ID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFound(ctx, err)
}
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewOrganization(organization), nil
}
// SigningSecret is the resolver for the signingSecret field.
func (r *webhookConfigurationResolver) SigningSecret(ctx context.Context, obj *types.WebhookConfiguration) (string, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
signingSecret, err := prb.WebhookConfigurations.GetSigningSecret(ctx, obj.ID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot get signing secret", log.Error(err))
return "", gqlutils.Internal(ctx)
}
return signingSecret, nil
}
// Permission is the resolver for the permission field.
func (r *webhookConfigurationResolver) Permission(ctx context.Context, obj *types.WebhookConfiguration, action string) (bool, error) {
return r.Resolver.Permission(ctx, obj, action)
}
// TotalCount is the resolver for the totalCount field.
func (r *webhookConfigurationConnectionResolver) TotalCount(ctx context.Context, obj *types.WebhookConfigurationConnection) (int, error) {
if err := r.authorize(ctx, obj.ParentID, probo.ActionWebhookConfigurationList); err != nil {
return 0, err
}
prb := r.ProboService(ctx, obj.ParentID.TenantID())
switch obj.Resolver.(type) {
case *organizationResolver:
count, err := prb.WebhookConfigurations.CountForOrganizationID(ctx, obj.ParentID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot count webhook configurations", log.Error(err))
return 0, gqlutils.Internal(ctx)
}
return count, nil
}
r.logger.ErrorCtx(ctx, "unsupported resolver for webhook configuration connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
return 0, gqlutils.Internal(ctx)
}
// ApplicabilityStatement returns schema.ApplicabilityStatementResolver implementation.
func (r *Resolver) ApplicabilityStatement() schema.ApplicabilityStatementResolver {
return &applicabilityStatementResolver{r}
@@ -8751,6 +8922,16 @@ func (r *Resolver) VendorService() schema.VendorServiceResolver { return &vendor
// Viewer returns schema.ViewerResolver implementation.
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
// WebhookConfiguration returns schema.WebhookConfigurationResolver implementation.
func (r *Resolver) WebhookConfiguration() schema.WebhookConfigurationResolver {
return &webhookConfigurationResolver{r}
}
// WebhookConfigurationConnection returns schema.WebhookConfigurationConnectionResolver implementation.
func (r *Resolver) WebhookConfigurationConnection() schema.WebhookConfigurationConnectionResolver {
return &webhookConfigurationConnectionResolver{r}
}
type applicabilityStatementResolver struct{ *Resolver }
type applicabilityStatementConnectionResolver struct{ *Resolver }
type assetResolver struct{ *Resolver }
@@ -8823,3 +9004,5 @@ type vendorDataPrivacyAgreementResolver struct{ *Resolver }
type vendorRiskAssessmentResolver struct{ *Resolver }
type vendorServiceResolver struct{ *Resolver }
type viewerResolver struct{ *Resolver }
type webhookConfigurationResolver struct{ *Resolver }
type webhookConfigurationConnectionResolver struct{ *Resolver }