serverpod_shared library

Classes

CliArgsConstants
Constants representing the keys used to access command line arguments from the map returned by CommandLineArgs.toMap().
DatabaseConfig
Configuration for a database.
DatabaseConstants
Database constants used by the serverpod framework.
FutureCallConfig
Configuration for future call handling.
MigrationConstants
Migration constants used by the serverpod framework.
PasswordManager
Keeps track of passwords used by the server. Passwords are loaded from the config/passwords.yaml file.
PostgresDatabaseConfig
PostgreSQL-specific database configuration.
RedisConfig
Configuration for Redis.
ServerConfig
Configuration for a server.
ServerpodConfig
Parser for the Serverpod configuration file.
ServerpodConfigMap
The configuration sections for the serverpod configuration file.
ServerpodFutureCallConfigMap
The configuration sections for the future call configuration.
ServerpodServerConfigMap
The configuration sections for the serverpod server configuration file.
ServerpodUrlConstants
Serverpod URL constants used by the serverpod framework.
SessionLogConfig
Configuration for session logging.
SqliteDatabaseConfig
SQLite-specific database configuration.
WebAuthCookieConfig
Configuration for the cookie used to carry the web authentication token.

Enums

ConsoleLogFormat
Valid values for console log format.
CookieSameSite
The SameSite attribute of a cookie, controlling whether it is sent on cross-site requests. Maps to the HTTP SameSite values.
DatabaseDialect
Database dialect type.
ServerpodEnv
The default environment variables used by the server.
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.
ServerpodPassword
The default passwords used by the server.
ServerpodRole
The main role of the server. By default, Serverpod is running as a monolith, but it can also be configured to run as a serverless server, or in maintenance mode where it runs scheduled tasks, such as executing future calls.

Extensions

DurationComponentsExtension on Duration
Extension on Dart's Duration class to provide access to individual time components like days, hours, minutes, seconds, and milliseconds.
FileEx on FileSystemEntity
Convenience helpers added to every FileSystemEntity (files, directories, links).
StringManipulationExtension on String
String utilities shared by Serverpod packages.

Constants

durationComponentPattern → const String
Regular expression pattern that matches a duration component with an integer value followed by a valid unit (d, h, min, s, ms).
fullDurationPattern → const String
Regular expression pattern that matches a complete duration string consisting of multiple duration components separated by spaces.
serverpodIssueTrackerUrl → const String
URL where users can report internal Serverpod errors.

Functions

bindUnixSocket(String path) → Future<ServerSocket>
Binds a ServerSocket to a Unix domain socket at path.
connectUnixSocket(String path, {Duration? timeout}) → Future<Socket>
Connects to a Unix domain socket at path.
databaseTypeToLowerCamelCase(String databaseType) → String
Splits at spaces and joins to lowerCamelCase.
ensureSecureDirectorySync(String path) → void
Atomically ensures a directory exists at path with mode 0700 on POSIX (and an owner-restricted ACL on Windows). No-op if path already exists.
formatInternalErrorMessage([Object? error]) → String
Formats an unexpected error using Serverpod's standard issue-reporting guidance.
generateRandomBytes(int length) → Uint8List
Generates a list of secure random bytes of the specified length.
generateRandomString([int length = 32]) → String
Generates a secure random string of the specified length.
hasUnixSocketSupport() → bool
Returns true if the current platform supports Unix domain sockets.
inferDatabaseConfigFromConfigMap(Map configMap, {Map<String, String> environment = const {}}) → DatabaseConfig?
Infer the database config from one run-mode config map (the body of config/<runMode>.yaml), using the same database merging rules as ServerpodConfig.loadFromMap.
inferDatabaseDialectFromConfigMap(Map configMap, {Map<String, String> environment = const {}}) → DatabaseDialect?
Infer the database dialect from one run-mode config map (the body of config/<runMode>.yaml), using the same database merging rules as ServerpodConfig.loadFromMap.
isValidDuration(dynamic value) → bool
Checks if the given value is a valid duration string, using the fullDurationPattern.
maxUnixSocketPathBytes() → int
Maximum number of bytes a Unix domain socket path may occupy on the current platform.
parseDuration(dynamic input) → Duration
Parses the valid duration string into a CustomDuration object. This allows for easy access to individual components such as days, hours, minutes, seconds, and milliseconds.
requireUnixSocketPathFits(String path) → void
Throws a SocketException if path (after shortening) does not fit within the platform's sockaddr_un.sun_path.
requireUnixSocketSupport() → void
Throws a SocketException if the current platform does not support Unix domain sockets.
shortestPath(String path) → String
Returns the shortest equivalent form of path.
shortestPathRelativeTo(String path, {required String from}) → String
Like shortestPath, but the relative form is computed from from instead of Directory.current.
sslCertificatePath(String runMode, int serverId) → String
Returns the path to SSL certificate for the specified server.
sslPrivateKeyPath(String runMode, int serverId) → String
Returns the path to the private SSL key for the specified server.
truncateIdentifier(String identifier, int maxLength, {int hashLength = 4}) → String
Deterministically truncates an identifier to a maxLength String.
uint8ListAreEqual(Uint8List a, Uint8List b) → bool
Checks whether the 2 given lists contain the same data.

Typedefs

Convert<T> = T Function(String value)
The configuration sections for the serverpod configuration file.
DatabaseConfigParser = DatabaseConfig Function(Map dbSetup, Map passwords, String name)
Parser for the database configuration.

Exceptions / Errors

ExitException
Exception used to signal a non-recoverable error that should exit the application.
GenerateMigrationDatabaseDefinitionException
Exception thrown when the migration failed to create a database definition from the projects model files.
MigrationAbortedException
Exception thrown when a migration is aborted.
MigrationLiveDatabaseDefinitionException
Exception thrown when trying to load the live database definition.
MigrationRepairTargetNotFoundException
Exception thrown when a migration target is not found.
MigrationRepairWriteException
Exception thrown when writing a migration fails.
MigrationUnsupportedByDialectException
Exception thrown when the target database dialect cannot express part of the database definition.
MigrationVersionAlreadyExistsException
Exception thrown when the migration directory already exists.
MigrationVersionLoadException
Exception thrown when loading a migration version fails.
PasswordMissingException
Exception class for all password missing exceptions.
StreamClosedWithErrorException
This is an exception that is thrown when a stream is closed with an error