serverpod library

Classes

AbstractWidget
The base class for all web widgets. Override this class to create a custom widget type, or use one of the default types which covers most common use cases.
AnyExpression<T>
A database expression that returns all rows where any of the related rows match the filtering criteria.
AsEventHandler<T extends DiagnosticEvent>
Adapter class to use an EventHandlerFunction as a DiagnosticEventHandler. Since this class inherits TypedEventHandler it can filter on event type.
AuthenticationInfo
Holds the id for an authenticated user and which scopes it can access. Allowed scopes are defined for each Endpoint.
BadRequestMessage
A message sent when a bad request is received.
CacheMissHandler<T extends SerializableModel>
A CacheMissHandler is used to define a function that is called when a cache miss occurs. The function is expected to return a new object that will be stored in the cache.
ClientCallOpContext
The context of a client call operation. Subclasses represent web, method, and method streaming calls.
CloseMethodStreamCommand
A message sent over a websocket connection to close a websocket stream of data to an endpoint method.
CloudStorage
The CloudStorage provides a standardized interface to store binary files in the cloud. The default implementation is to use the database for binary storage, but it can be extended to support Google Cloud, Amazon S3, or any other cloud storage service.
Column<T>
Abstract class representing a database Column. Subclassed by the different supported column types such as ColumnInt or ColumnString.
ColumnBigInt
A Column holding BigInt.
ColumnBool
A Column holding an bool.
ColumnByteData
A Column holding ByteData.
ColumnComparable<T>
A Column whose values can be compared equal or unequal to other values. Attends full specification of default PG comparison operations: https://www.postgresql.org/docs/current/functions-comparison.html#FUNCTIONS-COMPARISON-OP-TABLE
ColumnCount
A Column holding a count of rows.
ColumnDateTime
A Column holding an DateTime. In the database it is stored as a timestamp without time zone.
ColumnDouble
A Column holding an double.
ColumnDuration
A Column holding Duration.
ColumnEnum<E extends Enum>
A Column holding an enum.
ColumnEnumExtended<E extends Enum>
Intended for internal use only
ColumnExpression<T>
Database expression for a column.
ColumnInt
A Column holding an int.
ColumnSerializable
A Column holding an SerializableModel. The entity will be stored in the database as a json column.
ColumnString
A Column holding an String.
ColumnUri
A Column holding Uri.
ColumnUuid
A Column holding UuidValue.
ConnectionInfo
Represents the connection information of a network request. Can be HTTP but also other types of network connections.
Constant
A constant Expression.
Database
Provides easy access to the database in relation to the current Session.
DatabaseAccessor
Interface for accessing the database.
DatabaseCloudStorage
The DatabaseCloudStorage uses the standard Serverpod database to store binary files. It's the default CloudStorage interface of Serverpod, but you may want to replace it with a more robust service depending on your needs, especially in your production environment.
DatabaseConfig
Configuration for a Postgres database,
DatabaseResult
Database result.
DatabaseResultRow
Database result row.
DatabaseResultSchema
Database result schema.
DatabaseResultSchemaColumn
Database result schema column.
DiagnosticEvent
Base interface for all diagnostic events.
DiagnosticEventContext
Base class for information about the context in which a DiagnosticEvent was submitted.
DiagnosticEventHandler
Base interface for DiagnosticEvent handlers.
DiagnosticEventRecord<E extends DiagnosticEvent>
A record with a submitted diagnostic event.
Endpoint
The Endpoint is an entrypoint to the Server. To add a custom Endpoint to a Server, create a subclass and place it in the endpoints directory. Code will generated that builds the corresponding client library. To add methods that can be accessed from the client, make sure that the first argument of the method is a Session parameter.
EndpointConnector
The EndpointConnector associates a name with and endpoint and its EndpointMethodConnectors.
EndpointDispatch
The EndpointDispatch is responsible for directing requests to the Server to the correct Endpoint and method. Typically, this class is overridden by an Endpoints class that is generated.
EndpointMethodConnector
The EndpointMethodConnector is a base class for connectors that connect methods their implementation.
EscapedExpression
A database expression that is escaped. This is used to escape values that are not expressions, such as strings and numbers.
EveryExpression<T>
A database expression that returns all rows where all of the related rows match the filtering criteria.
ExceptionEvent
An event that represents an exception that occurred in the server.
ExceptionHandler
A DiagnosticEventHandler that handles ExceptionEvent instances.
ExceptionResult<T extends SerializableException>
The result of a failed Endpoint method call, with a custom exception.
ExperimentalApi
Experimental API for Serverpod.
ExperimentalFeatures
Setup of experimental features.
Expression<T>
A database Expression.
FutureCall<T extends SerializableModel>
Superclass of a FutureCall, override the invoke method to create a custom FutureCall. The call also needs to be registered with the top ServerPod object before starting the Server.
FutureCallOpContext
The context of a future call operation.
FutureCallSession
Created when a FutureCall is being made. It contains all data associated with the current call and provides easy access to the database.
Include
The base include class, should not be used directly.
IncludeList
Defines what tables to join when querying a table.
IncludeObject
Defines what tables to join when querying a table.
InternalSession
A Session used internally in the ServerPod. Typically used to access the database and do logging for events that are not triggered from a call, or a stream.
ManyRelation<T extends Table>
Many relation field between two tables.
MessageCentral
The MessageCentral handles communication within the server, and between servers in a cluster. It is especially useful when working with streaming endpoints. The message central can pass on any serializable to a channel. The channel can be listened to by from any place in the server.
MessageCentralAccess
Provides access to the Serverpod's MessageCentral.
MessageCentralServerpodChannels
Channels that are listened to by the Serverpod Framework.
MethodCallContext
Context for a MethodConnector call
MethodCallOpContext
The context of a method call operation.
MethodCallSession
When a call is made to the Server a MethodCallSession object is created. It contains all data associated with the current connection and provides easy access to the database.
MethodConnector
The MethodConnector hooks up a method with its name and the actual call to the method.
MethodStreamCallContext
Context for a MethodStreamConnector call
MethodStreamConnector
The MethodStreamConnector hooks up a method with its name and implementation. The method communicates with the client using a websocket connection. Enabling support for streaming return values or parameters.
MethodStreamMessage
A message sent to a method stream.
MethodStreamSerializableException
A serializable exception sent over a method stream.
MethodStreamSession
When a connection is made to the Server to an endpoint method that uses a stream MethodStreamSession object is created. It contains all data associated with the current connection and provides easy access to the database.
NoneExpression<T>
A database expression that returns all rows where none of the related rows match the filtering criteria.
NotExpression
A database expression to invert the result of another expression.
OpenMethodStreamCommand
A message sent over a websocket connection to open a websocket stream of data to an endpoint method.
OpenMethodStreamResponse
A message sent over a websocket connection to respond to an OpenMethodStreamCommand.
OperationEventContext
Represents the operation that the event was caused by or in relation to. An operation is a client-originated call / operation or a scheduled operation, i.e. a method call, a streaming call, a web call, or a future call.
Order
Defines how to order a database column.
ParameterDescription
Defines a parameter in a MethodConnector.
PathCacheMaxAge
A path pattern to match, and the max age that paths that match the pattern should be cached for, in seconds.
PgErrorCode
A class containing constants for PostgreSQL error codes.
PingCommand
A message sent over a websocket connection to check if the connection is still alive. The other end should respond with a PongCommand.
PongCommand
A response to a PingCommand.
ProtocolSerialization
The ProtocolSerialization defines a toJsonForProtocol method which makes it possible to limit what fields are serialized
QueryParameters
Provides parameters for direct database queries
QueryParametersNamed
Named parameters for direct database queries.
QueryParametersPositional
Positional parameters for direct database queries
RedisConfig
Configuration for Redis.
Result
The Result of an Endpoint method call.
ResultAuthenticationFailed
The result of a failed Endpoint method call where authentication failed.
ResultInternalServerError
The result of a failed Endpoint method call where an Exception was thrown during execution of the method.
ResultInvalidParams
The result of a failed Endpoint method call where the parameters where not valid.
ResultNoSuchEndpoint
The result of a failed Endpoint method call where the endpoint was not found.
ResultStatusCode
The result of a failed Endpoint method call, with a custom status code, and an optional message.
ResultSuccess
A successful result from an Endpoint method call containing the return value of the call.
Route
A Route defines a destination in Serverpod's web server. It will handle a call and generate an appropriate response by manipulating the HttpRequest object. You override Route, or more likely it's subclass WidgetRoute to create your own custom routes in your server.
RouteStaticDirectory
Route for serving a directory of static files.
Savepoint
A savepoint in a transaction.
Scope
Used to define who can access an Endpoint. Authenticated users can be associated with a Scope, if the same scope is defined in the Endpoint the user is granted access. The scope is defined by its name.
SecurityContextConfig
Configuration for the security context.
SerializableEntity
DEPRECATED: This class is deprecated and will be removed in version 2.1. Please implement the SerializableModel interface instead for creating serializable models.
SerializableModel
The SerializableModel is the base interface for all serializable objects in Serverpod, except primitives.
SerializationManager
The SerializationManager is responsible for creating objects from a serialization, but also for serializing objects. This class is typically extended by generated code.
SerializationManagerServer
The SerializationManager is responsible for creating objects from a serialization, but also for serializing objects. This class is typically overridden by generated code. SerializationManagerServer is an extension to also handle Tables.
Server
Handling incoming calls and routing them to the correct Endpoint methods.
ServerConfig
Configuration for a server.
ServerHealthMetric
Represents a snapshot of a specific health metric. An entry is written every minute for each server. All health data can be accessed through Serverpod Insights.
ServerHealthMetricInclude
ServerHealthMetricIncludeList
ServerHealthMetricRepository
ServerHealthMetricTable
Serverpod
The Serverpod handles all setup and manages the main Server. In addition to the user managed server, it also runs a server for handling the DistributedCache and other connections through the InsightsEndpoint.
ServerpodConfig
Parser for the Serverpod configuration file.
ServerpodRunMode
Defines valid run modes for the Serverpod.
Session
When a call is made to the Server a Session object is created. It contains all data associated with the current connection and provides easy access to the database.
SessionLogConfig
Configuration for session logging.
StorageAccess
Collects methods for accessing cloud storage.
StreamingSession
When a web socket connection is opened to the Server a StreamingSession object is created. It contains all data associated with the current connection and provides easy access to the database.
StreamOpContext
The context of a stream operation / message.
StreamParameterDescription<T>
Description of a stream parameter.
Table<T_ID>
Represents a database table.
TableRow<T_ID>
Holds data corresponding to a row in the database. Concrete classes are typically generated. Instances of TableRow can also be serialized and either passed to clients or cached.
Templates
Loads and caches templates.
Transaction
Holds the state of a running database transaction.
TransactionSettings
Settings for a transaction.
TwoPartExpression
A database expression with two parts.
TypedEventHandler<T extends DiagnosticEvent>
A DiagnosticEventHandler that handles events of a specific type.
Uuid
uuid for Dart Author: Yulian Kuncheff Released under MIT License.
UuidValue
WebCallOpContext
The context of a web call operation.
WebCallSession
When a request is made to the web server a WebCallSession object is created. It contains all data associated with the current connection and provides easy access to the database.
WebServer
The Serverpod webserver.
WebSocketMessage
Base class for messages sent over a WebSocket connection.
WebSocketMessageInfo
Interface of WebSocketMessage subclasses that have endpoint, method and connection id info.
Widget
A widget based on a HTML template. The name of the template should correspond to a template file in your server's web/templates directory. Set the custom values of the template by populating the values field. If values are set that aren't Strings, the toString method will be called on the value. The templates are loaded when the server starts. If you add new templates or modify existing templates, you will need to restart the server for them to take effect.
WidgetJson
A widget that renders JSON output. The output will be the result of passing the provided object to jsonEncode.
WidgetList
Combines a List of Widgets into a single widget.
WidgetRedirect
A widget that renders a HTTP redirect to the provided url.
WidgetRoute
A WidgetRoute is the most convenient way to create routes in your server. Override the build method and return an appropriate Widget.

Enums

AuthenticationFailureReason
The type of failures that can occur during authentication.
CloseReason
The reason a stream was closed.
EnumSerialization
IsolationLevel
Isolation levels for transactions.
LogLevel
Represents different log levels.
MethodStreamReturnType
The type of return value from a MethodStreamConnector.
Namespace
RFC4122 & RFC9562 provided namespaces for v3, v5, and v8 namespace based UUIDs
OpenMethodStreamResponseType
The response to an OpenMethodStreamCommand.
OperationType
Represents the type of "operation" during which the event was caused.
OriginSpace
Denotes whether an event's origin is application (user) space or framework space.
RouteMethod
Defines HTTP call methods for routes.
ServerpodLoggingMode
The overarching logging mode of the server. This can be set to either normal or verbose. In normal mode, only important messages are logged, which is the default.
ValidationMode
The options for UUID Validation strictness

Extensions

Base64Dec on String
Extension for decoding ByteData in protocol.
Base64Enc on ByteData
Extension for encoding ByteData in the protocol.
BigIntJsonExtension on BigInt
Expose toJson on BigInt Expose static fromJson builder
ByteDataJsonExtension on ByteData
Expose toJson on ByteData Expose static fromJson builder
CloneByteData on ByteData
Adds clone method that create a deep copy of a ByteData.
ConnectionInfoExtension on HttpConnectionInfo
Extension on HttpConnectionInfo that adds a toConnectionInfo converter method.
DateTimeJsonExtension on DateTime
Expose toJson on DateTime Expose static fromJson builder
DurationJsonExtension on Duration
Expose toJson on Duration Expose static fromJson builder
IdColumnIterable on Iterable
An extension on iterable for Id columns.
ListJsonExtension on List<T>
Expose toJson on List
MapJsonExtension on Map<K, V>
Expose toJson on Map
RemoteIp on HttpRequest
Extends HttpRequest with useful methods.
SetJsonExtension on Set<T>
Expose toJson on Set
UriJsonExtension on Uri
Expose toJson on Uri Expose static fromJson builder
UuidValueJsonExtension on UuidValue
Expose toJson on UuidValue Expose static fromJson builder

Constants

autoSerializedTypes → const List<String>
All datatypes that are serialized by default. Used internally in Serverpod code generation.
basicAuthSchemeName → const String
The name of the default Serverpod scheme for HTTP "authorization" headers. Note, the scheme name is case-insensitive and should be compared in a case-insensitive manner.
extensionSerializedTypes → const List<String>
All datatypes that has extensions to support serialization. Used internally in Serverpod code generation.
hasCloneExtensionTypes → const List<String>
List of types that has a clone method extension and therefore can be copied by calling clone().
useResult → const UseResult
Used to annotate a method, field, or getter within a class, mixin, or extension, or a or top-level getter, variable or function to indicate that the value obtained by invoking it should be used. A value is considered used if it is assigned to a variable, passed to a function, or used as the target of an invocation, or invoked (if the result is itself a function).

Properties

nonMutableTypeNames List<String>
List of types that are not mutable and therefore do not need to be copied or handled in a copyWith method.
final
templates Templates
Global access to all templates loaded when starting the webserver.
final

Functions

createRelationTable<T>({required String relationFieldName, required Column field, required Column foreignField, TableRelation? tableRelation, required T createTable(TableRelation foreignTableRelation)}) → T
Creates a new Table containing TableRelation with information about how the tables are joined.
getType<T>() Type
Get the type provided as an generic. Useful for getting a nullable type.
isValidAuthHeaderValue(String value) bool
Returns true if the provided value is a valid HTTP "authorization" header value (which includes starting with an authentication scheme name).
isWrappedBasicAuthHeaderValue(String value) bool
Returns true if the provided value is a Serverpod-wrapped auth key.
unwrapAuthHeaderValue(String? authValue) String?
Returns the auth key from an auth value that has potentially been wrapped. This operation is the inverse of wrapAsBasicAuthHeaderValue. If null is provided, null is returned.
wrapAsBasicAuthHeaderValue(String key) String
Returns a value that is compliant with the HTTP auth header format by encoding and wrapping the provided auth key as a Basic auth value.

Typedefs

AuthenticationHandler = Future<AuthenticationInfo?> Function(Session session, String token)
Returns authentication information for a given Session and token or null if the key is invalid.
ColumnSelections<T extends Table> = List<Column> Function(T)
A function that returns a Column for a Table.
Convert<T> = T Function(String value)
The configuration sections for the serverpod configuration file.
EventHandlerFunction<T extends DiagnosticEvent> = void Function(T event, {required DiagnosticEventContext context, required OriginSpace space})
Function signature type for functions that handle a DiagnosticEvent.
HealthCheckHandler = Future<List<ServerHealthMetric>> Function(Serverpod pod, DateTime timestamp)
Performs a set of custom health checks on a Serverpod.
MessageCentralListenerCallback = void Function(SerializableModel message)
The callback used by listeners of the MessageCentral.
MethodCall = Future Function(Session session, Map<String, dynamic> params)
Calls a named method referenced in a MethodConnector.
MethodStream = dynamic Function(Session session, Map<String, dynamic> params, Map<String, Stream> streamParams)
Calls a named method referenced in a MethodStreamConnector.
OrderByBuilder<T extends Table> = Column Function(T)
A function that returns a Column for a Table to be used with order by
OrderByListBuilder<T extends Table> = List<Order> Function(T)
A function that returns a list of Order for a Table to be used with order by list.
TransactionFunction<R> = Future<R> Function(Transaction transaction)
A function performing a transaction, passed to the transaction method.
WhereExpressionBuilder<T extends Table> = Expression Function(T)
A function that returns an Expression for a Table to be used with where clauses.
WillCloseListener = FutureOr<void> Function(Session session)
A listener that will be called when the session is about to close.

Exceptions / Errors

AuthHeaderEncodingException
An exception thrown upon erroneous encoding of an auth header.
CloudStorageException
Exception thrown by CloudStorage.
DatabaseDeleteRowException
Exception thrown when a delete row operation fails.
DatabaseException
Exception thrown when an error occurs in the database.
DatabaseInsertRowException
Exception thrown when an insert row operation fails.
DatabaseQueryException
Exception thrown when an exception occurs during a database query.
DatabaseUpdateRowException
Exception thrown when an update row operation fails.
DeserializationTypeNotFoundException
Exception thrown when no deserialization type was found during protocol deserialization
EndpointDispatchException
The result of a failed EndpointDispatch.getMethodStreamCallContext, EndpointDispatch.getMethodCallContext or EndpointDispatch.getEndpointConnector call.
EndpointNotFoundException
The endpoint was not found.
ExitException
Exception used to signal a
InvalidEndpointMethodTypeException
The found endpoint method was not of the expected type.
InvalidParametersException
The input parameters were invalid.
MethodNotFoundException
The endpoint method was not found.
NotAuthorizedException
The user is not authorized to access the endpoint.
SerializableException
This is SerializableException that can be used to pass Domain exceptions from the Server to the Client
UnknownMessageException
Exception thrown when an unknown message is received.