core

package
v0.0.0-...-49190db Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package core is the backbone of PocketBase.

It defines the main PocketBase App interface and its base implementation.

Index

Constants

View Source
const (
	EmailPlaceholderAppName   string = "{APP_NAME}"
	EmailPlaceholderAppUrl    string = "{APP_URL}"
	EmailPlaceholderToken     string = "{TOKEN}"
	EmailPlaceholderActionUrl string = "{ACTION_URL}"
)

Common settings placeholder tokens

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminAuthEvent

type AdminAuthEvent struct {
	HttpContext echo.Context
	Admin       *models.Admin
	Token       string
}

type AdminCreateEvent

type AdminCreateEvent struct {
	HttpContext echo.Context
	Admin       *models.Admin
}

type AdminDeleteEvent

type AdminDeleteEvent struct {
	HttpContext echo.Context
	Admin       *models.Admin
}

type AdminUpdateEvent

type AdminUpdateEvent struct {
	HttpContext echo.Context
	Admin       *models.Admin
}

type AdminViewEvent

type AdminViewEvent struct {
	HttpContext echo.Context
	Admin       *models.Admin
}

type AdminsListEvent

type AdminsListEvent struct {
	HttpContext echo.Context
	Admins      []*models.Admin
	Result      *search.Result
}

type App

type App interface {
	// DB returns the default app database instance.
	DB() *dbx.DB

	// Dao returns the default app Dao instance.
	//
	// This Dao could operate only on the tables and models
	// associated with the default app database. For example,
	// trying to access the request logs table will result in error.
	Dao() *daos.Dao

	// LogsDB returns the app logs database instance.
	LogsDB() *dbx.DB

	// LogsDao returns the app logs Dao instance.
	//
	// This Dao could operate only on the tables and models
	// associated with the logs database. For example, trying to access
	// the users table from LogsDao will result in error.
	LogsDao() *daos.Dao

	// DataDir returns the app data directory path.
	DataDir() string

	// EncryptionEnv returns the name of the app secret env key
	// (used for settings encryption).
	EncryptionEnv() string

	// IsDebug returns whether the app is in debug mode
	// (showing more detailed error logs, executed sql statements, etc.).
	IsDebug() bool

	// Settings returns the loaded app settings.
	Settings() *Settings

	// Cache returns the app internal cache store.
	Cache() *store.Store[any]

	// SubscriptionsBroker returns the app realtime subscriptions broker instance.
	SubscriptionsBroker() *subscriptions.Broker

	// NewMailClient creates and returns a configured app mail client.
	NewMailClient() mailer.Mailer

	// NewFilesystem creates and returns a configured filesystem.System instance.
	//
	// NB! Make sure to call `Close()` on the returned result
	// after you are done working with it.
	NewFilesystem() (*filesystem.System, error)

	// RefreshSettings reinitializes and reloads the stored application settings.
	RefreshSettings() error

	// Bootstrap takes care for initializing the application
	// (open db connections, load settings, etc.)
	Bootstrap() error

	// ResetBootstrapState takes care for releasing initialized app resources
	// (eg. closing db connections).
	ResetBootstrapState() error

	// OnBeforeServe hook is triggered before serving the internal router (echo),
	// allowing you to adjust its options and attach new routes.
	OnBeforeServe() *hook.Hook[*ServeEvent]

	// OnModelBeforeCreate hook is triggered before inserting a new
	// entry in the DB, allowing you to modify or validate the stored data.
	OnModelBeforeCreate() *hook.Hook[*ModelEvent]

	// OnModelAfterCreate hook is triggered after successfully
	// inserting a new entry in the DB.
	OnModelAfterCreate() *hook.Hook[*ModelEvent]

	// OnModelBeforeUpdate hook is triggered before updating existing
	// entry in the DB, allowing you to modify or validate the stored data.
	OnModelBeforeUpdate() *hook.Hook[*ModelEvent]

	// OnModelAfterUpdate hook is triggered after successfully updating
	// existing entry in the DB.
	OnModelAfterUpdate() *hook.Hook[*ModelEvent]

	// OnModelBeforeDelete hook is triggered before deleting an
	// existing entry from the DB.
	OnModelBeforeDelete() *hook.Hook[*ModelEvent]

	// OnModelAfterDelete is triggered after successfully deleting an
	// existing entry from the DB.
	OnModelAfterDelete() *hook.Hook[*ModelEvent]

	// OnMailerBeforeAdminResetPasswordSend hook is triggered right before
	// sending a password reset email to an admin.
	//
	// Could be used to send your own custom email template if
	// [hook.StopPropagation] is returned in one of its listeners.
	OnMailerBeforeAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent]

	// OnMailerAfterAdminResetPasswordSend hook is triggered after
	// admin password reset email was successfully sent.
	OnMailerAfterAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent]

	// OnMailerBeforeUserResetPasswordSend hook is triggered right before
	// sending a password reset email to a user.
	//
	// Could be used to send your own custom email template if
	// [hook.StopPropagation] is returned in one of its listeners.
	OnMailerBeforeUserResetPasswordSend() *hook.Hook[*MailerUserEvent]

	// OnMailerAfterUserResetPasswordSend hook is triggered after
	// a user password reset email was successfully sent.
	OnMailerAfterUserResetPasswordSend() *hook.Hook[*MailerUserEvent]

	// OnMailerBeforeUserVerificationSend hook is triggered right before
	// sending a verification email to a user.
	//
	// Could be used to send your own custom email template if
	// [hook.StopPropagation] is returned in one of its listeners.
	OnMailerBeforeUserVerificationSend() *hook.Hook[*MailerUserEvent]

	// OnMailerAfterUserVerificationSend hook is triggered after a user
	// verification email was successfully sent.
	OnMailerAfterUserVerificationSend() *hook.Hook[*MailerUserEvent]

	// OnMailerBeforeUserChangeEmailSend hook is triggered right before
	// sending a confirmation new address email to a a user.
	//
	// Could be used to send your own custom email template if
	// [hook.StopPropagation] is returned in one of its listeners.
	OnMailerBeforeUserChangeEmailSend() *hook.Hook[*MailerUserEvent]

	// OnMailerAfterUserChangeEmailSend hook is triggered after a user
	// change address email was successfully sent.
	OnMailerAfterUserChangeEmailSend() *hook.Hook[*MailerUserEvent]

	// OnRealtimeConnectRequest hook is triggered right before establishing
	// the SSE client connection.
	OnRealtimeConnectRequest() *hook.Hook[*RealtimeConnectEvent]

	// OnRealtimeBeforeSubscribeRequest hook is triggered before changing
	// the client subscriptions, allowing you to further validate and
	// modify the submitted change.
	OnRealtimeBeforeSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent]

	// OnRealtimeAfterSubscribeRequest hook is triggered after the client
	// subscriptions were successfully changed.
	OnRealtimeAfterSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent]

	// OnSettingsListRequest hook is triggered on each successful
	// API Settings list request.
	//
	// Could be used to validate or modify the response before
	// returning it to the client.
	OnSettingsListRequest() *hook.Hook[*SettingsListEvent]

	// OnSettingsBeforeUpdateRequest hook is triggered before each API
	// Settings update request (after request data load and before settings persistence).
	//
	// Could be used to additionally validate the request data or
	// implement completely different persistence behavior
	// (returning [hook.StopPropagation]).
	OnSettingsBeforeUpdateRequest() *hook.Hook[*SettingsUpdateEvent]

	// OnSettingsAfterUpdateRequest hook is triggered after each
	// successful API Settings update request.
	OnSettingsAfterUpdateRequest() *hook.Hook[*SettingsUpdateEvent]

	// OnFileDownloadRequest hook is triggered before each API File download request.
	//
	// Could be used to validate or modify the file response before
	// returning it to the client.
	OnFileDownloadRequest() *hook.Hook[*FileDownloadEvent]

	// OnAdminsListRequest hook is triggered on each API Admins list request.
	//
	// Could be used to validate or modify the response before returning it to the client.
	OnAdminsListRequest() *hook.Hook[*AdminsListEvent]

	// OnAdminViewRequest hook is triggered on each API Admin view request.
	//
	// Could be used to validate or modify the response before returning it to the client.
	OnAdminViewRequest() *hook.Hook[*AdminViewEvent]

	// OnAdminBeforeCreateRequest hook is triggered before each API
	// Admin create request (after request data load and before model persistence).
	//
	// Could be used to additionally validate the request data or implement
	// completely different persistence behavior (returning [hook.StopPropagation]).
	OnAdminBeforeCreateRequest() *hook.Hook[*AdminCreateEvent]

	// OnAdminAfterCreateRequest hook is triggered after each
	// successful API Admin create request.
	OnAdminAfterCreateRequest() *hook.Hook[*AdminCreateEvent]

	// OnAdminBeforeUpdateRequest hook is triggered before each API
	// Admin update request (after request data load and before model persistence).
	//
	// Could be used to additionally validate the request data or implement
	// completely different persistence behavior (returning [hook.StopPropagation]).
	OnAdminBeforeUpdateRequest() *hook.Hook[*AdminUpdateEvent]

	// OnAdminAfterUpdateRequest hook is triggered after each
	// successful API Admin update request.
	OnAdminAfterUpdateRequest() *hook.Hook[*AdminUpdateEvent]

	// OnAdminBeforeDeleteRequest hook is triggered before each API
	// Admin delete request (after model load and before actual deletion).
	//
	// Could be used to additionally validate the request data or implement
	// completely different delete behavior (returning [hook.StopPropagation]).
	OnAdminBeforeDeleteRequest() *hook.Hook[*AdminDeleteEvent]

	// OnAdminAfterDeleteRequest hook is triggered after each
	// successful API Admin delete request.
	OnAdminAfterDeleteRequest() *hook.Hook[*AdminDeleteEvent]

	// OnAdminAuthRequest hook is triggered on each successful API Admin
	// authentication request (sign-in, token refresh, etc.).
	//
	// Could be used to additionally validate or modify the
	// authenticated admin data and token.
	OnAdminAuthRequest() *hook.Hook[*AdminAuthEvent]

	// OnUsersListRequest hook is triggered on each API Users list request.
	//
	// Could be used to validate or modify the response before returning it to the client.
	OnUsersListRequest() *hook.Hook[*UsersListEvent]

	// OnUserViewRequest hook is triggered on each API User view request.
	//
	// Could be used to validate or modify the response before returning it to the client.
	OnUserViewRequest() *hook.Hook[*UserViewEvent]

	// OnUserBeforeCreateRequest hook is triggered before each API User
	// create request (after request data load and before model persistence).
	//
	// Could be used to additionally validate the request data or implement
	// completely different persistence behavior (returning [hook.StopPropagation]).
	OnUserBeforeCreateRequest() *hook.Hook[*UserCreateEvent]

	// OnUserAfterCreateRequest hook is triggered after each
	// successful API User create request.
	OnUserAfterCreateRequest() *hook.Hook[*UserCreateEvent]

	// OnUserBeforeUpdateRequest hook is triggered before each API User
	// update request (after request data load and before model persistence).
	//
	// Could be used to additionally validate the request data or implement
	// completely different persistence behavior (returning [hook.StopPropagation]).
	OnUserBeforeUpdateRequest() *hook.Hook[*UserUpdateEvent]

	// OnUserAfterUpdateRequest hook is triggered after each
	// successful API User update request.
	OnUserAfterUpdateRequest() *hook.Hook[*UserUpdateEvent]

	// OnUserBeforeDeleteRequest hook is triggered before each API User
	// delete request (after model load and before actual deletion).
	//
	// Could be used to additionally validate the request data or implement
	// completely different delete behavior (returning [hook.StopPropagation]).
	OnUserBeforeDeleteRequest() *hook.Hook[*UserDeleteEvent]

	// OnUserAfterDeleteRequest hook is triggered after each
	// successful API User delete request.
	OnUserAfterDeleteRequest() *hook.Hook[*UserDeleteEvent]

	// OnUserAuthRequest hook is triggered on each successful API User
	// authentication request (sign-in, token refresh, etc.).
	//
	// Could be used to additionally validate or modify the
	// authenticated user data and token.
	OnUserAuthRequest() *hook.Hook[*UserAuthEvent]

	// OnUserListExternalAuths hook is triggered on each API user's external auths list request.
	//
	// Could be used to validate or modify the response before returning it to the client.
	OnUserListExternalAuths() *hook.Hook[*UserListExternalAuthsEvent]

	// OnUserBeforeUnlinkExternalAuthRequest hook is triggered before each API user's
	// external auth unlink request (after models load and before the actual relation deletion).
	//
	// Could be used to additionally validate the request data or implement
	// completely different delete behavior (returning [hook.StopPropagation]).
	OnUserBeforeUnlinkExternalAuthRequest() *hook.Hook[*UserUnlinkExternalAuthEvent]

	// OnUserAfterUnlinkExternalAuthRequest hook is triggered after each
	// successful API user's external auth unlink request.
	OnUserAfterUnlinkExternalAuthRequest() *hook.Hook[*UserUnlinkExternalAuthEvent]

	// OnRecordsListRequest hook is triggered on each API Records list request.
	//
	// Could be used to validate or modify the response before returning it to the client.
	OnRecordsListRequest() *hook.Hook[*RecordsListEvent]

	// OnRecordViewRequest hook is triggered on each API Record view request.
	//
	// Could be used to validate or modify the response before returning it to the client.
	OnRecordViewRequest() *hook.Hook[*RecordViewEvent]

	// OnRecordBeforeCreateRequest hook is triggered before each API Record
	// create request (after request data load and before model persistence).
	//
	// Could be used to additionally validate the request data or implement
	// completely different persistence behavior (returning [hook.StopPropagation]).
	OnRecordBeforeCreateRequest() *hook.Hook[*RecordCreateEvent]

	// OnRecordAfterCreateRequest hook is triggered after each
	// successful API Record create request.
	OnRecordAfterCreateRequest() *hook.Hook[*RecordCreateEvent]

	// OnRecordBeforeUpdateRequest hook is triggered before each API Record
	// update request (after request data load and before model persistence).
	//
	// Could be used to additionally validate the request data or implement
	// completely different persistence behavior (returning [hook.StopPropagation]).
	OnRecordBeforeUpdateRequest() *hook.Hook[*RecordUpdateEvent]

	// OnRecordAfterUpdateRequest hook is triggered after each
	// successful API Record update request.
	OnRecordAfterUpdateRequest() *hook.Hook[*RecordUpdateEvent]

	// OnRecordBeforeDeleteRequest hook is triggered before each API Record
	// delete request (after model load and before actual deletion).
	//
	// Could be used to additionally validate the request data or implement
	// completely different delete behavior (returning [hook.StopPropagation]).
	OnRecordBeforeDeleteRequest() *hook.Hook[*RecordDeleteEvent]

	// OnRecordAfterDeleteRequest hook is triggered after each
	// successful API Record delete request.
	OnRecordAfterDeleteRequest() *hook.Hook[*RecordDeleteEvent]

	// OnCollectionsListRequest hook is triggered on each API Collections list request.
	//
	// Could be used to validate or modify the response before returning it to the client.
	OnCollectionsListRequest() *hook.Hook[*CollectionsListEvent]

	// OnCollectionViewRequest hook is triggered on each API Collection view request.
	//
	// Could be used to validate or modify the response before returning it to the client.
	OnCollectionViewRequest() *hook.Hook[*CollectionViewEvent]

	// OnCollectionBeforeCreateRequest hook is triggered before each API Collection
	// create request (after request data load and before model persistence).
	//
	// Could be used to additionally validate the request data or implement
	// completely different persistence behavior (returning [hook.StopPropagation]).
	OnCollectionBeforeCreateRequest() *hook.Hook[*CollectionCreateEvent]

	// OnCollectionAfterCreateRequest hook is triggered after each
	// successful API Collection create request.
	OnCollectionAfterCreateRequest() *hook.Hook[*CollectionCreateEvent]

	// OnCollectionBeforeUpdateRequest hook is triggered before each API Collection
	// update request (after request data load and before model persistence).
	//
	// Could be used to additionally validate the request data or implement
	// completely different persistence behavior (returning [hook.StopPropagation]).
	OnCollectionBeforeUpdateRequest() *hook.Hook[*CollectionUpdateEvent]

	// OnCollectionAfterUpdateRequest hook is triggered after each
	// successful API Collection update request.
	OnCollectionAfterUpdateRequest() *hook.Hook[*CollectionUpdateEvent]

	// OnCollectionBeforeDeleteRequest hook is triggered before each API
	// Collection delete request (after model load and before actual deletion).
	//
	// Could be used to additionally validate the request data or implement
	// completely different delete behavior (returning [hook.StopPropagation]).
	OnCollectionBeforeDeleteRequest() *hook.Hook[*CollectionDeleteEvent]

	// OnCollectionAfterDeleteRequest hook is triggered after each
	// successful API Collection delete request.
	OnCollectionAfterDeleteRequest() *hook.Hook[*CollectionDeleteEvent]

	// OnCollectionsBeforeImportRequest hook is triggered before each API
	// collections import request (after request data load and before the actual import).
	//
	// Could be used to additionally validate the imported collections or
	// to implement completely different import behavior (returning [hook.StopPropagation]).
	OnCollectionsBeforeImportRequest() *hook.Hook[*CollectionsImportEvent]

	// OnCollectionsAfterImportRequest hook is triggered after each
	// successful API collections import request.
	OnCollectionsAfterImportRequest() *hook.Hook[*CollectionsImportEvent]
}

App defines the main PocketBase app interface.

type AuthProviderConfig

type AuthProviderConfig struct {
	Enabled            bool   `form:"enabled" json:"enabled"`
	AllowRegistrations bool   `form:"allowRegistrations" json:"allowRegistrations"`
	ClientId           string `form:"clientId" json:"clientId,omitempty"`
	ClientSecret       string `form:"clientSecret" json:"clientSecret,omitempty"`
	AuthUrl            string `form:"authUrl" json:"authUrl,omitempty"`
	TokenUrl           string `form:"tokenUrl" json:"tokenUrl,omitempty"`
	UserApiUrl         string `form:"userApiUrl" json:"userApiUrl,omitempty"`
}

func (AuthProviderConfig) SetupProvider

func (c AuthProviderConfig) SetupProvider(provider auth.Provider) error

SetupProvider loads the current AuthProviderConfig into the specified provider.

func (AuthProviderConfig) Validate

func (c AuthProviderConfig) Validate() error

Validate makes `ProviderConfig` validatable by implementing validation.Validatable interface.

type BaseApp

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

BaseApp implements core.App and defines the base PocketBase app structure.

func NewBaseApp

func NewBaseApp(dataDir string, encryptionEnv string, isDebug bool) *BaseApp

NewBaseApp creates and returns a new BaseApp instance configured with the provided arguments.

To initialize the app, you need to call `app.Bootstrap()`.

func (*BaseApp) Bootstrap

func (app *BaseApp) Bootstrap() error

Bootstrap initializes the application (aka. create data dir, open db connections, load settings, etc.)

func (*BaseApp) Cache

func (app *BaseApp) Cache() *store.Store[any]

Cache returns the app internal cache store.

func (*BaseApp) DB

func (app *BaseApp) DB() *dbx.DB

DB returns the default app database instance.

func (*BaseApp) Dao

func (app *BaseApp) Dao() *daos.Dao

Dao returns the default app Dao instance.

func (*BaseApp) DataDir

func (app *BaseApp) DataDir() string

DataDir returns the app data directory path.

func (*BaseApp) EncryptionEnv

func (app *BaseApp) EncryptionEnv() string

EncryptionEnv returns the name of the app secret env key (used for settings encryption).

func (*BaseApp) IsDebug

func (app *BaseApp) IsDebug() bool

IsDebug returns whether the app is in debug mode (showing more detailed error logs, executed sql statements, etc.).

func (*BaseApp) LogsDB

func (app *BaseApp) LogsDB() *dbx.DB

LogsDB returns the app logs database instance.

func (*BaseApp) LogsDao

func (app *BaseApp) LogsDao() *daos.Dao

LogsDao returns the app logs Dao instance.

func (*BaseApp) NewFilesystem

func (app *BaseApp) NewFilesystem() (*filesystem.System, error)

NewFilesystem creates a new local or S3 filesystem instance based on the current app settings.

NB! Make sure to call `Close()` on the returned result after you are done working with it.

func (*BaseApp) NewMailClient

func (app *BaseApp) NewMailClient() mailer.Mailer

NewMailClient creates and returns a new SMTP or Sendmail client based on the current app settings.

func (*BaseApp) OnAdminAfterCreateRequest

func (app *BaseApp) OnAdminAfterCreateRequest() *hook.Hook[*AdminCreateEvent]

func (*BaseApp) OnAdminAfterDeleteRequest

func (app *BaseApp) OnAdminAfterDeleteRequest() *hook.Hook[*AdminDeleteEvent]

func (*BaseApp) OnAdminAfterUpdateRequest

func (app *BaseApp) OnAdminAfterUpdateRequest() *hook.Hook[*AdminUpdateEvent]

func (*BaseApp) OnAdminAuthRequest

func (app *BaseApp) OnAdminAuthRequest() *hook.Hook[*AdminAuthEvent]

func (*BaseApp) OnAdminBeforeCreateRequest

func (app *BaseApp) OnAdminBeforeCreateRequest() *hook.Hook[*AdminCreateEvent]

func (*BaseApp) OnAdminBeforeDeleteRequest

func (app *BaseApp) OnAdminBeforeDeleteRequest() *hook.Hook[*AdminDeleteEvent]

func (*BaseApp) OnAdminBeforeUpdateRequest

func (app *BaseApp) OnAdminBeforeUpdateRequest() *hook.Hook[*AdminUpdateEvent]

func (*BaseApp) OnAdminViewRequest

func (app *BaseApp) OnAdminViewRequest() *hook.Hook[*AdminViewEvent]

func (*BaseApp) OnAdminsListRequest

func (app *BaseApp) OnAdminsListRequest() *hook.Hook[*AdminsListEvent]

func (*BaseApp) OnBeforeServe

func (app *BaseApp) OnBeforeServe() *hook.Hook[*ServeEvent]

func (*BaseApp) OnCollectionAfterCreateRequest

func (app *BaseApp) OnCollectionAfterCreateRequest() *hook.Hook[*CollectionCreateEvent]

func (*BaseApp) OnCollectionAfterDeleteRequest

func (app *BaseApp) OnCollectionAfterDeleteRequest() *hook.Hook[*CollectionDeleteEvent]

func (*BaseApp) OnCollectionAfterUpdateRequest

func (app *BaseApp) OnCollectionAfterUpdateRequest() *hook.Hook[*CollectionUpdateEvent]

func (*BaseApp) OnCollectionBeforeCreateRequest

func (app *BaseApp) OnCollectionBeforeCreateRequest() *hook.Hook[*CollectionCreateEvent]

func (*BaseApp) OnCollectionBeforeDeleteRequest

func (app *BaseApp) OnCollectionBeforeDeleteRequest() *hook.Hook[*CollectionDeleteEvent]

func (*BaseApp) OnCollectionBeforeUpdateRequest

func (app *BaseApp) OnCollectionBeforeUpdateRequest() *hook.Hook[*CollectionUpdateEvent]

func (*BaseApp) OnCollectionViewRequest

func (app *BaseApp) OnCollectionViewRequest() *hook.Hook[*CollectionViewEvent]

func (*BaseApp) OnCollectionsAfterImportRequest

func (app *BaseApp) OnCollectionsAfterImportRequest() *hook.Hook[*CollectionsImportEvent]

func (*BaseApp) OnCollectionsBeforeImportRequest

func (app *BaseApp) OnCollectionsBeforeImportRequest() *hook.Hook[*CollectionsImportEvent]

func (*BaseApp) OnCollectionsListRequest

func (app *BaseApp) OnCollectionsListRequest() *hook.Hook[*CollectionsListEvent]

func (*BaseApp) OnFileDownloadRequest

func (app *BaseApp) OnFileDownloadRequest() *hook.Hook[*FileDownloadEvent]

func (*BaseApp) OnMailerAfterAdminResetPasswordSend

func (app *BaseApp) OnMailerAfterAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent]

func (*BaseApp) OnMailerAfterUserChangeEmailSend

func (app *BaseApp) OnMailerAfterUserChangeEmailSend() *hook.Hook[*MailerUserEvent]

func (*BaseApp) OnMailerAfterUserResetPasswordSend

func (app *BaseApp) OnMailerAfterUserResetPasswordSend() *hook.Hook[*MailerUserEvent]

func (*BaseApp) OnMailerAfterUserVerificationSend

func (app *BaseApp) OnMailerAfterUserVerificationSend() *hook.Hook[*MailerUserEvent]

func (*BaseApp) OnMailerBeforeAdminResetPasswordSend

func (app *BaseApp) OnMailerBeforeAdminResetPasswordSend() *hook.Hook[*MailerAdminEvent]

func (*BaseApp) OnMailerBeforeUserChangeEmailSend

func (app *BaseApp) OnMailerBeforeUserChangeEmailSend() *hook.Hook[*MailerUserEvent]

func (*BaseApp) OnMailerBeforeUserResetPasswordSend

func (app *BaseApp) OnMailerBeforeUserResetPasswordSend() *hook.Hook[*MailerUserEvent]

func (*BaseApp) OnMailerBeforeUserVerificationSend

func (app *BaseApp) OnMailerBeforeUserVerificationSend() *hook.Hook[*MailerUserEvent]

func (*BaseApp) OnModelAfterCreate

func (app *BaseApp) OnModelAfterCreate() *hook.Hook[*ModelEvent]

func (*BaseApp) OnModelAfterDelete

func (app *BaseApp) OnModelAfterDelete() *hook.Hook[*ModelEvent]

func (*BaseApp) OnModelAfterUpdate

func (app *BaseApp) OnModelAfterUpdate() *hook.Hook[*ModelEvent]

func (*BaseApp) OnModelBeforeCreate

func (app *BaseApp) OnModelBeforeCreate() *hook.Hook[*ModelEvent]

func (*BaseApp) OnModelBeforeDelete

func (app *BaseApp) OnModelBeforeDelete() *hook.Hook[*ModelEvent]

func (*BaseApp) OnModelBeforeUpdate

func (app *BaseApp) OnModelBeforeUpdate() *hook.Hook[*ModelEvent]

func (*BaseApp) OnRealtimeAfterSubscribeRequest

func (app *BaseApp) OnRealtimeAfterSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent]

func (*BaseApp) OnRealtimeBeforeSubscribeRequest

func (app *BaseApp) OnRealtimeBeforeSubscribeRequest() *hook.Hook[*RealtimeSubscribeEvent]

func (*BaseApp) OnRealtimeConnectRequest

func (app *BaseApp) OnRealtimeConnectRequest() *hook.Hook[*RealtimeConnectEvent]

func (*BaseApp) OnRecordAfterCreateRequest

func (app *BaseApp) OnRecordAfterCreateRequest() *hook.Hook[*RecordCreateEvent]

func (*BaseApp) OnRecordAfterDeleteRequest

func (app *BaseApp) OnRecordAfterDeleteRequest() *hook.Hook[*RecordDeleteEvent]

func (*BaseApp) OnRecordAfterUpdateRequest

func (app *BaseApp) OnRecordAfterUpdateRequest() *hook.Hook[*RecordUpdateEvent]

func (*BaseApp) OnRecordBeforeCreateRequest

func (app *BaseApp) OnRecordBeforeCreateRequest() *hook.Hook[*RecordCreateEvent]

func (*BaseApp) OnRecordBeforeDeleteRequest

func (app *BaseApp) OnRecordBeforeDeleteRequest() *hook.Hook[*RecordDeleteEvent]

func (*BaseApp) OnRecordBeforeUpdateRequest

func (app *BaseApp) OnRecordBeforeUpdateRequest() *hook.Hook[*RecordUpdateEvent]

func (*BaseApp) OnRecordViewRequest

func (app *BaseApp) OnRecordViewRequest() *hook.Hook[*RecordViewEvent]

func (*BaseApp) OnRecordsListRequest

func (app *BaseApp) OnRecordsListRequest() *hook.Hook[*RecordsListEvent]

func (*BaseApp) OnSettingsAfterUpdateRequest

func (app *BaseApp) OnSettingsAfterUpdateRequest() *hook.Hook[*SettingsUpdateEvent]

func (*BaseApp) OnSettingsBeforeUpdateRequest

func (app *BaseApp) OnSettingsBeforeUpdateRequest() *hook.Hook[*SettingsUpdateEvent]

func (*BaseApp) OnSettingsListRequest

func (app *BaseApp) OnSettingsListRequest() *hook.Hook[*SettingsListEvent]

func (*BaseApp) OnUserAfterCreateRequest

func (app *BaseApp) OnUserAfterCreateRequest() *hook.Hook[*UserCreateEvent]

func (*BaseApp) OnUserAfterDeleteRequest

func (app *BaseApp) OnUserAfterDeleteRequest() *hook.Hook[*UserDeleteEvent]

func (*BaseApp) OnUserAfterUnlinkExternalAuthRequest

func (app *BaseApp) OnUserAfterUnlinkExternalAuthRequest() *hook.Hook[*UserUnlinkExternalAuthEvent]

func (*BaseApp) OnUserAfterUpdateRequest

func (app *BaseApp) OnUserAfterUpdateRequest() *hook.Hook[*UserUpdateEvent]

func (*BaseApp) OnUserAuthRequest

func (app *BaseApp) OnUserAuthRequest() *hook.Hook[*UserAuthEvent]

func (*BaseApp) OnUserBeforeCreateRequest

func (app *BaseApp) OnUserBeforeCreateRequest() *hook.Hook[*UserCreateEvent]

func (*BaseApp) OnUserBeforeDeleteRequest

func (app *BaseApp) OnUserBeforeDeleteRequest() *hook.Hook[*UserDeleteEvent]

func (*BaseApp) OnUserBeforeUnlinkExternalAuthRequest

func (app *BaseApp) OnUserBeforeUnlinkExternalAuthRequest() *hook.Hook[*UserUnlinkExternalAuthEvent]

func (*BaseApp) OnUserBeforeUpdateRequest

func (app *BaseApp) OnUserBeforeUpdateRequest() *hook.Hook[*UserUpdateEvent]

func (*BaseApp) OnUserListExternalAuths

func (app *BaseApp) OnUserListExternalAuths() *hook.Hook[*UserListExternalAuthsEvent]

func (*BaseApp) OnUserViewRequest

func (app *BaseApp) OnUserViewRequest() *hook.Hook[*UserViewEvent]

func (*BaseApp) OnUsersListRequest

func (app *BaseApp) OnUsersListRequest() *hook.Hook[*UsersListEvent]

func (*BaseApp) RefreshSettings

func (app *BaseApp) RefreshSettings() error

RefreshSettings reinitializes and reloads the stored application settings.

func (*BaseApp) ResetBootstrapState

func (app *BaseApp) ResetBootstrapState() error

ResetBootstrapState takes care for releasing initialized app resources (eg. closing db connections).

func (*BaseApp) Settings

func (app *BaseApp) Settings() *Settings

Settings returns the loaded app settings.

func (*BaseApp) SubscriptionsBroker

func (app *BaseApp) SubscriptionsBroker() *subscriptions.Broker

SubscriptionsBroker returns the app realtime subscriptions broker instance.

type CollectionCreateEvent

type CollectionCreateEvent struct {
	HttpContext echo.Context
	Collection  *models.Collection
}

type CollectionDeleteEvent

type CollectionDeleteEvent struct {
	HttpContext echo.Context
	Collection  *models.Collection
}

type CollectionUpdateEvent

type CollectionUpdateEvent struct {
	HttpContext echo.Context
	Collection  *models.Collection
}

type CollectionViewEvent

type CollectionViewEvent struct {
	HttpContext echo.Context
	Collection  *models.Collection
}

type CollectionsImportEvent

type CollectionsImportEvent struct {
	HttpContext echo.Context
	Collections []*models.Collection
}

type CollectionsListEvent

type CollectionsListEvent struct {
	HttpContext echo.Context
	Collections []*models.Collection
	Result      *search.Result
}

type EmailAuthConfig

type EmailAuthConfig struct {
	Enabled           bool     `form:"enabled" json:"enabled"`
	ExceptDomains     []string `form:"exceptDomains" json:"exceptDomains"`
	OnlyDomains       []string `form:"onlyDomains" json:"onlyDomains"`
	MinPasswordLength int      `form:"minPasswordLength" json:"minPasswordLength"`
}

func (EmailAuthConfig) Validate

func (c EmailAuthConfig) Validate() error

Validate makes `EmailAuthConfig` validatable by implementing validation.Validatable interface.

type EmailTemplate

type EmailTemplate struct {
	Body      string `form:"body" json:"body"`
	Subject   string `form:"subject" json:"subject"`
	ActionUrl string `form:"actionUrl" json:"actionUrl"`
}

func (EmailTemplate) Resolve

func (t EmailTemplate) Resolve(
	appName string,
	appUrl,
	token string,
) (subject, body, actionUrl string)

Resolve replaces the placeholder parameters in the current email template and returns its components as ready-to-use strings.

func (EmailTemplate) Validate

func (t EmailTemplate) Validate() error

Validate makes EmailTemplate validatable by implementing validation.Validatable interface.

type FileDownloadEvent

type FileDownloadEvent struct {
	HttpContext echo.Context
	Collection  *models.Collection
	Record      *models.Record
	FileField   *schema.SchemaField
	ServedPath  string
	ServedName  string
}

type LogsConfig

type LogsConfig struct {
	MaxDays int `form:"maxDays" json:"maxDays"`
}

func (LogsConfig) Validate

func (c LogsConfig) Validate() error

Validate makes LogsConfig validatable by implementing validation.Validatable interface.

type MailerAdminEvent

type MailerAdminEvent struct {
	MailClient mailer.Mailer
	Admin      *models.Admin
	Meta       map[string]any
}

type MailerUserEvent

type MailerUserEvent struct {
	MailClient mailer.Mailer
	User       *models.User
	Meta       map[string]any
}

type MetaConfig

type MetaConfig struct {
	AppName                    string        `form:"appName" json:"appName"`
	AppUrl                     string        `form:"appUrl" json:"appUrl"`
	HideControls               bool          `form:"hideControls" json:"hideControls"`
	SenderName                 string        `form:"senderName" json:"senderName"`
	SenderAddress              string        `form:"senderAddress" json:"senderAddress"`
	VerificationTemplate       EmailTemplate `form:"verificationTemplate" json:"verificationTemplate"`
	ResetPasswordTemplate      EmailTemplate `form:"resetPasswordTemplate" json:"resetPasswordTemplate"`
	ConfirmEmailChangeTemplate EmailTemplate `form:"confirmEmailChangeTemplate" json:"confirmEmailChangeTemplate"`
}

func (MetaConfig) Validate

func (c MetaConfig) Validate() error

Validate makes MetaConfig validatable by implementing validation.Validatable interface.

type ModelEvent

type ModelEvent struct {
	Dao   *daos.Dao
	Model models.Model
}

type RealtimeConnectEvent

type RealtimeConnectEvent struct {
	HttpContext echo.Context
	Client      subscriptions.Client
}

type RealtimeSubscribeEvent

type RealtimeSubscribeEvent struct {
	HttpContext   echo.Context
	Client        subscriptions.Client
	Subscriptions []string
}

type RecordCreateEvent

type RecordCreateEvent struct {
	HttpContext echo.Context
	Record      *models.Record
}

type RecordDeleteEvent

type RecordDeleteEvent struct {
	HttpContext echo.Context
	Record      *models.Record
}

type RecordUpdateEvent

type RecordUpdateEvent struct {
	HttpContext echo.Context
	Record      *models.Record
}

type RecordViewEvent

type RecordViewEvent struct {
	HttpContext echo.Context
	Record      *models.Record
}

type RecordsListEvent

type RecordsListEvent struct {
	HttpContext echo.Context
	Collection  *models.Collection
	Records     []*models.Record
	Result      *search.Result
}

type S3Config

type S3Config struct {
	Enabled        bool   `form:"enabled" json:"enabled"`
	Bucket         string `form:"bucket" json:"bucket"`
	Region         string `form:"region" json:"region"`
	Endpoint       string `form:"endpoint" json:"endpoint"`
	AccessKey      string `form:"accessKey" json:"accessKey"`
	Secret         string `form:"secret" json:"secret"`
	ForcePathStyle bool   `form:"forcePathStyle" json:"forcePathStyle"`
}

func (S3Config) Validate

func (c S3Config) Validate() error

Validate makes S3Config validatable by implementing validation.Validatable interface.

type ServeEvent

type ServeEvent struct {
	App    App
	Router *echo.Echo
}

type Settings

type Settings struct {
	Meta MetaConfig `form:"meta" json:"meta"`
	Logs LogsConfig `form:"logs" json:"logs"`
	Smtp SmtpConfig `form:"smtp" json:"smtp"`
	S3   S3Config   `form:"s3" json:"s3"`

	AdminAuthToken          TokenConfig `form:"adminAuthToken" json:"adminAuthToken"`
	AdminPasswordResetToken TokenConfig `form:"adminPasswordResetToken" json:"adminPasswordResetToken"`
	UserAuthToken           TokenConfig `form:"userAuthToken" json:"userAuthToken"`
	UserPasswordResetToken  TokenConfig `form:"userPasswordResetToken" json:"userPasswordResetToken"`
	UserEmailChangeToken    TokenConfig `form:"userEmailChangeToken" json:"userEmailChangeToken"`
	UserVerificationToken   TokenConfig `form:"userVerificationToken" json:"userVerificationToken"`

	EmailAuth    EmailAuthConfig    `form:"emailAuth" json:"emailAuth"`
	GoogleAuth   AuthProviderConfig `form:"googleAuth" json:"googleAuth"`
	FacebookAuth AuthProviderConfig `form:"facebookAuth" json:"facebookAuth"`
	GithubAuth   AuthProviderConfig `form:"githubAuth" json:"githubAuth"`
	GitlabAuth   AuthProviderConfig `form:"gitlabAuth" json:"gitlabAuth"`
	DiscordAuth  AuthProviderConfig `form:"discordAuth" json:"discordAuth"`
	TwitterAuth  AuthProviderConfig `form:"twitterAuth" json:"twitterAuth"`
	// contains filtered or unexported fields
}

Settings defines common app configuration options.

func NewSettings

func NewSettings() *Settings

NewSettings creates and returns a new default Settings instance.

func (*Settings) Clone

func (s *Settings) Clone() (*Settings, error)

Clone creates a new deep copy of the current settings.

func (*Settings) Merge

func (s *Settings) Merge(other *Settings) error

Merge merges `other` settings into the current one.

func (*Settings) NamedAuthProviderConfigs

func (s *Settings) NamedAuthProviderConfigs() map[string]AuthProviderConfig

NamedAuthProviderConfigs returns a map with all registered OAuth2 provider configurations (indexed by their name identifier).

func (*Settings) RedactClone

func (s *Settings) RedactClone() (*Settings, error)

RedactClone creates a new deep copy of the current settings, while replacing the secret values with `******`.

func (*Settings) Validate

func (s *Settings) Validate() error

Validate makes Settings validatable by implementing validation.Validatable interface.

type SettingsListEvent

type SettingsListEvent struct {
	HttpContext      echo.Context
	RedactedSettings *Settings
}

type SettingsUpdateEvent

type SettingsUpdateEvent struct {
	HttpContext echo.Context
	OldSettings *Settings
	NewSettings *Settings
}

type SmtpConfig

type SmtpConfig struct {
	Enabled  bool   `form:"enabled" json:"enabled"`
	Host     string `form:"host" json:"host"`
	Port     int    `form:"port" json:"port"`
	Username string `form:"username" json:"username"`
	Password string `form:"password" json:"password"`

	// Whether to enforce TLS encryption for the mail server connection.
	//
	// When set to false StartTLS command is send, leaving the server
	// to decide whether to upgrade the connection or not.
	Tls bool `form:"tls" json:"tls"`
}

func (SmtpConfig) Validate

func (c SmtpConfig) Validate() error

Validate makes SmtpConfig validatable by implementing validation.Validatable interface.

type TokenConfig

type TokenConfig struct {
	Secret   string `form:"secret" json:"secret"`
	Duration int64  `form:"duration" json:"duration"`
}

func (TokenConfig) Validate

func (c TokenConfig) Validate() error

Validate makes TokenConfig validatable by implementing validation.Validatable interface.

type UserAuthEvent

type UserAuthEvent struct {
	HttpContext echo.Context
	User        *models.User
	Token       string
	Meta        any
}

type UserCreateEvent

type UserCreateEvent struct {
	HttpContext echo.Context
	User        *models.User
}

type UserDeleteEvent

type UserDeleteEvent struct {
	HttpContext echo.Context
	User        *models.User
}

type UserListExternalAuthsEvent

type UserListExternalAuthsEvent struct {
	HttpContext   echo.Context
	User          *models.User
	ExternalAuths []*models.ExternalAuth
}

type UserUnlinkExternalAuthEvent

type UserUnlinkExternalAuthEvent struct {
	HttpContext  echo.Context
	User         *models.User
	ExternalAuth *models.ExternalAuth
}

type UserUpdateEvent

type UserUpdateEvent struct {
	HttpContext echo.Context
	User        *models.User
}

type UserViewEvent

type UserViewEvent struct {
	HttpContext echo.Context
	User        *models.User
}

type UsersListEvent

type UsersListEvent struct {
	HttpContext echo.Context
	Users       []*models.User
	Result      *search.Result
}

Jump to

Keyboard shortcuts

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