datastore

package
v1.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2023 License: MPL-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultProjectConfig = ProjectConfig{
		RetentionPolicy:          &DefaultRetentionPolicy,
		MaxIngestSize:            config.MaxResponseSize,
		ReplayAttacks:            false,
		IsRetentionPolicyEnabled: false,
		DisableEndpoint:          false,
		AddEventIDTraceHeaders:   false,
		RateLimit:                &DefaultRateLimitConfig,
		Strategy:                 &DefaultStrategyConfig,
		Signature:                GetDefaultSignatureConfig(),
		MetaEvent:                &MetaEventConfiguration{IsEnabled: false},
	}

	DefaultStrategyConfig = StrategyConfiguration{
		Type:       DefaultStrategyProvider,
		Duration:   100,
		RetryCount: 10,
	}

	DefaultRateLimitConfig = RateLimitConfiguration{
		Count:    1000,
		Duration: 60,
	}

	DefaultRetryConfig = RetryConfiguration{
		Type:       LinearStrategyProvider,
		Duration:   10,
		RetryCount: 3,
	}

	DefaultAlertConfig = AlertConfiguration{
		Count:     4,
		Threshold: "1h",
	}
	DefaultStoragePolicy = StoragePolicyConfiguration{
		Type: OnPrem,
		OnPrem: &OnPremStorage{
			Path: null.NewString(convoy.DefaultOnPremDir, true),
		},
	}

	DefaultRetentionPolicy = RetentionPolicyConfiguration{
		Policy:       "720h",
		SearchPolicy: "720h",
	}
)
View Source
var (
	ErrOrgNotFound       = errors.New("organisation not found")
	ErrDeviceNotFound    = errors.New("device not found")
	ErrOrgInviteNotFound = errors.New("organisation invite not found")
	ErrOrgMemberNotFound = errors.New("organisation member not found")
)
View Source
var (
	ErrSignupDisabled                = errors.New("user registration is disabled")
	ErrUserNotFound                  = errors.New("user not found")
	ErrSourceNotFound                = errors.New("source not found")
	ErrEventNotFound                 = errors.New("event not found")
	ErrProjectNotFound               = errors.New("project not found")
	ErrAPIKeyNotFound                = errors.New("api key not found")
	ErrEndpointNotFound              = errors.New("endpoint not found")
	ErrSubscriptionNotFound          = errors.New("subscription not found")
	ErrEventDeliveryNotFound         = errors.New("event delivery not found")
	ErrEventDeliveryAttemptNotFound  = errors.New("event delivery attempt not found")
	ErrPortalLinkNotFound            = errors.New("portal link not found")
	ErrNotAuthorisedToAccessDocument = errors.New("your credentials cannot access or modify this resource")
	ErrConfigNotFound                = errors.New("config not found")
	ErrDuplicateProjectName          = errors.New("a project with this name already exists")
	ErrDuplicateEmail                = errors.New("a user with this email already exists")
	ErrNoActiveSecret                = errors.New("no active secret found")
	ErrSecretNotFound                = errors.New("secret not found")
	ErrMetaEventNotFound             = errors.New("meta event not found")
)
View Source
var DefaultCursor = fmt.Sprintf("%d", math.MaxInt)
View Source
var PeriodValues = map[string]Period{
	"daily":   Daily,
	"weekly":  Weekly,
	"monthly": Monthly,
	"yearly":  Yearly,
}

Functions

func IsValidPeriod

func IsValidPeriod(period string) bool

Types

type APIKey

type APIKey struct {
	UID       string    `json:"uid" db:"id"`
	MaskID    string    `json:"mask_id,omitempty" db:"mask_id"`
	Name      string    `json:"name" db:"name"`
	Role      auth.Role `json:"role" db:"role"`
	Hash      string    `json:"hash,omitempty" db:"hash"`
	Salt      string    `json:"salt,omitempty" db:"salt"`
	Type      KeyType   `json:"key_type" db:"key_type"`
	UserID    string    `json:"user_id" db:"user_id"`
	ExpiresAt null.Time `json:"expires_at,omitempty" db:"expires_at"`
	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at"`
}

type APIKeyRepository

type APIKeyRepository interface {
	CreateAPIKey(context.Context, *APIKey) error
	UpdateAPIKey(context.Context, *APIKey) error
	FindAPIKeyByID(context.Context, string) (*APIKey, error)
	FindAPIKeyByProjectID(context.Context, string) (*APIKey, error)
	FindAPIKeyByMaskID(context.Context, string) (*APIKey, error)
	FindAPIKeyByHash(context.Context, string) (*APIKey, error)
	RevokeAPIKeys(context.Context, []string) error
	LoadAPIKeysPaged(context.Context, *ApiKeyFilter, *Pageable) ([]APIKey, PaginationData, error)
}

type AlertConfiguration added in v0.6.0

type AlertConfiguration struct {
	Count     int    `json:"count" db:"count"`
	Threshold string `json:"threshold" db:"threshold" valid:"duration~please provide a valid time duration"`
}

type ApiKey added in v0.6.0

type ApiKey struct {
	HeaderValue string `json:"header_value" db:"header_value" valid:"required"`
	HeaderName  string `json:"header_name" db:"header_name" valid:"required"`
}

type ApiKeyFilter added in v0.7.0

type ApiKeyFilter struct {
	ProjectID   string
	EndpointID  string
	EndpointIDs []string
	UserID      string
	KeyType     KeyType
}

type AppMetadata

type AppMetadata struct {
	UID          string `json:"uid" bson:"uid"`
	Title        string `json:"title" bson:"title"`
	ProjectID    string `json:"project_id" bson:"project_id"`
	SupportEmail string `json:"support_email" bson:"support_email"`
}

type Application

type Application struct {
	UID             string `json:"uid" db:"id"`
	ProjectID       string `json:"project_id" db:"project_id"`
	Title           string `json:"name" db:"title"`
	SupportEmail    string `json:"support_email,omitempty" db:"support_email"`
	SlackWebhookURL string `json:"slack_webhook_url,omitempty" db:"slack_webhook_url"`
	IsDisabled      bool   `json:"is_disabled,omitempty" db:"is_disabled"`

	Endpoints []DeprecatedEndpoint `json:"endpoints,omitempty" db:"endpoints"`
	CreatedAt time.Time            `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt time.Time            `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt null.Time            `json:"deleted_at,omitempty" db:"deleted_at,omitempty" swaggertype:"string"`

	Events int64 `json:"events,omitempty" db:"-"`
}

Deprecated

type BasicAuth added in v0.6.0

type BasicAuth struct {
	UserName string `json:"username" db:"username" valid:"required" `
	Password string `json:"password" db:"password" valid:"required"`
}

type CLIMetadata added in v0.7.0

type CLIMetadata struct {
	EventType string `json:"event_type" db:"event_type"`
	SourceID  string `json:"source_id" db:"source_id"`
}

func (*CLIMetadata) Scan added in v0.9.0

func (m *CLIMetadata) Scan(value interface{}) error

func (*CLIMetadata) Value added in v0.9.0

func (m *CLIMetadata) Value() (driver.Value, error)

type Configuration added in v0.6.0

type Configuration struct {
	UID                string                      `json:"uid" db:"id"`
	IsAnalyticsEnabled bool                        `json:"is_analytics_enabled" db:"is_analytics_enabled"`
	IsSignupEnabled    bool                        `json:"is_signup_enabled" db:"is_signup_enabled"`
	StoragePolicy      *StoragePolicyConfiguration `json:"storage_policy" db:"storage_policy"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type ConfigurationRepository added in v0.6.0

type ConfigurationRepository interface {
	CreateConfiguration(context.Context, *Configuration) error
	LoadConfiguration(context.Context) (*Configuration, error)
	UpdateConfiguration(context.Context, *Configuration) error
}

type CustomResponse added in v1.1.6

type CustomResponse struct {
	Body        string `json:"body" db:"body"`
	ContentType string `json:"content_type" db:"content_type"`
}

type DeliveryAttempt

type DeliveryAttempt struct {
	UID        string `json:"uid" db:"id"`
	MsgID      string `json:"msg_id" db:"msg_id"`
	URL        string `json:"url" db:"url"`
	Method     string `json:"method" db:"method"`
	EndpointID string `json:"endpoint_id" db:"endpoint_id"`
	APIVersion string `json:"api_version" db:"api_version"`

	IPAddress        string     `json:"ip_address,omitempty" db:"ip_address"`
	RequestHeader    HttpHeader `json:"request_http_header,omitempty" db:"request_http_header"`
	ResponseHeader   HttpHeader `json:"response_http_header,omitempty" db:"response_http_header"`
	HttpResponseCode string     `json:"http_status,omitempty" db:"http_status"`
	ResponseData     string     `json:"response_data,omitempty" db:"response_data"`
	Error            string     `json:"error,omitempty" db:"error"`
	Status           bool       `json:"status,omitempty" db:"statu,"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type DeliveryAttempts added in v0.9.0

type DeliveryAttempts []DeliveryAttempt

func (*DeliveryAttempts) Scan added in v0.9.0

func (h *DeliveryAttempts) Scan(value interface{}) error

func (DeliveryAttempts) Value added in v0.9.0

func (h DeliveryAttempts) Value() (driver.Value, error)

type DeprecatedEndpoint added in v0.8.0

type DeprecatedEndpoint struct {
	UID                string   `json:"uid" db:"uid"`
	TargetURL          string   `json:"target_url" db:"target_url"`
	Description        string   `json:"description" db:"description"`
	Secret             string   `json:"-" db:"secret"`
	Secrets            []Secret `json:"secrets" db:"secrets"`
	AdvancedSignatures bool     `json:"advanced_signatures" db:"advanced_signatures"`

	HttpTimeout       string                  `json:"http_timeout" db:"http_timeout"`
	RateLimit         int                     `json:"rate_limit" db:"rate_limit"`
	RateLimitDuration string                  `json:"rate_limit_duration" db:"rate_limit_duration"`
	Authentication    *EndpointAuthentication `json:"authentication" db:"authentication,omitempty"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at,omitempty" swaggertype:"string"`
}

Deprecated

type Device added in v0.7.0

type Device struct {
	UID        string       `json:"uid" db:"id"`
	ProjectID  string       `json:"project_id,omitempty" db:"project_id"`
	EndpointID string       `json:"endpoint_id,omitempty" db:"endpoint_id"`
	HostName   string       `json:"host_name,omitempty" db:"host_name"`
	Status     DeviceStatus `json:"status,omitempty" db:"status"`
	LastSeenAt time.Time    `json:"last_seen_at,omitempty" db:"last_seen_at,omitempty" swaggertype:"string"`
	CreatedAt  time.Time    `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt  time.Time    `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt  null.Time    `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type DeviceRepository added in v0.7.0

type DeviceRepository interface {
	CreateDevice(ctx context.Context, device *Device) error
	UpdateDevice(ctx context.Context, device *Device, appID, projectID string) error
	UpdateDeviceLastSeen(ctx context.Context, device *Device, appID, projectID string, status DeviceStatus) error
	DeleteDevice(ctx context.Context, uid string, appID, projectID string) error
	FetchDeviceByID(ctx context.Context, uid string, appID, projectID string) (*Device, error)
	FetchDeviceByHostName(ctx context.Context, hostName string, appID, projectID string) (*Device, error)
	LoadDevicesPaged(ctx context.Context, projectID string, filter *ApiKeyFilter, pageable Pageable) ([]Device, PaginationData, error)
}

type DeviceStatus added in v0.7.0

type DeviceStatus string
const (
	DeviceStatusOffline  DeviceStatus = "offline"
	DeviceStatusOnline   DeviceStatus = "online"
	DeviceStatusDisabled DeviceStatus = "disabled"
)

type EncodingType added in v0.6.0

type EncodingType string
const (
	Base64Encoding EncodingType = "base64"
	HexEncoding    EncodingType = "hex"
)

func (EncodingType) String added in v0.7.2

func (e EncodingType) String() string

type Endpoint

type Endpoint struct {
	UID                string  `json:"uid" db:"id"`
	ProjectID          string  `json:"project_id" db:"project_id"`
	OwnerID            string  `json:"owner_id,omitempty" db:"owner_id"`
	TargetURL          string  `json:"target_url" db:"target_url"`
	Title              string  `json:"title" db:"title"`
	Secrets            Secrets `json:"secrets" db:"secrets"`
	AdvancedSignatures bool    `json:"advanced_signatures" db:"advanced_signatures"`
	Description        string  `json:"description" db:"description"`
	SlackWebhookURL    string  `json:"slack_webhook_url,omitempty" db:"slack_webhook_url"`
	SupportEmail       string  `json:"support_email,omitempty" db:"support_email"`
	AppID              string  `json:"-" db:"app_id"` // Deprecated but necessary for backward compatibility

	HttpTimeout string         `json:"http_timeout" db:"http_timeout"`
	RateLimit   int            `json:"rate_limit" db:"rate_limit"`
	Events      int64          `json:"events,omitempty" db:"event_count"`
	Status      EndpointStatus `json:"status" db:"status"`

	RateLimitDuration string                  `json:"rate_limit_duration" db:"rate_limit_duration"`
	Authentication    *EndpointAuthentication `json:"authentication" db:"authentication"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

func (*Endpoint) FindSecret added in v0.9.0

func (e *Endpoint) FindSecret(secretID string) *Secret

func (*Endpoint) GetActiveSecretIndex added in v0.7.2

func (e *Endpoint) GetActiveSecretIndex() (int, error)

func (*Endpoint) GetAuthConfig added in v0.9.0

func (e *Endpoint) GetAuthConfig() EndpointAuthentication

type EndpointAuthentication added in v0.7.0

type EndpointAuthentication struct {
	Type   EndpointAuthenticationType `json:"type,omitempty" db:"type" valid:"optional,in(api_key)~unsupported authentication type"`
	ApiKey *ApiKey                    `json:"api_key" db:"api_key"`
}

type EndpointAuthenticationType added in v0.7.0

type EndpointAuthenticationType string
const (
	APIKeyAuthentication EndpointAuthenticationType = "api_key"
)

type EndpointConfig added in v0.9.0

type EndpointConfig struct {
	AdvancedSignatures bool                    `json:"advanced_signatures" db:"advanced_signatures"`
	Secrets            []Secret                `json:"secrets" db:"secrets"`
	RateLimit          *RateLimitConfiguration `json:"ratelimit" db:"ratelimit"`
	Authentication     *EndpointAuthentication `json:"authentication" db:"authentication"`
}

type EndpointMetadata

type EndpointMetadata []*Endpoint

func (*EndpointMetadata) Scan added in v0.9.0

func (s *EndpointMetadata) Scan(v interface{}) error

type EndpointRepository added in v0.8.0

type EndpointRepository interface {
	CreateEndpoint(ctx context.Context, endpoint *Endpoint, projectID string) error
	FindEndpointByID(ctx context.Context, id string, projectID string) (*Endpoint, error)
	FindEndpointsByID(ctx context.Context, ids []string, projectID string) ([]Endpoint, error)
	FindEndpointsByAppID(ctx context.Context, appID string, projectID string) ([]Endpoint, error)
	FindEndpointsByOwnerID(ctx context.Context, projectID string, ownerID string) ([]Endpoint, error)
	FindEndpointByTargetURL(ctx context.Context, projectID string, targetURL string) (*Endpoint, error)
	UpdateEndpoint(ctx context.Context, endpoint *Endpoint, projectID string) error
	UpdateEndpointStatus(ctx context.Context, projectID, endpointID string, status EndpointStatus) error
	DeleteEndpoint(ctx context.Context, endpoint *Endpoint, projectID string) error
	CountProjectEndpoints(ctx context.Context, projectID string) (int64, error)
	LoadEndpointsPaged(ctx context.Context, projectID string, filter *Filter, pageable Pageable) ([]Endpoint, PaginationData, error)
	UpdateSecrets(ctx context.Context, endpointID string, projectID string, secrets Secrets) error
	DeleteSecret(ctx context.Context, endpoint *Endpoint, secretID string, projectID string) error
}

type EndpointStatus

type EndpointStatus string
const (
	ActiveEndpointStatus   EndpointStatus = "active"
	InactiveEndpointStatus EndpointStatus = "inactive"
	PendingEndpointStatus  EndpointStatus = "pending"
	PausedEndpointStatus   EndpointStatus = "paused"
)

type Event

type Event struct {
	UID       string    `json:"uid" db:"id"`
	EventType EventType `json:"event_type" db:"event_type"`

	SourceID         string                `json:"source_id,omitempty" db:"source_id"`
	AppID            string                `json:"app_id,omitempty" db:"app_id"` // Deprecated
	ProjectID        string                `json:"project_id,omitempty" db:"project_id"`
	Endpoints        pq.StringArray        `json:"endpoints" db:"endpoints"`
	Headers          httpheader.HTTPHeader `json:"headers" db:"headers"`
	EndpointMetadata EndpointMetadata      `json:"endpoint_metadata,omitempty" db:"endpoint_metadata"`
	Source           *Source               `json:"source_metadata,omitempty" db:"source_metadata"`
	URLQueryParams   string                `json:"url_query_params" db:"url_query_params"`
	IdempotencyKey   string                `json:"idempotency_key" db:"idempotency_key"`
	IsDuplicateEvent bool                  `json:"is_duplicate_event" db:"is_duplicate_event"`

	// Data is an arbitrary JSON value that gets sent as the body of the
	// webhook to the endpoints
	Data json.RawMessage `json:"data,omitempty" db:"data"`
	Raw  string          `json:"raw,omitempty" db:"raw"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

Event defines a payload to be sent to an application

func (*Event) GetRawHeaders added in v0.8.0

func (e *Event) GetRawHeaders() interface{}

func (*Event) GetRawHeadersJSON added in v0.8.0

func (e *Event) GetRawHeadersJSON() ([]byte, error)

type EventDelivery

type EventDelivery struct {
	UID            string                `json:"uid" db:"id"`
	ProjectID      string                `json:"project_id,omitempty" db:"project_id"`
	EventID        string                `json:"event_id,omitempty" db:"event_id"`
	EndpointID     string                `json:"endpoint_id,omitempty" db:"endpoint_id"`
	DeviceID       string                `json:"device_id" db:"device_id"`
	SubscriptionID string                `json:"subscription_id,omitempty" db:"subscription_id"`
	Headers        httpheader.HTTPHeader `json:"headers" db:"headers"`
	URLQueryParams string                `json:"url_query_params" db:"url_query_params"`
	IdempotencyKey string                `json:"idempotency_key" db:"idempotency_key"`

	Endpoint *Endpoint `json:"endpoint_metadata,omitempty" db:"endpoint_metadata"`
	Event    *Event    `json:"event_metadata,omitempty" db:"event_metadata"`
	Source   *Source   `json:"source_metadata,omitempty" db:"source_metadata"`
	Device   *Device   `json:"device_metadata,omitempty" db:"device_metadata"`

	DeliveryAttempts DeliveryAttempts    `json:"-" db:"attempts"`
	Status           EventDeliveryStatus `json:"status" db:"status"`
	Metadata         *Metadata           `json:"metadata" db:"metadata"`
	CLIMetadata      *CLIMetadata        `json:"cli_metadata" db:"cli_metadata"`
	Description      string              `json:"description,omitempty" db:"description"`
	CreatedAt        time.Time           `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt        time.Time           `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt        null.Time           `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

EventDelivery defines a payload to be sent to an endpoint

type EventDeliveryFilter added in v0.6.0

type EventDeliveryFilter struct {
	ProjectID      string `json:"project_id" bson:"project_id"`
	CreatedAtStart int64  `json:"created_at_start" bson:"created_at_start"`
	CreatedAtEnd   int64  `json:"created_at_end" bson:"created_at_end"`
}

type EventDeliveryRepository

type EventDeliveryRepository interface {
	CreateEventDelivery(context.Context, *EventDelivery) error
	FindEventDeliveryByID(ctx context.Context, projectID string, id string) (*EventDelivery, error)
	FindEventDeliveriesByIDs(ctx context.Context, projectID string, ids []string) ([]EventDelivery, error)
	FindEventDeliveriesByEventID(ctx context.Context, projectID string, id string) ([]EventDelivery, error)
	CountDeliveriesByStatus(ctx context.Context, projectID string, status EventDeliveryStatus, params SearchParams) (int64, error)
	UpdateStatusOfEventDelivery(ctx context.Context, projectID string, eventDelivery EventDelivery, status EventDeliveryStatus) error
	UpdateStatusOfEventDeliveries(ctx context.Context, projectID string, ids []string, status EventDeliveryStatus) error
	FindDiscardedEventDeliveries(ctx context.Context, projectID, deviceId string, params SearchParams) ([]EventDelivery, error)

	UpdateEventDeliveryWithAttempt(ctx context.Context, projectID string, eventDelivery EventDelivery, attempt DeliveryAttempt) error
	CountEventDeliveries(ctx context.Context, projectID string, endpointIDs []string, eventID string, status []EventDeliveryStatus, params SearchParams) (int64, error)
	DeleteProjectEventDeliveries(ctx context.Context, projectID string, filter *EventDeliveryFilter, hardDelete bool) error
	LoadEventDeliveriesPaged(ctx context.Context, projectID string, endpointIDs []string, eventID, subscriptionID string, status []EventDeliveryStatus, params SearchParams, pageable Pageable, idempotencyKey string) ([]EventDelivery, PaginationData, error)
	LoadEventDeliveriesIntervals(ctx context.Context, projectID string, params SearchParams, period Period) ([]EventInterval, error)
}

type EventDeliveryStatus

type EventDeliveryStatus string
const (
	// ScheduledEventStatus : when an Event has been scheduled for delivery
	ScheduledEventStatus  EventDeliveryStatus = "Scheduled"
	ProcessingEventStatus EventDeliveryStatus = "Processing"
	DiscardedEventStatus  EventDeliveryStatus = "Discarded"
	FailureEventStatus    EventDeliveryStatus = "Failure"
	SuccessEventStatus    EventDeliveryStatus = "Success"
	RetryEventStatus      EventDeliveryStatus = "Retry"
)

func (EventDeliveryStatus) IsValid added in v0.4.10

func (e EventDeliveryStatus) IsValid() bool

type EventFilter added in v0.6.0

type EventFilter struct {
	ProjectID      string `json:"project_id" bson:"project_id"`
	CreatedAtStart int64  `json:"created_at_start" bson:"created_at_start"`
	CreatedAtEnd   int64  `json:"created_at_end" bson:"created_at_end"`
}

type EventInterval

type EventInterval struct {
	Data  EventIntervalData `json:"data" db:"data"`
	Count uint64            `json:"count" db:"count"`
}

type EventIntervalData

type EventIntervalData struct {
	Interval  int64  `json:"index" db:"index"`
	Time      string `json:"date" db:"total_time"`
	GroupStub string `json:"-" db:"group_only"` // ugnore
}

type EventRepository

type EventRepository interface {
	CreateEvent(context.Context, *Event) error
	FindEventByID(ctx context.Context, projectID string, id string) (*Event, error)
	FindEventsByIDs(ctx context.Context, projectID string, ids []string) ([]Event, error)
	CountProjectMessages(ctx context.Context, projectID string) (int64, error)
	CountEvents(ctx context.Context, projectID string, f *Filter) (int64, error)
	LoadEventsPaged(ctx context.Context, projectID string, f *Filter) ([]Event, PaginationData, error)
	DeleteProjectEvents(ctx context.Context, projectID string, f *EventFilter, hardDelete bool) error
	DeleteProjectTokenizedEvents(ctx context.Context, projectID string, filter *EventFilter) error
	FindEventsByIdempotencyKey(ctx context.Context, projectID string, idempotencyKey string) ([]Event, error)
	FindFirstEventWithIdempotencyKey(ctx context.Context, projectID string, idempotencyKey string) (*Event, error)
	CopyRows(ctx context.Context, projectID string, interval int) error
}

type EventType

type EventType string

EventType is used to identify a specific event. This could be "user.new" This will be used for data indexing Makes it easy to filter by a list of events

type ExportRepository added in v0.9.0

type ExportRepository interface {
	ExportRecords(ctx context.Context, tableName, projectID string, createdAt time.Time, w io.Writer) (int64, error)
}

type Filter added in v0.5.0

type Filter struct {
	Query          string
	OwnerID        string
	Project        *Project
	EndpointID     string
	EndpointIDs    []string
	SubscriptionID string
	EventID        string
	SourceID       string
	Pageable       Pageable
	IdempotencyKey string
	Status         []EventDeliveryStatus
	SearchParams   SearchParams
}

type FilterBy added in v0.6.5

type FilterBy struct {
	EndpointID   string
	EndpointIDs  []string
	ProjectID    string
	SourceID     string
	SearchParams SearchParams
}

func (*FilterBy) String added in v0.6.5

func (f *FilterBy) String() *string

type FilterConfiguration added in v0.6.0

type FilterConfiguration struct {
	EventTypes pq.StringArray `json:"event_types" db:"event_types"`
	Filter     FilterSchema   `json:"filter" db:"filter"`
}

type FilterSchema added in v0.8.0

type FilterSchema struct {
	Headers M `json:"headers" db:"headers"`
	Body    M `json:"body" db:"body"`
}

type GooglePubSubConfig added in v0.9.0

type GooglePubSubConfig struct {
	SubscriptionID string `json:"subscription_id" db:"subscription_id"`
	ServiceAccount []byte `json:"service_account" db:"service_account"`
	ProjectID      string `json:"project_id" db:"project_id"`
}

type HMac added in v0.6.0

type HMac struct {
	Header   string       `json:"header" db:"header" valid:"required"`
	Hash     string       `json:"hash" db:"hash" valid:"supported_hash,required"`
	Secret   string       `json:"secret" db:"secret" valid:"required"`
	Encoding EncodingType `json:"encoding" db:"encoding" valid:"supported_encoding~please provide a valid encoding type,required"`
}

type HookEventType added in v1.1.6

type HookEventType string
const (
	ProjectUpdated       HookEventType = "project.updated"
	EndpointCreated      HookEventType = "endpoint.created"
	EndpointUpdated      HookEventType = "endpoint.updated"
	EndpointDeleted      HookEventType = "endpoint.deleted"
	EventDeliveryUpdated HookEventType = "eventdelivery.updated"
	EventDeliverySuccess HookEventType = "eventdelivery.success"
	EventDeliveryFailed  HookEventType = "eventdelivery.failed"
)

type HttpHeader

type HttpHeader map[string]string

func (HttpHeader) SetHeadersInRequest added in v0.6.0

func (h HttpHeader) SetHeadersInRequest(r *http.Request)

type InviteStatus added in v0.6.0

type InviteStatus string
const (
	InviteStatusAccepted  InviteStatus = "accepted"
	InviteStatusDeclined  InviteStatus = "declined"
	InviteStatusPending   InviteStatus = "pending"
	InviteStatusCancelled InviteStatus = "cancelled"
)

func (InviteStatus) String added in v0.6.0

func (i InviteStatus) String() string

type Job added in v1.1.6

type Job struct {
	UID         string    `json:"uid" db:"id"`
	Type        string    `json:"type" db:"type"`
	Status      JobStatus `json:"status,omitempty" db:"status"`
	ProjectID   string    `json:"project_id,omitempty" db:"project_id"`
	FailedAt    null.Time `json:"failed_at,omitempty" db:"failed_at,omitempty" swaggertype:"string"`
	StartedAt   null.Time `json:"started_at,omitempty" db:"started_at,omitempty" swaggertype:"string"`
	CompletedAt null.Time `json:"completed_at,omitempty" db:"completed_at,omitempty" swaggertype:"string"`
	CreatedAt   time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt   time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt   null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type JobRepository added in v1.1.6

type JobRepository interface {
	CreateJob(ctx context.Context, job *Job) error
	MarkJobAsStarted(ctx context.Context, uid, projectID string) error
	MarkJobAsCompleted(ctx context.Context, uid, projectID string) error
	MarkJobAsFailed(ctx context.Context, uid, projectID string) error
	DeleteJob(ctx context.Context, uid string, projectID string) error
	FetchJobById(ctx context.Context, uid string, projectID string) (*Job, error)
	FetchRunningJobsByProjectId(ctx context.Context, projectID string) ([]Job, error)
	FetchJobsByProjectId(ctx context.Context, projectID string) ([]Job, error)
	LoadJobsPaged(ctx context.Context, projectID string, pageable Pageable) ([]Job, PaginationData, error)
}

type JobStatus added in v1.1.6

type JobStatus string
const (
	JobStatusReady     JobStatus = "ready"
	JobStatusRunning   JobStatus = "running"
	JobStatusFailed    JobStatus = "failed"
	JobStatusCompleted JobStatus = "completed"
)

type KafkaAuth added in v1.1.6

type KafkaAuth struct {
	Type     string `json:"type" db:"type"`
	Hash     string `json:"hash" db:"hash"`
	TLS      bool   `json:"tls" db:"tls"`
	Username string `json:"username" db:"username"`
	Password string `json:"password" db:"password"`
}

type KafkaPubSubConfig added in v1.1.6

type KafkaPubSubConfig struct {
	Brokers         []string   `json:"brokers" db:"brokers"`
	ConsumerGroupID string     `json:"consumer_group_id" db:"consumer_group_id"`
	TopicName       string     `json:"topic_name" db:"topic_name"`
	Auth            *KafkaAuth `json:"auth" db:"auth"`
}

type KeyType

type KeyType string
const (
	ProjectKey   KeyType = "project"
	AppPortalKey KeyType = "app_portal"
	CLIKey       KeyType = "cli"
	PersonalKey  KeyType = "personal_key"
)

func (KeyType) IsValid added in v0.7.0

func (k KeyType) IsValid() bool

func (KeyType) IsValidAppKey added in v0.7.0

func (k KeyType) IsValidAppKey() bool

type M added in v0.9.0

type M map[string]interface{}

func (M) Map added in v0.9.0

func (h M) Map() map[string]interface{}

func (*M) Scan added in v0.9.0

func (h *M) Scan(value interface{}) error

func (M) Value added in v0.9.0

func (h M) Value() (driver.Value, error)

type MetaEvent added in v1.1.6

type MetaEvent struct {
	UID       string              `json:"uid" db:"id"`
	ProjectID string              `json:"project_id" db:"project_id"`
	EventType string              `json:"event_type" db:"event_type"`
	Metadata  *Metadata           `json:"metadata" db:"metadata"`
	Attempt   *MetaEventAttempt   `json:"attempt" db:"attempt"`
	Status    EventDeliveryStatus `json:"status" db:"status"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type MetaEventAttempt added in v1.1.6

type MetaEventAttempt struct {
	RequestHeader  HttpHeader `json:"request_http_header" db:"request_http_header"`
	ResponseHeader HttpHeader `json:"response_http_header" db:"response_http_header"`
	ResponseData   string     `json:"response_data,omitempty" db:"response_data"`
}

func (*MetaEventAttempt) Scan added in v1.1.6

func (m *MetaEventAttempt) Scan(value interface{}) error

func (*MetaEventAttempt) Value added in v1.1.6

func (m *MetaEventAttempt) Value() (driver.Value, error)

type MetaEventConfiguration added in v1.1.6

type MetaEventConfiguration struct {
	IsEnabled bool           `json:"is_enabled" db:"is_enabled"`
	Type      MetaEventType  `json:"type" db:"type" valid:"optional, in(http|pub_sub)~unsupported meta event type"`
	EventType pq.StringArray `json:"event_type" db:"event_type"`
	URL       string         `json:"url" db:"url"`
	Secret    string         `json:"secret" db:"secret"`
	PubSub    *PubSubConfig  `json:"pub_sub" db:"pub_sub"`
}

type MetaEventPayload added in v1.1.6

type MetaEventPayload struct {
	EventType string          `json:"event_type"`
	Data      json.RawMessage `json:"data"`
}

type MetaEventRepository added in v1.1.6

type MetaEventRepository interface {
	CreateMetaEvent(context.Context, *MetaEvent) error
	FindMetaEventByID(ctx context.Context, projectID string, id string) (*MetaEvent, error)
	LoadMetaEventsPaged(ctx context.Context, projectID string, f *Filter) ([]MetaEvent, PaginationData, error)
	UpdateMetaEvent(ctx context.Context, projectID string, metaEvent *MetaEvent) error
}

type MetaEventType added in v1.1.6

type MetaEventType string
const (
	HTTPMetaEvent   MetaEventType = "http"
	PubSubMetaEvent MetaEventType = "pub_sub"
)

type Metadata

type Metadata struct {
	// Data to be sent to endpoint.
	Data     json.RawMessage  `json:"data" bson:"data"`
	Raw      string           `json:"raw" bson:"raw"`
	Strategy StrategyProvider `json:"strategy" bson:"strategy"`

	NextSendTime time.Time `json:"next_send_time" bson:"next_send_time"`

	// NumTrials: number of times we have tried to deliver this Event to
	// an application
	NumTrials uint64 `json:"num_trials" bson:"num_trials"`

	IntervalSeconds uint64 `json:"interval_seconds" bson:"interval_seconds"`

	RetryLimit uint64 `json:"retry_limit" bson:"retry_limit"`
}

func (*Metadata) Scan added in v0.9.0

func (m *Metadata) Scan(value interface{}) error

func (*Metadata) Value

func (m *Metadata) Value() (driver.Value, error)

type OnPremStorage added in v0.6.0

type OnPremStorage struct {
	Path null.String `json:"path" db:"path"`
}

type Organisation added in v0.6.0

type Organisation struct {
	UID            string      `json:"uid" db:"id"`
	OwnerID        string      `json:"" db:"owner_id"`
	Name           string      `json:"name" db:"name"`
	CustomDomain   null.String `json:"custom_domain" db:"custom_domain"`
	AssignedDomain null.String `json:"assigned_domain" db:"assigned_domain"`
	CreatedAt      time.Time   `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt      time.Time   `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt      null.Time   `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type OrganisationInvite added in v0.6.0

type OrganisationInvite struct {
	UID              string       `json:"uid" db:"id"`
	OrganisationID   string       `json:"organisation_id" db:"organisation_id"`
	OrganisationName string       `json:"organisation_name,omitempty" db:"-"`
	InviteeEmail     string       `json:"invitee_email" db:"invitee_email"`
	Token            string       `json:"token" db:"token"`
	Role             auth.Role    `json:"role" db:"role"`
	Status           InviteStatus `json:"status" db:"status"`
	ExpiresAt        time.Time    `json:"-" db:"expires_at"`
	CreatedAt        time.Time    `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt        time.Time    `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt        null.Time    `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type OrganisationInviteRepository added in v0.6.0

type OrganisationInviteRepository interface {
	LoadOrganisationsInvitesPaged(ctx context.Context, orgID string, inviteStatus InviteStatus, pageable Pageable) ([]OrganisationInvite, PaginationData, error)
	CreateOrganisationInvite(ctx context.Context, iv *OrganisationInvite) error
	UpdateOrganisationInvite(ctx context.Context, iv *OrganisationInvite) error
	DeleteOrganisationInvite(ctx context.Context, uid string) error
	FetchOrganisationInviteByID(ctx context.Context, uid string) (*OrganisationInvite, error)
	FetchOrganisationInviteByToken(ctx context.Context, token string) (*OrganisationInvite, error)
}

type OrganisationMember added in v0.6.0

type OrganisationMember struct {
	UID            string       `json:"uid" db:"id"`
	OrganisationID string       `json:"organisation_id" db:"organisation_id"`
	UserID         string       `json:"user_id" db:"user_id"`
	Role           auth.Role    `json:"role" db:"role"`
	UserMetadata   UserMetadata `json:"user_metadata" db:"user_metadata"`
	CreatedAt      time.Time    `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt      time.Time    `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt      null.Time    `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type OrganisationMemberRepository added in v0.6.0

type OrganisationMemberRepository interface {
	LoadOrganisationMembersPaged(ctx context.Context, organisationID, userID string, pageable Pageable) ([]*OrganisationMember, PaginationData, error)
	LoadUserOrganisationsPaged(ctx context.Context, userID string, pageable Pageable) ([]Organisation, PaginationData, error)
	FindUserProjects(ctx context.Context, userID string) ([]Project, error)
	CreateOrganisationMember(ctx context.Context, member *OrganisationMember) error
	UpdateOrganisationMember(ctx context.Context, member *OrganisationMember) error
	DeleteOrganisationMember(ctx context.Context, memberID string, orgID string) error
	FetchOrganisationMemberByID(ctx context.Context, memberID string, organisationID string) (*OrganisationMember, error)
	FetchOrganisationMemberByUserID(ctx context.Context, userID string, organisationID string) (*OrganisationMember, error)
}

type OrganisationRepository added in v0.6.0

type OrganisationRepository interface {
	LoadOrganisationsPaged(context.Context, Pageable) ([]Organisation, PaginationData, error)
	CreateOrganisation(context.Context, *Organisation) error
	UpdateOrganisation(context.Context, *Organisation) error
	DeleteOrganisation(context.Context, string) error
	FetchOrganisationByID(context.Context, string) (*Organisation, error)
	FetchOrganisationByCustomDomain(context.Context, string) (*Organisation, error)
	FetchOrganisationByAssignedDomain(context.Context, string) (*Organisation, error)
}

type PageDirection added in v0.9.0

type PageDirection string
const (
	Next PageDirection = "next"
	Prev PageDirection = "prev"
)

type Pageable

type Pageable struct {
	PerPage    int           `json:"per_page"`
	Direction  PageDirection `json:"direction"`
	PrevCursor string        `json:"prev_page_cursor"`
	NextCursor string        `json:"next_page_cursor"`
}

func (Pageable) Cursor added in v0.9.0

func (p Pageable) Cursor() string

func (Pageable) Limit added in v0.9.0

func (p Pageable) Limit() int

type PaginationData

type PaginationData struct {
	PrevRowCount    PrevRowCount `json:"-"`
	PerPage         int64        `json:"per_page"`
	HasNextPage     bool         `json:"has_next_page"`
	HasPreviousPage bool         `json:"has_prev_page"`
	PrevPageCursor  string       `json:"prev_page_cursor"`
	NextPageCursor  string       `json:"next_page_cursor"`
}

func (*PaginationData) Build added in v0.9.0

func (p *PaginationData) Build(pageable Pageable, items []string) *PaginationData

type Password added in v0.6.0

type Password struct {
	Plaintext string
	Hash      []byte
}

func (*Password) GenerateHash added in v0.6.0

func (p *Password) GenerateHash() error

func (*Password) Matches added in v0.6.0

func (p *Password) Matches() (bool, error)

type Period

type Period int
const (
	Daily Period = iota
	Weekly
	Monthly
	Yearly
)
type PortalLink struct {
	UID               string           `json:"uid" db:"id"`
	Name              string           `json:"name" db:"name"`
	ProjectID         string           `json:"project_id" db:"project_id"`
	Token             string           `json:"-" db:"token"`
	OwnerID           string           `json:"owner_id" db:"owner_id"`
	Endpoints         pq.StringArray   `json:"endpoints" db:"endpoints"`
	EndpointsMetadata EndpointMetadata `json:"endpoints_metadata" db:"endpoints_metadata"`
	CanManageEndpoint bool             `json:"can_manage_endpoint" db:"can_manage_endpoint"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at,omitempty" swaggertype:"string"`
}

type PortalLinkRepository added in v0.8.0

type PortalLinkRepository interface {
	CreatePortalLink(context.Context, *PortalLink) error
	UpdatePortalLink(ctx context.Context, projectID string, portal *PortalLink) error
	FindPortalLinkByID(ctx context.Context, projectID string, id string) (*PortalLink, error)
	FindPortalLinkByOwnerID(ctx context.Context, projectID string, id string) (*PortalLink, error)
	FindPortalLinkByToken(ctx context.Context, token string) (*PortalLink, error)
	LoadPortalLinksPaged(ctx context.Context, projectID string, f *FilterBy, pageable Pageable) ([]PortalLink, PaginationData, error)
	RevokePortalLink(ctx context.Context, projectID string, id string) error
}

type PrevRowCount added in v0.9.0

type PrevRowCount struct {
	Count int
}

type Project added in v0.8.0

type Project struct {
	UID             string             `json:"uid" db:"id"`
	Name            string             `json:"name" db:"name"`
	LogoURL         string             `json:"logo_url" db:"logo_url"`
	OrganisationID  string             `json:"organisation_id" db:"organisation_id"`
	ProjectConfigID string             `json:"-" db:"project_configuration_id"`
	Type            ProjectType        `json:"type" db:"type"`
	Config          *ProjectConfig     `json:"config" db:"config"`
	Statistics      *ProjectStatistics `json:"statistics" db:"statistics"`

	RetainedEvents int `json:"retained_events" db:"retained_events"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

func (*Project) IsDeleted added in v0.8.0

func (o *Project) IsDeleted() bool

func (*Project) IsOwner added in v0.8.0

func (o *Project) IsOwner(e *Endpoint) bool

type ProjectConfig added in v0.8.0

type ProjectConfig struct {
	MaxIngestSize            uint64                        `json:"max_payload_read_size" db:"max_payload_read_size"`
	ReplayAttacks            bool                          `json:"replay_attacks_prevention_enabled" db:"replay_attacks_prevention_enabled"`
	IsRetentionPolicyEnabled bool                          `json:"retention_policy_enabled" db:"retention_policy_enabled"`
	AddEventIDTraceHeaders   bool                          `json:"add_event_id_trace_headers"`
	DisableEndpoint          bool                          `json:"disable_endpoint" db:"disable_endpoint"`
	RetentionPolicy          *RetentionPolicyConfiguration `json:"retention_policy" db:"retention_policy"`
	RateLimit                *RateLimitConfiguration       `json:"ratelimit" db:"ratelimit"`
	Strategy                 *StrategyConfiguration        `json:"strategy" db:"strategy"`
	Signature                *SignatureConfiguration       `json:"signature" db:"signature"`
	MetaEvent                *MetaEventConfiguration       `json:"meta_event" db:"meta_event"`
}

func (*ProjectConfig) GetMetaEventConfig added in v1.1.6

func (p *ProjectConfig) GetMetaEventConfig() MetaEventConfiguration

func (*ProjectConfig) GetRateLimitConfig added in v0.9.0

func (p *ProjectConfig) GetRateLimitConfig() RateLimitConfiguration

func (*ProjectConfig) GetRetentionPolicyConfig added in v0.9.0

func (p *ProjectConfig) GetRetentionPolicyConfig() RetentionPolicyConfiguration

func (*ProjectConfig) GetSignatureConfig added in v0.9.0

func (p *ProjectConfig) GetSignatureConfig() SignatureConfiguration

func (*ProjectConfig) GetStrategyConfig added in v0.9.0

func (p *ProjectConfig) GetStrategyConfig() StrategyConfiguration

type ProjectEvents added in v1.1.6

type ProjectEvents struct {
	Id          string `json:"id" db:"id"`
	EventsCount int    `json:"events_count" db:"events_count"`
}

type ProjectFilter added in v0.8.0

type ProjectFilter struct {
	OrgID string `json:"org_id" bson:"org_id"`
}

type ProjectMetadata added in v0.8.0

type ProjectMetadata struct {
	RetainedEvents int `json:"retained_events" bson:"retained_events"`
}

type ProjectRepository added in v0.8.0

type ProjectRepository interface {
	LoadProjects(context.Context, *ProjectFilter) ([]*Project, error)
	CreateProject(context.Context, *Project) error
	UpdateProject(context.Context, *Project) error
	DeleteProject(ctx context.Context, uid string) error
	FetchProjectByID(context.Context, string) (*Project, error)
	GetProjectsWithEventsInTheInterval(ctx context.Context, interval int) ([]ProjectEvents, error)
	FillProjectsStatistics(ctx context.Context, project *Project) error
}

type ProjectStatistics added in v0.8.0

type ProjectStatistics struct {
	MessagesSent       int64 `json:"messages_sent" db:"messages_sent"`
	TotalEndpoints     int64 `json:"total_endpoints" db:"total_endpoints"`
	TotalSubscriptions int64 `json:"total_subscriptions" db:"total_subscriptions"`
	TotalSources       int64 `json:"total_sources" db:"total_sources"`
}

type ProjectType added in v0.8.0

type ProjectType string
const (
	OutgoingProject ProjectType = "outgoing"
	IncomingProject ProjectType = "incoming"
)

type ProviderConfig added in v0.6.0

type ProviderConfig struct {
	Twitter *TwitterProviderConfig `json:"twitter" db:"twitter"`
}

type PubSubConfig added in v0.9.0

type PubSubConfig struct {
	Type    PubSubType          `json:"type" db:"type"`
	Workers int                 `json:"workers" db:"workers"`
	Sqs     *SQSPubSubConfig    `json:"sqs" db:"sqs"`
	Google  *GooglePubSubConfig `json:"google" db:"google"`
	Kafka   *KafkaPubSubConfig  `json:"kafka" db:"kafka"`
}

func (*PubSubConfig) Scan added in v0.9.0

func (p *PubSubConfig) Scan(value interface{}) error

func (PubSubConfig) Value added in v0.9.0

func (p PubSubConfig) Value() (driver.Value, error)

type PubSubHandler added in v0.9.0

type PubSubHandler func(context.Context, *Source, string) error

type PubSubType added in v0.9.0

type PubSubType string
const (
	SqsPubSub    PubSubType = "sqs"
	GooglePubSub PubSubType = "google"
	KafkaPubSub  PubSubType = "kafka"
)

type RateLimitConfiguration added in v0.6.0

type RateLimitConfiguration struct {
	Count    int    `json:"count" db:"count"`
	Duration uint64 `json:"duration" db:"duration"`
}

type RetentionPolicyConfiguration added in v0.6.0

type RetentionPolicyConfiguration struct {
	Policy       string `json:"policy" db:"policy" valid:"required~please provide a valid retention policy"`
	SearchPolicy string `json:"search_policy" db:"search_policy"`
}

type RetryConfiguration added in v0.6.0

type RetryConfiguration struct {
	Type       StrategyProvider `json:"type,omitempty" db:"type" valid:"supported_retry_strategy~please provide a valid retry strategy type"`
	Duration   uint64           `json:"duration,omitempty" db:"duration" valid:"duration~please provide a valid time duration"`
	RetryCount uint64           `json:"retry_count" db:"retry_count" valid:"int~please provide a valid retry count"`
}

type S3Storage added in v0.6.0

type S3Storage struct {
	Bucket       null.String `json:"bucket" db:"bucket" valid:"required~please provide a bucket name"`
	AccessKey    null.String `json:"access_key,omitempty" db:"access_key" valid:"required~please provide an access key"`
	SecretKey    null.String `json:"secret_key,omitempty" db:"secret_key" valid:"required~please provide a secret key"`
	Region       null.String `json:"region,omitempty" db:"region"`
	SessionToken null.String `json:"session_token" db:"session_token"`
	Endpoint     null.String `json:"endpoint,omitempty" db:"endpoint"`
}

type SQSPubSubConfig added in v0.9.0

type SQSPubSubConfig struct {
	AccessKeyID   string `json:"access_key_id" db:"access_key_id"`
	SecretKey     string `json:"secret_key" db:"secret_key"`
	DefaultRegion string `json:"default_region" db:"default_region"`
	QueueName     string `json:"queue_name" db:"queue_name"`
}

type SearchFilter added in v0.6.5

type SearchFilter struct {
	Query    string
	FilterBy FilterBy
	Pageable Pageable
}

type SearchIndexParams added in v1.1.6

type SearchIndexParams struct {
	ProjectID string `json:"project_id"`
	Interval  int    `json:"interval"`
}

type SearchParams

type SearchParams struct {
	CreatedAtStart int64 `json:"created_at_start" bson:"created_at_start"`
	CreatedAtEnd   int64 `json:"created_at_end" bson:"created_at_end"`
}

type Secret added in v0.7.2

type Secret struct {
	UID   string `json:"uid" db:"id"`
	Value string `json:"value" db:"value"`

	ExpiresAt null.Time `json:"expires_at,omitempty" db:"expires_at,omitempty" swaggertype:"string"`
	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type Secrets added in v0.9.0

type Secrets []Secret

func (*Secrets) Scan added in v0.9.0

func (s *Secrets) Scan(value interface{}) error

func (Secrets) Value added in v0.9.0

func (s Secrets) Value() (driver.Value, error)

type SignatureConfiguration

type SignatureConfiguration struct {
	Hash     string                         `json:"-" db:"hash"` // Deprecated
	Header   config.SignatureHeaderProvider `json:"header,omitempty" valid:"required~please provide a valid signature header"`
	Versions SignatureVersions              `json:"versions" db:"versions"`
}

func GetDefaultSignatureConfig added in v0.7.2

func GetDefaultSignatureConfig() *SignatureConfiguration

type SignatureVersion added in v0.7.2

type SignatureVersion struct {
	UID       string       `json:"uid" db:"id"`
	Hash      string       `json:"hash,omitempty" db:"hash" valid:"required~please provide a valid hash,supported_hash~unsupported hash type"`
	Encoding  EncodingType `json:"encoding" db:"encoding" valid:"required~please provide a valid signature header"`
	CreatedAt time.Time    `json:"created_at,omitempty" db:"created_at" swaggertype:"string"`
}

type SignatureVersions added in v0.9.0

type SignatureVersions []SignatureVersion

func (*SignatureVersions) Scan added in v0.9.0

func (s *SignatureVersions) Scan(v interface{}) error

func (SignatureVersions) Value added in v0.9.0

func (s SignatureVersions) Value() (driver.Value, error)

type Source added in v0.6.0

type Source struct {
	UID             string          `json:"uid" db:"id"`
	ProjectID       string          `json:"project_id" db:"project_id"`
	MaskID          string          `json:"mask_id" db:"mask_id"`
	Name            string          `json:"name" db:"name"`
	URL             string          `json:"url" db:"-"`
	Type            SourceType      `json:"type" db:"type"`
	Provider        SourceProvider  `json:"provider" db:"provider"`
	IsDisabled      bool            `json:"is_disabled" db:"is_disabled"`
	VerifierID      string          `json:"-" db:"source_verifier_id"`
	Verifier        *VerifierConfig `json:"verifier" db:"verifier"`
	CustomResponse  CustomResponse  `json:"custom_response" db:"custom_response"`
	ProviderConfig  *ProviderConfig `json:"provider_config" db:"provider_config"`
	ForwardHeaders  pq.StringArray  `json:"forward_headers" db:"forward_headers"`
	PubSub          *PubSubConfig   `json:"pub_sub" db:"pub_sub"`
	IdempotencyKeys pq.StringArray  `json:"idempotency_keys" db:"idempotency_keys"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

type SourceFilter added in v0.6.0

type SourceFilter struct {
	Type     string
	Provider string
}

type SourceProvider added in v0.6.0

type SourceProvider string
const (
	GithubSourceProvider  SourceProvider = "github"
	TwitterSourceProvider SourceProvider = "twitter"
	ShopifySourceProvider SourceProvider = "shopify"
)

func (SourceProvider) IsValid added in v0.7.0

func (s SourceProvider) IsValid() bool

type SourceRepository added in v0.6.0

type SourceRepository interface {
	CreateSource(context.Context, *Source) error
	UpdateSource(ctx context.Context, projectID string, source *Source) error
	FindSourceByID(ctx context.Context, projectID string, id string) (*Source, error)
	FindSourceByName(ctx context.Context, projectId string, name string) (*Source, error)
	FindSourceByMaskID(ctx context.Context, maskID string) (*Source, error)
	DeleteSourceByID(ctx context.Context, projectID string, id string, sourceVerifierID string) error
	LoadSourcesPaged(ctx context.Context, projectID string, filter *SourceFilter, pageable Pageable) ([]Source, PaginationData, error)
}

type SourceType added in v0.6.0

type SourceType string
const (
	HTTPSource     SourceType = "http"
	RestApiSource  SourceType = "rest_api"
	PubSubSource   SourceType = "pub_sub"
	DBChangeStream SourceType = "db_change_stream"
)

func (SourceType) IsValid added in v0.7.0

func (s SourceType) IsValid() bool

type StoragePolicyConfiguration added in v0.6.0

type StoragePolicyConfiguration struct {
	Type   StorageType    `json:"type,omitempty" db:"type" valid:"supported_storage~please provide a valid storage type,required"`
	S3     *S3Storage     `json:"s3" db:"s3"`
	OnPrem *OnPremStorage `json:"on_prem" db:"on_prem"`
}

type StorageType added in v0.6.0

type StorageType string
const (
	S3     StorageType = "s3"
	OnPrem StorageType = "on_prem"
)

type StrategyConfiguration

type StrategyConfiguration struct {
	Type       StrategyProvider `json:"type" db:"type" valid:"optional~please provide a valid strategy type, in(linear|exponential)~unsupported strategy type"`
	Duration   uint64           `json:"duration" db:"duration" valid:"optional~please provide a valid duration in seconds,int"`
	RetryCount uint64           `json:"retry_count" db:"retry_count" valid:"optional~please provide a valid retry count,int"`
}

type StrategyProvider added in v0.6.0

type StrategyProvider string
const (
	DefaultStrategyProvider                      = LinearStrategyProvider
	LinearStrategyProvider      StrategyProvider = "linear"
	ExponentialStrategyProvider StrategyProvider = "exponential"
)

type Subscription added in v0.6.0

type Subscription struct {
	UID        string           `json:"uid" db:"id"`
	Name       string           `json:"name" db:"name"`
	Type       SubscriptionType `json:"type" db:"type"`
	ProjectID  string           `json:"-" db:"project_id"`
	SourceID   string           `json:"-" db:"source_id"`
	EndpointID string           `json:"-" db:"endpoint_id"`
	DeviceID   string           `json:"-" db:"device_id"`
	Function   null.String      `json:"function" db:"function"`

	Source   *Source   `json:"source_metadata" db:"source_metadata"`
	Endpoint *Endpoint `json:"endpoint_metadata" db:"endpoint_metadata"`
	Device   *Device   `json:"device_metadata" db:"device_metadata"`

	// subscription config
	AlertConfig     *AlertConfiguration     `json:"alert_config,omitempty" db:"alert_config"`
	RetryConfig     *RetryConfiguration     `json:"retry_config,omitempty" db:"retry_config"`
	FilterConfig    *FilterConfiguration    `json:"filter_config,omitempty" db:"filter_config"`
	RateLimitConfig *RateLimitConfiguration `json:"rate_limit_config,omitempty" db:"rate_limit_config"`

	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at" swaggertype:"string"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at" swaggertype:"string"`
	DeletedAt null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
}

func (*Subscription) GetAlertConfig added in v0.9.0

func (s *Subscription) GetAlertConfig() AlertConfiguration

For DB access

func (*Subscription) GetFilterConfig added in v0.9.0

func (s *Subscription) GetFilterConfig() FilterConfiguration

func (*Subscription) GetRateLimitConfig added in v0.9.0

func (s *Subscription) GetRateLimitConfig() RateLimitConfiguration

func (*Subscription) GetRetryConfig added in v0.9.0

func (s *Subscription) GetRetryConfig() RetryConfiguration

type SubscriptionRepository added in v0.6.0

type SubscriptionRepository interface {
	CreateSubscription(context.Context, string, *Subscription) error
	UpdateSubscription(ctx context.Context, projectID string, subscription *Subscription) error
	LoadSubscriptionsPaged(ctx context.Context, projectID string, filter *FilterBy, pageable Pageable) ([]Subscription, PaginationData, error)
	DeleteSubscription(ctx context.Context, projectID string, subscription *Subscription) error
	FindSubscriptionByID(ctx context.Context, projectID, id string) (*Subscription, error)
	FindSubscriptionsBySourceID(ctx context.Context, projectID, sourceID string) ([]Subscription, error)
	FindSubscriptionsByEndpointID(ctx context.Context, projectId string, endpointID string) ([]Subscription, error)
	FindSubscriptionByDeviceID(ctx context.Context, projectId string, deviceID string, subscriptionType SubscriptionType) (*Subscription, error)
	FindCLISubscriptions(ctx context.Context, projectID string) ([]Subscription, error)
	CountEndpointSubscriptions(ctx context.Context, projectID, endpointID string) (int64, error)
	TestSubscriptionFilter(ctx context.Context, payload, filter interface{}) (bool, error)
	TransformPayload(ctx context.Context, function string, payload map[string]interface{}) (interface{}, []string, error)
}

type SubscriptionType added in v0.7.0

type SubscriptionType string
const (
	SubscriptionTypeCLI SubscriptionType = "cli"
	SubscriptionTypeAPI SubscriptionType = "api"
)

type TwitterProviderConfig added in v0.6.0

type TwitterProviderConfig struct {
	CrcVerifiedAt null.Time `json:"crc_verified_at" db:"crc_verified_at"`
}

type User added in v0.6.0

type User struct {
	UID                        string    `json:"uid" db:"id"`
	FirstName                  string    `json:"first_name" db:"first_name"`
	LastName                   string    `json:"last_name" db:"last_name"`
	Email                      string    `json:"email" db:"email"`
	EmailVerified              bool      `json:"email_verified" db:"email_verified"`
	Password                   string    `json:"-" db:"password"`
	ResetPasswordToken         string    `json:"-" db:"reset_password_token"`
	EmailVerificationToken     string    `json:"-" db:"email_verification_token"`
	CreatedAt                  time.Time `json:"created_at,omitempty" db:"created_at,omitempty" swaggertype:"string"`
	UpdatedAt                  time.Time `json:"updated_at,omitempty" db:"updated_at,omitempty" swaggertype:"string"`
	DeletedAt                  null.Time `json:"deleted_at,omitempty" db:"deleted_at" swaggertype:"string"`
	ResetPasswordExpiresAt     time.Time `json:"reset_password_expires_at,omitempty" db:"reset_password_expires_at,omitempty" swaggertype:"string"`
	EmailVerificationExpiresAt time.Time `json:"-" db:"email_verification_expires_at,omitempty" swaggertype:"string"`
}

type UserMetadata added in v0.6.0

type UserMetadata struct {
	UserID    string `json:"-" db:"user_id"`
	FirstName string `json:"first_name" db:"first_name"`
	LastName  string `json:"last_name" db:"last_name"`
	Email     string `json:"email" db:"email"`
}

type UserRepository added in v0.6.0

type UserRepository interface {
	CreateUser(context.Context, *User) error
	UpdateUser(ctx context.Context, user *User) error
	FindUserByEmail(context.Context, string) (*User, error)
	FindUserByID(context.Context, string) (*User, error)
	FindUserByToken(context.Context, string) (*User, error)
	FindUserByEmailVerificationToken(ctx context.Context, token string) (*User, error)
	LoadUsersPaged(context.Context, Pageable) ([]User, PaginationData, error)
}

type VerifierConfig added in v0.6.0

type VerifierConfig struct {
	Type      VerifierType `json:"type,omitempty" db:"type" valid:"supported_verifier~please provide a valid verifier type"`
	HMac      *HMac        `json:"hmac" db:"hmac"`
	BasicAuth *BasicAuth   `json:"basic_auth" db:"basic_auth"`
	ApiKey    *ApiKey      `json:"api_key" db:"api_key"`
}

type VerifierType added in v0.6.0

type VerifierType string
const (
	NoopVerifier      VerifierType = "noop"
	HMacVerifier      VerifierType = "hmac"
	BasicAuthVerifier VerifierType = "basic_auth"
	APIKeyVerifier    VerifierType = "api_key"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL