Change webhook table names
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -2293,13 +2293,13 @@ type WebhookConfiguration implements Node {
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
|
||||
calls(
|
||||
events(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: WebhookCallOrder
|
||||
): WebhookCallConnection! @goField(forceResolver: true)
|
||||
orderBy: WebhookEventOrder
|
||||
): WebhookEventConnection! @goField(forceResolver: true)
|
||||
|
||||
permission(action: String!): Boolean! @goField(forceResolver: true)
|
||||
}
|
||||
@@ -2318,54 +2318,54 @@ type WebhookConfigurationEdge {
|
||||
node: WebhookConfiguration!
|
||||
}
|
||||
|
||||
enum WebhookCallStatus
|
||||
@goModel(model: "go.probo.inc/probo/pkg/coredata.WebhookCallStatus") {
|
||||
enum WebhookEventStatus
|
||||
@goModel(model: "go.probo.inc/probo/pkg/coredata.WebhookEventStatus") {
|
||||
SUCCEEDED
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookCallStatusSucceeded")
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventStatusSucceeded")
|
||||
FAILED
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookCallStatusFailed")
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventStatusFailed")
|
||||
}
|
||||
|
||||
enum WebhookCallOrderField
|
||||
enum WebhookEventOrderField
|
||||
@goModel(
|
||||
model: "go.probo.inc/probo/pkg/coredata.WebhookCallOrderField"
|
||||
model: "go.probo.inc/probo/pkg/coredata.WebhookEventOrderField"
|
||||
) {
|
||||
CREATED_AT
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.WebhookCallOrderFieldCreatedAt"
|
||||
value: "go.probo.inc/probo/pkg/coredata.WebhookEventOrderFieldCreatedAt"
|
||||
)
|
||||
}
|
||||
|
||||
input WebhookCallOrder
|
||||
input WebhookEventOrder
|
||||
@goModel(
|
||||
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookCallOrderBy"
|
||||
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookEventOrderBy"
|
||||
) {
|
||||
field: WebhookCallOrderField!
|
||||
field: WebhookEventOrderField!
|
||||
direction: OrderDirection!
|
||||
}
|
||||
|
||||
type WebhookCall implements Node {
|
||||
type WebhookEvent implements Node {
|
||||
id: ID!
|
||||
webhookEventId: ID!
|
||||
webhookDataId: ID!
|
||||
webhookConfigurationId: ID!
|
||||
endpointUrl: String!
|
||||
status: WebhookCallStatus!
|
||||
status: WebhookEventStatus!
|
||||
response: String
|
||||
createdAt: Datetime!
|
||||
}
|
||||
|
||||
type WebhookCallConnection
|
||||
type WebhookEventConnection
|
||||
@goModel(
|
||||
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookCallConnection"
|
||||
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookEventConnection"
|
||||
) {
|
||||
edges: [WebhookCallEdge!]!
|
||||
edges: [WebhookEventEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
totalCount: Int! @goField(forceResolver: true)
|
||||
}
|
||||
|
||||
type WebhookCallEdge {
|
||||
type WebhookEventEdge {
|
||||
cursor: CursorKey!
|
||||
node: WebhookCall!
|
||||
node: WebhookEvent!
|
||||
}
|
||||
|
||||
type StateOfApplicability implements Node {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2623,24 +2623,6 @@ type Viewer struct {
|
||||
SignableDocument *SignableDocument `json:"signableDocument,omitempty"`
|
||||
}
|
||||
|
||||
type WebhookCall struct {
|
||||
ID gid.GID `json:"id"`
|
||||
WebhookEventID gid.GID `json:"webhookEventId"`
|
||||
WebhookConfigurationID gid.GID `json:"webhookConfigurationId"`
|
||||
EndpointURL string `json:"endpointUrl"`
|
||||
Status coredata.WebhookCallStatus `json:"status"`
|
||||
Response *string `json:"response,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
func (WebhookCall) IsNode() {}
|
||||
func (this WebhookCall) GetID() gid.GID { return this.ID }
|
||||
|
||||
type WebhookCallEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *WebhookCall `json:"node"`
|
||||
}
|
||||
|
||||
type WebhookConfiguration struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
@@ -2649,7 +2631,7 @@ type WebhookConfiguration struct {
|
||||
SelectedEvents []coredata.WebhookEventType `json:"selectedEvents"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
Calls *WebhookCallConnection `json:"calls"`
|
||||
Events *WebhookEventConnection `json:"events"`
|
||||
Permission bool `json:"permission"`
|
||||
}
|
||||
|
||||
@@ -2660,3 +2642,21 @@ type WebhookConfigurationEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *WebhookConfiguration `json:"node"`
|
||||
}
|
||||
|
||||
type WebhookEvent struct {
|
||||
ID gid.GID `json:"id"`
|
||||
WebhookDataID gid.GID `json:"webhookDataId"`
|
||||
WebhookConfigurationID gid.GID `json:"webhookConfigurationId"`
|
||||
EndpointURL string `json:"endpointUrl"`
|
||||
Status coredata.WebhookEventStatus `json:"status"`
|
||||
Response *string `json:"response,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
func (WebhookEvent) IsNode() {}
|
||||
func (this WebhookEvent) GetID() gid.GID { return this.ID }
|
||||
|
||||
type WebhookEventEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *WebhookEvent `json:"node"`
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
WebhookCallOrderBy OrderBy[coredata.WebhookCallOrderField]
|
||||
WebhookEventOrderBy OrderBy[coredata.WebhookEventOrderField]
|
||||
|
||||
WebhookCallConnection struct {
|
||||
WebhookEventConnection struct {
|
||||
TotalCount int
|
||||
Edges []*WebhookCallEdge
|
||||
Edges []*WebhookEventEdge
|
||||
PageInfo PageInfo
|
||||
|
||||
Resolver any
|
||||
@@ -33,18 +33,18 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func NewWebhookCallConnection(
|
||||
p *page.Page[*coredata.WebhookCall, coredata.WebhookCallOrderField],
|
||||
func NewWebhookEventConnection(
|
||||
p *page.Page[*coredata.WebhookEvent, coredata.WebhookEventOrderField],
|
||||
parentType any,
|
||||
parentID gid.GID,
|
||||
) *WebhookCallConnection {
|
||||
var edges = make([]*WebhookCallEdge, len(p.Data))
|
||||
) *WebhookEventConnection {
|
||||
var edges = make([]*WebhookEventEdge, len(p.Data))
|
||||
|
||||
for i := range edges {
|
||||
edges[i] = NewWebhookCallEdge(p.Data[i], p.Cursor.OrderBy.Field)
|
||||
edges[i] = NewWebhookEventEdge(p.Data[i], p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &WebhookCallConnection{
|
||||
return &WebhookEventConnection{
|
||||
Edges: edges,
|
||||
PageInfo: *NewPageInfo(p),
|
||||
|
||||
@@ -53,27 +53,27 @@ func NewWebhookCallConnection(
|
||||
}
|
||||
}
|
||||
|
||||
func NewWebhookCallEdge(wc *coredata.WebhookCall, orderBy coredata.WebhookCallOrderField) *WebhookCallEdge {
|
||||
return &WebhookCallEdge{
|
||||
Cursor: wc.CursorKey(orderBy),
|
||||
Node: NewWebhookCall(wc),
|
||||
func NewWebhookEventEdge(we *coredata.WebhookEvent, orderBy coredata.WebhookEventOrderField) *WebhookEventEdge {
|
||||
return &WebhookEventEdge{
|
||||
Cursor: we.CursorKey(orderBy),
|
||||
Node: NewWebhookEvent(we),
|
||||
}
|
||||
}
|
||||
|
||||
func NewWebhookCall(wc *coredata.WebhookCall) *WebhookCall {
|
||||
func NewWebhookEvent(we *coredata.WebhookEvent) *WebhookEvent {
|
||||
var response *string
|
||||
if len(wc.Response) > 0 {
|
||||
s := string(wc.Response)
|
||||
if len(we.Response) > 0 {
|
||||
s := string(we.Response)
|
||||
response = &s
|
||||
}
|
||||
|
||||
return &WebhookCall{
|
||||
ID: wc.ID,
|
||||
WebhookEventID: wc.WebhookEventID,
|
||||
WebhookConfigurationID: wc.WebhookConfigurationID,
|
||||
EndpointURL: wc.EndpointURL,
|
||||
Status: wc.Status,
|
||||
return &WebhookEvent{
|
||||
ID: we.ID,
|
||||
WebhookDataID: we.WebhookDataID,
|
||||
WebhookConfigurationID: we.WebhookConfigurationID,
|
||||
EndpointURL: we.EndpointURL,
|
||||
Status: we.Status,
|
||||
Response: response,
|
||||
CreatedAt: wc.CreatedAt,
|
||||
CreatedAt: we.CreatedAt,
|
||||
}
|
||||
}
|
||||
@@ -8559,23 +8559,6 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer
|
||||
}, nil
|
||||
}
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *webhookCallConnectionResolver) TotalCount(ctx context.Context, obj *types.WebhookCallConnection) (int, error) {
|
||||
if err := r.authorize(ctx, obj.ParentID, probo.ActionWebhookConfigurationGet); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
|
||||
count, err := prb.WebhookConfigurations.CountCallsForConfigurationID(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count webhook calls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, 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 {
|
||||
@@ -8599,6 +8582,10 @@ func (r *webhookConfigurationResolver) Organization(ctx context.Context, obj *ty
|
||||
|
||||
// SigningSecret is the resolver for the signingSecret field.
|
||||
func (r *webhookConfigurationResolver) SigningSecret(ctx context.Context, obj *types.WebhookConfiguration) (string, error) {
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionWebhookConfigurationUpdate); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
signingSecret, err := prb.WebhookConfigurations.GetSigningSecret(ctx, obj.ID)
|
||||
@@ -8610,20 +8597,20 @@ func (r *webhookConfigurationResolver) SigningSecret(ctx context.Context, obj *t
|
||||
return signingSecret, nil
|
||||
}
|
||||
|
||||
// Calls is the resolver for the calls field.
|
||||
func (r *webhookConfigurationResolver) Calls(ctx context.Context, obj *types.WebhookConfiguration, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.WebhookCallOrderBy) (*types.WebhookCallConnection, error) {
|
||||
// Events is the resolver for the events field.
|
||||
func (r *webhookConfigurationResolver) Events(ctx context.Context, obj *types.WebhookConfiguration, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.WebhookEventOrderBy) (*types.WebhookEventConnection, error) {
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionWebhookConfigurationGet); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.WebhookCallOrderField]{
|
||||
Field: coredata.WebhookCallOrderFieldCreatedAt,
|
||||
pageOrderBy := page.OrderBy[coredata.WebhookEventOrderField]{
|
||||
Field: coredata.WebhookEventOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.WebhookCallOrderField]{
|
||||
pageOrderBy = page.OrderBy[coredata.WebhookEventOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
@@ -8631,13 +8618,13 @@ func (r *webhookConfigurationResolver) Calls(ctx context.Context, obj *types.Web
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.WebhookConfigurations.ListCallsForConfigurationID(ctx, obj.ID, cursor)
|
||||
page, err := prb.WebhookConfigurations.ListEventsForConfigurationID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list webhook calls", log.Error(err))
|
||||
r.logger.ErrorCtx(ctx, "cannot list webhook events", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewWebhookCallConnection(page, r, obj.ID), nil
|
||||
return types.NewWebhookEventConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// Permission is the resolver for the permission field.
|
||||
@@ -8667,6 +8654,23 @@ func (r *webhookConfigurationConnectionResolver) TotalCount(ctx context.Context,
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *webhookEventConnectionResolver) TotalCount(ctx context.Context, obj *types.WebhookEventConnection) (int, error) {
|
||||
if err := r.authorize(ctx, obj.ParentID, probo.ActionWebhookConfigurationGet); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
|
||||
count, err := prb.WebhookConfigurations.CountEventsForConfigurationID(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count webhook events", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// ApplicabilityStatement returns schema.ApplicabilityStatementResolver implementation.
|
||||
func (r *Resolver) ApplicabilityStatement() schema.ApplicabilityStatementResolver {
|
||||
return &applicabilityStatementResolver{r}
|
||||
@@ -8969,11 +8973,6 @@ func (r *Resolver) VendorService() schema.VendorServiceResolver { return &vendor
|
||||
// Viewer returns schema.ViewerResolver implementation.
|
||||
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
|
||||
|
||||
// WebhookCallConnection returns schema.WebhookCallConnectionResolver implementation.
|
||||
func (r *Resolver) WebhookCallConnection() schema.WebhookCallConnectionResolver {
|
||||
return &webhookCallConnectionResolver{r}
|
||||
}
|
||||
|
||||
// WebhookConfiguration returns schema.WebhookConfigurationResolver implementation.
|
||||
func (r *Resolver) WebhookConfiguration() schema.WebhookConfigurationResolver {
|
||||
return &webhookConfigurationResolver{r}
|
||||
@@ -8984,6 +8983,11 @@ func (r *Resolver) WebhookConfigurationConnection() schema.WebhookConfigurationC
|
||||
return &webhookConfigurationConnectionResolver{r}
|
||||
}
|
||||
|
||||
// WebhookEventConnection returns schema.WebhookEventConnectionResolver implementation.
|
||||
func (r *Resolver) WebhookEventConnection() schema.WebhookEventConnectionResolver {
|
||||
return &webhookEventConnectionResolver{r}
|
||||
}
|
||||
|
||||
type applicabilityStatementResolver struct{ *Resolver }
|
||||
type applicabilityStatementConnectionResolver struct{ *Resolver }
|
||||
type assetResolver struct{ *Resolver }
|
||||
@@ -9056,6 +9060,6 @@ type vendorDataPrivacyAgreementResolver struct{ *Resolver }
|
||||
type vendorRiskAssessmentResolver struct{ *Resolver }
|
||||
type vendorServiceResolver struct{ *Resolver }
|
||||
type viewerResolver struct{ *Resolver }
|
||||
type webhookCallConnectionResolver struct{ *Resolver }
|
||||
type webhookConfigurationResolver struct{ *Resolver }
|
||||
type webhookConfigurationConnectionResolver struct{ *Resolver }
|
||||
type webhookEventConnectionResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user