app

package
v1.0.0-beta.201 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPageNumber = 1
	DefaultPageSize   = 100
)

Variables

This section is empty.

Functions

func IsAppCustomerPreConditionError

func IsAppCustomerPreConditionError(err error) bool

func IsAppDefaultNotFoundError

func IsAppDefaultNotFoundError(err error) bool

func IsAppNotFoundError

func IsAppNotFoundError(err error) bool

IsAppNotFoundError returns true if the error is a AppNotFoundError.

func IsAppProviderAuthenticationError

func IsAppProviderAuthenticationError(err error) bool

func IsAppProviderError

func IsAppProviderError(err error) bool

func IsAppProviderPreConditionError

func IsAppProviderPreConditionError(err error) bool

Types

type Adapter

type Adapter interface {
	AppAdapter

	entutils.TxCreator
}

type App

type App interface {
	GetAppBase() AppBase
	GetID() AppID
	GetType() AppType
	GetName() string
	GetDescription() *string
	GetStatus() AppStatus
	GetMetadata() map[string]string
	GetListing() MarketplaceListing

	// ValidateCapabilities validates if the app can run for the given capabilities
	ValidateCapabilities(capabilities ...CapabilityType) error

	// Customer data
	GetCustomerData(ctx context.Context, input GetAppInstanceCustomerDataInput) (CustomerData, error)
	UpsertCustomerData(ctx context.Context, input UpsertAppInstanceCustomerDataInput) error
	DeleteCustomerData(ctx context.Context, input DeleteAppInstanceCustomerDataInput) error
}

App represents an installed app

type AppAdapter

type AppAdapter interface {
	// Marketplace
	RegisterMarketplaceListing(input RegisterMarketplaceListingInput) error
	GetMarketplaceListing(ctx context.Context, input MarketplaceGetInput) (RegistryItem, error)
	ListMarketplaceListings(ctx context.Context, input MarketplaceListInput) (pagination.PagedResponse[RegistryItem], error)
	InstallMarketplaceListingWithAPIKey(ctx context.Context, input InstallAppWithAPIKeyInput) (App, error)
	GetMarketplaceListingOauth2InstallURL(ctx context.Context, input GetOauth2InstallURLInput) (GetOauth2InstallURLOutput, error)
	AuthorizeMarketplaceListingOauth2Install(ctx context.Context, input AuthorizeOauth2InstallInput) error

	// Installed app
	CreateApp(ctx context.Context, input CreateAppInput) (AppBase, error)
	GetApp(ctx context.Context, input GetAppInput) (App, error)
	GetDefaultApp(ctx context.Context, input GetDefaultAppInput) (App, error)
	UpdateApp(ctx context.Context, input UpdateAppInput) (App, error)
	ListApps(ctx context.Context, input ListAppInput) (pagination.PagedResponse[App], error)
	UninstallApp(ctx context.Context, input UninstallAppInput) error
	UpdateAppStatus(ctx context.Context, input UpdateAppStatusInput) error

	// Customer data
	ListCustomerData(ctx context.Context, input ListCustomerInput) (pagination.PagedResponse[CustomerApp], error)
	EnsureCustomer(ctx context.Context, input EnsureCustomerInput) error
	DeleteCustomer(ctx context.Context, input DeleteCustomerInput) error
}

type AppBase

type AppBase struct {
	models.ManagedResource

	Type     AppType            `json:"type"`
	Status   AppStatus          `json:"status"`
	Default  bool               `json:"default"`
	Listing  MarketplaceListing `json:"listing"`
	Metadata map[string]string  `json:"metadata,omitempty"`
}

AppBase represents an abstract with the base fields of an app

func (AppBase) GetAppBase

func (a AppBase) GetAppBase() AppBase

func (AppBase) GetDescription

func (a AppBase) GetDescription() *string

func (AppBase) GetID

func (a AppBase) GetID() AppID

func (AppBase) GetListing

func (a AppBase) GetListing() MarketplaceListing

func (AppBase) GetMetadata

func (a AppBase) GetMetadata() map[string]string

func (AppBase) GetName

func (a AppBase) GetName() string

func (AppBase) GetStatus

func (a AppBase) GetStatus() AppStatus

func (AppBase) GetType

func (a AppBase) GetType() AppType

func (AppBase) Validate

func (a AppBase) Validate() error

Validate validates the app base

func (AppBase) ValidateCapabilities

func (a AppBase) ValidateCapabilities(capabilities ...CapabilityType) error

ValidateCapabilities validates if the app can run for the given capabilities

type AppCustomerPreConditionError

type AppCustomerPreConditionError struct {
	// contains filtered or unexported fields
}

func NewAppCustomerPreConditionError

func NewAppCustomerPreConditionError(appID AppID, appType AppType, customerID *customer.CustomerID, condition string) *AppCustomerPreConditionError

AppCustomerPreConditionError

func (AppCustomerPreConditionError) Error

func (AppCustomerPreConditionError) Unwrap

type AppDefaultNotFoundError

type AppDefaultNotFoundError struct {
	// contains filtered or unexported fields
}

func NewAppDefaultNotFoundError

func NewAppDefaultNotFoundError(appType AppType, namespace string) *AppDefaultNotFoundError

AppDefaultNotFoundError

func (AppDefaultNotFoundError) Error

func (e AppDefaultNotFoundError) Error() string

func (AppDefaultNotFoundError) Unwrap

func (e AppDefaultNotFoundError) Unwrap() error

type AppFactory

type AppFactory interface {
	NewApp(context.Context, AppBase) (App, error)
	InstallAppWithAPIKey(ctx context.Context, input AppFactoryInstallAppWithAPIKeyInput) (App, error)
	UninstallApp(ctx context.Context, input UninstallAppInput) error
}

type AppFactoryInstallAppWithAPIKeyInput

type AppFactoryInstallAppWithAPIKeyInput struct {
	Namespace string
	APIKey    string
	BaseURL   string
	Name      string
}

func (AppFactoryInstallAppWithAPIKeyInput) Validate

type AppID

type AppID struct {
	Namespace string
	ID        string
}

AppID represents the unique identifier for an installed app

func (AppID) Validate

func (i AppID) Validate() error

type AppNotFoundError

type AppNotFoundError struct {
	// contains filtered or unexported fields
}

func NewAppNotFoundError

func NewAppNotFoundError(appID AppID) *AppNotFoundError

AppNotFoundError

func (AppNotFoundError) Error

func (e AppNotFoundError) Error() string

func (AppNotFoundError) Unwrap

func (e AppNotFoundError) Unwrap() error

type AppProviderAuthenticationError

type AppProviderAuthenticationError struct {
	// contains filtered or unexported fields
}

func NewAppProviderAuthenticationError

func NewAppProviderAuthenticationError(appID *AppID, namespace string, providerError error) *AppProviderAuthenticationError

AppProviderAuthenticationError

func (AppProviderAuthenticationError) Error

func (AppProviderAuthenticationError) Unwrap

type AppProviderError

type AppProviderError struct {
	// contains filtered or unexported fields
}

func NewAppProviderError

func NewAppProviderError(appID *AppID, namespace string, providerError error) *AppProviderError

AppProviderError

func (AppProviderError) Error

func (e AppProviderError) Error() string

func (AppProviderError) Unwrap

func (e AppProviderError) Unwrap() error

type AppProviderPreConditionError

type AppProviderPreConditionError struct {
	// contains filtered or unexported fields
}

func NewAppProviderPreConditionError

func NewAppProviderPreConditionError(appID AppID, condition string) *AppProviderPreConditionError

func (AppProviderPreConditionError) Error

func (AppProviderPreConditionError) Unwrap

type AppService

type AppService interface {
	// Marketplace
	RegisterMarketplaceListing(input RegisterMarketplaceListingInput) error
	GetMarketplaceListing(ctx context.Context, input MarketplaceGetInput) (RegistryItem, error)
	ListMarketplaceListings(ctx context.Context, input MarketplaceListInput) (pagination.PagedResponse[RegistryItem], error)
	InstallMarketplaceListingWithAPIKey(ctx context.Context, input InstallAppWithAPIKeyInput) (App, error)
	GetMarketplaceListingOauth2InstallURL(ctx context.Context, input GetOauth2InstallURLInput) (GetOauth2InstallURLOutput, error)
	AuthorizeMarketplaceListingOauth2Install(ctx context.Context, input AuthorizeOauth2InstallInput) error

	// Installed app
	CreateApp(ctx context.Context, input CreateAppInput) (AppBase, error)
	GetApp(ctx context.Context, input GetAppInput) (App, error)
	UpdateAppStatus(ctx context.Context, input UpdateAppStatusInput) error
	GetDefaultApp(ctx context.Context, input GetDefaultAppInput) (App, error)
	UpdateApp(ctx context.Context, input UpdateAppInput) (App, error)
	ListApps(ctx context.Context, input ListAppInput) (pagination.PagedResponse[App], error)
	UninstallApp(ctx context.Context, input UninstallAppInput) error

	// Customer data
	ListCustomerData(ctx context.Context, input ListCustomerInput) (pagination.PagedResponse[CustomerApp], error)
	EnsureCustomer(ctx context.Context, input EnsureCustomerInput) error
	DeleteCustomer(ctx context.Context, input DeleteCustomerInput) error
}

type AppStatus

type AppStatus string

AppStatus represents the status of an app

const (
	AppStatusReady        AppStatus = "ready"
	AppStatusUnauthorized AppStatus = "unauthorized"
)

type AppType

type AppType string

AppType represents the type of an app

const (
	AppTypeStripe  AppType = "stripe"
	AppTypeSandbox AppType = "sandbox"
)

type AuthorizeOauth2InstallInput

type AuthorizeOauth2InstallInput struct {
	MarketplaceListingID

	Code string
	// Success response fields
	State string
	// Error response fields
	Error            string
	ErrorDescription string
	ErrorURI         string
}

func (AuthorizeOauth2InstallInput) Validate

func (i AuthorizeOauth2InstallInput) Validate() error

type Capability

type Capability struct {
	Type        CapabilityType `json:"type"`
	Key         string         `json:"key"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
}

func (Capability) Validate

func (c Capability) Validate() error

type CapabilityType

type CapabilityType string
const (
	CapabilityTypeReportUsage      CapabilityType = "reportUsage"
	CapabilityTypeReportEvents     CapabilityType = "reportEvents"
	CapabilityTypeCalculateTax     CapabilityType = "calculateTax"
	CapabilityTypeInvoiceCustomers CapabilityType = "invoiceCustomers"
	CapabilityTypeCollectPayments  CapabilityType = "collectPayments"
)

type CreateAppInput

type CreateAppInput struct {
	// AppID is optional. If not provided, a new AppID will be generated by the database
	ID          *AppID
	Namespace   string
	Name        string
	Description string
	Type        AppType
}

CreateAppInput is the input for creating an app

func (CreateAppInput) Validate

func (i CreateAppInput) Validate() error

type CustomerApp

type CustomerApp struct {
	App          App
	CustomerData CustomerData
}

type CustomerData

type CustomerData interface {
	Validate() error
}

type DeleteAppInstanceCustomerDataInput

type DeleteAppInstanceCustomerDataInput struct {
	CustomerID customer.CustomerID
}

func (DeleteAppInstanceCustomerDataInput) Validate

type DeleteCustomerInput

type DeleteCustomerInput struct {
	AppID      *AppID
	CustomerID *customer.CustomerID
}

func (DeleteCustomerInput) Validate

func (a DeleteCustomerInput) Validate() error

type EnsureCustomerInput

type EnsureCustomerInput struct {
	AppID      AppID
	CustomerID customer.CustomerID
}

func (EnsureCustomerInput) Validate

func (a EnsureCustomerInput) Validate() error

type GetAppInput

type GetAppInput = AppID

GetAppInput is the input for getting an installed app

type GetAppInstanceCustomerDataInput

type GetAppInstanceCustomerDataInput struct {
	CustomerID customer.CustomerID
}

func (GetAppInstanceCustomerDataInput) Validate

type GetDefaultAppInput

type GetDefaultAppInput struct {
	Namespace string
	Type      AppType
}

GetAppInput is the input for getting the default app for a type

func (GetDefaultAppInput) Validate

func (i GetDefaultAppInput) Validate() error

type GetOauth2InstallURLInput

type GetOauth2InstallURLInput = MarketplaceListingID

type GetOauth2InstallURLOutput

type GetOauth2InstallURLOutput struct {
	URL string
}

type InstallAppWithAPIKeyInput

type InstallAppWithAPIKeyInput struct {
	MarketplaceListingID

	Namespace string
	APIKey    string
	Name      string
}

func (InstallAppWithAPIKeyInput) Validate

func (i InstallAppWithAPIKeyInput) Validate() error

type ListAppInput

type ListAppInput struct {
	Namespace string
	pagination.Page

	Type           *AppType
	IncludeDeleted bool
	// Only list apps that has data for the given customer
	CustomerID *customer.CustomerID
}

ListAppInput is the input for listing installed apps

func (ListAppInput) Validate

func (i ListAppInput) Validate() error

type ListCustomerInput

type ListCustomerInput struct {
	pagination.Page
	CustomerID customer.CustomerID
	Type       *AppType
}

func (ListCustomerInput) Validate

func (a ListCustomerInput) Validate() error

type MarketplaceGetInput

type MarketplaceGetInput = MarketplaceListingID

type MarketplaceListInput

type MarketplaceListInput struct {
	pagination.Page
}

func (MarketplaceListInput) Validate

func (i MarketplaceListInput) Validate() error

type MarketplaceListing

type MarketplaceListing struct {
	Type         AppType      `json:"type"`
	Name         string       `json:"name"`
	Description  string       `json:"description"`
	Capabilities []Capability `json:"capabilities"`
}

func (MarketplaceListing) Validate

func (p MarketplaceListing) Validate() error

type MarketplaceListingID

type MarketplaceListingID struct {
	Type AppType
}

func (MarketplaceListingID) Validate

func (i MarketplaceListingID) Validate() error

type RegisterMarketplaceListingInput

type RegisterMarketplaceListingInput = RegistryItem

type RegistryItem

type RegistryItem struct {
	Listing MarketplaceListing
	Factory AppFactory
}

func (RegistryItem) Validate

func (r RegistryItem) Validate() error

type Service

type Service interface {
	AppService
}

type UninstallAppInput

type UninstallAppInput = AppID

type UpdateAppInput

type UpdateAppInput struct {
	AppID       AppID
	Name        string
	Description *string
	Default     bool
	Metadata    *map[string]string
}

UpdateAppInput is the input for setting an app as default for a type

func (UpdateAppInput) Validate

func (i UpdateAppInput) Validate() error

type UpdateAppStatusInput

type UpdateAppStatusInput struct {
	ID     AppID
	Status AppStatus
}

UpdateAppStatusInput is the input for updating an app status

func (UpdateAppStatusInput) Validate

func (i UpdateAppStatusInput) Validate() error

type UpsertAppInstanceCustomerDataInput

type UpsertAppInstanceCustomerDataInput struct {
	CustomerID customer.CustomerID
	Data       CustomerData
}

func (UpsertAppInstanceCustomerDataInput) Validate

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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