2022-07-06 23:19:05 +02:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/pocketbase/pocketbase/daos"
|
|
|
|
"github.com/pocketbase/pocketbase/models"
|
|
|
|
"github.com/pocketbase/pocketbase/models/schema"
|
2022-11-26 14:42:45 +02:00
|
|
|
"github.com/pocketbase/pocketbase/models/settings"
|
2022-07-06 23:19:05 +02:00
|
|
|
"github.com/pocketbase/pocketbase/tools/mailer"
|
|
|
|
"github.com/pocketbase/pocketbase/tools/search"
|
|
|
|
"github.com/pocketbase/pocketbase/tools/subscriptions"
|
|
|
|
|
|
|
|
"github.com/labstack/echo/v5"
|
|
|
|
)
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Serve events data
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2022-11-26 14:42:45 +02:00
|
|
|
type BootstrapEvent struct {
|
|
|
|
App App
|
|
|
|
}
|
|
|
|
|
2022-07-06 23:19:05 +02:00
|
|
|
type ServeEvent struct {
|
|
|
|
App App
|
|
|
|
Router *echo.Echo
|
|
|
|
}
|
|
|
|
|
2022-12-02 16:36:15 +02:00
|
|
|
type ApiErrorEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Error error
|
|
|
|
}
|
|
|
|
|
2022-07-06 23:19:05 +02:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Model DAO events data
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
type ModelEvent struct {
|
|
|
|
Dao *daos.Dao
|
|
|
|
Model models.Model
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Mailer events data
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2022-10-30 10:28:14 +02:00
|
|
|
type MailerRecordEvent struct {
|
2022-07-06 23:19:05 +02:00
|
|
|
MailClient mailer.Mailer
|
2022-11-21 14:53:05 +02:00
|
|
|
Message *mailer.Message
|
2022-10-30 10:28:14 +02:00
|
|
|
Record *models.Record
|
2022-07-06 23:19:05 +02:00
|
|
|
Meta map[string]any
|
|
|
|
}
|
|
|
|
|
|
|
|
type MailerAdminEvent struct {
|
|
|
|
MailClient mailer.Mailer
|
2022-11-21 14:53:05 +02:00
|
|
|
Message *mailer.Message
|
2022-07-06 23:19:05 +02:00
|
|
|
Admin *models.Admin
|
|
|
|
Meta map[string]any
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Realtime API events data
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
type RealtimeConnectEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Client subscriptions.Client
|
|
|
|
}
|
|
|
|
|
2022-12-02 14:25:36 +02:00
|
|
|
type RealtimeDisconnectEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Client subscriptions.Client
|
|
|
|
}
|
|
|
|
|
|
|
|
type RealtimeMessageEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Client subscriptions.Client
|
|
|
|
Message *subscriptions.Message
|
|
|
|
}
|
|
|
|
|
2022-07-06 23:19:05 +02:00
|
|
|
type RealtimeSubscribeEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Client subscriptions.Client
|
|
|
|
Subscriptions []string
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Settings API events data
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
type SettingsListEvent struct {
|
|
|
|
HttpContext echo.Context
|
2022-11-26 14:42:45 +02:00
|
|
|
RedactedSettings *settings.Settings
|
2022-07-06 23:19:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type SettingsUpdateEvent struct {
|
|
|
|
HttpContext echo.Context
|
2022-11-26 14:42:45 +02:00
|
|
|
OldSettings *settings.Settings
|
|
|
|
NewSettings *settings.Settings
|
2022-07-06 23:19:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Record API events data
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
type RecordsListEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Collection *models.Collection
|
|
|
|
Records []*models.Record
|
|
|
|
Result *search.Result
|
|
|
|
}
|
|
|
|
|
|
|
|
type RecordViewEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Record *models.Record
|
|
|
|
}
|
|
|
|
|
|
|
|
type RecordCreateEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Record *models.Record
|
|
|
|
}
|
|
|
|
|
|
|
|
type RecordUpdateEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Record *models.Record
|
|
|
|
}
|
|
|
|
|
|
|
|
type RecordDeleteEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Record *models.Record
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Admin API events data
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
type AdminsListEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Admins []*models.Admin
|
|
|
|
Result *search.Result
|
|
|
|
}
|
|
|
|
|
|
|
|
type AdminViewEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Admin *models.Admin
|
|
|
|
}
|
|
|
|
|
|
|
|
type AdminCreateEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Admin *models.Admin
|
|
|
|
}
|
|
|
|
|
|
|
|
type AdminUpdateEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Admin *models.Admin
|
|
|
|
}
|
|
|
|
|
|
|
|
type AdminDeleteEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Admin *models.Admin
|
|
|
|
}
|
|
|
|
|
|
|
|
type AdminAuthEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Admin *models.Admin
|
|
|
|
Token string
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2022-10-30 10:28:14 +02:00
|
|
|
// Auth Record API events data
|
2022-07-06 23:19:05 +02:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2022-10-30 10:28:14 +02:00
|
|
|
type RecordAuthEvent struct {
|
2022-07-06 23:19:05 +02:00
|
|
|
HttpContext echo.Context
|
2022-10-30 10:28:14 +02:00
|
|
|
Record *models.Record
|
2022-07-06 23:19:05 +02:00
|
|
|
Token string
|
|
|
|
Meta any
|
|
|
|
}
|
|
|
|
|
2022-10-30 10:28:14 +02:00
|
|
|
type RecordListExternalAuthsEvent struct {
|
2022-08-31 12:38:31 +02:00
|
|
|
HttpContext echo.Context
|
2022-10-30 10:28:14 +02:00
|
|
|
Record *models.Record
|
2022-08-31 12:38:31 +02:00
|
|
|
ExternalAuths []*models.ExternalAuth
|
|
|
|
}
|
|
|
|
|
2022-10-30 10:28:14 +02:00
|
|
|
type RecordUnlinkExternalAuthEvent struct {
|
2022-08-31 12:38:31 +02:00
|
|
|
HttpContext echo.Context
|
2022-10-30 10:28:14 +02:00
|
|
|
Record *models.Record
|
2022-08-31 12:38:31 +02:00
|
|
|
ExternalAuth *models.ExternalAuth
|
2022-07-06 23:19:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Collection API events data
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
type CollectionsListEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Collections []*models.Collection
|
|
|
|
Result *search.Result
|
|
|
|
}
|
|
|
|
|
|
|
|
type CollectionViewEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Collection *models.Collection
|
|
|
|
}
|
|
|
|
|
|
|
|
type CollectionCreateEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Collection *models.Collection
|
|
|
|
}
|
|
|
|
|
|
|
|
type CollectionUpdateEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Collection *models.Collection
|
|
|
|
}
|
|
|
|
|
|
|
|
type CollectionDeleteEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Collection *models.Collection
|
|
|
|
}
|
|
|
|
|
2022-08-07 19:58:21 +02:00
|
|
|
type CollectionsImportEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Collections []*models.Collection
|
|
|
|
}
|
|
|
|
|
2022-07-06 23:19:05 +02:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// File API events data
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
type FileDownloadEvent struct {
|
|
|
|
HttpContext echo.Context
|
|
|
|
Collection *models.Collection
|
|
|
|
Record *models.Record
|
|
|
|
FileField *schema.SchemaField
|
|
|
|
ServedPath string
|
|
|
|
ServedName string
|
|
|
|
}
|