models

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package models contains common data structures and models used throughout the Apito engine

Index

Constants

View Source
const (
	// ExtKeyRelationCollectionCheck on CommonSystemParams.Ext makes CheckTableOrCollectionExists
	// probe the relation_* collection for param.Model (resolver ↔ driver contract).
	ExtKeyRelationCollectionCheck = "_apito_relation_collection_check"
	// IndexesRelationCollectionToken in CreateTableOrCollection's indexes slice requests creating
	// the relation edge collection for param.Model instead of the document collection.
	IndexesRelationCollectionToken = "__apito_relation_collection__"
)
View Source
const (
	SystemEventInfo                   = "info"
	SystemEventSchemaExecutionUpdated = "schema_execution_updated"
	SystemEventPluginStatusChanged    = "plugin_status_changed"
	SystemEventProjectCreated         = "project_created"
	SystemEventProjectUpdated         = "project_updated"
)

System notification event types (console operator bus).

View Source
const (
	ChangeEventCreated = "CREATED"
	ChangeEventUpdated = "UPDATED"
	ChangeEventDeleted = "DELETED"
)

Change event types for auto-generated per-model subscriptions.

View Source
const (
	SchemaOpStatusPending      = "pending"
	SchemaOpStatusApplying     = "applying"
	SchemaOpStatusCommitted    = "committed"
	SchemaOpStatusCompensating = "compensating"
	SchemaOpStatusFailed       = "failed"
	SchemaOpStatusNeedsRepair  = "needs_repair"
)

Schema operation ledger statuses.

View Source
const (
	SchemaOpTypeCreateModel      = "create_model"
	SchemaOpTypeAddField         = "add_field"
	SchemaOpTypeModelFieldOp     = "model_field_operation"
	SchemaOpTypeCreateConnection = "create_connection"
	SchemaOpTypeDeleteConnection = "delete_connection"
	SchemaOpTypeDeleteModel      = "delete_model"
	SchemaOpTypeRenameModel      = "rename_model"
	SchemaOpTypeDuplicateModel   = "duplicate_model"
	SchemaOpTypeConvertModel     = "convert_model"
	SchemaOpTypeUpdateModel      = "update_model"
	SchemaOpTypeRearrangeField   = "rearrange_field"
	SchemaOpTypePublishChangeset = "publish_schema_changeset"
)

Schema operation types (GraphQL mutation names / internal keys).

View Source
const (
	SchemaOpStepPending     = "pending"
	SchemaOpStepSucceeded   = "succeeded"
	SchemaOpStepFailed      = "failed"
	SchemaOpStepCompensated = "compensated"
)

SchemaOperationStepState is per-participant step state in steps_json.

View Source
const (
	SystemFileTypeMedia    = "media"
	SystemFileTypePDF      = "pdf"
	SystemFileTypeDocument = "document"
	SystemFileTypeOther    = "other"
)
View Source
const (
	ExtKeySystemFileType    = "file_type"
	ExtKeySystemFilesLimit  = "files_limit"
	ExtKeySystemFilesOffset = "files_offset"
)
View Source
const (
	// ProjectUsersTableName is the legacy system DB table / Mongo collection for app end-users (migration source).
	ProjectUsersTableName = "project_users"

	UserStatusActive     = "active"
	UserStatusSuspended  = "suspended"
	UserProviderLocal    = "local"
	UserProviderGoogle   = "google"
	UserDefaultRoleAdmin = "admin"
)

Project end-user accounts (application auth). Not SystemUser (console operators).

View Source
const LegacySQLiteTemplateFilename = "apito_project.db"

LegacySQLiteTemplateFilename is the historical single-file SQLite template name used before GENERAL_SQLITE_FILE_PER_PROJECT (sentinel when deciding to assign a per-project file).

View Source
const MinPasswordLength int = 8
View Source
const (
	// ProjectAuthUsersTableName is the reserved project DB table for application end-users.
	ProjectAuthUsersTableName = "users"
)

Variables

View Source
var ErrInvalidFileType = errors.New("invalid file_type")

ErrInvalidFileType is returned when file_type validation fails.

View Source
var ErrSubscriberNotFound = errors.New("subscriber not found")
View Source
var GlobalPermissions = []string{"contents", "models", "plugins", "media", "logic", "settings",
	"api_explorer", "usages", "addons", "extensions", "teams", "webhook",
	"api_secrets", "roles"}

Functions

func BoolPtr added in v1.7.0

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to b.

func BuildStoragePluginEnvVars added in v1.7.0

func BuildStoragePluginEnvVars(project *Project, cfg *Config) ([]*protobuff.EnvVariable, error)

BuildStoragePluginEnvVars returns env vars for storage plugin Init from resolved project storage.

func DedupeProjectSchemaFields added in v1.7.0

func DedupeProjectSchemaFields(schema *ProjectSchema)

DedupeProjectSchemaFields removes duplicate root-level fields per model (last wins).

func DefaultRegistrationRoleConfigured added in v1.7.0

func DefaultRegistrationRoleConfigured(p *Project) string

DefaultRegistrationRoleConfigured returns the stored default registration role (trimmed, may be empty).

func FileExtensionFromMIME added in v1.7.0

func FileExtensionFromMIME(contentType string) string

FileExtensionFromMIME returns a file extension without a leading dot (e.g. "png"). Used when the upload filename has no extension (common for browser "blob" uploads).

func FreeCloudPlatformConfigured added in v1.7.0

func FreeCloudPlatformConfigured(cfg *Config) bool

FreeCloudPlatformConfigured reports whether platform free-cloud S3/R2 credentials are set.

func FreeCloudStorageLimitBytes added in v1.7.0

func FreeCloudStorageLimitBytes(cfg *Config) int64

FreeCloudStorageLimitBytes returns the per-project free-cloud quota in bytes.

func GeneralAuthEffective added in v1.7.0

func GeneralAuthEffective(p *Project) bool

GeneralAuthEffective is true when general (password) login should be allowed.

func GeneralIdentifierMethod added in v1.7.0

func GeneralIdentifierMethod(p *Project) string

GeneralIdentifierMethod returns "email", "phone", or "email" as default when unset/invalid.

func GoogleAuthEffective added in v1.7.0

func GoogleAuthEffective(p *Project) bool

GoogleAuthEffective is true when Google login should be allowed.

func GoogleOAuthClientID added in v1.7.0

func GoogleOAuthClientID(p *Project) string

GoogleOAuthClientID returns the OAuth client ID from AuthenticationSettings (trimmed).

func GoogleOAuthClientSecret added in v1.7.0

func GoogleOAuthClientSecret(p *Project) string

GoogleOAuthClientSecret returns the OAuth client secret from AuthenticationSettings (trimmed).

func GoogleOAuthCodeExchangeReady added in v1.7.0

func GoogleOAuthCodeExchangeReady(p *Project) bool

GoogleOAuthCodeExchangeReady reports whether server-side OAuth code exchange can run.

func GoogleOAuthRedirectURI added in v1.7.0

func GoogleOAuthRedirectURI(p *Project) string

GoogleOAuthRedirectURI returns the configured authorized redirect URI for Google OAuth (code flow).

func HasGoogleClientSecretConfigured added in v1.7.0

func HasGoogleClientSecretConfigured(p *Project) bool

HasGoogleClientSecretConfigured reports whether a non-empty secret is stored.

func HasSecretAccessKeyConfigured added in v1.7.0

func HasSecretAccessKeyConfigured(p *Project) bool

HasSecretAccessKeyConfigured reports whether a non-empty secret access key is stored.

func HashGoogleOAuthRedirectURI added in v1.7.0

func HashGoogleOAuthRedirectURI(raw string) string

HashGoogleOAuthRedirectURI returns lowercase hex SHA-256 for binding state to redirect.

func InferFileTypeFromMIME added in v1.7.0

func InferFileTypeFromMIME(contentType string) string

InferFileTypeFromMIME maps a MIME type to a system file_type category.

func NormalizeProjectSchemaConnectionTypes added in v1.7.2

func NormalizeProjectSchemaConnectionTypes(schema *ProjectSchema)

NormalizeProjectSchemaConnectionTypes maps legacy pro draft "reverse" direction labels to "backward". Connection direction is always forward/backward; reverse_connection_type GraphQL args are cardinalities only.

func NormalizeUserPhoneKey added in v1.7.0

func NormalizeUserPhoneKey(s string) string

NormalizeUserPhoneKey lowercases and trims phone for lookups (case-insensitive sign-in).

func ProjectAuthUserToPublicMap added in v1.7.0

func ProjectAuthUserToPublicMap(u *ProjectAuthUser) map[string]interface{}

ProjectAuthUserToPublicMap returns a GraphQL-safe map (no secret).

func ProjectStorageConfigured added in v1.7.0

func ProjectStorageConfigured(p *Project, cfg *Config) bool

ProjectStorageConfigured reports whether uploads can proceed for the project's storage mode.

func RegistrationDefaultRole added in v1.7.0

func RegistrationDefaultRole(p *Project) string

RegistrationDefaultRole returns the role assigned to new users when none is specified. Empty configuration falls back to "none".

func SignGoogleOAuthState added in v1.7.0

func SignGoogleOAuthState(clientSecret, projectID, redirectURI string) (string, error)

SignGoogleOAuthState builds a signed OAuth state bound to project and redirect (HMAC keyed by Google client secret).

func SignTenantGoogleOAuthState deprecated added in v1.7.0

func SignTenantGoogleOAuthState(clientSecret, projectID, redirectURI string) (string, error)

Deprecated: use SignGoogleOAuthState.

func SystemFileListParams added in v1.7.0

func SystemFileListParams(param *CommonSystemParams) (fileType string, limit, offset int)

SystemFileListParams reads list filters from CommonSystemParams.Ext.

func TenantGoogleOAuthCodeExchangeReady deprecated added in v1.7.0

func TenantGoogleOAuthCodeExchangeReady(p *Project) bool

Deprecated: use GoogleOAuthCodeExchangeReady.

func UseFreeCloudStorageEffective added in v1.7.0

func UseFreeCloudStorageEffective(p *Project) bool

UseFreeCloudStorageEffective reports whether Apito platform storage should be used.

func UserToPublicMap added in v1.7.0

func UserToPublicMap(u *User) map[string]interface{}

UserToPublicMap returns a GraphQL-safe map (no secret).

func ValidateFileType added in v1.7.0

func ValidateFileType(s string) error

ValidateFileType returns an error when s is not a supported file_type value.

func ValidateGoogleOAuthRedirectURIForPersist added in v1.7.0

func ValidateGoogleOAuthRedirectURIForPersist(s string) error

ValidateGoogleOAuthRedirectURIForPersist returns an error if the URI is unset or malformed for storage.

func ValidateRegistrationDefaultRole added in v1.7.0

func ValidateRegistrationDefaultRole(project *Project, role string) error

ValidateRegistrationDefaultRole ensures a non-empty role exists on the project and is not admin.

func VerifyGoogleOAuthState added in v1.7.0

func VerifyGoogleOAuthState(clientSecret, projectID string, redirectURI string, state string) error

VerifyGoogleOAuthState checks timing, project binding, redirect binding, and HMAC.

func VerifyTenantGoogleOAuthState deprecated added in v1.7.0

func VerifyTenantGoogleOAuthState(clientSecret, projectID string, redirectURI string, state string) error

Deprecated: use VerifyGoogleOAuthState.

Types

type APIPermission

type APIPermission struct {
	Read   string `json:"read,omitempty" firestore:"read,omitempty" bson:"read,omitempty"`
	Create string `json:"create,omitempty" firestore:"create,omitempty" bson:"create,omitempty"`
	Update string `json:"update,omitempty" firestore:"update,omitempty" bson:"update,omitempty"`
	Delete string `json:"delete,omitempty" firestore:"delete,omitempty" bson:"delete,omitempty"`
}

type AdminResetPasswordRequest added in v1.5.2

type AdminResetPasswordRequest struct {
	Email       string `json:"email"`
	NewPassword string `json:"new_password"`
	AdminSecret string `json:"admin_secret"`
}

AdminResetPasswordRequest is the body for POST /admin/reset-password (protected by APITO_ADMIN_RESET_SECRET).

type ApiTracking

type ApiTracking struct {
	Increment uint32
	Bandwidth float64
}

type ApitoFunction

type ApitoFunction struct {
	ProjectID          string                            `bun:"type:uuid,pk" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	ID                 string                            `json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	Name               string                            `json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Description        string                            `json:"description,omitempty" firestore:"description,omitempty" bson:"description,omitempty"`
	GraphQLSchemaType  string                            `json:"graphql_schema_type,omitempty" firestore:"graphql_schema_type,omitempty" bson:"graphql_schema_type,omitempty"` // query or mutation
	EnvVars            []*protobuff.EnvVariable          `json:"env_vars,omitempty" firestore:"env_vars,omitempty" bson:"env_vars,omitempty"`
	FunctionPath       string                            `json:"function_path,omitempty" firestore:"function_path,omitempty" bson:"function_path,omitempty"`
	Request            *ApitoFunctionRequestResponseType `json:"request,omitempty" firestore:"request,omitempty" bson:"request,omitempty"`
	Response           *ApitoFunctionRequestResponseType `json:"response,omitempty" firestore:"response,omitempty" bson:"response,omitempty"`
	FunctionProviderID string                            `json:"function_provider_id,omitempty" firestore:"function_provider_id,omitempty" bson:"function_provider_id,omitempty"`
	//FunctionConnected        bool                              `json:"function_connected,omitempty" firestore:"function_connected,omitempty"`
	ProviderExportedVariable string                      `` /* 136-byte string literal not displayed */
	FunctionExportedVariable string                      `` /* 136-byte string literal not displayed */
	RuntimeConfig            *ApitoFunctionRuntimeConfig `json:"runtime_config,omitempty" firestore:"runtime_config,omitempty" bson:"runtime_config,omitempty"`

	UpdatedAt string `json:"updated_at,omitempty" firestore:"updated_at,omitempty" bson:"updated_at,omitempty"`
	CreatedAt string `json:"created_at,omitempty" firestore:"created_at,omitempty" bson:"created_at,omitempty"` // @got

	Language  string `json:"language,omitempty" firestore:"language,omitempty" bson:"language,omitempty"`       // golang, js, python supported
	BinaryURL string `json:"binary_url,omitempty" firestore:"binary_url,omitempty" bson:"binary_url,omitempty"` // s3 upload path

	RestAPISecretURLKey string `` // used to access this function directly via url
	/* 127-byte string literal not displayed */
}

type ApitoFunctionRequestResponseType

type ApitoFunctionRequestResponseType struct {
	Model           string      `json:"model,omitempty" firestore:"model,omitempty" bson:"model,omitempty"`
	Params          interface{} `json:"params,omitempty" firestore:"params,omitempty" bson:"params,omitempty"`
	IsArray         bool        `json:"is_array,omitempty" firestore:"is_array,omitempty" bson:"is_array,omitempty"`
	OptionalPayload bool        `json:"optional_payload,omitempty" firestore:"optional_payload,omitempty" bson:"optional_payload,omitempty"`
}

type ApitoFunctionRuntimeConfig

type ApitoFunctionRuntimeConfig struct {
	Runtime string `json:"runtime,omitempty" firestore:"runtime,omitempty" bson:"runtime,omitempty"`
	Memory  int64  `json:"memory,omitempty" firestore:"memory,omitempty" bson:"memory,omitempty"`
	Handler string `json:"handler,omitempty" firestore:"handler,omitempty" bson:"handler,omitempty"`
	TimeOut int64  `json:"time_out,omitempty" firestore:"time_out,omitempty" bson:"time_out,omitempty"`
}

type ApplicationCache

type ApplicationCache struct {
	Ctx                     context.Context         `json:"ctx,omitempty"`
	Project                 *Project                `json:"project,omitempty"`
	Param                   *CommonSystemParams     `json:"param,omitempty"`
	RawSchemas              *RawSchema              `json:"raw_schema,omitempty"`
	Dataloaders             map[string]*dlv6.Loader `json:"dataloaders,omitempty"`
	PluginSchemasRegistered map[string]bool         `json:"-"`

	IncomingRequest []*IncomingRequest      `json:"incoming_request"`
	GraphqlRequest  *GraphQLIncomingRequest `json:"graphql_request,omitempty"`
}

type AuditLogs

type AuditLogs struct {
	XKey      string `json:"_key,omitempty" firestore:"_key,omitempty" bson:"_key,omitempty"`
	ID        string `bun:"type:uuid,pk" json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	UserID    string `bun:"user_id,type:uuid,nullzero" json:"user_id,omitempty" firestore:"user_id,omitempty" bson:"user_id,omitempty"`
	ProjectID string `bun:"project_id,type:uuid,nullzero" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`

	RequestPayload  string `json:"request_payload,omitempty" firestore:"request_payload,omitempty" bson:"request_payload,omitempty"`
	RequestPath     string `json:"request_path,omitempty" firestore:"request_path,omitempty" bson:"request_path,omitempty"`
	ResponseCode    int    `json:"response_code,omitempty" firestore:"response_code,omitempty" bson:"response_code,omitempty"`
	ResponsePayload string `json:"response_payload,omitempty" firestore:"response_payload,omitempty" bson:"response_payload,omitempty"`

	Activity         string `json:"activity,omitempty" firestore:"activity,omitempty" bson:"activity,omitempty"`
	InternalFunction string `json:"internal_function,omitempty" firestore:"internal_function,omitempty" bson:"internal_function,omitempty"`

	GraphqlOperationName string `json:"graphql_operation_name,omitempty" firestore:"graphql_operation_name,omitempty" bson:"graphql_operation_name,omitempty"`
	GraphqlPayload       string `json:"graphql_payload,omitempty" firestore:"graphql_payload,omitempty" bson:"graphql_payload,omitempty"`
	GraphqlVariable      string `json:"graphql_variable,omitempty" firestore:"graphql_variable,omitempty" bson:"graphql_variable,omitempty"`

	InternalError string `json:"internal_error,omitempty" firestore:"internal_error,omitempty" bson:"internal_error,omitempty"`
	CreatedAt     string `json:"created_at,omitempty" firestore:"created_at,omitempty" bson:"created_at,omitempty"`
}

type AuthenticationSettings added in v1.7.0

type AuthenticationSettings struct {
	EnableGeneralAuth           *bool  `json:"enable_general_auth,omitempty" firestore:"enable_general_auth,omitempty" bson:"enable_general_auth,omitempty"`
	EnableGoogleAuth            *bool  `json:"enable_google_auth,omitempty" firestore:"enable_google_auth,omitempty" bson:"enable_google_auth,omitempty"`
	GeneralAuthenticationMethod string `` /* 145-byte string literal not displayed */
	GoogleClientID              string `json:"google_client_id,omitempty" firestore:"google_client_id,omitempty" bson:"google_client_id,omitempty"`
	GoogleClientSecret          string `json:"google_client_secret,omitempty" firestore:"google_client_secret,omitempty" bson:"google_client_secret,omitempty"`
	GoogleOAuthRedirectURI      string `` /* 133-byte string literal not displayed */
	DefaultRegistrationRole     string `` /* 133-byte string literal not displayed */
}

AuthenticationSettings holds per-project sign-in configuration (all project types).

func ApplyUpdateProjectAuthenticationInput added in v1.7.0

func ApplyUpdateProjectAuthenticationInput(project *Project, input map[string]interface{}) (*AuthenticationSettings, error)

ApplyUpdateProjectAuthenticationInput merges GraphQL input into AuthenticationSettings.

func EnsureAuthenticationSettings added in v1.7.0

func EnsureAuthenticationSettings(p *Project) *AuthenticationSettings

EnsureAuthenticationSettings returns a non-nil AuthenticationSettings pointer on Project.

type BroadcastEvent added in v1.7.0

type BroadcastEvent struct {
	Channel   string      `json:"channel"`
	ProjectID string      `json:"project_id"`
	Event     string      `json:"event,omitempty"`
	Payload   interface{} `json:"payload,omitempty"`
	At        string      `json:"at,omitempty"`
}

BroadcastEvent is the payload for the generic broadcast/publish channel layer (chat, presence-lite, custom app messages) — Supabase Broadcast equivalent.

type CSVTemplateGenerator

type CSVTemplateGenerator struct {
	ModelName string `json:"model_name"`
}

type CommonSystemParams

type CommonSystemParams struct {
	Role          *Role  `json:"role,omitempty"`
	Plan          string `json:"plan,omitempty"`
	UserID        string `json:"user_id,omitempty"`
	RelationModel string `json:"relation_model,omitempty"`
	Email         string `json:"email,omitempty"`
	ProjectID     string `json:"project_id,omitempty"`

	ResolveParams *graphql.ResolveParams `json:"resolve_params,omitempty"`

	SystemCollectionName string `json:"system_collection_name,omitempty"`

	DocumentID  string   `json:"document_id,omitempty"`
	DocumentIDs []string `json:"document_ids,omitempty"`

	Document    *types.DefaultDocumentStructure `json:"document,omitempty"`
	Model       *ModelType                      `json:"model_type,omitempty"`
	ConDisParam []*ConnectDisconnectParam       `json:"con_dis_param,omitempty"`
	FieldInfo   *FieldInfo                      `json:"field_info,omitempty"`

	KnownAs        string `json:"known_as,omitempty"`
	Revision       bool   `json:"revision,omitempty"`
	SinglePageData bool   `json:"single_page_data,omitempty"`

	DocPublishStatus string `json:"doc_publish_status,omitempty"`

	IsSystemRequest                 bool `json:"is_system_request,omitempty"`
	IsEntireCollectionSearchRequest bool `json:"is_entire_collection_search_request,omitempty"`
	IsDataloaderRequest             bool `json:"is_dataloader_request,omitempty"`
	IsIntersectionResult            bool `json:"is_intersection_result,omitempty"`

	// these three used in intersection of two collections
	SkipSort          bool `json:"skip_sort,omitempty"`
	SkipPagination    bool `json:"skip_pagination,omitempty"`
	SkipWhereFilter   bool `json:"skip_filter,omitempty"`         // used in intersection of two collections, where filter is not needed
	SkipDefaultFilter bool `json:"skip_default_filter,omitempty"` // if you want to skip the default filter

	ReturnOnlyID     bool   `json:"return_only_id,omitempty"`
	OnlyReturnCount  bool   `json:"only_return_count,omitempty"`
	IsAggregateQuery bool   `json:"is_aggregate_query,omitempty"`
	ReturnOverwrite  string `json:"return_overwrite,omitempty"`

	QuerySelectionSets *ast.SelectionSet `json:"query_selection_sets,omitempty"`

	UnmarshalStructure interface{} `json:"unmarshal_structure"`

	// Ext holds opaque extension data populated by the pro layer (e.g. scoping metadata).
	Ext map[string]interface{} `json:"ext,omitempty"`

	// RuntimeConfig is the engine Config pointer for optional hooks (QueryFilterHook, DocumentPreInsertHook)
	// used by drivers and AQL builders. Set on each request from GraphQLServer (see NewParam / GetApplicationCache).
	RuntimeConfig *Config `json:"-"`

	// ProjectSchemaModels is the full project model list (from cache) for SQL drivers that need to reconcile
	// has_many pivot tables against schema (e.g. connection filters). Not serialized.
	ProjectSchemaModels []*ModelType `json:"-"`
}

type Config

type Config struct {
	Environment string `env:"ENVIRONMENT" env-default:"local"`

	BrankaKey string `env:"BRANKA_KEY" env-default:""`

	CORSOrigin   string `env:"CORS_ORIGIN" env-default:"http://localhost:4000"`
	CookieDomain string `env:"COOKIE_DOMAIN" env-default:"localhost"`

	UptraceDNS string `env:"UPTRACE_DNS" env-default:""`

	PluginPath string `env:"PLUGIN_PATH" env-default:"plugins"`

	CacheEngine     string `env:"CACHE_DB" env-default:"memory"`
	CacheDBHost     string `env:"CACHE_DB_HOST" env-default:""`
	CacheDBPort     string `env:"CACHE_DB_PORT" env-default:""`
	CacheDBUser     string `env:"CACHE_DB_USER" env-default:""`
	CacheDBPassword string `env:"CACHE_DB_PASSWORD" env-default:""`
	CacheDBName     string `env:"CACHE_DB_NAME" env-default:"apito_cache.db"`

	CacheTTL string `env:"CACHE_TTL" env-default:"600"`

	// Server Information
	ServePort string `env:"SERVE_PORT" env-default:"5050"` // Server Listening Port

	DefaultDatabaseDir string `env:"DEFAULT_DATABASE_DIR" env-default:"~/.apito/db"`
	// SQLiteDataDir is the persistent root for local SQLite replicas (sqlite/ subtree).
	// Default ./db is relative to the engine working directory; production mounts a volume at this path.
	SQLiteDataDir string `env:"SQLITE_DATA_DIR" env-default:"./db"`
	// LibsqlSyncDataDir is deprecated; use SQLITE_DATA_DIR. Kept for one release of backward compatibility.
	LibsqlSyncDataDir string `env:"LIBSQL_SYNC_DATA_DIR" env-default:""`

	// System Database Information
	SystemDatabaseEngine string `env:"SYSTEM_DB_ENGINE" env-default:"coredb"`
	SystemDBUser         string `env:"SYSTEM_DB_USER" env-default:""`
	SystemDBPassword     string `env:"SYSTEM_DB_PASSWORD" env-default:""`
	SystemDBHost         string `env:"SYSTEM_DB_HOST" env-default:""`
	SystemDBPort         string `env:"SYSTEM_DB_PORT" env-default:""`
	SystemDBName         string `env:"SYSTEM_DB_NAME" env-default:"apito_system.db"`

	// GeneralPostgresIsolation: "database" (default, CREATE DATABASE per project) or "schema" (CREATE SCHEMA + search_path on shared database name stored on the project driver).
	GeneralPostgresIsolation string `env:"GENERAL_POSTGRES_ISOLATION" env-default:"database"`
	// GeneralSQLiteFilePerProject uses utility.SQLiteProjectFileName(project_id) under DefaultDatabaseDir for new SQLite general projects using default template credentials.
	GeneralSQLiteFilePerProject bool `env:"GENERAL_SQLITE_FILE_PER_PROJECT" env-default:"false"`
	// GeneralMySQLIsolation is only "database" supported: MySQL/MariaDB use CREATE DATABASE per project (no PG-style shared-schema mode in this engine).
	GeneralMySQLIsolation string `env:"GENERAL_MYSQL_ISOLATION" env-default:"database"`

	KVStorageEngine         string `env:"KV_ENGINE" env-default:"coredb"`
	KVStorageEngineHost     string `env:"KV_HOST" env-default:""`
	KVStorageEnginePort     string `env:"KV_PORT" env-default:""`
	KVStorageEngineUser     string `env:"KV_USER" env-default:""`
	KVStorageEnginePassword string `env:"KV_PASSWORD" env-default:""`
	KVStorageEngineDatabase string `env:"KV_DATABASE" env-default:"apito_kv.db"`

	// Realtime bus: unified NATS JetStream fan-out (subscriptions + console notify).
	// "nats" = embedded or external NATS with JetStream (production default).
	// "memory" = in-process fan-out (single node, tests/local).
	RealtimeEngine string `env:"REALTIME_ENGINE" env-default:"nats"`
	// RealtimeNatsURL, when set, connects to an external/clustered NATS instead of
	// embedding an in-process server (e.g. "nats://nats:4222").
	RealtimeNatsURL string `env:"REALTIME_NATS_URL" env-default:""`
	// RealtimeNatsPort exposes the embedded NATS server on a TCP port for
	// clustering/leaf-node connections. -1 (default) keeps it in-process only.
	RealtimeNatsPort int `env:"REALTIME_NATS_PORT" env-default:"-1"`
	// RealtimeNatsJetStream enables JetStream durable streams for replay and
	// cross-instance fan-out (default on for production NATS backend).
	RealtimeNatsJetStream bool `env:"REALTIME_NATS_JETSTREAM" env-default:"true"`
	// RealtimeNatsStoreDir is the JetStream file store directory for embedded NATS.
	RealtimeNatsStoreDir string `env:"REALTIME_NATS_STORE_DIR" env-default:""`

	// Token Encryption Credential
	PublicKeyPath  string `env:"PUBLIC_KEY_PATH" env-default:"keys/public.key"`
	PrivateKeyPath string `env:"PRIVATE_KEY_PATH" env-default:"keys/private.key"`

	// Sentry Credential
	SentryKey     string `env:"SENTRY_KEY" env-default:""`
	SentryProject string `env:"SENTRY_PROJECT" env-default:""`
	SentryAPI     string `env:"SENTRY_API" env-default:""`

	AuthServiceProvider string `env:"AUTH_SERVICE_PROVIDER" env-default:"local"`

	GoogleOauthClientID     string `env:"GOOGLE_OAUTH_CLIENT_ID" env-default:""`
	GoogleOauthClientSecret string `env:"GOOGLE_OAUTH_CLIENT_SECRET" env-default:""`
	GoogleOauthRedirectURL  string `env:"GOOGLE_OAUTH_REDIRECT_URL" env-default:""`

	GithubOauthClientID     string `env:"GITHUB_OAUTH_CLIENT_ID" env-default:""`
	GithubOauthClientSecret string `env:"GITHUB_OAUTH_CLIENT_SECRET" env-default:""`
	GithubOauthRedirectURL  string `env:"GITHUB_OAUTH_REDIRECT_URL" env-default:""`

	TokenTTL string `env:"TOKEN_TTL" env-default:"60"`

	// Platform free-cloud object storage (R2/S3-compatible). Used when project storage_settings.use_free_cloud_storage=true.
	FreeCloudDefaultS3AccessKey      string  `env:"FREE_CLOUD_DEFAULT_S3_ACCESS_KEY" env-default:""`
	FreeCloudDefaultS3SecretKey      string  `env:"FREE_CLOUD_DEFAULT_S3_SECRET_KEY" env-default:""`
	FreeCloudDefaultS3Endpoint       string  `env:"FREE_CLOUD_DEFAULT_S3_ENDPOINT" env-default:""`
	FreeCloudDefaultS3BucketName     string  `env:"FREE_CLOUD_DEFAULT_S3_BUCKET_NAME" env-default:""`
	FreeCloudDefaultS3PublicBaseURL  string  `env:"FREE_CLOUD_DEFAULT_S3_PUBLIC_BASE_URL" env-default:""`
	FreeCloudDefaultS3ForcePathStyle bool    `env:"FREE_CLOUD_DEFAULT_S3_FORCE_PATH_STYLE" env-default:"true"`
	FreeCloudStorageLimitGB          float64 `env:"FREE_CLOUD_STORAGE_LIMIT_GB" env-default:"0.5"`

	// Resend API key for transactional email (team invites, etc.).
	ResendAPIKey string `env:"RESEND_API_KEY" env-default:""`

	// Admin password reset: secret required to call POST /admin/reset-password (e.g. set in ~/.apito/bin/.env)
	AdminResetSecret string `env:"APITO_ADMIN_RESET_SECRET" env-default:""`

	// Optional driver factory for dependency injection. If nil, built-in defaults are used.
	DriverFactory interface{} `env:"-"` // Will be type-asserted to DatabaseDriverFactory

	// DatabaseCheckWrapper optionally wraps the system database check HTTP handler.
	// Type: func(auth any) echo.HandlerFunc (router type-asserts; avoids importing echo here).
	DatabaseCheckWrapper interface{} `env:"-"`

	// ConnectionRoutingHook returns a scope key for sub-project connection isolation.
	// If it returns (key, true) with a non-empty key, the executor uses a scoped connection.
	ConnectionRoutingHook func(ctx context.Context, projectID string) (scopeKey string, ok bool) `env:"-"`

	// QueryFilterHook returns additional filters to apply before every query (e.g. row-level isolation).
	QueryFilterHook func(ctx context.Context, params *CommonSystemParams) []*QueryFilter `env:"-"`

	// DocumentPreInsertHook is called before a document is inserted; can mutate the document or return an error.
	DocumentPreInsertHook func(ctx context.Context, params *CommonSystemParams, doc map[string]interface{}) error `env:"-"`

	// DocumentPreInsertDocHook is called after the driver builds *types.DefaultDocumentStructure and before persist.
	// Pro may mutate the struct; open-core must not interpret field semantics.
	DocumentPreInsertDocHook func(ctx context.Context, params *CommonSystemParams, doc *types.DefaultDocumentStructure) error `env:"-"`

	// PostTokenValidateHook runs after token validation succeeds (bearer or cookie path).
	// Pro may read scopes/headers/cookies and stamp echo context; open-core stays policy-free.
	PostTokenValidateHook func(ctx echo.Context, claims *TokenClaims) `env:"-"`

	// DDLPostCreateHook is called after a model table/collection is created; can add columns or indexes.
	DDLPostCreateHook func(ctx context.Context, project *Project, model *ModelType, dbHandle interface{}) error `env:"-"`

	// PostDocumentInsertHook is called after a document is successfully inserted.
	PostDocumentInsertHook func(ctx context.Context, params *CommonSystemParams, docID string) error `env:"-"`

	// SchemaIterateHook is called when a schema change needs to propagate to sub-project databases.
	SchemaIterateHook func(ctx context.Context, project *Project, fn func(ctx context.Context, driver interface{}) error) error `env:"-"`

	// SkipSchemaBaseDDLHook lets extensions skip base project physical DDL for tenant-only storage layouts.
	SkipSchemaBaseDDLHook func(ctx context.Context, project *Project) bool `env:"-"`

	// PostSchemaChangeHook runs after a successful schema orchestration commit (pro: Turso Sync flush).
	PostSchemaChangeHook func(ctx context.Context, baseDriver interface{}, project *Project) `env:"-"`

	// SchemaMutationHook runs before schema DDL orchestration; handled=true skips runSchemaChange.
	SchemaMutationHook SchemaMutationHook `env:"-"`

	// SchemaVersioningEnabled stages schema mutations for review (pro registers the hook).
	SchemaVersioningEnabled bool `env:"PRO_SCHEMA_VERSIONING_ENABLED" env-default:"true"`
	// SchemaVersioningBypass applies schema mutations immediately through orchestration.
	SchemaVersioningBypass bool `env:"PRO_SCHEMA_VERSIONING_BYPASS" env-default:"false"`

	// TokenClaimsHook allows the pro layer to inject additional claims into JWT/token payloads.
	TokenClaimsHook func(project *Project, claims map[string]interface{}) `env:"-"`

	// ProjectAPITokenClaimsHook allows optional claim enrichment before project API key issuance.
	// Open-core stays policy-free and simply invokes this hook when set.
	ProjectAPITokenClaimsHook func(ctx echo.Context, project *Project, claims *TokenClaims) `env:"-"`

	// ProjectUserGraphQLHooks allows the host to override project end-user GraphQL resolvers before the open-core default.
	// Type: *resolver.ProjectUserGraphQLHooks (set by pro at boot).
	ProjectUserGraphQLHooks interface{} `env:"-"`

	// ProjectUserItemFieldsHook lets the host extend the project end-user GraphQL object.
	// Type: resolver.ProjectUserItemFieldsHook (set by pro at boot). Open-core does not name host fields.
	ProjectUserItemFieldsHook interface{} `env:"-"`

	// ProjectUserGraphQLOperationFieldHook lets the host extend Args (or other field config) on named
	// project end-user operations (createUser, searchUsers, …). Type: resolver.ProjectUserGraphQLOperationFieldHook.
	ProjectUserGraphQLOperationFieldHook interface{} `env:"-"`

	// ProjectUserAPITokenHook lets the host adjust API token type/scopes for app end-user login.
	// Open-core default: tokenType "user", scopes ["project:<projectID>"].
	ProjectUserAPITokenHook func(cache *ApplicationCache, userID, role string) (tokenType string, scopes []string) `env:"-"`

	// EnsureScopedDatabaseHook runs before default scoped DB creation (e.g. Postgres/MySQL per-scope isolation).
	EnsureScopedDatabaseHook func(ctx context.Context, projectID string, base, derived *DriverCredentials) error `env:"-"`

	// LoadProjectCacheHook allows the pro layer to modify a project after loading from the system DB.
	LoadProjectCacheHook func(ctx context.Context, project *Project) `env:"-"`

	// RealtimeTopicHook lets the host rewrite a realtime subscription topic before
	// publish/subscribe (e.g. inject a tenant scope prefix). Open-core builds a
	// neutral base topic and applies this hook identically on both the emit and
	// subscribe sides so they match. Open-core does not encode tenant semantics.
	RealtimeTopicHook func(ctx context.Context, baseTopic string) string `env:"-"`

	// NamingV2ArangoPerModelCollections is used when applying Arango naming V2 physical migration:
	// true means one document collection per model layout; false uses a single p_{projectId} bucket.
	NamingV2ArangoPerModelCollections func(ctx context.Context, project *Project) bool `env:"-"`

	// NamingV2RelationTenantModel returns the tenant root model name for relation edges (e.g. "restaurant").
	// When set, Arango naming migration moves legacy root-level tenant_id into ext and sets ext.tenant_model.
	NamingV2RelationTenantModel func(ctx context.Context, project *Project) string `env:"-"`

	// BuildSystemParamHook allows the pro layer to enrich CommonSystemParams after the base build.
	BuildSystemParamHook func(ctx context.Context, project *Project, param *CommonSystemParams) `env:"-"`

	// InitProjectBaseHook is for extending the project base initialization.
	// driver is the concrete ProjectDBInterface implementation. Default when nil: type-assert and call InitProjectBase.
	InitProjectBaseHook func(ctx context.Context, driver interface{}, param *CommonSystemParams) error `env:"-"`

	// ProjectTypeForClaims maps open-core Project to a JWT "project_type" value (e.g. int32). OSS leaves nil and JWT uses "general".
	ProjectTypeForClaims func(*Project) interface{} `env:"-"`

	// PostApplicationCacheHook runs after GetApplicationCache assembles cache (param, ctx, plugins).
	// Pro may enrich cache.Ctx / cache.Param here so resolvers using the embedded *GraphQLServer see the same context
	// as the outer server. Type: func(echo.Context, *ApplicationCache).
	PostApplicationCacheHook interface{} `env:"-"`

	// SchemaObjectsExtensionHook runs inside BuildServerQueriesAndMutations right after
	// InitPrivateObjects(). The pro layer uses it to AddFieldConfig on core schema objects
	// (e.g. ModelType, ProjectModel) before the schema is sent through channels.
	SchemaObjectsExtensionHook func(objs interface{}) `env:"-"`

	// MaxModelsPerProject caps models processed by publicSchemaBuilder (0 = no limit).
	MaxModelsPerProject int `env:"MAX_MODELS_PER_PROJECT" env-default:"0"`

	// EnableCompiledSchemaCache caches pre-connection GraphQL shape (fingerprint: project + role + schema).
	EnableCompiledSchemaCache bool `env:"ENABLE_COMPILED_SCHEMA_CACHE" env-default:"false"`

	// EnableClosureFreeResolvers reserved for future resolver refactors (relation fields).
	EnableClosureFreeResolvers bool `env:"ENABLE_CLOSURE_FREE_RESOLVERS" env-default:"false"`

	// RoleAgnosticSchemaCache builds one superset schema per project (pre-connection cache key omits role); resolvers enforce real role.
	RoleAgnosticSchemaCache bool `env:"ROLE_AGNOSTIC_SCHEMA_CACHE" env-default:"false"`

	// AdjustPublicSchemaForRequestHook runs after collectFilteredModelsForPublicSchema and may
	// mutate permissions and filteredModels (e.g. tenant-scoped public API shape). When set,
	// the compiled public schema cache fingerprint includes the effective API permission map.
	AdjustPublicSchemaForRequestHook func(ctx context.Context, cache *ApplicationCache, project *Project, permissions map[string]*APIPermission, filteredModels []*PublicSchemaModelFilter) error `env:"-"`

	// SchemaBuildTelemetry emits OTel spans around publicSchemaBuilder when true.
	SchemaBuildTelemetry bool `env:"SCHEMA_BUILD_TELEMETRY" env-default:"true"`

	// SchemaBuildMetrics registers OTel counter schema_build_total and histogram schema_build_duration_seconds.
	SchemaBuildMetrics bool `env:"SCHEMA_BUILD_METRICS" env-default:"false"`

	// MetricsEnabled gates apito_* OpenTelemetry instruments (HTTP, GraphQL, pool, DB decorator, cache, KV, queue, session).
	// When false, telemetry helpers no-op. When true, instruments record if a global MeterProvider is registered (OSS or extended builds).
	MetricsEnabled bool `env:"METRICS_ENABLED" env-default:"true"`

	// SystemMetricsToken is an optional Bearer secret compared by the router when a build exposes a protected metrics scrape path.
	// Open-core does not mount that route; deployments that add one should set this in production.
	SystemMetricsToken string `env:"SYSTEM_METRICS_TOKEN" env-default:""`

	// OTELExporterOTLPEndpoint optional OTLP HTTP endpoint for traces. Empty disables OTLP trace export for builds that wire a TracerProvider.
	OTELExporterOTLPEndpoint string `env:"OTEL_EXPORTER_OTLP_ENDPOINT" env-default:""`
}

func (*Config) StorageEnginesSummary added in v1.6.3

func (c *Config) StorageEnginesSummary() string

StorageEnginesSummary returns one line listing configured storage engines (no hosts, secrets, or DSNs).

type ConnectDisconnectParam

type ConnectDisconnectParam struct {
	DocCollectionName string
	DocRelationName   string

	ActionIDs       []string
	CurrentActionID string // used in single delete relation
	ActionIDType    string // direct, indirect

	ConnectionType      string
	ForwardConnectionID string

	ForwardConnectionType      *ConnectionType
	ForwardConnectionModelType *ModelType

	BackwardConnectionType      *ConnectionType
	BackwardConnectionModelType *ModelType

	KnownAs string

	InjectableHasOneConnects []*InjectableHasOneConnection
}

type ConnectionType

type ConnectionType struct {
	Model    string `json:"model,omitempty" firestore:"model,omitempty" bson:"model,omitempty"`
	Relation string `json:"relation,omitempty" firestore:"relation,omitempty" bson:"relation,omitempty"`
	Type     string `json:"type,omitempty" firestore:"type,omitempty" bson:"type,omitempty"`
	KnownAs  string `json:"known_as,omitempty" firestore:"known_as,omitempty" bson:"known_as,omitempty"`
}

type DBPaginationFilter

type DBPaginationFilter struct {
	Total int `json:"total"`
	Page  int `json:"page"`
	Limit int `json:"limit"`
}

type DataLoaders

type DataLoaders struct {
	MultiLoader *dataloader.Loader[string, interface{}]
}

DataLoaders Dataloaders

type DocumentRevisionHistory

type DocumentRevisionHistory struct {
	ID         string `json:"id"`
	RevisionAt string `json:"revision_at"`
	Status     string `json:"status"`
}

type DriverCredentials

type DriverCredentials struct {
	// for sql migration purposes
	ProjectID string `bun:"type:uuid,pk" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	// normal sql & nosql database
	Engine   string `json:"engine,omitempty" bson:"engine,omitempty"`
	Host     string `json:"host,omitempty" bson:"host,omitempty"`
	Port     string `json:"port,omitempty" bson:"port,omitempty"`
	User     string `json:"user,omitempty" bson:"user,omitempty"`
	Password string `json:"password,omitempty" bson:"password,omitempty"`
	Database string `json:"database,omitempty" bson:"database,omitempty"`
	// for embedded database
	DatabaseDir string `json:"database_dir,omitempty" bson:"database_dir,omitempty"`
	// for sqlite and other file based databases
	File string `json:"file,omitempty" bson:"file,omitempty"`
	// Schema is the PostgreSQL schema name for per-project isolation when GENERAL_POSTGRES_ISOLATION=schema
	// (shared database from Database field, separate schema per project). Ignored for non-Postgres engines.
	Schema string `json:"schema,omitempty" bson:"schema,omitempty"`
	// SSLMode for PostgreSQL when the server requires TLS. Empty defaults to disable in DSN builder.
	SSLMode string `json:"ssl_mode,omitempty" bson:"ssl_mode,omitempty"`
}

type EdgeRelation

type EdgeRelation struct {
	XFrom string `json:"_from,omitempty" bson:"_from,omitempty"`
	XTo   string `json:"_to,omitempty" bson:"_to,omitempty"`
	Key   string `json:"_key,omitempty" bson:"_id,omitempty"`

	Relation string `json:"relation,omitempty" bson:"relation,omitempty"`
	From     string `json:"from,omitempty" bson:"from,omitempty"`
	FromID   string `json:"from_id,omitempty" bson:"from_id,omitempty"`
	To       string `json:"to,omitempty" bson:"to,omitempty"`
	ToID     string `json:"to_id,omitempty" bson:"to_id,omitempty"`

	Role        string                 `json:"role,omitempty" bson:"role,omitempty"`
	KnownAs     string                 `json:"known_as,omitempty" bson:"known_as,omitempty"`
	Permissions []string               `json:"permissions,omitempty" bson:"permissions,omitempty"`
	CreatedAt   string                 `json:"created_at,omitempty" bson:"created_at,omitempty"`
	Ext         map[string]interface{} `json:"ext,omitempty" bson:"ext,omitempty"`
}

type EmailSendRequest

type EmailSendRequest struct {
	AppURL       string   `json:"app_url"`
	Sender       string   `json:"sender"`
	ProjectName  string   `json:"project_name"`
	TempPassword string   `json:"temp_password"`
	Recipients   []string `json:"recipients"`
	Subject      string   `json:"subject"`
	HtmlBody     string   `json:"html_body"`
	TextBody     string   `json:"text_body"`
}

type FieldDetails

type FieldDetails struct {
	Identifier string
	Kind       reflect.Kind
	SubFields  []*FieldInfo
	Local      string

	FieldType  string
	Validation *Validation
	Value      interface{}
}

type FieldInfo

type FieldInfo struct {
	Identifier      string       `json:"identifier,omitempty" firestore:"identifier,omitempty" bson:"identifier,omitempty"`
	Description     string       `json:"description,omitempty" firestore:"description,omitempty" bson:"description,omitempty"`
	InputType       string       `json:"input_type,omitempty" firestore:"input_type,omitempty" bson:"input_type,omitempty"`
	FieldType       string       `json:"field_type,omitempty" firestore:"field_type,omitempty" bson:"field_type,omitempty"`
	FieldSubType    string       `json:"field_sub_type,omitempty" bson:"field_sub_type,omitempty"`
	SubFieldInfo    []*FieldInfo `json:"sub_field_info,omitempty" firestore:"modules,omitempty" bson:"sub_field_info,omitempty"`
	Validation      *Validation  `json:"validation,omitempty" firestore:"validation,omitempty" bson:"validation,omitempty"`
	Serial          uint32       `json:"serial,omitempty" firestore:"serial,omitempty" bson:"serial,omitempty"`
	Label           string       `json:"label,omitempty" firestore:"label,omitempty" bson:"label,omitempty"`
	SystemGenerated bool         `json:"system_generated,omitempty" firestore:"system_generated,omitempty" bson:"system_generated,omitempty"`
	//RepeatedGroupIdentifier string       `json:"repeated_group_identifier,omitempty" firestore:"repeated_group_identifier,omitempty" bson:"repeated_group_identifier,omitempty"`
	IsObjectField  bool   `json:"is_object_field,omitempty" firestore:"is_object_field,omitempty" bson:"is_object_field,omitempty"`
	ParentField    string `json:"parent_field,omitempty" firestore:"parent_field,omitempty" bson:"parent_field,omitempty"`
	EnableIndexing bool   `json:"enable_indexing,omitempty" firestore:"enable_indexing,omitempty" bson:"enable_indexing,omitempty"`
}

func DedupeFieldsByIdentifier added in v1.7.0

func DedupeFieldsByIdentifier(fields []*FieldInfo) []*FieldInfo

DedupeFieldsByIdentifier keeps one FieldInfo per identifier (last occurrence wins).

type FileDetails

type FileDetails struct {
	ID            string        `json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	XKey          string        `json:"_key,omitempty" firestore:"_key,omitempty" bson:"_key,omitempty"`
	Type          string        `json:"type,omitempty" firestore:"type,omitempty" bson:"type,omitempty"`
	FileExtension string        `json:"file_extension,omitempty" firestore:"file_extension,omitempty" bson:"file_extension,omitempty"`
	FileName      string        `json:"file_name,omitempty" firestore:"file_name,omitempty" bson:"file_name,omitempty"`
	ContentType   string        `json:"content_type,omitempty" firestore:"content_type,omitempty" bson:"content_type,omitempty"`
	Size          int64         `json:"size,omitempty" firestore:"size,omitempty" bson:"size,omitempty"`
	S3Key         string        `json:"s3_key,omitempty" firestore:"s3_key,omitempty" bson:"s3_key,omitempty"`
	URL           string        `json:"url,omitempty" firestore:"url,omitempty" bson:"url,omitempty"`
	CreatedAt     string        `json:"created_at,omitempty" firestore:"created_at,omitempty" bson:"created_at,omitempty"`
	UploadParam   *UploadParams `json:"upload_param,omitempty" firestore:"upload_param,omitempty" bson:"upload_param,omitempty"`
	Buffer        []byte        `json:"buffer,omitempty" firestore:"upload_param,omitempty" bson:"buffer,omitempty"`
}
type FileLink struct {
	Link      string `json:"link,omitempty" firestore:"link,omitempty" bson:"link,omitempty"`
	Title     string `json:"title,omitempty" firestore:"title,omitempty" bson:"title,omitempty"`
	CreatedAt string `json:"created_at,omitempty" firestore:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty" firestore:"updated_at,omitempty" bson:"updated_at,omitempty"`
}

FileLink represents a file link with metadata

type FilePickParameter

type FilePickParameter struct {
	NumberOfImages uint32      `json:"number_of_images,omitempty" firestore:"number_of_images,omitempty" bson:"number_of_images,omitempty"`
	S3Folder       string      `json:"s3_folder,omitempty" firestore:"s3_folder,omitempty" bson:"s3_folder,omitempty"`
	PickerTitle    string      `json:"picker_title,omitempty" firestore:"picker_title,omitempty" bson:"picker_title,omitempty"`
	Origin         *SystemUser `json:"origin,omitempty" firestore:"origin,omitempty" bson:"origin,omitempty"`
}

type Filter

type Filter struct {
	Page     uint32 `json:"page,omitempty" firestore:"page,omitempty" bson:"page,omitempty"`
	Offset   uint32 `json:"offset,omitempty" firestore:"offset,omitempty" bson:"offset,omitempty"`
	Limit    uint32 `json:"limit,omitempty" firestore:"limit,omitempty" bson:"limit,omitempty"`
	Order    string `json:"order,omitempty" firestore:"order,omitempty" bson:"order,omitempty"`
	Min      uint32 `json:"min,omitempty" firestore:"min,omitempty" bson:"min,omitempty"`
	Max      uint32 `json:"max,omitempty" firestore:"max,omitempty" bson:"max,omitempty"`
	Category string `json:"category,omitempty" firestore:"category,omitempty" bson:"category,omitempty"`
}

type FilterInformation

type FilterInformation struct {
	Condition string         `json:"condition"`
	Filters   []*QueryFilter `json:"filters"`
}

type FilteredModel

type FilteredModel struct {
	Name              string
	WhereFilter       []string
	IsConnectionQuery bool
	HasMetaQuery      bool
	KnownAs           string // used in known_as relation node it is equal tographql alias
	IsDataloaderModel bool   // used in dataloader model
}

func FilterUniqueStrings

func FilterUniqueStrings(models []*FilteredModel) []*FilteredModel

type FunctionCache

type FunctionCache struct {
	Functions         *plugin.Plugin
	FuncConfiguration *ApitoFunction
}

System apito function model ( old )

type GraphQLIncomingRequest

type GraphQLIncomingRequest struct {
	Query         string                 `json:"query" url:"query" schema:"query"`
	Variables     map[string]interface{} `json:"variables" url:"variables" schema:"variables"`
	OperationName string                 `json:"operation_name" url:"operation_name" schema:"operation_name"`
	QueryType     string                 `json:"query_type" url:"query_type" schema:"query_type"` // query, mutation, subscription
}

type HashiCorpPluginCache

type HashiCorpPluginCache struct {
	Client               *hcplugin.Client
	PluginConfigurations *protobuff.PluginDetails
	RPCClient            hcplugin.ClientProtocol
}

HashiCorpPluginCache for HashiCorp go-plugin system

type HttpResponse

type HttpResponse struct {
	Message string      `json:"message,omitempty"`
	Body    interface{} `json:"body,omitempty"`
	Code    uint32      `json:"code,omitempty"`
	Token   string      `json:"token,omitempty"`
	Error   string      `json:"error,omitempty"`
}

type ImageMetaInfo

type ImageMetaInfo struct {
	Identifier string `json:"identifier,omitempty" firestore:"identifier,omitempty" bson:"identifier,omitempty"`
	Name       string `json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Width      uint32 `json:"width,omitempty" firestore:"width,omitempty" bson:"width,omitempty"`
	Height     uint32 `json:"height,omitempty" firestore:"height,omitempty" bson:"height,omitempty"`
	Type       string `json:"type,omitempty" firestore:"type,omitempty" bson:"type,omitempty"`
}

type IncomingRequest

type IncomingRequest struct {
	OperationType     string
	FilteredModels    []*FilteredModel
	FilteredFunctions []*ApitoFunction
	IsPluginRequest   bool
}

type InitParams

type InitParams struct {
	ProjectID string             `json:"project_id" bson:"project_id,omitempty"`
	ProjectDB *DriverCredentials `json:"system_credentials" bson:"system_credentials,omitempty"`
	CacheDB   *DriverCredentials `json:"cache_db" bson:"cache_db,omitempty"`
	SharedDB  *DriverCredentials `json:"shared_db" bson:"shared_db,omitempty"`
	// ProDriverExtras is pro-binary-only metadata (e.g. *ProDriverCredentials) for project drivers that need secrets outside DriverCredentials. Not serialized.
	ProDriverExtras interface{} `json:"-" bson:"-"`
}

type InjectableHasOneConnection

type InjectableHasOneConnection struct {
	ModelName string
	IDs       []string
	Data      map[string]string
}

type JWTTokens

type JWTTokens struct {
	AccessToken  string                 `json:"access_token"`
	IDToken      string                 `json:"id_token"`
	RefreshToken string                 `json:"refresh_token"`
	Ext          map[string]interface{} `json:"ext,omitempty"`
}

type KeyValue

type KeyValue struct {
	Key   string `json:"key,omitempty" firestore:"key,omitempty" bson:"key,omitempty"`
	Value string `json:"value,omitempty" firestore:"value,omitempty" bson:"value,omitempty"`
}

type LoginRequest

type LoginRequest struct {
	Username string `json:"username,omitempty" firestore:"username,omitempty" bson:"username,omitempty"`
	Email    string `json:"email,omitempty" firestore:"email,omitempty" bson:"email,omitempty"`
	Secret   string `json:"secret,omitempty" firestore:"secret,omitempty" bson:"secret,omitempty"`
}

type MetaField

type MetaField struct {
	SourceID string `json:"source_id,omitempty" firestore:"source_id,omitempty" bson:"source_id,omitempty"`

	CreatedAt      string      `json:"created_at,omitempty" firestore:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt      string      `json:"updated_at,omitempty" firestore:"updated_at,omitempty" bson:"updated_at,omitempty"`
	CreatedBy      *SystemUser `json:"created_by,omitempty" firestore:"title,omitempty" bson:"created_by,omitempty"`
	LastModifiedBy *SystemUser `json:"last_modified_by,omitempty" firestore:"created_by,omitempty" bson:"last_modified_by,omitempty"`

	Status         string `json:"status,omitempty" firestore:"status,omitempty" bson:"status,omitempty"`
	RootRevisionID string `json:"root_revision_id,omitempty" firestore:"root_revision_id,omitempty" bson:"root_revision_id,omitempty"`
	Revision       bool   `json:"revision,omitempty" firestore:"revision,omitempty" bson:"revision,omitempty"`
	RevisionAt     string `json:"revision_at,omitempty" firestore:"revision_at,omitempty" bson:"revision_at,omitempty"`

	// used in filterAbsentStudent where multiple record is processed but we need to return only attendance id
	ResourceID string `json:"resource_id,omitempty" firestore:"resource_id,omitempty" bson:"resource_id,omitempty"`
}

type ModelChangeEvent added in v1.7.0

type ModelChangeEvent struct {
	Event          string                 `json:"event"`
	Model          string                 `json:"model"`
	ProjectID      string                 `json:"project_id"`
	ID             string                 `json:"id"`
	Node           interface{}            `json:"node,omitempty"`
	PreviousValues interface{}            `json:"previousValues,omitempty"`
	Meta           map[string]interface{} `json:"meta,omitempty"`
}

ModelChangeEvent is the payload pushed to <model>Changed subscribers when a document is created, updated or deleted. node/previousValues carry the full document as JSON (DB-engine agnostic), mirroring Supabase postgres_changes.

type ModelDocsResponse

type ModelDocsResponse struct {
	Docs  []*types.DefaultDocumentStructure `json:"docs"`
	Count int                               `json:"count"`
}

type ModelType

type ModelType struct {
	ProjectID       string            `bun:"type:uuid,pk" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	Name            string            `bun:"type:text,pk" json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Description     string            `json:"description,omitempty" bson:"description,omitempty"`
	Fields          []*FieldInfo      `json:"fields,omitempty" firestore:"fields,omitempty" bson:"fields,omitempty"`
	Connections     []*ConnectionType `json:"connections,omitempty" firestore:"connections,omitempty" bson:"connections,omitempty"`
	HookIds         []string          `json:"hook_ids,omitempty" firestore:"hook_ids,omitempty" bson:"hook_ids,omitempty"`
	Locals          []string          `json:"locals,omitempty" firestore:"locals,omitempty" bson:"locals,omitempty"`
	RepeatedGroups  []string          `json:"repeated_groups,omitempty" firestore:"locals,omitempty" bson:"repeated_groups,omitempty"`
	SystemGenerated bool              `json:"system_generated,omitempty" firestore:"system_generated,omitempty" bson:"system_generated,omitempty"`
	SinglePage      bool              `json:"single_page,omitempty" firestore:"system_generated,omitempty" bson:"single_page,omitempty"`
	SinglePageUUID  string            `json:"single_page_uuid,omitempty" firestore:"system_generated,omitempty" bson:"single_page_uuid,omitempty"`
	HasConnections  bool              `json:"has_connections,omitempty" firestore:"has_connections,omitempty" bson:"has_connections,omitempty"`
	EnableRevision  bool              `json:"enable_revision,omitempty" firestore:"enable_revision,omitempty" bson:"enable_revision,omitempty"`
	RevisionFilter  []*KeyValue       `json:"revision_filter,omitempty" firestore:"revision_filter,omitempty" bson:"revision_filter,omitempty"`

	// Ext holds opaque extension data populated by the extension layer (e.g. model classification metadata).
	Ext map[string]interface{} `json:"ext,omitempty" firestore:"ext,omitempty" bson:"ext,omitempty"`
}

type Organization

type Organization struct {
	XKey        string `json:"_key,omitempty" firestore:"_key,omitempty" bson:"_key,omitempty"`
	ID          string `bun:"type:uuid,pk" json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	Name        string `json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Description string `json:"description,omitempty" firestore:"description,omitempty" bson:"description,omitempty"`
	// Owner/creator FK for SystemUser.Organization has-many (join:id=user_id).
	UserID string        `bun:"user_id,type:uuid" json:"user_id,omitempty" firestore:"user_id,omitempty" bson:"user_id,omitempty"`
	Teams  []*Team       `bun:"m2m:organization_teams,join:Organization=Team" json:"teams,omitempty" firestore:"teams,omitempty" bson:"teams,omitempty"`
	Users  []*SystemUser `bun:"m2m:user_organizations,join:Organization=User" json:"users,omitempty" firestore:"users,omitempty" bson:"users,omitempty"`
}

type OrganizationTeam added in v1.6.1

type OrganizationTeam struct {
	OrganizationID string        `bun:"type:uuid,pk" json:"organization_id,omitempty" firestore:"organization_id,omitempty" bson:"organization_id,omitempty"`
	TeamID         string        `bun:"type:uuid,pk" json:"team_id,omitempty" firestore:"team_id,omitempty" bson:"team_id,omitempty"`
	AssignedBy     string        `` /* 128-byte string literal not displayed */
	AssignedAt     string        `` /* 133-byte string literal not displayed */
	Organization   *Organization `` /* 139-byte string literal not displayed */
	Team           *Team         `bun:"rel:belongs-to,join:team_id=id" json:"team,omitempty" firestore:"team,omitempty" bson:"team,omitempty"`
}

OrganizationTeam is the SQL join row for organization ↔ team (see organization_teams).

type PassChangeRequest

type PassChangeRequest struct {
	OldPassword string `json:"old_password,omitempty" firestore:"old_password,omitempty" bson:"old_password,omitempty"`
	NewPassword string `json:"new_password,omitempty" firestore:"new_password,omitempty" bson:"new_password,omitempty"`
}

type PictureDeleteRequest

type PictureDeleteRequest struct {
	Urls      []string `json:"urls,omitempty" firestore:"urls,omitempty" bson:"urls,omitempty"`
	Model     string   `json:"model,omitempty" firestore:"model,omitempty" bson:"model,omitempty"`
	ID        string   `json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	FieldName string   `json:"field_name,omitempty" firestore:"field_name,omitempty" bson:"field_name,omitempty"`
}

type PluginCache

type PluginCache struct {
	Plugin               *plugin.Plugin
	PluginConfigurations *protobuff.PluginDetails
}

new plugin system models

type PreviewMode

type PreviewMode struct {
	Title  string `json:"title,omitempty" firestore:"title,omitempty" bson:"title,omitempty"`
	Icon   string `json:"icon,omitempty" firestore:"icon,omitempty" bson:"icon,omitempty"`
	Status string `json:"status,omitempty" firestore:"status,omitempty" bson:"status,omitempty"`
	ID     string `json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
}

type Project

type Project struct {
	XKey string `json:"_key,omitempty" firestore:"_key,omitempty" bson:"_key,omitempty"`
	ID   string `bun:"type:uuid,pk" json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`

	Name        string                `json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Description string                `json:"description,omitempty" firestore:"description,omitempty" bson:"description,omitempty"`
	Schema      *ProjectSchema        `bun:"rel:belongs-to,join:id=project_id" json:"schema,omitempty" firestore:"schema,omitempty" bson:"schema,omitempty"`
	CreatedAt   string                `json:"created_at,omitempty" firestore:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt   string                `json:"updated_at,omitempty" firestore:"updated_at,omitempty" bson:"updated_at,omitempty"`
	ExpireAt    string                `json:"expire_at,omitempty" firestore:"expire_at,omitempty" bson:"expire_at,omitempty"`
	Plugins     []*SavedPluginDetails `bun:"rel:has-many" json:"plugins,omitempty" firestore:"plugins,omitempty" bson:"plugins,omitempty"`
	Settings    *ProjectSettings      `bun:"rel:belongs-to,join:id=project_id" json:"settings,omitempty"  firestore:"settings,omitempty" bson:"settings,omitempty"`

	Tokens []*ProjectToken `bun:"rel:has-many" json:"tokens,omitempty" firestore:"tokens,omitempty" bson:"tokens,omitempty"`

	Roles      map[string]*Role   `` /* 178-byte string literal not displayed */
	Driver     *DriverCredentials `bun:"rel:belongs-to,join:id=project_id" json:"driver,omitempty"  firestore:"driver,omitempty" bson:"driver,omitempty"`
	TempBanned bool               `json:"temp_banned,omitempty" firestore:"temp_banned,omitempty" bson:"temp_banned,omitempty"`

	ProjectTemplate string `json:"project_template,omitempty" firestore:"project_template,omitempty" bson:"project_template,omitempty"`

	Teams          []*Team       `bun:"m2m:team_projects,join:Project=Team" json:"teams,omitempty"  firestore:"teams,omitempty" bson:"teams,omitempty"`
	Users          []*SystemUser `bun:"m2m:user_projects,join:Project=User" json:"users,omitempty"  firestore:"users,omitempty" bson:"users,omitempty"`
	OrganizationID string        `json:"organization_id,omitempty" firestore:"organization_id,omitempty" bson:"organization_id,omitempty"`
	Organization   *Organization `` /* 139-byte string literal not displayed */

	SystemMessages []*SystemMessage `bun:"rel:has-many" json:"system_messages,omitempty" firestore:"system_messages,omitempty" bson:"system_messages,omitempty"`
	Workspaces     []*Workspace     `bun:"rel:has-many" json:"workspaces,omitempty" firestore:"workspaces,omitempty" bson:"workspaces,omitempty"`

	// for sync
	SyncedProperty *SyncProject `` /* 143-byte string literal not displayed */

	ProjectSecretKey string `json:"project_secret_key,omitempty" firestore:"project_secret_key,omitempty" bson:"project_secret_key,omitempty"`

	AuthenticationSettings *AuthenticationSettings `` /* 127-byte string literal not displayed */
	StorageSettings        *StorageSettings        `json:"storage_settings,omitempty" firestore:"storage_settings,omitempty" bson:"storage_settings,omitempty"`
}

Project user project

type ProjectApiTracking

type ProjectApiTracking map[string]ApiTracking

type ProjectAuthUser added in v1.7.0

type ProjectAuthUser struct {
	bun.BaseModel `bun:"table:users,alias:u"`

	ID        string    `bun:"id,pk" json:"id"`
	TenantID  string    `bun:"tenant_id,nullzero" json:"tenant_id,omitempty"`
	Username  string    `bun:"username,notnull" json:"-"`
	Email     string    `bun:"email" json:"email,omitempty"`
	Phone     string    `bun:"phone,nullzero" json:"phone,omitempty"`
	Secret    string    `bun:"secret" json:"-"`
	Role      string    `bun:"role,notnull" json:"role"`
	Provider  string    `bun:"provider,notnull" json:"provider"`
	GoogleSub string    `bun:"google_sub" json:"google_sub,omitempty"`
	Status    string    `bun:"status,notnull" json:"status"`
	CreatedAt time.Time `bun:"created_at,nullzero" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,nullzero" json:"updated_at"`
}

ProjectAuthUser is an app end-user row stored in the project database (table: users). Project scope is implied by the database connection; tenant_id is used for SaaS shared-DB isolation.

func ProjectAuthUserFromUser added in v1.7.0

func ProjectAuthUserFromUser(u *User, tenantID string) *ProjectAuthUser

ProjectAuthUserFromUser converts a legacy User into a project DB row. tenantID is stored only for SaaS shared-DB projects; leave empty for general or per-tenant DB routing.

type ProjectCreateRequest

type ProjectCreateRequest struct {
	ID          string             `json:"id" bson:"_id,omitempty"`
	Name        string             `json:"name" bson:"name,omitempty"`
	Description string             `json:"description" bson:"description,omitempty"`
	Token       string             `json:"token" bson:"token,omitempty"`
	Engine      string             `json:"engine" bson:"engine,omitempty"`
	Driver      *DriverCredentials `json:"driver" bson:"driver,omitempty"`
	Example     string             `json:"example" bson:"example,omitempty"`
	// DeleteDatabase opts in to physical/platform database removal on project delete (REST only).
	DeleteDatabase bool `json:"delete_database,omitempty" bson:"delete_database,omitempty"`
}

type ProjectFile added in v1.7.0

type ProjectFile struct {
	bun.BaseModel `bun:"table:files,alias:pf"`

	ID            string `bun:"id,type:uuid,pk" json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	ProjectID     string `bun:"project_id,type:uuid,nullzero" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	FileType      string `bun:"file_type,notnull" json:"file_type,omitempty" firestore:"file_type,omitempty" bson:"file_type,omitempty"`
	FileName      string `bun:"file_name,notnull" json:"file_name,omitempty" firestore:"file_name,omitempty" bson:"file_name,omitempty"`
	FileExtension string `` /* 130-byte string literal not displayed */
	ContentType   string `bun:"content_type,nullzero" json:"content_type,omitempty" firestore:"content_type,omitempty" bson:"content_type,omitempty"`
	Size          int64  `bun:"size,notnull" json:"size,omitempty" firestore:"size,omitempty" bson:"size,omitempty"`
	StorageKey    string `bun:"storage_key,notnull" json:"-" firestore:"storage_key,omitempty" bson:"storage_key,omitempty"`
	URL           string `bun:"url,nullzero" json:"url,omitempty" firestore:"url,omitempty" bson:"url,omitempty"`
	CreatedBy     string `bun:"created_by,type:uuid,nullzero" json:"created_by,omitempty" firestore:"created_by,omitempty" bson:"created_by,omitempty"`
	CreatedAt     string `bun:"created_at,nullzero" json:"created_at,omitempty" firestore:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt     string `bun:"updated_at,nullzero" json:"updated_at,omitempty" firestore:"updated_at,omitempty" bson:"updated_at,omitempty"`
}

ProjectFile is file metadata stored in the project database (table: files).

type ProjectSchema

type ProjectSchema struct {
	ProjectID string           `bun:"type:uuid,pk" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"_id,omitempty"`
	Models    []*ModelType     `bun:"rel:has-many,join:project_id=project_id" json:"models,omitempty" firestore:"models,omitempty" bson:"models,omitempty"`
	Functions []*ApitoFunction `` /* 131-byte string literal not displayed */
	// NamingSchemaVersion 0 = legacy; 1 = canonical snake_case model ids (see utility.NamingSchemaVersionV2).
	NamingSchemaVersion int `json:"naming_schema_version,omitempty" firestore:"naming_schema_version,omitempty" bson:"naming_schema_version,omitempty"`
}

type ProjectSettings

type ProjectSettings struct {
	bun.BaseModel `bun:"table:project_settings"`

	ProjectID             string   `bun:"type:uuid,pk" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"_id,omitempty"`
	Locals                []string `bun:"type:json,nullzero" json:"locals,omitempty" firestore:"locals,omitempty" bson:"locals,omitempty"`
	SystemGraphqlHooks    bool     `` /* 133-byte string literal not displayed */
	EnableRevisionHistory bool     `` /* 135-byte string literal not displayed */

	DefaultStoragePlugin  string `` /* 140-byte string literal not displayed */
	DefaultFunctionPlugin string `` /* 143-byte string literal not displayed */

	DefaultLocale string `bun:",nullzero" json:"default_locale,omitempty" firestore:"default_locale,omitempty" bson:"default_locale,omitempty"`
}

type ProjectStorageRuntimeConfig added in v1.7.0

type ProjectStorageRuntimeConfig struct {
	ProjectID       string
	Endpoint        string
	Bucket          string
	AccessKeyID     string
	SecretAccessKey string
	Region          string
	PublicBaseURL   string
	ForcePathStyle  bool
}

ProjectStorageRuntimeConfig is the resolved upload backend for a project.

func ResolveProjectStorageConfig added in v1.7.0

func ResolveProjectStorageConfig(project *Project, cfg *Config) (*ProjectStorageRuntimeConfig, error)

ResolveProjectStorageConfig loads free-cloud platform creds or per-project custom storage.

type ProjectToken added in v1.2.1

type ProjectToken struct {
	ProjectID string `bun:"project_id,type:uuid" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	Name      string `bun:",nullzero" json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Token     string `bun:",nullzero" json:"token,omitempty" firestore:"token,omitempty" bson:"token,omitempty"`
	Role      string `bun:",nullzero" json:"role,omitempty" firestore:"role,omitempty" bson:"role,omitempty"`
	Expire    string `bun:",nullzero" json:"expire,omitempty" firestore:"expire,omitempty" bson:"expire,omitempty"`
}

type ProjectWithRoles

type ProjectWithRoles struct {
	User        *SystemUser `json:"user,omitempty" firestore:"user,omitempty" bson:"user,omitempty"`
	Project     *Project    `json:"project,omitempty" firestore:"project" bson:"project,omitempty"`
	Role        string      `json:"role,omitempty" firestore:"role,omitempty" bson:"role,omitempty"`
	Permissions []string    `json:"permissions,omitempty" firestore:"permissions,omitempty" bson:"permissions,omitempty"`
}

type PublicSchemaModelFilter added in v1.6.1

type PublicSchemaModelFilter struct {
	Model             *ModelType
	Filter            *FilteredModel
	HasMetaQuery      bool
	IsDataloaderModel bool
	KnownAs           string
}

PublicSchemaModelFilter is one model (plus optional request filter metadata) participating in a public GraphQL schema build.

type QueryBuilder

type QueryBuilder struct {
	RawFilterData map[string]interface{}
	DefaultModel  *ModelType

	UserID                   string   `json:"user_id"`
	ProjectID                string   `json:"project_id"`
	RootCollectionFilterType string   `json:"doc_filter_type"`
	DocumentID               string   `json:"document_id"`
	DocumentIDs              []string `json:"document_ids"`

	ParentVariableName string `json:"parent_variable_name"`
	VariablePrefix     string `json:"variable_prefix"`
	VariableName       string `json:"variable_name"`
	CollectionName     string `json:"main_collection_name"`

	RelationCollectionName string               `json:"relation_collection_name"`
	RelationConnection     *ConnectionType      `json:"relation_connection"`
	RelationWhereFilter    []*FilterInformation `json:"relation_where_filter"`

	DefaultFilterCondition string `json:"filter_condition"`

	WhereFilter      []*FilterInformation `json:"where_filter"`   // filter by the user
	DefaultFilter    []*FilterInformation `json:"default_filter"` // default filter that needs to be appended like _key or type of meta.status == 'published'
	SortFilter       []*QueryFilter       `json:"sort_and_limit_param"`
	PaginationFilter *DBPaginationFilter  `json:"limit_filter"`
	FilterByLocal    string               `json:"local"`
	FilterByStatus   string               `json:"status"`

	GroupByFilter map[string]interface{} `json:"group_by_filter"` // used for colelct or group by results

	ConnectionFilter map[string]interface{} `json:"connection_filter"`

	ApitoFields []*FieldInfo `json:"apito_fields"`

	//QueryFilters  []*FilterInformation     `json:"query_filters"`
	SubQueries      []*QueryBuilder          `json:"sub_queries"`
	NestedQueries   []*QueryBuilder          `json:"nested_queries"`
	ReturnFields    map[string]*FieldDetails `json:"return_fields"`
	ReturnOverwrite string                   `json:"return_overwrite"`

	ReturnFieldsSelection *ast.SelectionSet `json:"return_fields_selection"`

	IncludeDefaultSortAndLimit bool `json:"include_default_sort_and_limit"`
	IntersectResult            bool `json:"intersect_result"`
	FetchRevisionDocumentsOnly bool `json:"fetch_revision_documents_only"`
	IsDataloaderQuery          bool `json:"is_dataloader_query"`

	GroupByVariable1 string `json:"group_by_variable1"`
	GroupByVariable2 string `json:"group_by_variable2"`

	IsSystemRequest         bool `json:"is_system_query"`
	IsSystemCollectionQuery bool `json:"is_system_collection_query"`
	IsEntireCollectionQuery bool `json:"is_entire_collection_query"`

	SkipSort          bool `json:"skip_sort"`
	SkipPagination    bool `json:"skip_limit"`
	SkipWhereFilter   bool `json:"skip_where_filter"`
	SkipDefaultFilter bool `json:"skip_default_filter"`

	ReturnOnlyID     bool `json:"return_only_id"`
	ReturnOnlyCount  bool `json:"return_only_count"`
	IsAggregateQuery bool `json:"is_aggregate_query"`

	FinalQuery string `json:"final_query"`

	Ext map[string]interface{} `json:"ext,omitempty"`

	// RuntimeConfig and HookParam wire QueryFilterHook from AQL builder without importing drivers.
	RuntimeConfig *Config             `json:"-"`
	HookParam     *CommonSystemParams `json:"-"`
}

type QueryFilter

type QueryFilter struct {
	KeyWrapperFunction     string      `json:"key_wrapper_function"`     // LOWER(x.name)
	Variable               string      `json:"variable"`                 // x
	Key                    string      `json:"key"`                      // name
	Condition              string      `json:"condition"`                // ==
	Value                  interface{} `json:"value"`                    // fahim
	ComplexPredefinedQuery string      `json:"complex_predefined_query"` // for array filter -> COUNT(array[* FILTER CONTAINS(name, CURRENT)])
	IgnoreValue            bool        `json:"ignore_value"`             // for sub query or IntersectIDs sometime we need to ignore the value ex: NOT IN IntersectIDs null
}

type RawSchema

type RawSchema struct {
	Queries   graphql.Fields
	Mutations graphql.Fields
}

type RegisterRequest

type RegisterRequest struct {
	User             *SystemUser `json:"user,omitempty" firestore:"user,omitempty" bson:"user,omitempty"`
	VerificationCode string      `json:"verification_code,omitempty" firestore:"profession,omitempty" bson:"verification_code,omitempty"`
	AddedByAdmin     bool        `json:"added_by_admin,omitempty" firestore:"added_by_admin,omitempty" bson:"added_by_admin,omitempty"`
}

type Request

type Request struct {
	ID           string  `json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	Type         string  `json:"type,omitempty" firestore:"type,omitempty" bson:"type,omitempty"`
	Filter       *Filter `json:"filter,omitempty" firestore:"filter,omitempty" bson:"filter,omitempty"`
	SearchString string  `json:"search_string,omitempty" firestore:"search_string,omitempty" bson:"search_string,omitempty"`
	Retry        bool    `json:"retry,omitempty" firestore:"retry,omitempty" bson:"retry,omitempty"`
}

type ResolverKey

type ResolverKey struct {
	Key  interface{}
	Meta *MetaField
}

func NewResolverKey

func NewResolverKey(key interface{}, meta *MetaField) *ResolverKey

func (*ResolverKey) GetMeta

func (rk *ResolverKey) GetMeta() *MetaField

func (*ResolverKey) Raw

func (rk *ResolverKey) Raw() interface{}

func (*ResolverKey) String

func (rk *ResolverKey) String() string

type Response

type Response struct {
	Message string `json:"message,omitempty" bson:"message,omitempty"`
	Code    string `json:"code,omitempty" bson:"code,omitempty"`
}

type Role

type Role struct {
	ID                        string                    `bun:"id,pk,notnull,type:uuid,default:gen_random_uuid()" json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	APIPermissions            map[string]*APIPermission `bun:",type:jsonb" json:"api_permissions,omitempty" firestore:"permissions,omitempty" bson:"api_permissions,omitempty"`
	AdministrativePermissions []string                  `` /* 136-byte string literal not displayed */
	LogicExecutions           []string                  `json:"logic_executions,omitempty" firestore:"logic_executions,omitempty" bson:"logic_executions,omitempty"`
	SystemGenerated           bool                      `json:"system_generated,omitempty" firestore:"system_generated,omitempty" bson:"system_generated,omitempty"`
	IsAdmin                   bool                      `json:"is_admin,omitempty" firestore:"is_admin,omitempty" bson:"is_admin,omitempty"`
	IsProjectUser             bool                      `json:"is_project_user,omitempty" firestore:"is_project_user,omitempty" bson:"is_project_user,omitempty"`
	ReadOnlyProject           bool                      `json:"read_only_project,omitempty" firestore:"read_only_project,omitempty" bson:"read_only_project,omitempty"`
}

func (*Role) MarshalAPIPermissions

func (u *Role) MarshalAPIPermissions() ([]byte, error)

MarshalApiPermissions serializes ApiPermissions to JSON.

func (*Role) UnmarshalAPIPermissions

func (u *Role) UnmarshalAPIPermissions(data []byte) error

UnmarshalApiPermissions deserializes JSON to ApiPermissions.

type SavedPluginDetails added in v1.5.0

type SavedPluginDetails struct {
	ProjectID      string                         `bun:"type:uuid,notnull" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	ID             string                         `json:"id,omitempty" firestore:"id,omitempty" bson:"id,omitempty"`
	EnvVars        []*protobuff.EnvVariable       `json:"env_vars,omitempty" firestore:"env_vars,omitempty" bson:"env_vars,omitempty"`
	ActivateStatus protobuff.PluginActivateStatus `json:"activate_status,omitempty" firestore:"activate_status,omitempty" bson:"activate_status,omitempty"`
	LoadStatus     protobuff.PluginLoadStatus     `json:"load_status,omitempty" firestore:"load_status,omitempty" bson:"load_status,omitempty"`
	Enable         bool                           `json:"enable,omitempty" firestore:"enable,omitempty" bson:"enable,omitempty"`
}

type SchemaBuildPermission

type SchemaBuildPermission struct {
	CanQuery        bool
	CanCreateRecord bool
	CanEditRecord   bool
	CanDeleteRecord bool
}

func BuildPermissions

func BuildPermissions(role string) *SchemaBuildPermission

type SchemaMutationHook added in v1.7.0

type SchemaMutationHook func(ctx context.Context, req *SchemaMutationRequest) (*SchemaMutationResult, bool, error)

SchemaMutationHook runs before a schema-changing system mutation applies physical DDL. Return handled=true to stop open-core; handled=false delegates to the default orchestration path.

type SchemaMutationRequest added in v1.7.0

type SchemaMutationRequest struct {
	OperationType string
	Project       *Project
	Args          map[string]interface{}
	UserID        string
	Role          string
}

SchemaMutationRequest carries neutral metadata for staging or bypass decisions.

type SchemaMutationResult added in v1.7.0

type SchemaMutationResult struct {
	ProjectID    string
	ChangesetID  string
	DraftVersion int
	HasDraft     bool
	Message      string
	Response     interface{}
}

SchemaMutationResult is returned when the hook stages a change instead of applying immediately.

type SchemaOperation added in v1.7.0

type SchemaOperation struct {
	bun.BaseModel `bun:"table:schema_operations,alias:schema_op"`

	ID               string `bun:"id,pk,type:uuid"`
	ProjectID        string `bun:"project_id,type:uuid,notnull"`
	OperationType    string `bun:"operation_type,type:text,notnull"`
	Status           string `bun:"status,type:text,notnull"`
	RequestJSON      string `bun:"request_json,type:text"`
	BeforeSchemaJSON string `bun:"before_schema_json,type:text"`
	StepsJSON        string `bun:"steps_json,type:text"`
	Error            string `bun:"error,type:text"`
	AttemptCount     int    `bun:"attempt_count,type:int,notnull,default:0"`
	CreatedAt        string `bun:"created_at,type:timestamp,notnull"`
	UpdatedAt        string `bun:"updated_at,type:timestamp,notnull"`
}

SchemaOperation is the persisted saga log for a schema mutation.

func (*SchemaOperation) SetSteps added in v1.7.0

func (o *SchemaOperation) SetSteps(steps []SchemaOperationStep) error

SetSteps encodes steps into StepsJSON.

func (*SchemaOperation) Steps added in v1.7.0

func (o *SchemaOperation) Steps() ([]SchemaOperationStep, error)

Steps decodes StepsJSON into structured steps.

type SchemaOperationStep added in v1.7.0

type SchemaOperationStep struct {
	Key     string `json:"key"`
	Scope   string `json:"scope,omitempty"` // empty = base project; otherwise scope_key (e.g. tenant id)
	State   string `json:"state"`
	Error   string `json:"error,omitempty"`
	Updated string `json:"updated_at,omitempty"`
}

SchemaOperationStep records one orchestration step (base DB, scoped target, system, cache).

type SearchResponse

type SearchResponse[T any] struct {
	Results        []*T
	GroupedResults map[string][]*T
	Total          int64 `json:"total,omitempty"`
}

type StorageSettings added in v1.7.0

type StorageSettings struct {
	UseFreeCloudStorage *bool  `json:"use_free_cloud_storage,omitempty" firestore:"use_free_cloud_storage,omitempty" bson:"use_free_cloud_storage,omitempty"`
	Endpoint            string `json:"endpoint,omitempty" firestore:"endpoint,omitempty" bson:"endpoint,omitempty"`
	Region              string `json:"region,omitempty" firestore:"region,omitempty" bson:"region,omitempty"`
	Bucket              string `json:"bucket,omitempty" firestore:"bucket,omitempty" bson:"bucket,omitempty"`
	AccessKeyID         string `json:"access_key_id,omitempty" firestore:"access_key_id,omitempty" bson:"access_key_id,omitempty"`
	SecretAccessKey     string `json:"secret_access_key,omitempty" firestore:"secret_access_key,omitempty" bson:"secret_access_key,omitempty"`
	PublicBaseURL       string `json:"public_base_url,omitempty" firestore:"public_base_url,omitempty" bson:"public_base_url,omitempty"`
	ForcePathStyle      *bool  `json:"force_path_style,omitempty" firestore:"force_path_style,omitempty" bson:"force_path_style,omitempty"`
}

StorageSettings configures project media/object storage (Apito-hosted or custom S3-compatible).

func ApplyUpdateProjectStorageInput added in v1.7.0

func ApplyUpdateProjectStorageInput(existing *Project, input map[string]interface{}, hasExistingSecret bool) (*StorageSettings, error)

ApplyUpdateProjectStorageInput merges GraphQL/storage update input into StorageSettings.

type Subscriber

type Subscriber struct {
	Data     chan interface{}
	UserID   string
	IsActive bool
}

type SubscriptionEvent

type SubscriptionEvent struct {
	Type      string `json:"type"`
	ProjectID string `json:"project_id"`
	UserID    string `json:"user_id"`
	Message   string `json:"message"`
}

type SupportAndTicket

type SupportAndTicket struct {
	XKey             string         `json:"_key,omitempty" bson:"_key,omitempty"`
	ID               string         `json:"id,omitempty" bson:"_id,omitempty"`
	Type             string         `json:"type,omitempty" bson:"type,omitempty"`
	ProjectID        string         `json:"project_id,omitempty" bson:"project_id,omitempty"`
	Resolved         bool           `json:"resolved,omitempty" bson:"resolved,omitempty"`
	Title            string         `json:"title,omitempty" bson:"title,omitempty"`
	IssueDescription string         `json:"issue_description,omitempty" bson:"issue_description,omitempty"`
	CreatedAt        string         `json:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt        string         `json:"updated_at,omitempty" bson:"updated_at,omitempty"`
	Replies          []*TicketReply `json:"replies,omitempty" bson:"replies,omitempty"`
}

type SyncProject

type SyncProject struct {
	ProjectID                string `bun:"type:uuid,pk" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"_id,omitempty"`
	SyncedTokenUsed          string `json:"synced_token_used,omitempty" firestore:"synced_token_used,omitempty" bson:"synced_token_used,omitempty"`
	LocalProjectID           string `json:"local_project_id,omitempty" firestore:"local_project_id,omitempty" bson:"local_project_id,omitempty"`
	MergeWithExistingProject bool   `` /* 139-byte string literal not displayed */
	LastSyncedAt             string `json:"last_synced_at,omitempty" firestore:"last_synced_at,omitempty" bson:"last_synced_at,omitempty"`
}

type SyncToken added in v1.2.1

type SyncToken struct {
	ProjectID string `json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	Name      string `json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Token     string `json:"token,omitempty" firestore:"token,omitempty" bson:"token,omitempty"`
	TokenType string `json:"token_type,omitempty" firestore:"token_type,omitempty" bson:"token_type,omitempty"`
	Expire    string `json:"expire,omitempty" firestore:"expire,omitempty" bson:"expire,omitempty"`
	CreatedAt string `json:"created_at,omitempty" firestore:"created_at,omitempty" bson:"created_at,omitempty"`
	// extra information
	ProjectIDs []string `json:"project_ids,omitempty" firestore:"project_ids,omitempty" bson:"project_ids,omitempty"`
	Scopes     []string `json:"scopes,omitempty" firestore:"scopes,omitempty" bson:"scopes,omitempty"`
}

type SystemFile added in v1.7.0

type SystemFile = ProjectFile

SystemFile is an alias for ProjectFile (legacy name used by REST/SDK responses).

type SystemMessage

type SystemMessage struct {
	ProjectID   string `json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	Message     string `json:"message,omitempty" firestore:"message,omitempty" bson:"message,omitempty"`
	Code        string `json:"code,omitempty" firestore:"code,omitempty" bson:"code,omitempty"`
	Redirection string `json:"redirection,omitempty" firestore:"redirection,omitempty" bson:"redirection,omitempty"`
	Hide        bool   `json:"hide,omitempty" firestore:"hide,omitempty" bson:"hide,omitempty"`
}

type SystemUser

type SystemUser struct {
	XKey string `json:"_key,omitempty" firestore:"_key,omitempty" bson:"_key,omitempty"`
	ID   string `bun:"type:uuid,pk" json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`

	Secret       string `json:"secret,omitempty" firestore:"secret,omitempty" bson:"secret,omitempty"`
	TempPassword string `json:"temp_password,omitempty" firestore:"temp_password,omitempty" bson:"temp_password,omitempty"`

	FirstName string `json:"first_name,omitempty" firestore:"first_name,omitempty" bson:"first_name,omitempty"`
	LastName  string `json:"last_name,omitempty" firestore:"last_name,omitempty" bson:"last_name,omitempty"`
	Role      string `json:"role,omitempty" firestore:"role,omitempty" bson:"role,omitempty"`
	Username  string `json:"username,omitempty" firestore:"username,omitempty" bson:"username,omitempty"`
	Email     string `json:"email,omitempty" firestore:"email,omitempty" bson:"email,omitempty"`
	Avatar    string `json:"avatar,omitempty" firestore:"avatar,omitempty" bson:"avatar,omitempty"`

	CurrentProjectID string `json:"current_project_id,omitempty" firestore:"current_project_id,omitempty" bson:"current_project_id,omitempty"`
	RegisterProvider string `json:"register_provider,omitempty" firestore:"register_provider,omitempty" bson:"register_provider,omitempty"`

	ProjectUser               bool     `json:"project_user,omitempty" firestore:"project_user,omitempty" bson:"project_user,omitempty"`
	AdministrativePermissions []string `json:"administrative_permissions,omitempty" firestore:"email,omitempty" bson:"administrative_permissions,omitempty"`

	ProjectAssignedRole      string   `json:"project_assigned_role,omitempty" bson:"project_assigned_role,omitempty"`
	ProjectAccessPermissions []string `json:"project_access_permissions,omitempty" bson:"project_access_permissions,omitempty"`

	IsAdmin bool `json:"is_admin,omitempty" firestore:"is_admin,omitempty" bson:"is_admin,omitempty"`

	RefreshToken    string `json:"refresh_token,omitempty" firestore:"refresh_token,omitempty" bson:"refresh_token,omitempty"`
	AccessToken     string `json:"access_token,omitempty" firestore:"access_token,omitempty" bson:"access_token,omitempty"`
	ReadOnlyProject bool   `json:"read_only_project,omitempty" firestore:"read_only_project,omitempty" bson:"read_only_project,omitempty"`
	LastLoggedIn    string `json:"last_logged_in,omitempty" firestore:"last_logged_in,omitempty" bson:"last_logged_in,omitempty"`

	CreatedAt string `` /* 143-byte string literal not displayed */
	UpdatedAt string `bun:"type:timestamp,notnull" json:"updated_at,omitempty" firestore:"updated_at,omitempty" bson:"updated_at,omitempty"`

	IsPaymentDue bool `json:"is_payment_due,omitempty" firestore:"is_payment_due,omitempty" bson:"is_payment_due,omitempty"`

	// Stored as JSON in SQL (nested document); not a separate sync_token table (avoids invalid has-many FK).
	SyncTokens []*SyncToken `bun:"type:jsonb,nullzero" json:"sync_tokens,omitempty" firestore:"sync_tokens,omitempty" bson:"sync_tokens,omitempty"`

	DefaultTeamID         string        `` /* 135-byte string literal not displayed */
	DefaultOrganizationID string        `` /* 131-byte string literal not displayed */
	DefaultTeam           *Team         `` /* 139-byte string literal not displayed */
	DefaultOrganization   *Organization `` /* 162-byte string literal not displayed */

	Projects     []*Project      `bun:"m2m:user_projects,join:User=Project" json:"projects,omitempty" firestore:"projects,omitempty" bson:"projects,omitempty"`
	Teams        []*Team         `bun:"m2m:user_teams,join:User=Team" json:"teams,omitempty" firestore:"teams,omitempty" bson:"teams,omitempty"`
	Organization []*Organization `` /* 129-byte string literal not displayed */

	IsActive bool `json:"is_active,omitempty" firestore:"is_active,omitempty" bson:"is_active,omitempty"`
}

type Team

type Team struct {
	XKey        string        `json:"_key,omitempty" firestore:"_key,omitempty" bson:"_key,omitempty"`
	ID          string        `bun:"type:uuid,pk" json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	Name        string        `json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Description string        `json:"description,omitempty" firestore:"description,omitempty" bson:"description,omitempty"`
	CreatedBy   string        `json:"created_by,omitempty" firestore:"created_by,omitempty" bson:"created_by,omitempty"`
	Users       []*SystemUser `bun:"m2m:user_teams,join:Team=User" json:"users,omitempty" firestore:"users,omitempty" bson:"users,omitempty"`
	Projects    []*Project    `bun:"m2m:team_projects,join:Team=Project" json:"projects,omitempty" firestore:"projects,omitempty" bson:"projects,omitempty"`
}

type TeamMemberAddRequest

type TeamMemberAddRequest struct {
	ProjectID   string   `json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	UserID      string   `json:"user_id,omitempty" firestore:"user_id,omitempty" bson:"user_id,omitempty"`
	Email       string   `json:"email,omitempty" firestore:"email,omitempty" bson:"email,omitempty"`
	Role        string   `json:"role,omitempty" firestore:"role,omitempty" bson:"role,omitempty"`
	TeamID      string   `json:"team_id,omitempty" firestore:"team_id,omitempty" bson:"team_id,omitempty"`
	Permissions []string `json:"permissions,omitempty" firestore:"permissions,omitempty" bson:"permissions,omitempty"`
}

type TeamProject

type TeamProject struct {
	TeamID    string   `bun:"type:uuid,pk" json:"team_id" bson:"team_id,omitempty"`
	ProjectID string   `bun:"type:uuid,pk" json:"project_id" bson:"project_id,omitempty"`
	LinkedAt  string   `bun:"linked_at,type:timestamp,nullzero" json:"linked_at,omitempty" bson:"linked_at,omitempty"`
	Team      *Team    `bun:"rel:belongs-to,join:team_id=id" bson:"team,omitempty"`
	Project   *Project `bun:"rel:belongs-to,join:project_id=id" bson:"project,omitempty"`
}

type TicketReply

type TicketReply struct {
	Description string      `json:"description,omitempty" bson:"description,omitempty"`
	User        *SystemUser `json:"user,omitempty" bson:"user,omitempty"`
	CreatedAt   string      `json:"created_at,omitempty" bson:"created_at,omitempty"`
	Edited      bool        `json:"edited,omitempty" bson:"edited,omitempty"`
}

type TokenClaims

type TokenClaims struct {
	ProjectID     string `json:"project_id"`
	TokenUniqueID string `json:"token_unique_id"`

	Role   string `json:"role"`
	UserID string `json:"user_id"`
	Email  string `json:"email"`

	IsProjectUser bool `json:"is_project_user"`
	IsReadOnly    bool `json:"is_read_only"`

	AccessPermissions []string `json:"access_permissions"`

	TokenType      string `json:"token_type"`       // access_token or id_token
	PaymentDueDate string `json:"payment_due_date"` // used if the user dosnt pay

	ExpireAt int64 `json:"expire_at"` // unix timestamp

	ProjectIDs []string               `json:"project_ids"` // ['project_id_1', 'project_id_2']
	Scopes     []string               `json:"scopes"`      // ['read', 'write']
	Ext        map[string]interface{} `json:"ext,omitempty"`
}

func (*TokenClaims) HasAllScopes added in v1.2.1

func (claims *TokenClaims) HasAllScopes(scopes []string) bool

HasAllScopes checks if token has all of the specified scopes

func (*TokenClaims) HasAnyScope added in v1.2.1

func (claims *TokenClaims) HasAnyScope(scopes []string) bool

HasAnyScope checks if token has any of the specified scopes

func (*TokenClaims) HasScope added in v1.2.1

func (claims *TokenClaims) HasScope(scope string) bool

HasScope checks if token has a specific scope

func (*TokenClaims) IsExpired added in v1.2.1

func (claims *TokenClaims) IsExpired() bool

IsExpired checks if token is expired

func (*TokenClaims) TimeRemaining added in v1.2.1

func (claims *TokenClaims) TimeRemaining() int64

TimeRemaining returns seconds until token expires

type UploadParams

type UploadParams struct {
	DocID      string `json:"doc_id,omitempty" firestore:"doc_id,omitempty" bson:"doc_id,omitempty"`
	ProjectID  string `json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	ModelName  string `json:"model_name,omitempty" firestore:"model_name,omitempty" bson:"model_name,omitempty"`
	FieldName  string `json:"field_name,omitempty" firestore:"field_name,omitempty" bson:"field_name,omitempty"`
	AllowMulti bool   `json:"allow_multi,omitempty" firestore:"allow_multi,omitempty" bson:"allow_multi,omitempty"`
	Provider   string `json:"provider,omitempty" firestore:"provider,omitempty" bson:"provider,omitempty"`
}

type User added in v1.7.0

type User struct {
	bun.BaseModel `bun:"table:project_users,alias:pu"`

	ID        string `bun:"id,pk" json:"id" bson:"_id,omitempty"`
	ProjectID string `bun:"project_id,notnull" json:"project_id" bson:"project_id,omitempty"`

	// Username is an internal stable key for SQL uniqueness (project_id, username).
	Username string `bun:"username,notnull" json:"-" bson:"username,omitempty"`
	Email    string `bun:"email" json:"email,omitempty" bson:"email,omitempty"`
	Phone    string `bun:"phone,nullzero" json:"phone,omitempty" bson:"phone,omitempty"`
	Secret   string `bun:"secret" json:"-" bson:"secret,omitempty"`

	Role      string `bun:"role,notnull" json:"role" bson:"role,omitempty"`
	Provider  string `bun:"provider,notnull" json:"provider" bson:"provider,omitempty"`
	GoogleSub string `bun:"google_sub" json:"google_sub,omitempty" bson:"google_sub,omitempty"`

	Status string `bun:"status,notnull" json:"status" bson:"status,omitempty"`

	CreatedAt time.Time `bun:"created_at,nullzero" json:"created_at" bson:"created_at,omitempty"`
	UpdatedAt time.Time `bun:"updated_at,nullzero" json:"updated_at" bson:"updated_at,omitempty"`
}

User is a project-scoped application end-user (legacy system DB: project_users; target store: project DB users).

func UserFromProjectAuthUser added in v1.7.0

func UserFromProjectAuthUser(projectID string, row *ProjectAuthUser) *User

UserFromProjectAuthUser maps a project DB row to the legacy User shape (ProjectID supplied by caller).

type UserOrganization added in v1.6.1

type UserOrganization struct {
	UserID         string        `bun:"type:uuid,pk" json:"user_id,omitempty" firestore:"user_id,omitempty" bson:"user_id,omitempty"`
	OrganizationID string        `bun:"type:uuid,pk" json:"organization_id,omitempty" firestore:"organization_id,omitempty" bson:"organization_id,omitempty"`
	Role           string        `bun:"role,type:text,nullzero" json:"role,omitempty" firestore:"role,omitempty" bson:"role,omitempty"`
	JoinedAt       string        `bun:"joined_at,type:timestamp,nullzero" json:"joined_at,omitempty" firestore:"joined_at,omitempty" bson:"joined_at,omitempty"`
	User           *SystemUser   `bun:"rel:belongs-to,join:user_id=id" json:"user,omitempty" firestore:"user,omitempty" bson:"user,omitempty"`
	Organization   *Organization `` /* 139-byte string literal not displayed */
}

UserOrganization is the SQL join row for user ↔ organization membership (see user_organizations).

type UserProject

type UserProject struct {
	UserID      string      `bun:"type:uuid,pk" json:"user_id" bson:"user_id,omitempty"`
	ProjectID   string      `bun:"type:uuid,pk" json:"project_id" bson:"project_id,omitempty"`
	Role        string      `bun:"role,type:text,nullzero" json:"role,omitempty" bson:"role,omitempty"`
	Permissions string      `bun:"permissions,type:text,nullzero" json:"permissions,omitempty" bson:"permissions,omitempty"`
	User        *SystemUser `bun:"rel:belongs-to,join:user_id=id" bson:"user,omitempty"`
	Project     *Project    `bun:"rel:belongs-to,join:project_id=id" bson:"project,omitempty"`
}

type UserTeam

type UserTeam struct {
	UserID string      `bun:"type:uuid,pk" json:"user_id" bson:"user_id,omitempty"`
	TeamID string      `bun:"type:uuid,pk" json:"team_id" bson:"team_id,omitempty"`
	User   *SystemUser `bun:"rel:belongs-to,join:user_id=id" bson:"user,omitempty"`
	Team   *Team       `bun:"rel:belongs-to,join:team_id=id" bson:"team,omitempty"`
}

type UserToTeams

type UserToTeams struct {
	UserID     string      `bun:"type:uuid,pk" json:"user_id,omitempty" firestore:"user_id,omitempty" bson:"user_id,omitempty"`
	SystemUser *SystemUser `` /* 128-byte string literal not displayed */
	TeamID     string      `bun:"type:uuid,pk" json:"team_id,omitempty" firestore:"team_id,omitempty" bson:"team_id,omitempty"`
	Team       *Team       `bun:"rel:belongs-to,join:team_id=id" json:"team,omitempty" firestore:"team,omitempty" bson:"team,omitempty"`
}

type ValidIdentifier added in v1.1.4

type ValidIdentifier struct {
	Label       string
	Identifier  string
	ParentField string
}

type Validation

type Validation struct {
	Required bool `json:"required,omitempty" firestore:"required,omitempty" bson:"required,omitempty"`
	Hide     bool `json:"hide,omitempty" firestore:"hide,omitempty" bson:"hide,omitempty"`
	//AsTitle  bool     `json:"as_title,omitempty" firestore:"as_title,omitempty" bson:"as_title,omitempty"`
	Locals []string `json:"locals,omitempty" firestore:"locals,omitempty" bson:"locals,omitempty"`
	Unique bool     `json:"unique,omitempty" firestore:"unique,omitempty" bson:"unique,omitempty"`

	CharLimit        []uint32  `json:"char_limit,omitempty" firestore:"char_limit,omitempty" bson:"char_limit,omitempty"`
	IntRangeLimit    []uint32  `json:"int_range_limit,omitempty" firestore:"int_range_limit,omitempty" bson:"int_range_limit,omitempty"`
	DoubleRangeLimit []float64 `json:"double_range_limit,omitempty" firestore:"double_range_limit,omitempty" bson:"double_range_limit,omitempty"`

	Placeholder          string        `json:"placeholder,omitempty" firestore:"placeholder,omitempty" bson:"placeholder,omitempty"`
	FixedListElements    []interface{} `json:"fixed_list_elements,omitempty" firestore:"fixed_list_elements,omitempty" bson:"fixed_list_elements,omitempty"`
	FixedListElementType string        `` // if the list element is string or int or float
	/* 127-byte string literal not displayed */

	IsMultiChoice bool `json:"is_multi_choice,omitempty" firestore:"is_multi_choice,omitempty" bson:"is_multi_choice,omitempty"`
	IsEmail       bool `json:"is_email,omitempty" firestore:"is_email,omitempty" bson:"is_email,omitempty"`
	IsGallery     bool `json:"is_gallery,omitempty" firestore:"is_gallery,omitempty" bson:"is_gallery,omitempty"`
	IsPassword    bool `json:"is_password,omitempty" firestore:"is_gallery,omitempty" bson:"is_password,omitempty"`
	//IsSystemRole      bool      `json:"is_system_role,omitempty" firestore:"is_gallery,omitempty" bson:"is_system_role,omitempty"`
	IsURL bool `json:"is_url,omitempty" firestore:"is_url,omitempty" bson:"is_url,omitempty"`
	// hide the field for the roles
	HideForRoles []string `json:"hide_for_roles,omitempty" firestore:"hide_for_roles,omitempty" bson:"hide_for_roles,omitempty"`
}

type Webhook

type Webhook struct {
	ID              string   `bun:"id,type:uuid,pk" json:"id,omitempty" firestore:"id,omitempty" bson:"_id,omitempty"`
	XKey            string   `json:"_key,omitempty" firestore:"_key,omitempty" bson:"_key,omitempty"`
	Type            string   `json:"type,omitempty" firestore:"type,omitempty" bson:"type,omitempty"`
	Model           string   `json:"model,omitempty" firestore:"model,omitempty" bson:"model,omitempty"`
	ProjectID       string   `bun:"project_id,type:uuid,pk" json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"` //
	Name            string   `json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Events          []string `json:"events,omitempty" firestore:"events,omitempty" bson:"events,omitempty"`
	URL             string   `json:"url,omitempty" firestore:"url,omitempty" bson:"url,omitempty"`
	LogicExecutions []string `json:"logic_executions,omitempty" firestore:"logic_executions,omitempty" bson:"logic_executions,omitempty"`
}

type WebhookPost

type WebhookPost struct {
	Id      string      `json:"id"`
	Event   string      `json:"event"`
	Model   string      `json:"model"`
	Payload interface{} `json:"payload"`
}

type Workspace

type Workspace struct {
	ProjectID    string `json:"project_id,omitempty" firestore:"project_id,omitempty" bson:"project_id,omitempty"`
	Name         string `json:"name,omitempty" firestore:"name,omitempty" bson:"name,omitempty"`
	Active       bool   `json:"active,omitempty" firestore:"active,omitempty" bson:"active,omitempty"`
	IsProduction bool   `json:"is_production,omitempty" firestore:"is_production,omitempty" bson:"is_production,omitempty"`
	IsDefault    bool   `json:"is_default,omitempty" firestore:"is_default,omitempty" bson:"is_default,omitempty"`
}

type XResponse

type XResponse struct {
	Data       interface{}            `json:"data,omitempty"`
	Errors     json.RawMessage        `json:"errors,omitempty"`
	Extensions map[string]interface{} `json:"extensions,omitempty"`
}

Jump to

Keyboard shortcuts

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