APIRoot class abstract

Root class of an API.

Mixed-in types

Constructors

APIRoot(String name, String version, {dynamic apiConfig, APIConfigProvider? apiConfigProvider, Iterable<APIRequestHandler>? preApiRequestHandlers, Iterable<APIRequestHandler>? posApiRequestHandlers})

Properties

apiConfig ↔ APIConfig
The API Configuration.
getter/setter pair
authenticationRoute → String
no setter
currentAPIRequest → ZoneField<APIRequest>
Returns the current APIRequest of the current call.
final
cyclicDependencies → List<Initializable>
The dependencies of the current (or last) initialization attempt that were not waited for: they were (transitively) waiting for this instance (a cycle), so they may still be initializing when initialize runs or when this instance is initialized.
no setterinherited
defaultModuleName → String?
The default module to use when request module doesn't match.
no setter
hashCode → int
The hash code for this object.
no setteroverride
initializationStatus → InitializationStatus
Returns the current InitializationStatus.
no setterinherited
isAsyncInitialization → bool
Returns true if this instance initialization was asynchronous.
no setterinherited
isAuxiliaryInstance → bool
Returns true if this instance is a copy passed to another Isolate (usually through APIServerWorker).
no setter
isClosed → bool
no setterinherited
isInitialized → bool
Returns true if this instance is already initialized.
no setterinherited
isInitializing → bool
Returns true if this instance is in the middle of the initialization process.
no setterinherited
logger ↔ APILogger?
The logger of this APIRoot instance. See APILogger.
getter/setter pair
modules → Set<APIModule>
Returns the modules of this API.
no setter
modulesNames → Set<String>
Returns the names of the modules of this API.
no setter
name → String
API name.
final
posApiRequestHandlers → Set<APIRequestHandler>
APIRequestHandler list to try after attempt an API call.
final
preApiRequestHandlers → Set<APIRequestHandler>
APIRequestHandler list to try before attempt an API call.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
security → APISecurity?
no setter
securityModule → APIModule?
no setter
securityModuleName → String?
no setter
sharedStore → SharedStore
The SharedStore of this APIRoot. This SharedStore will be automatically shared among Isolate copies.
no setter
sharedStoreID → String
The global ID of the sharedStore.
no setter
version → String
API version.
final

Methods

acceptsRequest(APIRequest apiRequest) → bool
Returns true if apiRequest is an accepted route/call.
apiInfo([APIRequest? apiRequest]) → APIRootInfo
Returns a APIRootInfo.
call<T>(APIRequest request, {bool externalCall = false}) → FutureOr<APIResponse<T>>
Calls the API.
callAuthenticate(String email, String password) → Future<APIAuthentication?>
callHandlers<T>(Iterable<APIRequestHandler> handlers, APIRequest request, [String handlersType = 'external']) → FutureOr<APIResponse<T>?>
Attempt to process request using an APIRequestHandler at handlers.
checkInitialized({bool allowInProgress = true}) → void
Checks if this instance is initialized, initializing it if possible.
inherited
checkNotClosed() → void
inherited
close() → bool
doCall<T>(APIRequestMethod method, String path, {Map<String, dynamic>? parameters, Map<String, dynamic>? headers, dynamic payload}) → FutureOr<APIResponse<T>>
Perform an API call.
doInitialization({Initializable? parent}) → FutureOr<InitializationResult>
Initialize this instance if is not initialized yet. Same as ensureInitialized.
inherited
ensureInitialized({Initializable? parent}) → FutureOr<InitializationResult>
Ensures that this instance is initialized.
inherited
ensureInitializedAsync({Initializable? parent}) → FutureOr<InitializationResult>
Ensures that this instance is initialized. If is not initialized yet it will force an asynchronous initialization and return a Future.
inherited
executeInitialized<R>(ExecuteInitializedCallback<R> callback, {Initializable? parent}) → FutureOr<R>
Executes the callback ensuring that this instance was initialized.
inherited
getModule(String name) → APIModule?
Returns a module with name.
getModuleByRequest(APIRequest request) → APIModule?
Returns an APIModule based in the request.
initialize() → FutureOr<InitializationResult>
Initialization implementation. Do not call it directly, use doInitialization.
override
initializeDependencies() → FutureOr<List<Initializable>>
Return a List of Initializable instances that need to be initialized BEFORE initialize this instance.
override
loadDependencies() → FutureOr<List<Initializable>>
Gracefully loads the Initializable dependencies for this APIRoot.
loadEntityProviders() → FutureOr<List<EntityProvider>>
Gracefully loads the EntityProvider needed for this APIRoot.
loadEntityRepositoryProviders() → FutureOr<List<EntityRepositoryProvider>>
Gracefully loads the EntityRepositoryProvider needed for this APIRoot.
loadModules() → FutureOr<Set<APIModule>>
Loads the modules of this API.
log(String type, String? message, [Object? error, StackTrace? stackTrace]) → void
Logs to logger, if present.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onClose() → void
Called when this instance is closed.
onNoRouteForPath<T>(APIRequest request) → FutureOr<APIResponse<T>>
resolveModule(APIRequest request) → String
Resolves the module name of a request.
toString({bool withModulesNames = true}) → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

boot() → void
get({bool singleton = true}) → APIRoot?
Returns the last APIRoot if instantiated.
getByAPIRequestZone(Zone zone) → ({APIRequest? apiRequest, APIRoot? apiRoot})
Returns the APIRoot by associated APIRequest zone.
getByName(String name, {bool caseSensitive = false, bool lastAsDefault = false}) → APIRoot?
Returns an APIRoot instance with name.
getByType<A extends APIRoot>({Type? type, bool lastAsDefault = false}) → A?
Returns an APIRoot instance by type.
getWhere(bool matcher(APIRoot apiRoot), {bool lastAsDefault = false}) → APIRoot?
Returns the first APIRoot matched by matcher.
getWithinName(String part, {bool lastAsDefault = false, bool caseSensitive = false}) → APIRoot?